Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR changes the depth field in GeometryPixel from u32 to f32 to resolve GPU denormalization issues where small u32 values, when bitcast to f32, could be rounded to zero on some GPUs. This change propagates through the rendering pipeline, affecting type conversions, comparisons, and GPU texture formats.
Key Changes
- Changed
GeometryPixel::depthfromu32tof32in the core raster library - Updated all depth comparisons from integer (e.g.,
p.depth > 0) to floating-point (e.g.,p.depth > 0.0) - Modified GPU shader bindings to use
texture_2d<f32>instead oftexture_2d<u32>and removed bitcasting operations
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| fidget-raster/src/lib.rs | Changed GeometryPixel::depth type from u32 to f32 with updated documentation |
| fidget-raster/src/render3d.rs | Replaced try_into().unwrap() conversions with direct as f32 casts for depth calculations |
| fidget-raster/src/effects.rs | Updated all depth comparisons from integer to floating-point literals (0 → 0.0) |
| fidget/tests/render3d.rs | Updated test assertions to compare depth against f32 values instead of integers |
| demos/viewer/src/shaders/geometry.wgsl | Changed texture type from texture_2d<u32> to texture_2d<f32> and removed bitcast operations for normals |
| demos/viewer/src/draw3d.rs | Updated texture format from Rgba32Uint to Rgba32Float and changed sample type to non-filterable float |
| demos/cli/src/main.rs | Updated depth comparisons to use 0.0 and modified heightmap calculation to work with f32 |
| demos/web-editor/crate/src/lib.rs | Updated depth comparison to use 0.0 instead of 0 |
| fidget/Cargo.toml, fidget-raster/Cargo.toml, Cargo.toml, Cargo.lock | Bumped versions from 0.4.1 to 0.4.2 for affected crates |
| CHANGELOG.md | Added entry documenting the type change for version 0.4.2 |
💡 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.
This makes it easier to send the
GeometryBufferto the GPU as af32x4texture. I previously just used bitcasting, but It turns out that a smallu32produces a denormalized float, and some GPUs will just round it to zero (!)Thanks to @alexneufeld for tracking this down in mkeeter/halfspace#1