Skip to main content
GameDev.net gamedev.net
🔒 Locked

render target access after present ?

Started by BartGallet May 13, 2003 at 4:10 PM 1 replies 350+ views
Original Post
BartGallet
BartGallet
leaving the fact that copying data from the GPU to the CPU is a bottle-neck, I do have enough processing power to make things run with a dual processor PC. However, I do have another complication. I have two renderviews. One of an observers point of view, looking at the robotic vehicle, and one view with the POV of the robotic vehicle. It is the latter view that I need to send to my vision software at 5Hz. I have two threads, one where I render the observer''s view at 20Hz, and the other which renders the robot''s POV. I am sharing the Directx device thru a critical region. All works fine when I just render the view, and I don''t do any image copy of the robot''s view from GPU to CPU. However, since that my observer''s view is running at 4 times the speed as my robot''s view, I want the robot''s view rendering kept at minimum, such that the observer''s view doesn''t have to wait to long when the robot''s view rendering is using the Directx Device. At least, not noticable-long. So I want to do the copying of the robot''s view to the CPU memory after I leave the critical region (i.e. after I have presented my robot''s view). The robot''s view is rendered on an aditional swap chain. And initially I had something like this pseudo code: 1 set render code to swapchain back buffer 2 render scene 3 copy back buffer 4 present 4 access copied backbuffer image bytes, and copy over to CPU but that doesn''t work. I assume that after presenting the backbuffer to the front, I cannot access that data anymore. So I modified my code like this 1 create offscreenplainbuffer 2 set render target to offscreen buffer 3 render 4 copy the offscreen buffer to backbuffer using UpdateSurface 5 present 6 access offscreen buffer image bytes, and copy over to CPU But that doesnt work either, the image I created is all black. Is my logic flawed? did I miss something? Cheers Bart
Osc
Osc
You need to make sure that the render queue has been flushed before you try to copy the render target. Calling Lock() on the surface should do the trick... you can get this to work on the backbuffer if it was created as lockable.
BartGallet
BartGallet
Thanks for your reply Osc.

The problem I have is that I generated a locked copy of the back buffer. But after the pipe-line was flushed (After I used Present), I could access the copy of the buffer, but the information of the image was gone.

I got around this through rendering to a surface using RenderToSurface. But I am still figuring out why I could not make it work with the locked surface which is a copy of the back buffer.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.