Hi,
I'm writing my own RenderMesh (a ROAM terrain mesh). Being ROAM, the
triangles change (at least a little bit), nearly every frame. I'm
having difficulty figuring out how to handle the renderbuffers. At the
moment, I've got a choice between a huge memory leak (1GB in 20-30s), or
what I think is potential for memory corruption/overflow.
I've been staring at the various CS mesh plugin code for a while now,
but it's still not quite making sense. I would appreciate some
suggestions, or pointers (pun semi-intended) in the right direction.
So, on every call to "GetRenderMeshes()", I update my renderbuffers.
For each of the index, texel, indices, colour and normal buffers I have
an instance variable that holds the result of createRenderBuffer (or
createIndexRenderBuffer as appropriate). I stuff my vertex data into
those renderbuffers, and then setup the RenderMeshes.
I've tried two techniques so far:
1) set the render buffer instance variables to 0 each time through and
then recreate them with the appropriate vertex count. I snarfed this
idea from genmesh, particularly SetVertexCount() which sets the buffer
variables to 0. However, doing this leaks memory at an horrendous rate
(50-100MB/s). My vague understanding is that because the instance vars
a csRef<iRenderBuffer>'s, (e.g.:
csRef<iRenderBuffer> vertexBuffer;
)
that the statement:
vertexBuffer=0;
should decref the csRenderBuffer. I would expect my code to be the
final place with any references to those buffers, and hence the
renderbuffer will deallocate. It doens't appear to be doing so
2) I re-use the renderbuffers every time (no setting to 0, no new calls
to createRenderBuffer). There is no memory increase, strongly implying
that it is the csRenderBuffers that are the source of the leak in 1
above), but because the number of vertices changes every time through, I
think it's just pure luck that i haven't had crashes and lockups yet.
IS there something I should be doing with my csRenderBufferHolder ( all
I do at the moment is call SetRenderBuffer with the new iRenderBuffer's).
Or perhaps something with the csFrameDataHolder? At the moment i just
get unused data and call "Empty" on it e.g.:
<.h>
csFrameDataHolder<csDirtyAccessArray<csRenderMesh*>> renderMeshesHolder;
<.c>
csDirtyAccessArray<csRenderMesh*>* renderMeshes =
&renderMeshesHolder.GetUnusedData(rmCreated,rview->GetCurrentFrameNumber());
renderMeshes->Empty ();
It must be something simple, but I'm stumped. Any help greatly appreciated,
Thanks,
Craig Miskell
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]