readback texture from gpu lead to block

Started by
1 comment, last by ChenA 8 years, 5 months ago
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.
hehe.
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.

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

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.

hehe.

This topic is closed to new replies.

Advertisement