Wait for GPU to finish GPU->GPU Resource copy
#1 Members - Reputation: 123
Posted 13 January 2012 - 12:29 PM
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...
#2 Moderators - Reputation: 5648
Posted 13 January 2012 - 02:08 PM
#3 GDNet+ - Reputation: 2622
Posted 13 January 2012 - 03:06 PM
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!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.
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article
#4 Members - Reputation: 123
Posted 13 January 2012 - 04:26 PM
#7 GDNet+ - Reputation: 2622
Posted 14 January 2012 - 10:48 AM
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.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.
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article






