Jump to content
  • Advertisement
Sign in to follow this  
Volgogradetzzz

Computations with DirectCompute. How to get data back?

This topic is 1127 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

Hello,

 

I'm trying to use my gpu for computations only (I don't even create a swap chain). But I'm not sure how to retrieve a data after shader do it's job. I want to modify the same data I passed. For this I'm using single structured buffer binded as D3D11_BIND_UNORDERED_ACCESS.

 

As far as I know I need to use D3D11_CPU_ACCESS_READ together with D3D11_USAGE_STAGING. But in this case I have an error:

A D3D11_USAGE_STAGING Resource cannot be bound to any parts of the graphics pipeline, so therefore cannot have any BindFlags bits set.

My next approach was to create a structured unordered buffer with D3D11_USAGE_DEFAULT usage. I applied calculations on it, next I called 

ID3D11DeviceContext::CopyResource()

to copy this buffer to the one with D3D11_CPU_ACCESS_READ and finally read the data. But I'm not sure this is a correct way - I don't like this extra copying between resources.

Share this post


Link to post
Share on other sites
Advertisement

It's correct and actually the only way: Have a staging buffer (no bind flags, cpu read), copy, then map/unmap to read data back.

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!