Use half-precision types in bloom downsample/upsample WGSL shaders#8508
Merged
mvaligursky merged 1 commit intomainfrom Mar 6, 2026
Merged
Use half-precision types in bloom downsample/upsample WGSL shaders#8508mvaligursky merged 1 commit intomainfrom
mvaligursky merged 1 commit intomainfrom
Conversation
Converts intermediate computations from f32 to half (f16) types in the bloom shader chain, reducing register pressure and enabling 2x ALU throughput on GPUs with native f16 support. Restructures upsample accumulation from accumulate-then-divide to multiply-before-accumulate to prevent f16 overflow. Made-with: Cursor
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the bloom render-pass downsample/upsample shader chunks to use half-precision (half*) for intermediate computations in WGSL, and adjusts the upsample accumulation math to reduce risk of intermediate overflow while preserving the filter result.
Changes:
- WGSL bloom downsample: convert sampled/intermediate color values and accumulation from
vec3ftohalf3(including BOXFILTER + PREMULTIPLY paths). - WGSL bloom upsample: convert sampled/intermediate color values and accumulation from
vec3ftohalf3. - WGSL + GLSL bloom upsample: change from “accumulate then divide” to pre-weighted accumulation (equivalent normalization, lower peak intermediate magnitude).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/scene/shader-lib/wgsl/chunks/render-pass/frag/upsample.js | Uses half3 intermediates and pre-weighted accumulation; casts back to vec3f for output. |
| src/scene/shader-lib/wgsl/chunks/render-pass/frag/downsample.js | Uses half3 intermediates/accumulation (incl. BOXFILTER/PREMULTIPLY) and casts back to vec3f for output. |
| src/scene/shader-lib/glsl/chunks/render-pass/frag/upsample.js | Switches to pre-weighted accumulation constants equivalent to prior normalize-by-16 approach. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use half-precision (f16) types for intermediate computations in the bloom downsample and upsample WGSL shaders.
Changes:
Performance: