DirectX and Batching Primitives

Started by
2 comments, last by vajuras 16 years, 11 months ago
I have this city scene where I have 28 materials. What I used to do was call D3DXMesh->DrawSubset(n) for all 28 materials. This mesh buffer has an attribute, index, & vertex buffer of course. Anyway, last night I get this bright idea to do my own batching. I assumed I'd get much better performance. Problem is- there's nothing to really batch in my scene atm because the mesh data is spread across 28 materials (textures). So thats 28 different primitives thats not taking advantage of DIP I guess. Sizes of each DIP vary anywhere from like 300 vertices to thousands. My coworker recommends I look into texture Atlas to merge all my materials to batch together primitives which sounds good. But I wonder- why is D3DXMesh->DrawSubset() so fast then? Was it because everything was in 1 vertex/index/attribute buffer- not spread out across 28 materials. I 'assumed' they were doing the samething I was doing, calling SetStreamSource, SetIndexBuffer, SetVertexBuffer, and DrawIndexedPrimitive (DIP) using traingle lists. I can post my source code later but as you imagine nothing really wrong with it. But my FPS has took a serious dive. I am baffled how D3DXMesh->DRawSubset() could achieve so much better performance. I am hoping I just need to reboot my computer and run the city scene again but I'm fairly certain thats not it heh.
Advertisement
It was probably fast because you were rendering only a few vertices. How many triangles are you rendering per frame?

Dave
66,000 triangles is getting fired off to the video card every frame. These triangles are now divided across 28 materials now though. So now I have 28 different vertex/index buffers
sorry it was my mistake. Using my own DIP(s) I get good performance now figured it out as soon as I got home. Was stressed out over nothing but oh well at least I learned something new talking to my friend about this

This topic is closed to new replies.

Advertisement