Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

[D3D12] Compute Shader copy from RWStructuredBuffer to RWTexture2D?

This topic is 797 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!