Archived

This topic is now archived and is closed to further replies.

Christoph

GetBackbuffer???

Recommended Posts

Hi, I want to copy a part from the backbuffer to a surface in order to lock it and compare the color values with a key color. I''m using GetBackbuffer, but the surface this function gives me is not lockable. I have also tried to copy a part of the backbuffer to another surface with StretchRect - an error occurs here as well. Do you have a tip how I can lock a rect of the backbuffer and read the color values? thx

Share this post


Link to post
Share on other sites
Note that requesting a lockable backbuffer puts the driver "at it's toes". It has to allocate a linear space in AGP memory for transferring the image back for the processor to use (and that can potentially take a huge amount of memory).
In games, locking the backbuffer is not recommended, for that reason; for productivity apps, it might not matter.

-Nik

EDIT: To clarify, taking a huge amount of extra memory == probable performance reduction. Not to mention that reading back from the video memory is slow in any case.

[edited by - Nik02 on May 26, 2004 4:07:44 PM]

Share this post


Link to post
Share on other sites
Have you looked at asynchronous notifications?

IDirect3DDevice::CreateQuery can create an occlusion query object, with which you can determine how many pixels pass the z testing. This count can be used in determining how much pixels have been occluded. This is very efficient, since drivers that support this capability track the number of occluded pixels anyway.

As the queries are asynchronous, the device returns the data if it can. If not ready, it bails quickly and returns the control to the calling thread, and you can use the previous value until the new value is ready to download.

Note that not all hardware will support asynch notification - you''d need to fall back to locking if this is the case.

-Nik

Share this post


Link to post
Share on other sites
Don''t lock the back-buffer for the sun visibility check...It''s simply too slow. I easily got ~40 FPS on a Radeon 8500 with 800x600 when reading the back-buffer back.

Either use occlusion culling as Nik02 suggests, or write your own software solution.

Share this post


Link to post
Share on other sites
Right, the backbuffer function is working, but now the performance sucks ;-).
So, what exactly should I do? Before testing, I render everything but the skybox. My sun is a billboard of the color RGB(0,255,255).
How do I have to apply a query object in combination with the z-test? Can you please post the settings I have to use?

Share this post


Link to post
Share on other sites