PDA

View Full Version : Mixing Vertex Array Range & 'normal' vertex arrays



MarcusL
04-22-2001, 04:39 PM
How do you do that properly?

When I start drawing with VARs, it works fine but as soon as I try to draw something with normal arrays I can never get the VAR to work again properly (it retreats into slowmotion, fetching data from agp mem and sending it to the card.)

it should be possible to do this:

main
{
void *mem = glAllocateMemoryNV(1000,0,1,.5)
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);
glVertexArrayRangeNV(1000,mem);

loop {
glVertexPointer(.., mem);
glDrawArrays(..);
if(count == 200)
draw_using_normal_arrays()
}
}

draw_using_normal_arrays()
{
void *mem2 = malloc(1000);
// fill mem2 with data
glVertexPointer(.., mem2);
glDisableClientState(GL_VERTEX_ARRAY_RANGE_NV);
glDrawArrays(...);
glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);
}

once the second function has run, I can't get the normal loop back to speed. I've tried setting glVertexArrayRange again, but to no avail.

IsaackRasmussen
04-22-2001, 09:17 PM
Each time you disable VAR, the driver flushes. So what you essentially are doing, is disabling parallelisme of your GF http://www.opengl.org/discussion_boards/ubb/smile.gif

You should probably draw your non-VAR stuff first to minimize flushes, or last, I'm not really sure. (Matt?)
And then afterwards, VAR stuff, so you only disable VAR once, per frame.

MarcusL
04-23-2001, 04:38 AM
No.. I don't disable VAR every frame, only on one frame (after rendering 200 times).

Also, I found out that the driver did a flush when I was replacing a displaylist. (But after removing that, the above problem still persists.)

LordKronos
04-23-2001, 06:05 AM
Strictly looking at your code, I noticed that after your first call to
glEnableClientStat(GL_VERTEX_ARRAY_RANGE_NV);
you called
glVertexArrayRangeNV(1000,mem);
but not after additional calls to
glEnableClientStat(GL_VERTEX_ARRAY_RANGE_NV);

Ive hardly touched VAR and dont remember much about coding it, so I dont remember what the call to glVertexArrayRangeNV does, but it just kinda stands out to me.

IsaackRasmussen
04-23-2001, 06:11 AM
Oops, my bad. I mistaken this,
if(count == 200)

For checking if current object had less than 200 polys.
Don't have a clue about your problem then.


Originally posted by macke:
No.. I don't disable VAR every frame, only on one frame (after rendering 200 times).

Also, I found out that the driver did a flush when I was replacing a displaylist. (But after removing that, the above problem still persists.)

MarcusL
04-23-2001, 06:19 AM
I probably am doing something else that breaks this, but I cannot figure out what.

It should work doing like I do, right? .. I'm going to write a simple test case and go from there, and see where the error is.

Korval
04-23-2001, 07:56 AM
I think Kronos may have the answer. If you re-enable VAR, you may have to reset the VAR memory as well (by calling glVertexArrayRangeNV).

MarcusL
04-23-2001, 08:00 AM
I actually did that in my main code, I just forgot it in the example. (I really should learn to write more small test cases rather than incorporating stuff in the big engine and test there.)

Nevertheless, if you draw using VAR's, then build a displaylist with geometry using normal vertex arrays, everytime you call that list the driver does a flush! I can't really see the reason for that.

At least my current drivers (7.58).

[This message has been edited by macke (edited 04-23-2001).]