StructuredBuffer in pixel shader using RDG

Hello!

I am creating a new pixel shader rendering pass that uses the RDG. I’d like to allocate a structured buffer, memcpy some data to it and read it (no write) from my shader.
I use GraphBuilder.CreateBuffer to queue the creation of the buffer, and I know *RHILockStructuredBuffer *can be used to do the data transfer inside the pass.
The issue I’m having is the binding of the buffer to the shader.

If I use an SRV (and include *SHADER_PARAMETER_RDG_BUFFER_SRV *in my shader), then the buffer does not actually get allocated and so this doesn’t work.
This difference is caused by differing behavior in *AllocateRHITextureUAVIfNeeded *and *AllocateRHIBufferSRVIfNeeded *which are called during ExecutePass. The former does *AllocateRHITextureIfNeeded *while the latter does not.

If I use a UAV (with SHADER_PARAMETER_RDG_BUFFER_UAV), then the buffer is allocated but seemingly not bound to my shader.
SetShaderParameters, which is called inside the pass, calls SetShaderUAVs() but this does nothing for pixel shaders.
The dummy function has the following comment: “Pixelshader UAVs are bound together with rendertargets using BeginRenderPass”
However, I can’t see where this would occur and my shader seems to be reading garbage data. I can verify the buffer contains the correct data using NVidia NSight.

I’ve been searching for examples in the code, but other usages of structuredbuffers either manually allocate the buffer (no RDG), are in compute shaders and/or don’t upload data to the buffer.

Am I missing something? Any help would be appreciated :slight_smile:

Thank you!

did you find the solution ??