Reduce Apple OpenGL vertex state churn - #6032
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
recheck |
There was a problem hiding this comment.
Pull request overview
This PR reduces redundant OpenGL state work on Apple GPUs by avoiding unconditional vertex/index buffer unbinds on shader transitions and by caching which vertex attribute pointer formats have already been submitted for the currently bound array buffer.
Changes:
- Skip
LLVertexBuffer::unbind()duringLLGLSLShader::bind()on Apple to retain buffer bindings across shader transitions. - Add an Apple-only cache in
LLVertexBuffer::setupVertexBuffer()to only submit newly neededglVertexAttribPointer*formats, with invalidation on buffer change or explicit unbind. - Preserve existing color/emissive attribute pointer remapping while avoiding redundant resubmission on Apple.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| indra/llrender/llvertexbuffer.cpp | Adds Apple-only vertex attribute pointer caching and invalidation to reduce redundant glVertexAttribPointer* calls. |
| indra/llrender/llglslshader.cpp | Avoids unbinding VBO/IBO on shader transitions on Apple to reduce driver translation churn. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I'll take a closer look at this this week. |
|
@LisaScheers Can you share Tracy runs of this change? |
|
@Geenz Yes, Both are
The PR processed 10.5% more shader-bind calls and approximately 3–7% more batch calls per frame, so it was not obviously benefiting from a lighter draw workload. |
Description
Reduces redundant OpenGL state translation on Apple GPUs by retaining the current vertex/index buffers across shader transitions and caching the vertex attribute pointer formats already valid for the bound buffer.
Only newly required formats are submitted. Color/emissive pointer remapping is preserved, cache state is invalidated on buffer replacement or explicit unbind, and non-Apple drivers retain the existing behavior.
A native Apple Silicon profile of the closely related Firestorm viewer showed repeated time in
glVertexAttribPointerARB_Exec, OpenGL object-name hash operations, and dispatch/state updates. The officialdevelopbranch has the same unconditional shader-transition unbind and pointer resubmission path.Related Issues
Issue Link: None; opened as a draft for upstream performance evaluation.
Checklist
Additional Notes
Validation performed:
git diff --checkA full official viewer build was not available because this host lacks the autobuild dependency bundle and full Xcode toolchain. This remains a draft pending native build and benchmark coverage.