Skip to content

Commit

Permalink
Fix hlsl storage format generation (#6993)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vecvec authored Jan 31, 2025
1 parent 8caefce commit 7cde470
Show file tree
Hide file tree
Showing 15 changed files with 1,303 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ By @brodycj in [#6924](https://github.com/gfx-rs/wgpu/pull/6924).

- Stop naga causing undefined behavior when a ray query misses. By @Vecvec in [#6752](https://github.com/gfx-rs/wgpu/pull/6752).

#### Dx12

- Fix HLSL storage format generation. By @Vecvec in [#6993](https://github.com/gfx-rs/wgpu/pull/6993)

#### WebGPU

- Improve efficiency of dropping read-only buffer mappings. By @kpreid in [#7007](https://github.com/gfx-rs/wgpu/pull/7007).
Expand Down
12 changes: 6 additions & 6 deletions naga/src/back/hlsl/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ impl crate::StorageFormat {
Self::R8Sint | Self::R16Sint | Self::R32Sint => "int",
Self::R64Uint => "uint64_t",

Self::Rg16Float | Self::Rg32Float => "float2",
Self::Rg8Unorm | Self::Rg16Unorm => "unorm float2",
Self::Rg8Snorm | Self::Rg16Snorm => "snorm float2",
Self::Rg16Float | Self::Rg32Float => "float4",
Self::Rg8Unorm | Self::Rg16Unorm => "unorm float4",
Self::Rg8Snorm | Self::Rg16Snorm => "snorm float4",

Self::Rg8Sint | Self::Rg16Sint | Self::Rg32Uint => "int2",
Self::Rg8Uint | Self::Rg16Uint | Self::Rg32Sint => "uint2",
Self::Rg8Sint | Self::Rg16Sint | Self::Rg32Uint => "int4",
Self::Rg8Uint | Self::Rg16Uint | Self::Rg32Sint => "uint4",

Self::Rg11b10Ufloat => "float3",
Self::Rg11b10Ufloat => "float4",

Self::Rgba16Float | Self::Rgba32Float => "float4",
Self::Rgba8Unorm | Self::Bgra8Unorm | Self::Rgba16Unorm | Self::Rgb10a2Unorm => {
Expand Down
17 changes: 17 additions & 0 deletions naga/tests/in/storage-textures.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@group(0) @binding(0) var s_r_r: texture_storage_2d<r32float, read>;
@group(0) @binding(1) var s_rg_r: texture_storage_2d<rg32float, read>;
@group(0) @binding(2) var s_rgba_r: texture_storage_2d<rgba32float, read>;
@compute @workgroup_size(1) fn csLoad() {
_ = textureLoad(s_r_r, vec2u(0));
_ = textureLoad(s_rg_r, vec2u(0));
_ = textureLoad(s_rgba_r, vec2u(0));
}

@group(1) @binding(0) var s_r_w: texture_storage_2d<r32float, write>;
@group(1) @binding(1) var s_rg_w: texture_storage_2d<rg32float, write>;
@group(1) @binding(2) var s_rgba_w: texture_storage_2d<rgba32float, write>;
@compute @workgroup_size(1) fn csStore() {
textureStore(s_r_w, vec2u(0), vec4f(0.0));
textureStore(s_rg_w, vec2u(0), vec4f(0.0));
textureStore(s_rgba_w, vec2u(0), vec4f(0.0));
}
Loading

0 comments on commit 7cde470

Please sign in to comment.