You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on occlusion culling and can't seem to write to a texture in my compute shader. wgpu wants the storage texture to be write-only, but there's no way to express that from my rust-gpu shader.
Specifically we need to add AccessQualifier to the Image type variables.
That is, this is an OpenCL feature, not a Vulkan one, and wgpu couldn't possibly make use of it (unless they misunderstood the specification, too?).
But it looks like this is used in Vulkan, at least in compute. And I'm hitting it in my use of wgpu.
I expect that I can try to tackle this, unless someone gets to it first.
Expected Behaviour
I expect to be able to specify that an Image is read-only, write-only, or read and write.
Example & Steps To Reproduce
Create a shader that uses a texture that gets written to. Try to use that shader in a wgpu compute pipeline.
My specific pipeline validation error is this:
wgpu error: Validation Error
Caused by:
In Device::create_compute_pipeline, label = 'compute-occlusion-copy-depth-to-pyramid'
Error matching shader requirements against the pipeline
Shader global ResourceBinding { group: 0, binding: 2 } is not available in the pipeline layout
Texture class Storage { format: R32Float, access: StorageAccess(STORE) } doesn't match the shader Storage { format: R32Float, access: StorageAccess(LOAD | STORE) }
But yours would be different.
I should also add that simply marking my storage texture as LOAD | STORE (read+write) from wgpu is not an option for me as I am targeting WebGPU, and read+write storage textures is a native-only opt-in feature ;).
Shader
pubtypeDepthImage2d = Image!(2D,type=f32, sampled=true, depth=true);pubtypeDepthPyramidImage = Image!(2D, format = r32f, sampled = true, depth = false);pubtypeDepthPyramidImageMut = Image!(2D, format = r32f, sampled = false, depth = false);// this needs to be write-only/// Copies a depth texture to the top mip of a pyramid of mips.#[spirv(compute(threads(32)))]pubfncompute_copy_depth_to_pyramid(#[spirv(descriptor_set = 0, binding = 0, storage_buffer)]desc:&PyramidDescriptor,#[spirv(descriptor_set = 0, binding = 1)]depth_texture:&DepthImage2d,#[spirv(descriptor_set = 0, binding = 2)]mip:&DepthPyramidImageMut,#[spirv(global_invocation_id)]global_id:UVec3,){if desc.should_skip_invocation(global_id){return;}let depth:Vec4 = depth_texture.fetch_with(global_id.xy(), sample_with::lod(0));unsafe{
mip.write(global_id.xy(), depth);}}
The text was updated successfully, but these errors were encountered:
I think I was barking up the wrong tree. It seems the problem is likely with wgpu, and I'm not sure it's possible to use Image::write on any storage texture with wgpu until something gets fixed, but I'll die on that hill later.
I'll close this and if we ever need it again we can resurrect it later.
I'm working on occlusion culling and can't seem to write to a texture in my compute shader.
wgpu
wants the storage texture to be write-only, but there's no way to express that from myrust-gpu
shader.Specifically we need to add
AccessQualifier
to theImage
type variables.Related to:
AccessQualifier
s toImage
, theImage!
macro and codegen EmbarkStudios/rust-gpu#1116Image!
should exposeAccessQualifier
. EmbarkStudios/rust-gpu#1097And in one of those issues @eddyb says:
But it looks like this is used in Vulkan, at least in compute. And I'm hitting it in my use of
wgpu
.I expect that I can try to tackle this, unless someone gets to it first.
Expected Behaviour
I expect to be able to specify that an
Image
is read-only, write-only, or read and write.Example & Steps To Reproduce
Create a shader that uses a texture that gets written to. Try to use that shader in a
wgpu
compute pipeline.My specific pipeline validation error is this:
But yours would be different.
I should also add that simply marking my storage texture as
LOAD | STORE
(read+write) fromwgpu
is not an option for me as I am targeting WebGPU, and read+write storage textures is a native-only opt-in feature ;).Shader
The text was updated successfully, but these errors were encountered: