• Advertisement
Sign in to follow this  

Access Another App's Depth Buffer

This topic is 3951 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 need to be able to read from another DirectX app's depth buffer. Is there any good way to do this? Example: App1 is a DirectX app running normally. App2 is started and enter is pressed, App2 captures App1's current depth buffer and writes it out to disk. I hope this is enough information. I am not a DirectX Pro :)

Share this post


Link to post
Share on other sites
Advertisement
Even the application owning the depth buffer would find this hard, so no - if at all possible from another process it'd be very difficult.

Look up Muhammad Haggag's D3D hooking example - you might get lucky with this and manage to capture a SetDepthStencil() call and/or manipulate the device state to enable you to get something on some hardware.

Care to share more details on why you want to do this?

Cheers,
Jack

Share this post


Link to post
Share on other sites
Thank you for your help jolly. That hooking example is great!

I need to render the depth buffer to the right of the main screen buffer (I plan on hooking into the set resolution call of DirectX to double the width of whatever resolution is requested). Then I plan on reading pixel data from the depth buffer, running whatever conversion is needed (get rid of stencil data, etc) and render it out to the right side of the screen.


Will IDirect3DDevice9::GetDepthStencilSurface() allow me access to the depth buffer data?

This only needs to work on one kind of card (Nvidia 7950GT). Although universal support would be great.

Thank you again

Share this post


Link to post
Share on other sites
Quote:
Original post by MurphyIdiot
Will IDirect3DDevice9::GetDepthStencilSurface() allow me access to the depth buffer data?
That call will obtain a reference you can use (e.g. defensive shallow copy) but not necessarily access. Depends on the format and device

Quote:
Original post by MurphyIdiot
This only needs to work on one kind of card (Nvidia 7950GT). Although universal support would be great.
You'd have to run enumeration code to be sure, don't assume any features.

Thing is, if you use MH's hooking code you'll have to intercept the implicit swap chain, as well as any extra ones created. You'd have to bend them for format support that allows you to read it back as it suits you...

Best of luck with it, but even if you get it functionally working you might find that the read-back kills Z performance on the hardware and means your target application runs like a dog and is no longer playable [oh]

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
Best of luck with it, but even if you get it functionally working you might find that the read-back kills Z performance on the hardware and means your target application runs like a dog and is no longer playable


I had assumed there would be some performance drop, maybe it would be ok with some lower app settings, that remains to be seen. Thanks for your help again jolly. You provided some good tips. I'll see what I can manage to do :)

Share this post


Link to post
Share on other sites
Would a depth buffer be possible to generate through a pixel shader?

The pixel shader reads into the current frame, gets the z depth for that pixel, and writes out the depth as a gray scale value on the side of the screen buffer.

I am thinking of using the dll hooking code to inject that shader into the pipeline for the target app.

I am also not a pro when it comes to shaders, is there any reason something like this couldn't work?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement