Template Function Kataglyphis::VulkanRendererInternals::walkSceneMeshes

Template Function Kataglyphis::VulkanRendererInternals::walkSceneMeshes#

Function Documentation#

template<typename PerModelSetup, typename CullPredicate, typename PerMeshSetup>
MeshDrawStats Kataglyphis::VulkanRendererInternals::walkSceneMeshes(vk::CommandBuffer commandBuffer, Kataglyphis::Scene *scene, PerModelSetup &&onModel, CullPredicate &&shouldCull, PerMeshSetup &&onMesh)#

The per-frame model x mesh draw walk, shared by every pass that iterates scene’s flattened meshes: forward/deferred rasterization (recordSceneMeshDraws below) and CascadedShadowMap::recordCommands. Owns the parts that must not drift between callers - the flat mesh index bookkeeping, the findMesh()+unknownBounds fallback, transformAABB, the considered/drawn counters, and the bind-VB/bind-IB/drawIndexed sequence - while leaving genuine per-caller differences to the two callbacks:

  • onModel(modelMatrix) runs once per model, before its meshes. Forward rasterization uses it to seed the push constant’s model/invModelRows; the shadow pass has nothing model-level to precompute and passes a no-op.

  • shouldCull(worldBounds) runs once per mesh (after onModel, before any draw-related side effect) and returning true skips the mesh. Forward rasterization tests one camera frustum; the shadow pass unions isVisibleAsShadowCaster over every cascade.

  • onMesh(modelMatrix, objectIndex, mesh) runs once per surviving mesh, before the shared bind+draw. It is where each caller pushes its own push-constant type/content (PushConstantRasterizer with inverse-transpose rows and the dynamic setCullMode, vs ShadowPushConstants with no cull-mode toggle since the shadow pipeline is built eCullMode = eNone).

mesh passed to shouldCull’s bounds and to onMesh may be null (a findMesh() miss); the shared walk treats a null mesh as an empty draw (unknown bounds, zero-size vertex/index buffers) rather than skipping it, matching the callers’ former inline behaviour.