DrawCall Batching

Started by
1 comment, last by Infinisearch 7 years, 3 months ago

Hey guys, I wanted to get some advice on how you implement draw call merging. As of right now I handle batching dynamically. Elements are submitted to the rendering pipeline using a "CRenderObject".. this contains information such as the constant buffer holding the world transform/etc.. the vertex/index buffers... the material.. the drawcall values, i.e firstIndexID...indexCount..etc, and any render flags necessary for shader passes. There are different Render Objects that have different rendering batching policies. For Example.. a CStaticMeshRenderObject is batched based on the source mesh, the submesh index, the material, and the render flags... For each generated batch, a CStaticMeshRenderObject allocates memory out of the structured buffer pool and fills the data with world transform info.. and etc. a CSkinnedMeshRenderObject is batched based on the same parameters of a CStaticMeshRenderObject.. but a CSkinnedRenderObject fills the structured buffer with skinning data. a CSpriteParticleRenderObject is batched based on material and render flags... and it fills dynamic vertex and index buffers for rendering.. and etc...

My Rendering pipeline is currently :

Perform Frustum Culling

For Each visible Scene Object

- Collect all CRenderObjects

For each rendering pass

- For Each CRenderObject that supports batching ,

- Batch based on per CRenderObject heuristic

- For Each batched group of CRenderObjects , allocate the required data for the batch.

Lock all global pools for rendering

For each rendering pass

- generate command lists

- etc...

The problem with this method is that it's done every frame, I wanted to know if anyone has a better method for drawcall batching that supports things such as skeletal mesh instancing. I know that ACU uses gpu instancing for their Crowd System.. but I don't know if they do it at higher level, or more like my low level implementation. Thank you.

Advertisement

In my engine, I use the object pointer, sub mesh index, and then a special 'instanceId' which is usually zero. But in the case of skeletal animation, the instanceId becomes the id of the animation playing in my instanced animation manager. This makes the drawing object unique during sorting. And when the group goes to draw, the bone constants are set once, (I use a call back to the mesh instance to get these). As like any other object, a transform for each object is stuffed into a constant buffer, and the draw occurs.

I batch my instances every frame. My thought being that the camera is always moving in a game, or if its not, objects are coming into and out of the frame all the time so the best fit instance list almost always changes. Last time I profiled figuring out batches was super super low amount of time compared to culling, sorting draw items and generating draw commands.

I think this is what you're looking for: https://www.gamedev.net/topic/666163-render-queue-design/

More over search for threads on render queue on gamedev.net

-potential energy is easily made kinetic-

This topic is closed to new replies.

Advertisement