Sign in to follow this  
Noggs

Another reading data from GPU on CPU question (Xbox360)

Recommended Posts

Noggs    141
I know this question has been done to death but I have a question specific to XNA running on an Xbox360 that I have not found an answer to. I am aware that on PC reading data back from the GPU is problematic, caused by limited bandwidth and the need for several buffers to avoid stalling, but with the unified memory on the 360 it would seem more viable.

Basically I am curious as to whether reading GPU processed data on the CPU is a better option on the 360? Unfortunately I don't have one to test but I'm wondering if anyone on this forum has attempted it?

Share this post


Link to post
Share on other sites
Erik Rufelt    5901
What data do you want to read back, and how often?
You can read back data on the PC without problems, it just depends on how much and how often, and then you might want to weigh the performance hit against the alternative.

EDIT: As to how much difference there is with XBox360 I don't know. However, one of the things that can cause problems is frame buffering. That is, 3 frames can often be buffered before they are drawn, so you must wait until all those 3 frames are drawn before the data you want to read is actually there. If you use that data to calculate the next frame, then there can't possibly be another frame buffered before the read is complete, which means the buffering is lost. So even if you had a system with the same exact memory for GPU and CPU that issue might still cause a problem. But again, it all depends on what you want to do with it.

Share this post


Link to post
Share on other sites
Noggs    141
Specifically a water simulation. I have a SIMD solution running on PC (in C++/DirectX) but I know that were I to port it to XNA the simulation would have to be written in C# without using SIMD on the 360. I need to read the simulation back to calculate the buoyancy forces on my objects.

I have experience with 360 C++ development and I think there is a 2 frame latency - the render command in the pending command buffer, and the currently rendering frame. Once the GPU has finished rendering the water simulation to a rendertarget it should be available on the CPU. I don't know if there are other forces at work during XNA C# code though.

Share this post


Link to post
Share on other sites
MJP    19753
Haven't really tried it myself, but I would bet that a copy still takes place so there's still going to be a bandwidth hit. But either way the major problem isn't the bandwidth, but rather the GPU/CPU synchronization like Erik mentioned. On XNA you have no access to low-level synch primitives, so your only possible approach is to triple-buffer and use VSYNC as a synchronization method.

Share this post


Link to post
Share on other sites
Noggs    141
Thanks for the replies, it sounds like it has similar issues as on DX9 on the PC. I'll have a go at getting it running using triple buffering and see how performance is.

Share this post


Link to post
Share on other sites
skytiger    294
if you do nothing but read back from the gpu it will work ok

as soon as there is any real rendering load on the gpu the readbacks become very slow (over 25 ms for a single texel)

in my experience it doesn't matter whether you wait 3 frames or 12 frames ... it makes no difference

shawn hargreaves said as much, but I ignored him ...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this