Instanced indirect rendering pipeline for SceneRenderer #10
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replace the current per-entity draw loop in
SceneRendererwith a GPU-driven instanced indirect rendering pipeline: batch entities by mesh, upload per-instance data (transform, color, etc.) to a buffer, and submit draws viavkCmdDrawIndexedIndirect/vkCmdDrawIndexedIndirectCountinstead of one push-constant draw call per entity.Motivation
SceneRenderer::render(engine/src/rendering/scene_renderer.cpp) is currently a stub with the intended-but-unimplemented approach of grouping entities by mesh and issuing one draw + push constant per transform:This doesn't scale — every instance is a separate draw call and CPU-side pushConstants update. Moving to indirect + instanced rendering lets the GPU batch identical-mesh draws together and cuts CPU submission overhead as scene entity counts grow.
Scope (rough, needs discovery)
PushConstantData— populated per-frame from the ECS (entt) view ofTransformComponent/mesh-owning entities.VkDrawIndexedIndirectCommandbuffer, one entry per unique mesh batch, built from grouping entities byMeshHandle.gl_InstanceIndexinstead of push constants.Buffer/Deviceinengine/src/vulkan/), and whether this reusesResourceRegistryor introduces new resource types.vkCmdDrawIndexedIndirect(loop of one call per mesh batch) orvkCmdDrawIndexedIndirectCount(single call, GPU-culled count) — likely worth starting with the former.TODOs / open questions (discovery)
drawIndirectFirstInstance, multiDrawIndirect availability on target hardware).Mesh(engine/src/resources/mesh.hpp) exposes what's needed (index count, first index, vertex offset) to build aVkDrawIndexedIndirectCommand.PushConstantDatainscene_renderer.cpp).!TEMP to be decoupled once scene batching and rendering implnote onSceneRendereronce batching lands.Notes
This is a fairly large change touching
SceneRenderer,Mesh,ResourceRegistry, and likely the Vulkan buffer/device wrappers — expect this to get broken into smaller follow-up issues once the approach is nailed down.