[D3D12] Compute Shader copy from RWStructuredBuffer to RWTexture2D?

Started by
2 comments, last by Adam Miles 7 years, 11 months ago

I have a compute shader where I have a RWStructuredBuffer sized to the same dimensions as a RWTexture2D. I want to perform a bunch of writes to the RWStructuredBuffer, then synchronize, and then copy the data to the RWTexture2D. All buffer accesses are within the same thread group..

When I do this, and display the texture with a quad, I see a bunch of flickering black regions through the texture. They pretty clearly correspond to the thread groups. This only happens with data written to and then read from the RWStructuredBuffer: I passed in a time value 'T', set the red channel of the texture to frac(T), and set the green/blue channels of the texture to the data read from the RWStructuredBuffer. Doing that, I see a smooth transition of red across all thread groups, but the green/blue are still flickering. I put a GroupMemoryBarrierWithGroupSync() (and all the various permutations of memory barriers) in between the writes to the RWStructuredBuffer and then the read from it. I have made sure I have resource barriers for transitions in the command list from UAV to Pixel Shader Resource. There's nothing in the output from the Debug Layer indicating a problem.

What am I missing?

Advertisement

Can you explain what you mean by "All buffer access are within the same thread group"?

Are we talking about just one single Dispatch here?

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

Well damn if that wasn't the exact right question to ask. Yes one dispatch, but while looking at it I realized I was calling Dispatch(32, 32, 1), and my CS was declared with [numthreads(16, 16, 1)]. My texture is 256x256 but that would result in a 512x512. I scaled it back to Dispatch(16, 16, 1) and it works as expected.

Thanks Adam.

If only my day job were that easy!

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

This topic is closed to new replies.

Advertisement