Naga验证此代码段:
[[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.));
}将rgba8unorm替换为rgba8uint会导致naga抛出错误。
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我尝试了不同的标量组合和vec4<>在textureStore: i32,u32,f32,但没有运气。
问题是:如何使用内置函数textureStore()与texture_storage_2d而不是texture_storage_2d?
编辑:下面是丹的答案,我尝试了以下方法
[[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));
} 它起作用了!
我试着用textureStore(输出,vec2(10,10),vec4(10,5,10,20))失败,忘记了textureStore中的u等等。
谢谢。
发布于 2021-12-17 20:31:20
要在rgba8uint中存储,需要使用vec4<u32>类型。有关每个纹理存储的对应类型,请参见这里。如果这不起作用,你可能会有不同的问题。(你是把10.等送到vec4<u32>吗?)应该是10u。Wgsl对类型非常严格。)
https://stackoverflow.com/questions/70391717
复制相似问题