Repository navigation
fix(render): bind params as storage and write colours in the target's encoding - #8
Merged
Merged
Conversation
On Windows' DX12 backend with the WARP software adapter every curve in a pass read the last curve's uniform block, so all curves took the last curve's colour; the storage buffers in the same bind groups read per-curve. Vulkan on hardware and on lavapipe never showed it. The blocks hold no arrays or vec3, so the layouts coincide and the repr(C) structs are unchanged.
egui-wgpu picks a non-sRGB swapchain format and gamma-encodes in its own shader, while rsplot wrote linearised colours into it, so every curve came out darker than its Color32 and than egui's legend swatch (#4f9bff showed as (20, 84, 255)); PNG export the same. gpu_color now keeps the sRGB bytes for a non-sRGB target and linearises only for an sRGB one, and the clear colour follows the same rule.
The data-area clear, the image tiles, the three 3D scene pipelines and the volume ray-caster still bound their params as uniforms, the binding type under which DX12/WARP read every draw's block from the last one bound. Same rule for every block now; none holds arrays or nested structs, so the repr(C) layouts and sizes are unchanged.
The colormap LUT and the direct-RGBA tiles were Rgba8UnormSrgb and the nan colour was linearised, so on egui-wgpu's non-sRGB swapchain the image shaders wrote linear values and every image came out darker than its colormap (viridis mid teal (33, 145, 140) read back as (4, 71, 66)). color_texel_format / nan_color_for_target now pick the encoding from the target, the same rule gpu_color applies to curve colours.
The scene shades in linear light and the blit copied it unconverted onto egui-wgpu's non-sRGB swapchain, so every 3D colour showed darker than its Color32. Scene3dPipeline now renders into the sRGB variant of the surface format and the blit encodes only for a non-sRGB surface; snapshot_scene reads back that sRGB target, so its bytes are gamma-encoded too.
…coding premultiply_rgba kept the caller's sRGB bytes whatever the colour target: right for egui-wgpu's non-sRGB swapchain, encoded twice on an sRGB one, where an opaque (255, 128, 0) voxel stored as (255, 188, 0). The voxels now go through rgba8_for_target (the image path's nan_color_for_target, shared).
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.
Found on a GPU-less Windows VM (DX12/WARP), where every draw in a pass read the last-bound uniform params block so all overlaid curves took one colour, and where everything rsplot wrote linear to egui-wgpu's non-sRGB swapchain showed darker than its Color32; the storage-buffer fix is empirical from that VM, the wgpu-side cause is not identified. The headless tests read the kittest target's bytes back verbatim, so each colour fix comes with a readback that fails on the pre-fix renderer; the sRGB-target volume test rebuilds the RenderState with the sRGB variant of its format.