Sign in to follow this  
AlexAlex

Rendering to offscreen surface many times.

Recommended Posts

Hello people. In my application I wish to render many objects to an offscreen surface and then save the image of each object to a file. Each object should be rendered to the surface and saved to the bitmap file seperately. That is, if I have a car and a dog, I wish to render the car, save it to a file and then render the dog and save it to the file too. The my rendering process is: for each object device.Clear() device.BeginScene() Render(object) device.EndScene() lock the render target surface and retreive the bits. Then save them to an image. The problem is that not all objects get rendered. That is, most of the resulting images are blank black images and sometimes I can see an object in one of the images. This phenomenon seems random and I cannot deterministically reproduce it. What could be a problem? Shouldn't EndScene() force rendering the object? When I lock the render target, do I know for sure that the scene has already been rendered to it? Alex.

Share this post


Link to post
Share on other sites
You should only have one set of BeginScene/EndScene calls between each Present.

What should guarantee the render is the lock. Although the more efficient way to get the data is GetRenderTargetData and then locking the CPU-side surface.

Share this post


Link to post
Share on other sites
I noticed similar problems when rendering out billboards. The first billboard worked fine, further billboards were trashed. A Present() between each render block cured the problem, although DX debug runtime casts some flashy graphics on your main screen while it lasts.

Propably a driver bug, but it is reproducable over more than a year now so maybe this behaviour is intended in some way. I can't imagine why, though.

Bye, Thomas

Share this post


Link to post
Share on other sites
Quote:
Original post by Schrompf
I noticed similar problems when rendering out billboards. The first billboard worked fine, further billboards were trashed. A Present() between each render block cured the problem, although DX debug runtime casts some flashy graphics on your main screen while it lasts.

Propably a driver bug, but it is reproducable over more than a year now so maybe this behaviour is intended in some way. I can't imagine why, though.

Bye, Thomas
That's the D3D debug runtimes telling you that you're doing something wrong, it's not a fdriver bug. Most likely you're using DISCARD as your swap effect, which tells the driver that it can wipe the backbuffer after you Present(). The debug runtimes enforce that by clearing the backbuffer to magenta and green on alternate frames. Just because it works on your drivers, doesn't mean it'll work on other drivers; particularly if the driver makes use of the knowledge that the backbuffer can be wiped and returns another surface...

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
That's the D3D debug runtimes telling you that you're doing something wrong, it's not a fdriver bug. Most likely you're using DISCARD as your swap effect, which tells the driver that it can wipe the backbuffer after you Present(). The debug runtimes enforce that by clearing the backbuffer to magenta and green on alternate frames. Just because it works on your drivers, doesn't mean it'll work on other drivers; particularly if the driver makes use of the knowledge that the backbuffer can be wiped and returns another surface...


Thanks, but this is not the point. My post is propably mis-leading. I just tried to tell AlexAlex that I noticed similar behaviour some time ago, that I deem it a driver bug, how I solved it and what potential side effects the solution had. The side effect being a brightly coloured screen when using the D3D debug runtime. Which in my point of view just adds insult to injury :-)

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