Skip to content

Comments

Only emit written color outputs in WGSL FragmentOutput struct#8465

Merged
slimbuck merged 3 commits intoplaycanvas:mainfrom
slimbuck:webgpu-fixes
Feb 20, 2026
Merged

Only emit written color outputs in WGSL FragmentOutput struct#8465
slimbuck merged 3 commits intoplaycanvas:mainfrom
slimbuck:webgpu-fixes

Conversation

@slimbuck
Copy link
Member

Summary

The WGSL shader processor previously included all color output members in the
FragmentOutput struct based on numRenderTargets, regardless of whether the
shader actually writes to them. This can cause WebGPU validation errors when a
fragment shader declares an output location it never assigns to.

This change updates generateFragmentOutputStruct to scan the shader source for
actual assignments (e.g. .color = , .color1 = ) and only emit @location
members for outputs that are written, matching the existing pattern already used
for fragDepth.

Changes

  • WebgpuShaderProcessorWGSL.generateFragmentOutputStruct now filters color
    outputs by checking if the shader source contains an assignment to each color
    member before including it in the struct

@slimbuck slimbuck requested review from a team and Copilot February 20, 2026 10:01
@slimbuck slimbuck self-assigned this Feb 20, 2026
@slimbuck slimbuck added the area: graphics Graphics related issue label Feb 20, 2026
Copy link
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 fixes WebGPU validation errors that occur when fragment shaders declare color output locations they never assign to. The WGSL shader processor is updated to conditionally emit color outputs in the FragmentOutput struct based on whether the shader actually writes to them, matching the existing pattern used for fragDepth.

Changes:

  • Modified generateFragmentOutputStruct to scan shader source for color output assignments before including them in the struct
  • Uses regex pattern matching to detect .color = , .color1 = , etc. assignments in the shader source

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

@slimbuck slimbuck merged commit 15ba73e into playcanvas:main Feb 20, 2026
10 of 12 checks passed
@slimbuck slimbuck deleted the webgpu-fixes branch February 20, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants