Skip to content

properly bind fragment uniform buffer in multi-pass rendering#337

Closed
SajanGhimire1 wants to merge 5 commits into
facebook:mainfrom
SajanGhimire1:patch-1
Closed

properly bind fragment uniform buffer in multi-pass rendering#337
SajanGhimire1 wants to merge 5 commits into
facebook:mainfrom
SajanGhimire1:patch-1

Conversation

@SajanGhimire1

@SajanGhimire1 SajanGhimire1 commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Fix syntax error in uniform buffer binding

Fixed misplaced brace that prevented uniform buffers from being bound
for Metal/D3D12 backends in multi-pass rendering.

Root Cause: The original code had incorrect brace placement:

if (backend != igl::BackendType::OpenGL) {
  if (fragmentParamBuffer) {
      commands->bindBuffer(0, fragmentParamBuffer.get());
  }
}  // <-- Ends here incorrectly

} else {  // <-- Syntax error: disconnected else
Previously, the fragment uniform buffer (`fragmentParamBuffer_`) was not correctly
bound for non-OpenGL backends, which could result in incorrect rendering or
unexpected colors in multi-pass render sessions.

- Ensures `fragmentParamBuffer_` is bound in `render()` for Metal and D3D12.
- Maintains correct uniform binding for OpenGL backends.
- Verified multi-pass rendering output remains consistent across backends.

Ref: TQMultiRenderPassSession.cpp
@meta-cla meta-cla Bot added the cla signed label Jan 14, 2026

@corporateshark corporateshark 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.

Please avoid reformatting any existing code. It makes the review and merge process much more involved.

Comment thread shell/renderSessions/TQMultiRenderPassSession.cpp Outdated
Comment thread shell/renderSessions/TQMultiRenderPassSession.cpp Outdated
Comment thread shell/renderSessions/TQMultiRenderPassSession.cpp Outdated
Comment thread shell/renderSessions/TQMultiRenderPassSession.cpp
Comment thread shell/renderSessions/TQMultiRenderPassSession.cpp Outdated
Added a check to ensure fragmentParamBuffer_ is valid before binding in the render pass. This prevents potential crashes while keeping all rendering logic and backend support intact.

@corporateshark corporateshark 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.

Please address the above-mentioned comments.

Add null check for fragmentParamBuffer when binding in render()
to avoid potential issues on non-OpenGL backends.

@SajanGhimire1 SajanGhimire1 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed the requested changes: added explicit check for fragment uniform buffer pointer without reformatting existing code.

struct VertexPosUv {
iglu::simdtypes::float3 position; // SIMD 128b aligned
iglu::simdtypes::float2 uv; // SIMD 128b aligned
iglu::simdtypes::float2 uv; // SIMD 128b aligned

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.

No need to change this line.

{{1.0f, 1.0f, 0.0}, {1.0, 1.0}},
{{-1.0f, -1.0, 0.0}, {0.0, 0.0}},
{{1.0f, -1.0f, 0.0}, {1.0, 0.0}},
{{1.0f, -1.0, 0.0}, {1.0, 0.0}},

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.

Please avoid changing this.


if (backend != igl::BackendType::OpenGL) {
commands->bindBuffer(0, fragmentParamBuffer.get());
if (fragmentParamBuffer) {

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.

Since calling bindBuffer() with a nullptr buffer is allowed by the API contract, what exact problem is this PR trying to solve?

@meta-codesync

meta-codesync Bot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

@corporateshark has imported this pull request. If you are a Meta employee, you can view this in D90706470.

@meta-codesync meta-codesync Bot closed this in bd388a9 Jan 15, 2026
@meta-codesync

meta-codesync Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

@corporateshark merged this pull request in bd388a9.

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

3 participants