Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ By @beholdnec in [#8505](https://github.com/gfx-rs/wgpu/pull/8505).
- Fixed use of a texture view without `TextureUsage::TEXTURE_BINDING` as a read-only depth attachment. By @andyleiserson in [#9346](https://github.com/gfx-rs/wgpu/pull/9346).
- Fixed a `debug_assert` during stride validation for indirect multi draw. By @kristoff3r in [#9332](https://github.com/gfx-rs/wgpu/pull/9332)
- Fixed stencil values read with `textureLoad` appearing in G instead of R. By @andyleiserson in [#9520](https://github.com/gfx-rs/wgpu/pull/9520).
- Fixed some cases where the `textureNum{Layers,Levels,Samples}` functions returned incorrect results. By @andyleiserson in [#9542](https://github.com/gfx-rs/wgpu/pull/9542).

#### Metal

Expand Down
1 change: 1 addition & 0 deletions cts_runner/fail.lst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ webgpu:api,validation,state,device_lost,destroy:* // crash
webgpu:api,validation,texture,destroy:submit_a_destroyed_texture_as_attachment:* // 44%, https://github.com/gfx-rs/wgpu/issues/8714

webgpu:shader,execution,expression,call,builtin,atan2:f16:* // dx12, fails with dxc, passes with fxc, https://github.com/gfx-rs/wgpu/issues/9179
webgpu:shader,execution,expression,call,builtin,textureDimensions:* // dx12, https://github.com/gfx-rs/wgpu/issues/9541

webgpu:shader,validation,decl,let:* // texture/sampler let
webgpu:shader,validation,decl,override:* // 93%, unrestricted_pointer_parameters not implemented, https://github.com/gfx-rs/wgpu/issues/5158
Expand Down
4 changes: 4 additions & 0 deletions cts_runner/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ webgpu:shader,execution,expression,call,builtin,firstLeadingBit:*
//FAIL: webgpu:shader,execution,expression,call,builtin,select:*
// - Fails with `const`/abstract int cases on all platforms because of <https://github.com/gfx-rs/wgpu/issues/4507>.
// - Fails with `vec3` & `f16` cases on macOS because of <https://github.com/gfx-rs/wgpu/issues/5262>.
fails-if(dx12) webgpu:shader,execution,expression,call,builtin,textureDimensions:*
webgpu:shader,execution,expression,call,builtin,textureNumLayers:*
webgpu:shader,execution,expression,call,builtin,textureNumLevels:*
webgpu:shader,execution,expression,call,builtin,textureNumSamples:*
webgpu:shader,execution,expression,call,builtin,textureSample:sampled_1d_coords:*
webgpu:shader,execution,expression,call,builtin,textureSampleBaseClampToEdge:2d_coords:stage="c";textureType="texture_2d<f32>";*
// NOTE: This is supposed to be an exhaustive listing underneath
Expand Down
26 changes: 18 additions & 8 deletions naga/src/back/hlsl/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,8 @@ impl<W: Write> super::Writer<'_, W> {

// GetDimensions Overloaded Methods
// https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-getdimensions#overloaded-methods
let (ret_swizzle, number_of_params) = match wiq.query {
// We rely on the validator to reject invalid queries.
let (ret_swizzle, number_of_out_params) = match wiq.query {
ImageQuery::Size | ImageQuery::SizeLevel => {
let ret = match wiq.dim {
IDim::D1 => "x",
Expand All @@ -677,13 +678,22 @@ impl<W: Write> super::Writer<'_, W> {
};
(ret, ret.len() + array_coords + extra_coords)
}
ImageQuery::NumLevels | ImageQuery::NumSamples | ImageQuery::NumLayers => {
if wiq.arrayed || wiq.dim == IDim::D3 {
("w", 4)
} else {
("z", 3)
ImageQuery::NumLevels | ImageQuery::NumSamples => {
// We want `NumberOfLevels` or `Samples`
match wiq.dim {
IDim::D1 => ("y", 2),
IDim::D3 => ("w", 4),
IDim::D2 | IDim::Cube => {
if wiq.arrayed {
("w", 4)
} else {
("z", 3)
}
}
}
}
// We want `Elements`
ImageQuery::NumLayers => ("z", 3 + extra_coords),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering why + extra_coords and it seems to be for NumberOfLevels of sampled textures. Looks good.

};

// Write `GetDimensions` function.
Expand All @@ -704,7 +714,7 @@ impl<W: Write> super::Writer<'_, W> {
},
}

for component in COMPONENTS[..number_of_params - 1].iter() {
for component in COMPONENTS[..number_of_out_params - 1].iter() {
write!(self.out, "{RETURN_VARIABLE_NAME}.{component}, ")?;
}

Expand All @@ -713,7 +723,7 @@ impl<W: Write> super::Writer<'_, W> {
self.out,
"{}.{}",
RETURN_VARIABLE_NAME,
COMPONENTS[number_of_params - 1]
COMPONENTS[number_of_out_params - 1]
)?;

writeln!(self.out, ");")?;
Expand Down
2 changes: 1 addition & 1 deletion naga/tests/out/hlsl/wgsl-binding-arrays.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ uint NagaNumLayers2DArray(Texture2DArray<float4> tex)
{
uint4 ret;
tex.GetDimensions(0, ret.x, ret.y, ret.z, ret.w);
return ret.w;
return ret.z;
}

uint NagaNumLevels2D(Texture2D<float4> tex)
Expand Down
4 changes: 2 additions & 2 deletions naga/tests/out/hlsl/wgsl-image.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ uint NagaNumLayers2DArray(Texture2DArray<float4> tex)
{
uint4 ret;
tex.GetDimensions(0, ret.x, ret.y, ret.z, ret.w);
return ret.w;
return ret.z;
}

uint NagaNumLevels2DArray(Texture2DArray<float4> tex)
Expand Down Expand Up @@ -226,7 +226,7 @@ uint NagaNumLayersCubeArray(TextureCubeArray<float4> tex)
{
uint4 ret;
tex.GetDimensions(0, ret.x, ret.y, ret.z, ret.w);
return ret.w;
return ret.z;
}

uint NagaNumLevels3D(Texture3D<float4> tex)
Expand Down
Loading