Skip to content

Fix excessive glObjectLabel calls for vertex/index buffers#2662

Open
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-excessive-globjectlabel-calls
Open

Fix excessive glObjectLabel calls for vertex/index buffers#2662
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-excessive-globjectlabel-calls

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

glObjectLabel was being called in setVertexAttrib on every render update for every vertex buffer, causing measurable CPU overhead visible in profiles and RenderDoc. Index buffers were never labeled at all since setVertexAttrib rejects them early.

Changes

  • updateBufferData(VertexBuffer): Add glObjectLabel call immediately after buffer creation (bufId == -1 path), consistent with how shaders are labeled at creation time
  • setVertexAttrib: Remove the per-frame glObjectLabel call entirely
  • Drop the vb.getName() != null guard — VertexBuffer.getName() never returns null (falls back to a generated name like VertexBuffer(Position))

Index buffers now get labeled correctly as a natural consequence of the move — they pass through updateBufferData just like vertex buffers.

// Before: called every frame in setVertexAttrib
if (debug && caps.contains(Caps.GLDebug)) {
    if (vb.getName() != null) glext.glObjectLabel(GLExt.GL_BUFFER, vb.getId(), vb.getName());
}

// After: called once at creation in updateBufferData (covers both VBOs and IBOs)
if (debug && caps.contains(Caps.GLDebug)) {
    glext.glObjectLabel(GLExt.GL_BUFFER, bufId, vb.getName());
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI linked an issue Mar 28, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix excessive calls to glObjectLabel in setVertexAttrib Fix excessive glObjectLabel calls for vertex/index buffers Mar 28, 2026
Copilot AI requested a review from riccardobl March 28, 2026 09:48
@riccardobl riccardobl marked this pull request as ready for review March 28, 2026 09:49
//statistics.onNewVertexBuffer();

if (debug && caps.contains(Caps.GLDebug)) {
glext.glObjectLabel(GLExt.GL_BUFFER, bufId, vb.getName());
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.

It's not that easy due to GL's bind-to-create concept.
See Trass3r@f994546.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

excessive calls to glObjectLabel etc

3 participants