PDA

View Full Version : VAR and wglAllocateMemoryNV/malloc



Hampel
01-29-2003, 04:53 AM
I do get a valid pointer back from wglAllocateMemoryNV(). But every combination of readFrequency, writeFrequency, and priority gives me memory which is slower than memory allocated with malloc(). I only write chunks sequencially to the memory via memcpy(); I never read data back from it. Indices are not stored in the VAR-memory obtained by wglAllocateMemoryNV()!

Before rendering a primitive I verify via
GL_VERTEX_ARRAY_RANGE_VALID_NV that the VAR is valid.

Some (read, write, priority)-combinations give me less performance drops (about 10%) but other combinations are halving my FPS or even worse with respect to memory allocated by malloc().

Any suggestions?

Stebet
01-29-2003, 07:22 AM
You must call glVertexArrayRangeNV on the range before you start drawing (or right after you initialize the array). Here's is a sample from my code:



fVertices = (GLfloat*)wglAllocateMemoryNV(8*vVertices->size()*sizeof(GLfloat), 0.2f, 0.2f, 0.5f);
glVertexArrayRangeNV(8*vVertices->size()*sizeof(GLfloat), fVertices);


Hope it helps.

Hampel
01-29-2003, 07:51 AM
Yes, I know!

I do something like that (out of my head):

void* ptr = wglAllocateMemoryNV(size, ...);
glVertexArrayRangeNV(size, ptr);
glEnableClientState(GL_VERTEX_ARRAY_RANGE_WITHOUT_ FLUSH_NV);
...
// setup vertex data by memcpy(ptr, ...)

// check if VAR is valid
GLint varEnabled = false;
glGetIntegerv(GL_VERTEX_ARRAY_RANGE_VALID_NV, &varEnabled);
if(!varEnabled) {
// warning
} else {
glDrawArrays(...);
}

I have tried all possible combinations of read-frequency, write-frequency, and priority for wglAllocateMemory(), but memory allocated via malloc() is always faster (up to 200%).

Hampel