Skip to content

Commit

Permalink
Fix webgl2 instancing bug (#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoam authored and bkaradzic committed Oct 1, 2018
1 parent 7835f60 commit 50a64a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/renderer_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4528,6 +4528,15 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
}
}

void ProgramGL::unbindInstanceData() const
{
for(uint32_t ii = 0; 0xffff != m_instanceData[ii]; ++ii)
{
GLint loc = m_instanceData[ii];
GL_CHECK(glDisableVertexAttribArray(loc));
}
}

void IndexBufferGL::destroy()
{
GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) );
Expand Down Expand Up @@ -7311,6 +7320,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
m_occlusionQuery.end();
}

if(isValid(draw.m_instanceDataBuffer))
{
program.unbindInstanceData();
}

statsNumPrimsSubmitted[primIndex] += numPrimsSubmitted;
statsNumPrimsRendered[primIndex] += numPrimsRendered;
statsNumInstances[primIndex] += numInstances;
Expand Down
1 change: 1 addition & 0 deletions src/renderer_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ namespace bgfx { namespace gl
void destroy();
void init();
void bindInstanceData(uint32_t _stride, uint32_t _baseVertex = 0) const;
void unbindInstanceData() const;

void bindAttributesBegin()
{
Expand Down

0 comments on commit 50a64a7

Please sign in to comment.