Naga validate this snippet:
[[group(0), binding(0)]] var output :
texture_storage_2d<rgba8unorm,write>;
[[stage(compute), workgroup_size(1)]]
fn main() {
textureStore(output, vec2<i32>(10,10), vec4<f32>(10.,5.,100.,200.));
}
Replacing rgba8unorm with rgba8uint makes naga throwing an error.
Entry point main at Compute is invalid: The value [9] can not be stored
Generating SPIR-V output requires validation to succeed, and it failed in a previous step
I tried different combinations of scalar with vec4<> in textureStore: i32,u32,f32 but no luck.
Question is: How can I use the builtin function textureStore() with texture_storage_2d<rgba8uint,write> instead of texture_storage_2d<rgba8unorm,write> ?
EDIT: Following Dan answer I tried the following
[[group(0), binding(0)]] var output :
texture_storage_2d<rgba8uint,write>;
[[stage(compute), workgroup_size(1)]]
fn main() {
textureStore(output, vec2<i32>(10,10), vec4<u32>(10u,5u,10u,20u));
}
It works!
I tried and failed with textureStore(output, vec2(10,10), vec4(10,5,10,20)); I forgot the u in 10u,5u, etc...
Thanks.
To store in a rgba8uint
, you need to use the type vec4<u32>
. See here for the corresponding type for each texture storage. If that's not working, you may have a different problem. (Are you passing in 10.
etc to the vec4<u32>
? It should be 10u
. Wgsl is very strict about types.)