Skip to content

Conversation

@SajanGhimire1
Copy link
Contributor

@SajanGhimire1 SajanGhimire1 commented Jan 14, 2026

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
Copy link
Contributor

@corporateshark corporateshark left a comment

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.

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.
Copy link
Contributor

@corporateshark corporateshark left a comment

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.
Copy link
Contributor Author

@SajanGhimire1 SajanGhimire1 left a comment

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
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
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
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
Copy link

meta-codesync bot commented Jan 14, 2026

@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
Copy link

meta-codesync bot commented Jan 15, 2026

@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants