VAR boggles...

Greetings fellow coders…

I’m quite perplexed.
Last night I had a 12 hour coding vigil to upgrade my pet engine from using immediate mode + display lists, to the ability to use any drawing mode available to it. At the moment it can successfully use:
- immediate mode
- Vertex Arrays (currently non-indexed)
- CVAs (only gave 2% improvement)
- VAR (currently no fence - static data)
- Display Lists

As I expected, display lists are STILL the fastest option for static data. But I wanted to test my options for dynamic data (just useing static data for testing).

Everything works fine. Except VAR. VAR works when using ~20,000 tris. But when I move to higher poly counts some of the tris seem to never get drawn. It’s as though DrawArrays() gets to a certain point and then decides to draw the FIRST vertex again. I tested this using GL_LINE_STRIP mode, where the LAST vertex that was successfully drawn would connect to the FIRST when they are totally unrelated.

An interesting addition to the problem, is that if you encapsulate the VAR within a display list, it renders FINE!!! So I can only assume that the data is present within the VAR, but for some reason it’s not getting drawn. What gives?

note:
I use 1 array for all my data. This array is segmented into 3 parts (vert, norm, UV). When copying data into the VAR I simply create an identical sized structure with wglAllocateMemoryNV() and memcpy() the entire structure in one swoop.
Data is never modified once it’s been created.
Up to 6MB has been allocated by wglAllocateMemoryNV() but it returns a valid pointer, so I don’t think that’s the issue.
I am using multitexturing, by reusing the same texturecoordinates twice (as a debugging measure). Seems to work OK. But I thought I’d mention it anyway.

Help! VAR seems to have so much potential. But I can’t afford to use it if it only draws half my geometry.

PS: I’ve been through the demo and whitepaper. But it didn’t help.

umm…I don’t have an answer to your question dude sorry. But I was hoping that while people are posting about VAR’s here I might as well ask…where can I get more info on these VAR’s? I’ve been hearing alot about them but don’t know where to find any programming resources and/or tutorials about using them.Anyone know a good place to start?

I’ve only been using VAR for about 24 hours now. But I had a REALLY hard time understanding what was going on.

If my understanding is correct they act identically to normal vertex arrays. Except the data is kept in AGP/VID memory rather than system memory.

You allocate the AGP/Vid RAM with pointer = wglAllocateMemoryNV( NumBytes, 0, 0, priority) instead of pointer = new char[].
If “priority” is in the range 0.25f->0.75f then AGP will be used. If it’s 0.75f->1.0f then Vid mem will be used.

Call these two functions to define our array and enable the VARextention.
glVertexArrayRangeNV( SizeOfArray, pointer);
glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);

Then copy your data into your freshly allocated array using memcpy().

Then you should be able to use call DrawArrays() (or whatever) just like you would normally do for a vertex array, only it’ll be a hell of a lot faster.


This is pretty much what I’ve worked out over the past couple of hours. It was 6am when I got it working so I might be wrong on a number of points. But it should be enough to get you started.

NOTE: when allocating agp/vid mem, try to allocate only ONE array. and pack all your data into it. Switching arrays is REALLY slow.

If I did a bodge job of explaining something just say so and I’ll see what I can do.

cheers.

Yea I was going to try them as well but what got my is the mem allocate part since I am uesing X not win9X is there a glx function the is the same as wglAllocateMemoryNV(…) I guess that I could just try glxAllocateMemoryNV(…) but I thought that someone here might know.

–Validus–

VAR is limited to 65536 vertices per vertex array. If you specify more, it’ll ignore them without any errors or warnings.

  • Tom

Limited to 64K verticies? Hmmmm. I guess that sounds about right.
But why would VAR only accept 64K at a time when normal vertex arrays seem to work fine with much higher vertex counts?

Update…

I managed to fix the problem. It was indeed a problem with the number of vertecies I was sending to the card. I’ve changed my routines to send vertecies in batches of 65535. Problem solved.

I’m a little peeved however… I’m not angry at the driver writers, I’m sure it’s not their doing. But whatever the reason, it seems a little inconvienient that the (VAR) DrawArrays() function will accept a DWORD when it simply ignores anything in the 2nd WORD. And all the documentation I’ve come accross only states that VAR is limited to 65535 entries when using indecies… I’m currently using raw verts.

Is this a Harware issue or a driver issue? Either way I’m sure it’s possible to get around it within the drivers the same way that I did manually.

I’m not actually angry at anyone… I just needed to let off some steam. I’m sure you can all relate.

After all is said and done everyone here is doing a great job and I’m glad that you’re around.

Cheers, thank you and good night.