ITADN

3D integer textures cannot be sampled

#9644OpenGardenerAether 创建于 2026-06-04
G
GardenerAethercommented
<!-- Thank you for filing this! Please read the [debugging tips](https://github.com/gfx-rs/wgpu/wiki/Debugging-wgpu-Applications). That may let you investigate on your own, or provide additional information that helps us to assist.--> 3D textures with integer formats fail to sample with cryptic `Unable to operate on image class Sampled { kind: Uint, multi: false}`, even with a non-filtering sampler as (from what I understand) is the only way to use integer textures. Reproduction: 1. Create a 3D texture with an integer colour format (I am using `R32Uint`) 2. A view of this texture is created with a `::default()` descriptor 3. A sampler is created; all address modes are `ClampToEdge`, and all filter modes are `Nearest` (this is irrelevant) 4. A group layout is created: for the texture view `TextureSampleType::Uint` and `TextureViewDimension::D3`, and for the sampler `SamplerBindingType::NonFiltering`. This bind group is used in the fragment shader. 5. Variables of `var t: texture_3d<u32>` and `var s: sampler` are created in the fragment shader. 6. An attempt to call `textureSample(t, s, v)` for some arbitrary `v: vec3<f32>`. The expectation is that this should just sample a `u32`, or more precisely a `vec4<u32>` from which I can extract `x` (where I presume the actual data would be). Instead, I get this deeply disturbing error: ``` Shader validation error: Function [0] 'DDA' is invalid ┌─ Shader:33:1 │ 33 │ ╭ fn DDA(ray_position: vec3<f32>, ray_direction: vec3<f32>) -> RayHit { 34 │ │ var i = floor(ray_position); 35 │ │ var dist: f32; 36 │ │ var normal: vec3<f32>; · │ 41 │ │ if textureSample(t_chunk, s_chunk, i).x != 0 { │ │ ^^^^^^^^^^^^^ naga::ir::Expression [19] · │ 51 │ │ return RayHit(normal, dist, ray_position + ray_direction * dist); 52 │ │ } │ ╰─^ naga::ir::Function [0] │ = Expression [19] is invalid = Unable to operate on image class Sampled { kind: Uint, multi: false } ``` I have essentially no more information to work off of from this; considering my original attempts involved 8 bit and 64 bit integers, and I was guaranteed the same error every time, I'm not entirely sure what to do at this point. I'm running on Asahi Linux (NixOS) on an M2 Pro. Wgpu version is the current trunk branch `6e8d0bd149fc6de7799755a4b9ee1ecd5fa63cb3`. I was previously using a separate fork for int16 support that may or may not have since been merged, which is where I first encountered the issue, and although I have not yet tested the current stable release (29.0.3), I have no reason to suspect the error would not be repeatable there. I do not know whether to mark this as a bug report, feature request, or support request, so I'm just assuming this is not intended or expected behaviour at the moment and therefore am marking it as a bug. Feel free to change the tags though if this is something else.
1 条评论