Reduce Apple OpenGL vertex state churn - #6032
Open
LisaScheers wants to merge 1 commit into
Open
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
recheck |
Contributor
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.
Comment on lines
+685
to
+686
| // Attribute pointer state belongs to the currently bound array buffer. Keep | ||
| // enough state to avoid resubmitting identical formats to OpenGL-on-Metal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.