Sign in to follow this  
Vertex333

Ways to update only parts of the screen.

Recommended Posts

If I have the information (rectangles) that only some parts of the screen get updates (the objects to be drawn are also known) and I want to only update the backbuffer (let the rest stay the same) what do I need to do? If I do not call clear, Debug will do this in an annoying way anyway. Additional I don't know if I can trust that everything is still there. I know that there is the option to set rectangles in the clear and present calls, but as far as I read these are only used for swap chains (clear isn't... ok). So how can I only update a region and display this to the screen, leaving the rest as it is. Thx, Vertex

Share this post


Link to post
Share on other sites
If you are using Direct3D9, you can resolve your issue with ViewPort.
Specifing a Viewport in device, it will clear and draw only on the selected region.
Viewport it's a simple RECT structure, so it will be very easy.

D3D10 does not take care of viewport in zbuffer clear, but only in rendering.

Share this post


Link to post
Share on other sites
Quote:
Original post by XVincentX
If you are using Direct3D9, you can resolve your issue with ViewPort.
Specifing a Viewport in device, it will clear and draw only on the selected region.
Viewport it's a simple RECT structure, so it will be very easy.

D3D10 does not take care of viewport in zbuffer clear, but only in rendering.
Thx!
I'm using D3D9, D3D10 zbuffer clear for the whole screen wouldn't be a problem for me either.

So, I can simply create a viewport with the region I want to update and set it on the device. Then I have to Begin/EndScene with drawcalls and finally present. Afterwards I have to update viewport for the next rectangle, set viewport again and so on.

Because I may have lots of Rectangles in !one Frame! I have to make multiple "partial updated" Frames out of it?

Wouldn't this be horrible for performance? Lets say I would have hundreds of viewports in "one" Frame.

Vertex

Share this post


Link to post
Share on other sites
You don't have to re-set the viewport each time. Use scissor tests :


// create a rectangle structure defining the area of your screen you want to draw on (in pixels, starting from the upper left corner)
RECT scissorRect = { 10, 10, 500, 500 };

// set it and enable scissortests
pd3dDevice->SetScissorRect(&scissorRect);
pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, true);

// render your scene as always, and only the part inside the scissorRect will be drawn

// unactivate scissor test to draw normally
pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);

Share this post


Link to post
Share on other sites
Quote:
Original post by Vertex333
If I do not call clear, Debug will do this in an annoying way anyway. Additional I don't know if I can trust that everything is still there.
Actually, you told it that it's free to do that. D3DSWAPEFFECT_DISCARD says "After every frame, you're free to do whatever you like with the backbuffer - Discard it". If you need to keep the backbuffer how it was, you'd need to use D3DSWAPEFFECT_COPY (Which will be considerably slower).

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by Vertex333
If I do not call clear, Debug will do this in an annoying way anyway. Additional I don't know if I can trust that everything is still there.
Actually, you told it that it's free to do that. D3DSWAPEFFECT_DISCARD says "After every frame, you're free to do whatever you like with the backbuffer - Discard it". If you need to keep the backbuffer how it was, you'd need to use D3DSWAPEFFECT_COPY (Which will be considerably slower).

Thx all!

@Evil Steve: Although copy is slower it might be faster if I have to redraw lots objects? Maybe some hundred or thousand Drawcalls/SetRS more. Here the question arises which way is faster? Any suggestions without measurement (costs only a little bit, or much)?

I had another Idea, copying it myself? Make a backup and use it for the next frame. Would not decrease the graphics chips performance that much. Mhm... I think I know what I will read in the next post: This may cost more than using the flag.

Thx,
Vertex

Share this post


Link to post
Share on other sites
Quote:
Original post by Vertex333
@Evil Steve: Although copy is slower it might be faster if I have to redraw lots objects? Maybe some hundred or thousand Drawcalls/SetRS more. Here the question arises which way is faster? Any suggestions without measurement (costs only a little bit, or much)?
Thousands of Draw calls is going to destroy your frame rate. You really need to do whatever you can to keep the number down.

Quote:
Original post by Vertex333
I had another Idea, copying it myself? Make a backup and use it for the next frame. Would not decrease the graphics chips performance that much. Mhm... I think I know what I will read in the next post: This may cost more than using the flag.
How would you make this backup? It's likely to be slower than using the flag, yes.

What exactly are you trying to do here? When you only update part of the screen, is that it for that frame? Or are you updating multiple viewports every frame?

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by Vertex333
@Evil Steve: Although copy is slower it might be faster if I have to redraw lots objects? Maybe some hundred or thousand Drawcalls/SetRS more. Here the question arises which way is faster? Any suggestions without measurement (costs only a little bit, or much)?
Thousands of Draw calls is going to destroy your frame rate. You really need to do whatever you can to keep the number down.

Quote:
Original post by Vertex333
I had another Idea, copying it myself? Make a backup and use it for the next frame. Would not decrease the graphics chips performance that much. Mhm... I think I know what I will read in the next post: This may cost more than using the flag.
How would you make this backup? It's likely to be slower than using the flag, yes.

What exactly are you trying to do here? When you only update part of the screen, is that it for that frame? Or are you updating multiple viewports every frame?

I don't know what I should to to keep the drawcalls down, since I "don't know" if 3D objects have the same properties. So, for every 3D Object one drawcall and up to some RS changes are needed. :( My only suggestion was to draw multiple objects with one draw call by using degenerated triangles in between the objects (when I last asked you about that you wrote that this wouldn't be a good solution or so...)

Backing up: mhm... render to texture,... it's slower than the flag anyway... Thx for conformance.

What I exactly have: Either I redraw the whole screen or update only parts. For the update I know which area (rectangle) to be updated and which objects to be redrawn are affected. If I correctly understand you that is all I do in a frame (but of course multiple parts/rectangles get update). I do not update multiple viewports every frame. I even do not know why I should do this anyway. (suggestion from previous post, multiple monitors, multiple windows,...)

thx,
Vertex

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