This document describes the data structures used by the renderer and their relationships.
Scene Graph to GPU Data
The renderer transforms the scene graph into flat GPU buffers. The hierarchy is:
Object (Actor/Entity)
└── MeshComponent (0..n)
└── Primitive (1..n)
└── Meshlet (1..n)
Object
An object is an Actor or Entity in the ECS (EnTT). Each object has:
- Transform: World-space position, rotation, scale
Objects can have zero or more MeshComponents attached.
MeshComponent
A MeshComponent references its parent entity and contains a SceneNode for local transforms. Each MeshComponent has:
- Transform: Local transform relative to the parent object
Primitive
Each mesh consists of one or more primitives. A primitive represents a single draw unit with:
- Engine::Core::MaterialData: Unified material struct with pipeline, texture indices, factors, and feature flags
- Engine::Rendering::GpuBuffers::ObjectCullingData: World-space culling data
- worldPositionAndRadius: glm::vec4, xyz = world position, w = radius
- objectIndex: Object index
- Engine::Rendering::GpuBuffers::LocalBoundsData: Local-space culling data for GPU transform
- localCenterAndRadius: glm::vec4, xyz = local center, w = local radius
Meshlet
Primitives are subdivided into meshlets for the mesh shader pipeline. GPU meshlets use Engine::Rendering::GpuBuffers::UnifiedMeshlet:
- Vertices: Offset and count into the vertex buffer
- Triangles: Offset and count into the triangle index buffer
- primitiveIndex: Shared geometry index
- pipelineIndex: Material pipeline index
- vertexDataAddress: Device address of meshlet-local vertex data
- triangleDataAddress: Device address of meshlet-local triangle data
The recorded mesh path skips meshlet culling. UnifiedMeshlet data is consumed by Engine/shaders/material/triangle.mesh through the binned visible meshlet records.
GPU Buffer Data Types
Dispatch
Indirect dispatch parameters for compute shaders:
struct Dispatch {
uint32_t groupCountX;
uint32_t groupCountY;
uint32_t groupCountZ;
};
ObjectCullingData
Per-object data for frustum culling:
struct ObjectCullingData {
glm::vec4 worldPositionAndRadius;
uint32_t objectIndex;
uint32_t _padding[3];
};
LocalBoundsData
Local-space bounds used by PrimitiveCulling.comp to compute world-space culling bounds on GPU:
struct LocalBoundsData {
glm::vec4 localCenterAndRadius;
};
Engine::Rendering::FrustumPlanes
Frustum planes for stereo culling:
struct FrustumPlanes {
std::array<glm::vec4, 6> planes[2];
};
Plane order in shaders is left, right, top, bottom, near, far.
Counters
Simple atomic counters track surviving objects/meshlets:
Binned counters track per-pipeline counts:
uint32_t counters[MAX_PIPELINE_COUNT];
Related Pages