Jump to content

  • Log In with Google      Sign In   
  • Create Account


Wait for GPU to finish GPU->GPU Resource copy


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Shuun   Members   -  Reputation: 123

Like
0Likes
Like

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


Sponsor:

#2 MJP   Moderators   -  Reputation: 10243

Like
0Likes
Like

Posted 13 January 2012 - 02:08 PM

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.

#3 Jason Z   Crossbones+   -  Reputation: 4699

Like
0Likes
Like

Posted 13 January 2012 - 03:06 PM

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!

#4 Shuun   Members   -  Reputation: 123

Like
0Likes
Like

Posted 13 January 2012 - 04:26 PM

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?

#5 Shuun   Members   -  Reputation: 123

Like
0Likes
Like

Posted 13 January 2012 - 04:29 PM

P.S Im not reading it back to CPU, operations are on GPU only.

(where is edit button? Posted Image )

#6 MJP   Moderators   -  Reputation: 10243

Like
1Likes
Like

Posted 13 January 2012 - 06:56 PM

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.

#7 Jason Z   Crossbones+   -  Reputation: 4699

Like
1Likes
Like

Posted 14 January 2012 - 10:48 AM

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.

#8 Shuun   Members   -  Reputation: 123

Like
0Likes
Like

Posted 15 January 2012 - 03:48 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS