Archived

This topic is now archived and is closed to further replies.

Dynamic buffer problem

This topic is 5619 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have glitches with my dynamic buffers, let me explain: I have a dynamic vb with space for 2000 x 32bytes vertex and a 2000 x 32bits dynamic index buffer shared by all effects in my demo. I running 2 different effects using the dynamic buffers, 1st is a marchingcubes effect, second is a volumelighting effect. Volumelight seem to work perfectly when used alone but when rendered after marchingcube its all fuked up. Marchingcubes seem to work but there is some thing that seem to be wrong because --> some of the last polygons that I render are lagging compared to the rest of the effect''s polygons. <-- My lock call on dynamvb is something like this (similar for dynaib): lock (Count) { if ((VertexCursor + Count) > VertexCount || FrameUpdated != GetCurrentFrame()) { FrameUpdated = GetCurrentFrame(); LockFlag = Discard; NextCursor = 0; }else { LockFlag = Append; } VertexCursor = NextCursor; d3ddev->Lock (VertexCursor * 32, Count * 32, FVF, LockFlag, pMem); NextCursor += Count; return pMem; } Volumelight do something like: memcopy (dynavb->lock (40), pVolumeLightVertexCache, 40 * 32); dynavb->Unlock (); memcopy (dynaib->lock (60), pVolumeLightFaceCache, 60 * 4); dynaib->Unlock (); setIndex (dynaib, vertexbase = dynavb->VeretxCursor); rederdesc desc; desc.indexed = true; desc.Type = trianglelist; desc.Minindex = 0; // since base index is set to vb cursor desc.numvertex = 40; desc.startindex = dynaib->IndexCursor; desc.primitivecount = 60 / 3; renderprimitive (desc); Marchingcubes does something like that: dword rendercursor = 0; dynavertex tempcache[500]; dynavertex trisCache[15]; // max 5 tris / iteration for (x = min, x < max; x++) for (y = min, y < max; y++) for (z = min, z < max; z++) { triscount = getSomeTriangles (trisCache); if ((rendercoursor + triscount) > 500) { memcopy (dynavb->lock (rendercoursor), tempcache, rendercoursor * 32); dynavb->unlock(); desc.indexed = false; desc.Type = trianglelist; desc.startvertex = dynavb->VertexCursor; desc.primitivecount = rendercoursor / 3; renderprimitive (desc); rendercoursor = 0; } for (i = 0; i < triscount; i += 3) { tempcache[rendercoursor++] = triscache[i + 0]; tempcache[rendercoursor++] = triscache[i + 1]; tempcache[rendercoursor++] = triscache[i + 2]; } } if (rendercoursor) { memcopy (dynavb->lock (rendercoursor), tempcache, rendercoursor * 32); dynavb->unlock(); desc.indexed = false; desc.Type = trianglelist; desc.startvertex = dynavb->VertexCursor; desc.primitivecount = rendercoursor / 3; renderprimitive (desc); rendercoursor = 0; } If you see something wrong please tell me. thx

Share this post


Link to post
Share on other sites
Oracle,

How should I use SetIndices and DrawIndexedPrimitive when using dynamic buffers? Locking seem allright but what about BaseVertexIndex and MinIndex? Is it correct to call lock with discard only once per frame if my dynamic vertex data does not fill the entire vertexbuffer capacity?

Share this post


Link to post
Share on other sites