Jump to content
  • Advertisement
Sign in to follow this  
Sharky

Texture readback (from GPU->CPU)

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

Hi gamedev community,

 

I have been asked to implement a method by which a single depth value can be sampled from the depth information of a g-buffer (deferred renderer using a 32-bit floating point texture storing viewspace depth) and then this floating point value returned to system memory for storage and use in calculations on the CPU.

 

For example, I would like to query the centre of the screen (effectively obtaining a depth value from the centre of the depth buffer) and then pass this back to the CPU / system memory. Sadly the depth buffer is the only source of depth information I have available to query for this particular application hence the need to pull values from it rather than elsewhere.

 

I am limited to using DirectX9 feature set, HLSL and Shader Model 3.0.

 

I am looking for suggestions as to how I might achieve this. I would suspect that I have to ultimately make use of the GetRenderTargetData function at some point and suffer the inherent GPU stalls that this results in. Any other ideas or things I may have missed?

 

Thanks in advance for your time.

 

p.s. I guess I'm basically looking for a view ray->scene intersection test that returns the first hit depth value whereby the only depth information I have available is that in the g-buffer. I hope that makes sense...

Share this post


Link to post
Share on other sites
Advertisement

It has been a while since I used DX9, but one approach could be to do a StretchRect call to copy the value that you want into a smaller buffer, and then map the smaller buffer to CPU memory.  That would let you only lock a small amount of memory, and only the part that you are interested in.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!