TextureFormat::R16Uint isn't usable
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
pipelined-rendering branch: 432ce72fafe30598d8726072b0608035d1786251
## Operating system & version
Windows 10
## What you did
Tried to use `TextureFormat::R16Uint` with `utexture2D` and `texelFetch`.
My preference would be to use `R16unorm`, but it doesn't currently exist. I'm attempting to use `R16Uint` as a work-around and normalize it in the shader.
Related:
https://github.com/gfx-rs/wgpu/issues/1934
https://github.com/gfx-rs/wgpu/issues/2107
## What you expected to happen
The shader would source data via `texelFetch`.
## What actually happened
WGPU Error
```
Oct 23 12:15:20.140 ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error
Caused by:
In Device::create_render_pipeline
error matching VERTEX shader requirements against the pipeline
shader global ResourceBinding { group: 2, binding: 3 } is not available in the layout pipeline layout
texture class Sampled { kind: Float, multi: false } doesn't match the shader Sampled { kind: Uint, multi: false }
```
## Additional information
```glsl
#version 450
#extension GL_EXT_samplerless_texture_functions : require
layout(set = 2, binding = 3) uniform utexture2D ChunkMaterial_height_map;
void main() {
// ...
uvec4 height_sample = texelFetch(ChunkMaterial_height_map, ivec2(v_UV.x, v_UV.y), 0);
}
```
```rust
let mut height_texture = Texture::new(size, dimension, height_data, TextureFormat::R16Uint);
```
It looks like the issue is that the sample type is hard coded instead of reflected:
https://github.com/bevyengine/bevy/blob/6a8a8c9d21f32e0e46623db9438813b009f9e014/crates/bevy_render/src/shader/shader_reflect.rs#L130-L137
Contributor guide
Assessment
This issue has not been assessed yet.