Original Post
Hi! I'm currently sorting my rendering accorting to Materials. Depending on which Shader/texture the material has. Now the thing is that I'm currently creating all my VertexBuffers "dynamic" in DX9. So basically now, lets say I have 3 meshes: Mesh1: Material1 VertexBuffer1 - Pos, Normal, UV Mesh2: Material1 VertexBuffer2 - Pos, Normal, UV Mesh3 Material1 VertexBuffer3 - Pos, Normal Here VertexBuffer1, 2 & 3 are SEPARATELY created VertexBuffers. And when It comes to sorting the Materials, there is no problem. The problem is that I have SO many SetStream(...) calls, even though the objects have the same materials. One SetStream(...) call for each Mesh. So I was wondering how you guys manage the creation of VertexBuffers ? I was thinking about something like this: Instead of creating a new VertexBuffer for each Mesh, I would let my implementation of CreateVertexBuffer manage all the VertexBuffers. I would then create a LARGE vertexbuffer for each new vertextype, that is requested. So, the above example with 3 meshes would be like: VertexBufferManager: VertexBuffer0 - Pos, Normal, UV & very LARGE VertexBuffer1 - Pos, Normal & very LARGE Mesh1: (a triangle) VirtualVertexBuffer - pointing to VertexBuffer0 with offset 0 Mesh2: (a triangle) VirtualVertexBuffer - pointing to VertexBuffer0 with offset 3 Mesh3: VirtualVertexBuffer - pointing to VertexBuffer1 with offset 0 Now for each material I would only need to make a certain amount of SetStream(...) calls. In this case: Material1: SetStream(..., VertexBuffer0, ...); for each geometry render it using the offset 3in VertexBuffer0 SetStream(..., VertexBuffer1, ...); for each geometry render it using the offset in VertexBuffer1 Material2: ... Would appreciate any thoughts on how this should be designed, will my design be flawed when updating vertexdata in the buffers? For eg. I want to update the vertexData in Mesh1: Lock(VirtualVertexBuffer)... This will lock VertexBuffer0 and thus it may not be used for rendering ? Do you think things like that will be a problem? Thank you!