VAR, read-frequency and memorysize


using VAR I’ve got some strange behaviour: Defining a read-frequency of 0.25 and above all works as

expected. But with a read-freq below 0.25 I get the requested memory pointer, but when writing to it

the app crashes after writing the 2^14th element! Any ideas what the reason might be?

The call is

 int nVARsize = 4*1000*100; // only if read freq >= 0.25
//int nVARsize = 4*4096; // max 2^14 if read freq < 0.25
float* pVARmemory = (float*)wglAllocateMemoryNV(nVARsize, 0.25f, 0.5f, 0.5f);

Tried on 30.82 on Win98 GeForce1 and 29.61 on WinXP GeForce2 GO.

edit: By defining read-freq < 0.25 the nVARsize has to be at most 2^14 to not crash, but then nothing is drawn!


[This message has been edited by kon (edited 10-23-2002).]

I’m not certain, but if I recall correctly, a read frequency less than 0.25 may well request video memory. At 0.5, you’re probably getting AGP.

Now, the important point here is that you’re writing outside your array bounds. The difference is that AGP memory, for whatever reason, doesn’t throw a fault, while video memory does. Since fault throwing is very dependent on where you’re writing, I’m not surprised that it doesn’t always cause a fault when you write past the end of the array.

The ultimate problem is that your VAR memory size is insufficient for what you’re writing. Note that the size of the VAR memory should be the number of bytes, not the number of “elements”.