1116: Don't send buffer cmds to non OpenGL 3.3 backend r=def- a=Jupeyy



Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
bors[bot] 2018-04-15 18:00:54 +00:00
commit 73a65a7026
4 changed files with 75 additions and 106 deletions

View file

@ -1209,6 +1209,60 @@ int CGraphics_Threaded::CreateQuadContainer()
return Index;
}
void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex)
{
if(m_UseOpenGL3_3)
{
SQuadContainer& Container = m_QuadContainers[ContainerIndex];
if(Container.m_Quads.size() > 0)
{
if(Container.m_QuadBufferObjectIndex == -1)
{
size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad);
Container.m_QuadBufferObjectIndex = CreateBufferObject(UploadDataSize, &Container.m_Quads[0]);
}
else
{
size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad);
RecreateBufferObject(Container.m_QuadBufferObjectIndex, UploadDataSize, &Container.m_Quads[0]);
}
if(Container.m_QuadBufferContainerIndex == -1)
{
SBufferContainerInfo Info;
Info.m_Stride = sizeof(CCommandBuffer::SVertex);
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
SBufferContainerInfo::SAttribute* pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = false;
pAttr->m_pOffset = 0;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = false;
pAttr->m_pOffset = (void*)(sizeof(float) * 2);
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 4;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = true;
pAttr->m_pOffset = (void*)(sizeof(float) * 2 + sizeof(float) * 2);
pAttr->m_Type = GRAPHICS_TYPE_UNSIGNED_BYTE;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Container.m_QuadBufferContainerIndex = CreateBufferContainer(&Info);
}
}
}
}
void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num)
{
SQuadContainer& Container = m_QuadContainers[ContainerIndex];
@ -1251,52 +1305,7 @@ void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CQuadItem *pA
}
}
if(Container.m_Quads.size() > 0)
{
if(Container.m_QuadBufferObjectIndex == -1)
{
size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad);
Container.m_QuadBufferObjectIndex = CreateBufferObject(UploadDataSize, &Container.m_Quads[0]);
}
else
{
size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad);
RecreateBufferObject(Container.m_QuadBufferObjectIndex, UploadDataSize, &Container.m_Quads[0]);
}
if(Container.m_QuadBufferContainerIndex == -1)
{
SBufferContainerInfo Info;
Info.m_Stride = sizeof(CCommandBuffer::SVertex);
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
SBufferContainerInfo::SAttribute* pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = false;
pAttr->m_pOffset = 0;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = false;
pAttr->m_pOffset = (void*)(sizeof(float) * 2);
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 4;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = true;
pAttr->m_pOffset = (void*)(sizeof(float) * 2 + sizeof(float) * 2);
pAttr->m_Type = GRAPHICS_TYPE_UNSIGNED_BYTE;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Container.m_QuadBufferContainerIndex = CreateBufferContainer(&Info);
}
}
QuadContainerUpload(ContainerIndex);
}
void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num)
@ -1332,59 +1341,17 @@ void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CFreeformItem
SetColor(&Quad.m_aVertices[3], 2);
}
if(Container.m_Quads.size() > 0)
{
if(Container.m_QuadBufferObjectIndex == -1)
{
size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad);
Container.m_QuadBufferObjectIndex = CreateBufferObject(UploadDataSize, &Container.m_Quads[0]);
}
else
{
size_t UploadDataSize = Container.m_Quads.size() * sizeof(SQuadContainer::SQuad);
RecreateBufferObject(Container.m_QuadBufferObjectIndex, UploadDataSize, &Container.m_Quads[0]);
}
if(Container.m_QuadBufferContainerIndex == -1)
{
SBufferContainerInfo Info;
Info.m_Stride = sizeof(CCommandBuffer::SVertex);
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
SBufferContainerInfo::SAttribute* pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = false;
pAttr->m_pOffset = 0;
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 2;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = false;
pAttr->m_pOffset = (void*)(sizeof(float) * 2);
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Info.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
pAttr = &Info.m_Attributes.back();
pAttr->m_DataTypeCount = 4;
pAttr->m_FuncType = 0;
pAttr->m_Normalized = true;
pAttr->m_pOffset = (void*)(sizeof(float) * 2 + sizeof(float) * 2);
pAttr->m_Type = GRAPHICS_TYPE_UNSIGNED_BYTE;
pAttr->m_VertBufferBindingIndex = Container.m_QuadBufferObjectIndex;
Container.m_QuadBufferContainerIndex = CreateBufferContainer(&Info);
}
}
QuadContainerUpload(ContainerIndex);
}
void CGraphics_Threaded::QuadContainerReset(int ContainerIndex)
{
SQuadContainer& Container = m_QuadContainers[ContainerIndex];
if(Container.m_QuadBufferContainerIndex != -1)
DeleteBufferContainer(Container.m_QuadBufferContainerIndex, true);
if(m_UseOpenGL3_3)
{
if(Container.m_QuadBufferContainerIndex != -1)
DeleteBufferContainer(Container.m_QuadBufferContainerIndex, true);
}
Container.m_Quads.clear();
Container.m_QuadBufferContainerIndex = Container.m_QuadBufferObjectIndex = -1;
}
@ -1412,12 +1379,12 @@ void CGraphics_Threaded::RenderQuadContainer(int ContainerIndex, int QuadOffset,
if((int)Container.m_Quads.size() < QuadOffset + QuadDrawNum || QuadDrawNum == 0)
return;
if(Container.m_QuadBufferContainerIndex == -1)
return;
if(m_UseOpenGL3_3)
{
if(Container.m_QuadBufferContainerIndex == -1)
return;
CCommandBuffer::SCommand_RenderQuadContainer Cmd;
Cmd.m_State = m_State;
Cmd.m_DrawNum = (unsigned int)QuadDrawNum * 6;
@ -1471,11 +1438,11 @@ void CGraphics_Threaded::RenderQuadContainerAsSprite(int ContainerIndex, int Qua
if((int)Container.m_Quads.size() < QuadOffset + 1)
return;
if(Container.m_QuadBufferContainerIndex == -1)
return;
if(m_UseOpenGL3_3)
{
if(Container.m_QuadBufferContainerIndex == -1)
return;
SQuadContainer::SQuad& Quad = Container.m_Quads[QuadOffset];
CCommandBuffer::SCommand_RenderQuadContainerAsSprite Cmd;
@ -1597,11 +1564,11 @@ void CGraphics_Threaded::RenderQuadContainerAsSpriteMultiple(int ContainerIndex,
if(DrawCount == 0)
return;
if(Container.m_QuadBufferContainerIndex == -1)
return;
if(m_UseOpenGL3_3)
{
if(Container.m_QuadBufferContainerIndex == -1)
return;
SQuadContainer::SQuad& Quad = Container.m_Quads[0];
CCommandBuffer::SCommand_RenderQuadContainerAsSpriteMultiple Cmd;

View file

@ -756,6 +756,7 @@ public:
virtual void QuadsText(float x, float y, float Size, const char *pText);
virtual int CreateQuadContainer();
virtual void QuadContainerUpload(int ContainerIndex);
virtual void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num);
virtual void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num);
virtual void QuadContainerReset(int ContainerIndex);

View file

@ -209,6 +209,7 @@ public:
};
virtual int CreateQuadContainer() = 0;
virtual void QuadContainerUpload(int ContainerIndex) = 0;
virtual void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) = 0;
virtual void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) = 0;
virtual void QuadContainerReset(int ContainerIndex) = 0;

View file

@ -343,8 +343,8 @@ void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser)
float tw = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_pFont, pInfo->m_Cursor.m_FontSize, pStr, -1);
pInfo->m_pSelf->Graphics()->TextureSet(-1);
pInfo->m_pSelf->Graphics()->QuadsBegin();
pInfo->m_pSelf->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f);
pInfo->m_pSelf->RenderTools()->DrawRoundRect(pInfo->m_Cursor.m_X-3, pInfo->m_Cursor.m_Y, tw+5, pInfo->m_Cursor.m_FontSize+4, pInfo->m_Cursor.m_FontSize/3);
pInfo->m_pSelf->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f);
pInfo->m_pSelf->RenderTools()->DrawRoundRect(pInfo->m_Cursor.m_X - 2.5f, pInfo->m_Cursor.m_Y - 4.f / 2.f, tw + 5.f, pInfo->m_Cursor.m_FontSize + 4.f, pInfo->m_Cursor.m_FontSize / 3.f);
pInfo->m_pSelf->Graphics()->QuadsEnd();
// scroll when out of sight