Jump to content
  • Advertisement
Sign in to follow this  
Semei

Wait for GPU to finish GPU->GPU Resource copy

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


Hi! How i could wait on my cpu thread for graphics device to complete copying resource before i continue executing ? DeviceContext-CopyResource is Asynchronous and creates some undesired behavior when i need to use it in my application, because i need the last copy to be done before i issue another...

Share this post


Link to post
Share on other sites
Advertisement
Can you further explain the actual problem that you're experiencing? You shouldn't have any problems with it being asynchronous, since the driver will handle synchronization for you. Any GPU operations that use the copied resource will cause the GPU to wait for the copy to finish, and any attempt at CPU readback will cause the CPU to stall and wait for the GPU to execute all pending commands so that the data is available.

Share this post


Link to post
Share on other sites

Can you further explain the actual problem that you're experiencing? You shouldn't have any problems with it being asynchronous, since the driver will handle synchronization for you. Any GPU operations that use the copied resource will cause the GPU to wait for the copy to finish, and any attempt at CPU readback will cause the CPU to stall and wait for the GPU to execute all pending commands so that the data is available.

I ditto this - if you are using D3D11, it shouldn't be possible for you to get an old / partially copied version of the resource. You can get into some strange situations if you are using the multithreaded facilities in D3D11, but it should be quite clear what is happening on each thread and when it gets played back on the immediate context --> you shouldn't have any problems with reading memory back to the CPU!

Share this post


Link to post
Share on other sites
Im rendering to a render target, then copying render target texture to shader resource, that is used as input when rendering to a render target. Problem is - the stall accours in unknown (ok, i could try to find first place where the texture is used besides when inputing it for render target, but that would somehow intruduce some random junk in my code.. ) Problem is that I need to know precise timing before last texture copy. Isnt there really a way to make it stall where i want it to?

Share this post


Link to post
Share on other sites
You don't need to do any kind of stalling, the driver will make sure everything is synchronized correctly when you use CopyResource. If you're getting incorrect results it is not a timing issue.

Share this post


Link to post
Share on other sites

You don't need to do any kind of stalling, the driver will make sure everything is synchronized correctly when you use CopyResource. If you're getting incorrect results it is not a timing issue.

And you can verify this by running with the reference device to render a frame. This will show you the ground truth of what you are telling the API to do. It would also be a good idea to use PIX to grab a rendered frame and work backwards to see where the issue is being introduced.

Share this post


Link to post
Share on other sites
Thanks for replies, seems that problem was only visual bug - i was changing texture faster than monitor could repaint it, creating some kind of tearing that only seemed like code problem.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!