Skip to content

Fix instancing data layout for all graphics backends.#1656

Merged
bkaradzic-microsoft merged 1 commit intoBabylonJS:masterfrom
bkaradzic-microsoft:fix-instancing
Apr 13, 2026
Merged

Fix instancing data layout for all graphics backends.#1656
bkaradzic-microsoft merged 1 commit intoBabylonJS:masterfrom
bkaradzic-microsoft:fix-instancing

Conversation

@bkaradzic-microsoft
Copy link
Copy Markdown
Contributor

VertexBuffer: Always pack instance data in reverse attribute order. bgfx maps i_data0 to the highest semantic (TEXCOORD7) in all backends, so reverse iteration is correct universally, not just D3D11/D3D12.

ShaderCompilerTraversers: Fix OpenGL traverser to assign i_data names in reverse order (--m_instanceAttributeCount), matching the Metal traverser. Previously it used forward order (m_instanceAttributeIndex++) which produced wrong attribute-to-slot mapping when combined with reverse instance buffer packing.

ShaderCompilerTraversers: Add splatIndex0-3 to IsInstance() so Gaussian Splatting attributes are recognized as instance data on OpenGL and Metal.

config.json: Re-enable Gaussian Splatting tests on OpenGL and Metal now that instancing is fixed for those backends.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 aims to fix per-instance vertex data packing and shader attribute naming so instancing maps consistently across all bgfx backends (notably OpenGL/Metal), and then re-enable previously excluded tests that depended on correct instancing.

Changes:

  • VertexBuffer: always packs instance data in reverse attribute order (previously conditional on D3D11/D3D12).
  • ShaderCompilerTraversers: OpenGL traverser now assigns i_data* instance attribute names in reverse order (matching Metal); adds splatIndex0-3 to instance attribute detection.
  • Playground config: re-enables previously excluded graphics API runs for some tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Plugins/ShaderCompiler/Source/ShaderCompilerTraversers.cpp Updates OpenGL instance attribute naming order and expands instance attribute detection for Gaussian Splatting.
Plugins/NativeEngine/Source/VertexBuffer.cpp Makes instance data packing reverse-order for all backends to match bgfx’s abstracted mapping.
Apps/Playground/Scripts/config.json Removes OpenGL/Metal exclusions to re-enable rendering tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Plugins/ShaderCompiler/Source/ShaderCompilerTraversers.cpp
Comment thread Plugins/ShaderCompiler/Source/ShaderCompilerTraversers.cpp
Comment thread Apps/Playground/Scripts/config.json
Copy link
Copy Markdown
Contributor

@bghgary bghgary left a comment

Choose a reason for hiding this comment

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

LGTM as long as the tests pass

@bkaradzic-microsoft bkaradzic-microsoft merged commit 02add01 into BabylonJS:master Apr 13, 2026
27 checks passed
@bkaradzic-microsoft bkaradzic-microsoft deleted the fix-instancing branch April 13, 2026 23:59
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.

4 participants