From aa176c7763e9dcf90c8ac2345f1b984a12fbefbe Mon Sep 17 00:00:00 2001 From: vrimar <5660247+vrimar@users.noreply.github.com> Date: Sat, 4 Jul 2026 10:31:07 -0400 Subject: [PATCH] Compare layout handle in vertex-stream rebind gate (#3811) The gate compares (handle, startVertex) but not the layout handle, so draws colliding on startVertex with different-stride layouts wrongly skip the rebind. Fix hasVertexStreamChanged() and OpenGL's inline copy. Matches #2562. --- src/renderer.h | 5 +++-- src/renderer_gl.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer.h b/src/renderer.h index 9afae1219..784b13569 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -788,8 +788,9 @@ namespace bgfx { const uint8_t idx = it.idx; - if (_current.m_stream[idx].m_handle.idx != _new.m_stream[idx].m_handle.idx - || _current.m_stream[idx].m_startVertex != _new.m_stream[idx].m_startVertex) + if (_current.m_stream[idx].m_handle.idx != _new.m_stream[idx].m_handle.idx + || _current.m_stream[idx].m_startVertex != _new.m_stream[idx].m_startVertex + || _current.m_stream[idx].m_layoutHandle.idx != _new.m_stream[idx].m_layoutHandle.idx) { return true; } diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index f1ff70a0c..584650858 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -8480,6 +8480,12 @@ namespace bgfx { namespace gl currentState.m_stream[idx].m_startVertex = draw.m_stream[idx].m_startVertex; bindAttribs = true; } + + if (currentState.m_stream[idx].m_layoutHandle.idx != draw.m_stream[idx].m_layoutHandle.idx) + { + currentState.m_stream[idx].m_layoutHandle = draw.m_stream[idx].m_layoutHandle; + bindAttribs = true; + } } }