Sign in to follow this  
Daniel Lee

howto speed up rendering with 5 viewports

Recommended Posts

allo, i'm working with 5 viewports and noticed that the graphics is rotating rather slow. I think its the repeatative re-initialising of the viewports in the draw loop. is there a better way to achieve higher visual performance and yet maintaining the 5 viewports. ciao

Share this post


Link to post
Share on other sites
If you are rendering the same meshes, you could use "Instancing".

I heard about it that you only need to send the vertex data to the graphics card once instead of 5 times (correct me?!).

You could also pre-transform the vertices in your program instead of matrices and use a vertex shader without matrix calculations.

Share this post


Link to post
Share on other sites
openGL does not have instancing, instancing is a d3d thing, it is not needed in openGL.

To speed things up you could try VBO, but not all hardware supports that.

allso remember, 5 viewports take five times as mutch time to render than one.

Share this post


Link to post
Share on other sites
Quote:
Original post by Daniel Lee
I think its the repeatative re-initialising of the viewports in the draw loop.


Find out for sure. It'd be a shame for you to put lots of effort into speeding one thing up, only to find it's another.

How many polys are you drawing? any shaders? how fast is it with 1 viewport and the same geometry + shaders? how fast is it with 5 viewports and simpler geometry + shaders? How fast drawing the geometry and shaders 5 times in one viewport?

Find these things out, and you'll probably have the answer.

Share this post


Link to post
Share on other sites
What you want to do is check the time it takes to render 1 viewport 1000times
and then check the time it takes to render 5 viewports 1000times.

This is what the result should be if its just because of render 5 times the ammount of stuff
5 * SingleViewportTime = PentViewportTimes * 1
ie
1 Viewport takes 10 secs
5 viewports takes 50 secs

then there isnt really anything that could be done.

Share this post


Link to post
Share on other sites
well looks like its there to stay. In my app those vertex are already in display lists. Maybe the nearest thing is to use
another higher performance card though the case of Dollar&Cents.

what do you think.
ciao

Share this post


Link to post
Share on other sites
Is this for a modelling program or game?

Could you only refresh when needed? Like if you need to rotate in one viewport, update that viewport only when you are doing something in that one. Stop once you are done with it...

Share this post


Link to post
Share on other sites
Display lists and VBO is not the same.

Even though display lists speed things up a bit vbos loads the triangle & vertex data onto the graphics card self and then when you render you simple direct the client calls to the vbos

ie
glVertexPointer3f(Pointer to VBO)
DrawElements(TRIANGLES)

Share this post


Link to post
Share on other sites
Quote:
Original post by dawidjoubert
Display lists and VBO is not the same.

Even though display lists speed things up a bit vbos loads the triangle & vertex data onto the graphics card self and then when you render you simple direct the client calls to the vbos


Display list may also reside on video ram (as always its the drivers decistion whats in vram and what not). And how VBOs perform agains display lists depends on many things. In most cases for static geometry, display list perform better.

As for how to use VBOs: lesson 45

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi

You can use compiled vertex array extension (GL_EXT_compiled_vertex_array).

void Render()
{
// Define all geometry data as single vertex array
// By using you can set up all you geometry data by a single func call
1) glInterleavedArrays(...);
2) glLockArrays();
// First viewport transforms glRotate etc
3) glDrawArrays(...);
// Second viewport transforms glRotate etc
3) glDrawArrays(...);
...
// Fifth viewport transforms glRotate etc
3) glDrawArrays(...);
4) glUnlockArrays();
}

1) Setup all you geometry data
2) This function call will transfer all data from 1) to GPU mem.
3) After glDrawArrays call GPU will render data from its mem.
4) Free GPU mem.

This code work very fast it can give about 100 - 150 fps speed up.

Share this post


Link to post
Share on other sites
Quote:

Fake it with one viewport (one context) and scissoring.


Multiple viewports do not mean multiple rendering contexts. Also, viewport and scissoring do not do the same thing. One affects the transformation process, the other just rejects pixels outsite of an area.

Anyway, a simple but very important issue: Are you clearing the buffer(depth+color+possibly stencil) each time you render one of the viewports? If yes, then it's unnecessary since I imagine the viewports don't overlap. Clearing the buffers is an expensive function. Just clear the buffer once in every frame, and then render the multiple viewports(glClear() clears the whole buffer, not just the pixels that are inside viewport boundaries).

Share this post


Link to post
Share on other sites
Quote:
Original post by nefthy
Display list may also reside on video ram (as always its the drivers decistion whats in vram and what not). And how VBOs perform agains display lists depends on many things. In most cases for static geometry, display list perform better.


Actually thats not true, static indexed VBO's are far quicker than display lists since

1. All data is in vram
2. Most drivers transform the vertex buffer only once, whereas display lists work upon an expanded data set. Normally an indexed data set is about 30 to 50% the size of the equivalent expanded set (which would explain the 300% speed increase mentioned by a previous poster). Currently, static indexed VBO's are the fastest rendering method available.

One nifty trick however is to insert the code to set each viewport and projection matrix into a display list. It probably won't help a great deal, but VBO's will.....

Share this post


Link to post
Share on other sites
so far all my code is built on the display list principle, and i would greatly like to try the use VBO. however there is some limitatiions if I have not misunderstood. By the way, is Vertex Arrays anything to do with Vertex Buffer Objects.?

Share this post


Link to post
Share on other sites
vertex buffer object's speed up vertex arrays by copying the data to the video card's memory (once), then renering many times. So VBO's give little improvment to dynamic data unless done well (whcih is hard).

compiled vertex arrays are very slow on modern hardware, as they are suited to software renderers, and the extension will often run software vertex processing too.

Display lists often will implicity use VBO's anyway, so VBOs may not give much performance improvement.
If you are creating the display list every frame however, thats your problem right there...

Whats your hardware?

Is it one window/render context with many opengl viewports? or many windows/render context's with a single opengl viewport?

Setting the openGL viewport can be considered a free operation.

Instancing only helps out when drawing many objects that are exactly the same in the same viewport, so it will not help here. Plus as mentioned it's D3D only.

More description of you application will help.

Share this post


Link to post
Share on other sites
Try to implement a code posted by "Anonymous Poster".
It's better than using display list anyway.

I think that compiled vertex arrays can give more performance speed up, rather then VBO. It's very hard to implement dynamic VBO. You need to alter buffers each frame.

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