Repository: gfx-rs/wgpu (language: rust)

Issue:
3d texture view is wrong in dx12
### Code

```rust
let texture1 = device
    .create_texture(&wgpu::TextureDescriptor {
        label: Some("Test Compute Texture 1"),
        size: wgpu::Extent3d {
            width: 16,
            height: 16,
            depth_or_array_layers: 16,
        },
        mip_level_count: 1,
        sample_count: 1,
        dimension: wgpu::TextureDimension::D3,
        format: wgpu::TextureFormat::Rgba32Uint,
        usage: wgpu::TextureUsages::COPY_SRC
            | wgpu::TextureUsages::COPY_DST
            | wgpu::TextureUsages::TEXTURE_BINDING
            | wgpu::TextureUsages::STORAGE_BINDING,
        view_formats: &[],
    });

let text_view = texture1.create_view(
    &wgpu::TextureViewDescriptor {
        label: Some("Test Compute Texture View 1"),
        ..Default::default()
    },
);
```
```wgsl
@group(0) @binding(0) var chunk: texture_storage_3d<rgba32uint, write>;

struct CsIn {
    @builtin(global_invocation_id) gid: vec3<u32>,
    @builtin(local_invocation_id) lid: vec3<u32>,
    @builtin(workgroup_id) wid: vec3<u32>,
}

@compute @workgroup_size(8,8,8)
fn test_fill(ci: CsIn) {
    let gid = ci.gid;
    let lid = ci.lid;
    textureStore(chunk, gid, vec4<u32>(gid, 1));
}
```

### The texture is treated as 2d, causing only layer 0 to be written

![image](https://github.com/gfx-rs/wgpu/assets/13982338/cec7311b-d417-45aa-aef8-b63043a96ce2)
![image](https://github.com/gfx-rs/wgpu/assets/13982338/d8b324d4-4532-4949-bb4d-7a688a91028c)
![image](https://github.com/gfx-rs/wgpu/assets/13982338/e0ffe481-b3f3-4b0f-bdb0-5b88ef54e0ed)
![image](https://github.com/gfx-rs/wgpu/assets/13982338/fee9188d-c4e9-43a0-9964-76dc112151d7)

**Platform**
```
OS: win11 22h2 22621.3007
wgpu: 0.19
```

#### Other
- It is normal on vk
  <details>
  <summary>On Vulkan</summary>

  ![image](https://github.com/gfx-rs/wgpu/assets/13982338/6134cc0b-1034-4b4f-8ff0-04374bc3f452)

  </details>

- It's normal to use 2d array
  <details>
  <summary>Use 2d array</summary>

  ```wgsl
  @group(0) @binding(0) var chunk: texture_storage_2d_array<rgba32uint, write>;

  struct CsIn {
      @builtin(global_invocation_id) gid: vec3<u32>,
      @builtin(local_invocation_id) lid: vec3<u32>,
      @builtin(workgroup_id) wid: vec3<u32>,
  }

  @compute @workgroup_size(8,8,8)
  fn test_fill(ci: CsIn) {
      let gid = ci.gid;
      textureStore(chunk, gid.xy, gid.z, vec4<u32>(gid, 1));
  }
  ```

  ![image](https://github.com/gfx-rs/wgpu/assets/13982338/75aa46d0-943e-456b-9a5a-6cbdf28bf588)
  ![image](https://github.com/gfx-rs/wgpu/assets/13982338/cd908110-b6f7-4bcd-903e-b75cd1913e50)

  </details>



Discussion / hints:
It looks like we are passing the wrong parameters to `D3D12_TEX3D_UAV`.

https://github.com/gfx-rs/wgpu/blob/6e020a079e9a512a7465252c238c5a85b1177fc5/wgpu-hal/src/dx12/view.rs#L211-L212

We should be passing `FirstWSlice: 0` and `WSize: -1` as there isn't currently a way to specify a specific depth slice in our API.

ref: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_tex3d_uav
@teoxoy: Does this have a relation to https://github.com/gfx-rs/wgpu/issues/4764?
They are related but this one is strictly for UAVs (storage textures) and https://github.com/gfx-rs/wgpu/issues/4764 is concerned with RTVs (render attachments).
I'm encountering this issue and was wondering if there's anything I can do to mitigate it in the meantime while a fix is still pending? Would switching to a texture 2D array be sufficient?
Using a texture 2D array should work.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 892da037ab..52af51bf8d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -90,6 +90,7 @@ By @brodycj in [#6924](https://github.com/gfx-rs/wgpu/pull/6924).
 #### Dx12
 
 - Fix HLSL storage format generation. By @Vecvec in [#6993](https://github.com/gfx-rs/wgpu/pull/6993)
+- Fix 3D storage texture bindings. By @SparkyPotato in [#7071](https://github.com/gfx-rs/wgpu/pull/7071)
 
 #### WebGPU
 
diff --git a/wgpu-hal/src/dx12/view.rs b/wgpu-hal/src/dx12/view.rs
index 8162b012af..fa8f2a4d61 100644
--- a/wgpu-hal/src/dx12/view.rs
+++ b/wgpu-hal/src/dx12/view.rs
@@ -184,8 +184,8 @@ impl ViewDescriptor {
                 desc.ViewDimension = Direct3D12::D3D12_UAV_DIMENSION_TEXTURE3D;
                 desc.Anonymous.Texture3D = Direct3D12::D3D12_TEX3D_UAV {
                     MipSlice: self.mip_level_base,
-                    FirstWSlice: self.array_layer_base,
-                    WSize: self.array_layer_count,
+                    FirstWSlice: 0,
+                    WSize: u32::MAX,
                 }
             }
             wgt::TextureViewDimension::Cube | wgt::TextureViewDimension::CubeArray => {


Test patch: