Skip to content

Reduce Apple OpenGL vertex state churn - #6032

Open
LisaScheers wants to merge 1 commit into
secondlife:developfrom
LisaScheers:lis/sl-reduce-opengl-metal-state-churn
Open

Reduce Apple OpenGL vertex state churn#6032
LisaScheers wants to merge 1 commit into
secondlife:developfrom
LisaScheers:lis/sl-reduce-opengl-metal-state-churn

Conversation

@LisaScheers

@LisaScheers LisaScheers commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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 official develop branch has the same unconditional shader-transition unbind and pointer resubmission path.

Related Issues

  • Please link to a relevant GitHub issue for additional context.

Issue Link: None; opened as a draft for upstream performance evaluation.


Checklist

  • I have provided a clear title and detailed description for this pull request.
  • If useful, I have included media such as screenshots and video to show off my changes.
  • The PR is linked to a relevant issue with sufficient context.
  • I have tested the changes locally and verified they work as intended.
  • All new and existing tests pass.
  • Code follows the project's style guidelines.
  • Documentation has been updated if needed.
  • Any dependent changes have been merged and published in downstream modules.
  • I have reviewed the contributing guidelines.

Additional Notes

Validation performed:

  • clean git diff --check
  • exact stable patch-ID match with the Firestorm implementation
  • reviewed cache invalidation and every color/emissive attribute combination
  • verified the non-Apple path remains unchanged

A 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.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@LisaScheers

Copy link
Copy Markdown
Contributor Author

recheck

@LisaScheers
LisaScheers marked this pull request as ready for review July 23, 2026 04:56
@akleshchev
akleshchev requested review from Geenz and Copilot July 27, 2026 18:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() during LLGLSLShader::bind() on Apple to retain buffer bindings across shader transitions.
  • Add an Apple-only cache in LLVertexBuffer::setupVertexBuffer() to only submit newly needed glVertexAttribPointer* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants