mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 00:11:11 +01:00
fix(dx12): Fix textureNum{Levels,Layers,Samples} functions (#9542)
This commit is contained in:
1 parent
ecbed8b574
commit
4c1ea47ea2
6 files changed
+27
-11
No files matched your search
@@ -225,6 +225,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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
@@ -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),
|
||||
};
|
||||
|
||||
// Write `GetDimensions` function.
|
||||
@@ -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}, ")?;
|
||||
}
|
||||
|
||||
@@ -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, ");")?;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user