Wait for GPU to finish GPU->GPU Resource copy

Started by
6 comments, last by Semei 12 years, 3 months ago

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...
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.

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!
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?
P.S Im not reading it back to CPU, operations are on GPU only.

(where is edit button? wacko.png )
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.

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.
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.

This topic is closed to new replies.

Advertisement