Organizing geometry


This could be quite long explanation, but I’ll try to keep it down as much as possible.

I’ve recently been redesigning my renderering system to support plug in classes for different codepaths (GF1, GF3, R8500 etc…) by having an abstract base class IRenderer with functions to do things like set the sectors of the portal engine that will be visible this frame, do a light pass, draw shadow volume geometry etc… and a class such as RenderNV20 will implement all the appropriate functions and optimize for a specific platform by using vertex programs, regiser combiners, texture shaders, and all that.

My problem comes in organizing all this incoming data into something that can be put into AGP memory, or even just a standard system memory vertex array. My initial approach is to have a memory manager that will page in all per-frame sector data (updating and shifting around if necessary), and I would allocate something like enough room for 4 * the largest sector’s data, and hope for the best :-p. (Use fences where applicable).

Dynamic model geometry has to be uploaded each frame as animation is done on the CPU, I can’t see any way around that unless I do a 3DMark03 and animate it for every light in a vertex program … no.

Then there is the shadow volume data. The extruded quads are static for static lights (duh), but often you can get rid of the caps and use a standard depth pass test to save fillrate, depending on if a polygon could project onto the near clip plane. Should simply be able to use a dynamic index buffer to organize that to happen. Should that be in system or video memory (I’d only be writing to it, gfx card would read it)?

For dynamic lights, their shadow volumes will have to be uploaded each frame, along with the shadow volumes for each model for each light … how fast is it going to be updating the AGP memory, the way I see it it needs to be damn fast, though a good dose of parallelism would help this along; also smart use of fences.

Also am I right in assuming that you don’t want to be changing the vertex pointer? Well you’re only supposed to allocate one chunk of AGP memory so what would you change it to … ?

If anyone has some words of wisdom or advice before I start coding this it would be appreciated.