Add Unbind Attributes (#1515)

This commit is contained in:
Hugo Amnov 2018-10-03 03:06:48 +02:00 committed by Бранимир Караџић
parent 29585d85ca
commit 71a1d659dc
2 changed files with 30 additions and 0 deletions

View File

@ -4515,6 +4515,19 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
}
void ProgramGL::unbindAttributes()
{
for(uint32_t ii = 0, iiEnd = m_usedCount; ii < iiEnd; ++ii)
{
if(Attrib::Count == m_unboundUsedAttrib[ii])
{
Attrib::Enum attr = Attrib::Enum(m_used[ii]);
GLint loc = m_attributes[attr];
GL_CHECK(glDisableVertexAttribArray(loc));
}
}
}
void ProgramGL::bindInstanceData(uint32_t _stride, uint32_t _baseVertex) const
{
uint32_t baseVertex = _baseVertex;
@ -6310,6 +6323,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
viewState.reset(_render, hmdEnabled);
uint16_t programIdx = kInvalidHandle;
uint16_t boundProgramIdx = kInvalidHandle;
SortKey key;
uint16_t view = UINT16_MAX;
FrameBufferHandle fbh = { BGFX_CONFIG_MAX_FRAME_BUFFERS };
@ -7145,6 +7159,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (bindAttribs || diffStartVertex)
{
if(kInvalidHandle != boundProgramIdx)
{
ProgramGL& boundProgram = m_program[boundProgramIdx];
boundProgram.unbindAttributes();
}
boundProgramIdx = programIdx;
program.bindAttributesBegin();
if (UINT8_MAX != draw.m_streamMask)
@ -7333,6 +7355,12 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
}
if(kInvalidHandle != boundProgramIdx)
{
ProgramGL& boundProgram = m_program[boundProgramIdx];
boundProgram.unbindAttributes();
}
submitBlit(bs, BGFX_CONFIG_MAX_VIEWS);
blitMsaaFbo();

View File

@ -1351,6 +1351,8 @@ namespace bgfx { namespace gl
}
}
void unbindAttributes();
GLuint m_id;
uint8_t m_unboundUsedAttrib[Attrib::Count]; // For tracking unbound used attributes between begin()/end().