Jump to content
  • Advertisement
Sign in to follow this  
ChenA

readback texture from gpu lead to block

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

i want read a texture from gpu to system memory
 
1.render to render target(D3D11_USAGE_DEFAULT) texture a
2.call CopyResource copy from a to D3D11_USAGE_STAGING texture b
3.in next frame, map b[j], read data, unmap b[j]
 
 
a and b is a texture array, i think if the array size is 2, it can prevent the cpu wait gpu.
because CopyResource is asynchronous, it will not executed the copy immediately.
this call is queued in the command buffer.
 

i list the render order in table below, gpu is 1 frame behind cpu

 

frame    map    cpu render    cpu copy    gpu render    gpu copy    i     j
N           0            0                    0                1                    1                0    1
N+1      1            1                    1                0                    0                1    0
N+2      0            0                    0                1                    1                0    1
 
so in the n+2 frame, call the map at texture b[0] shoudn't lead cpu to wait gpu
because copy from a[0] to b[0] is already completed in frame N+1.
 
but i test on my pc(gtx 650, win7 64bit, drive 353.30), it don't work, i need to set the
array size to 4 to prevent cpu wait gpu.
why?
thanks.
 
ps: if i use dx9,
1.render to render target(D3DPOOL_DEFAULT) texture a
2.call GetRenderTargetData copy from a to D3DPOOL_SYSMTEMMEM texture b
3.in next frame, lock texture b[j], read data, unlock b[j]
 
use two texture pingpong is enough, don't block the cpu.
 
 
 
 
Edited by ChenA

Share this post


Link to post
Share on other sites
Advertisement

Does using "SetMaximumFrameLatency(x)" have any bearing on your results? Try 1, 2 and 3 and let me know if it makes any difference. By default this is set to 3.

thanks, it works right now, after SetMaximumFrameLatency(1), just need two buffer.

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!