Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
RenderingDataManager.h
Go to the documentation of this file.
1#pragma once
6#include "VulkanBuffer.h"
8#include <entt/entt.hpp>
9#include <optional>
10#include <unordered_map>
11#include <unordered_set>
12#include <vector>
13
14#define object_rendering_id uint32_t
15#define primitive_rendering_id uint32_t
16#define meshlet_rendering_id uint32_t
17
18namespace EngineCore
19{
20 class ApplicationContext;
21 class AssetManager;
22 class Engine;
23 class MaterialAsset;
24 class MeshComponent;
25 class MeshAsset;
26 class Renderer;
27 class SceneManager;
28 class TextureAsset;
29 class Texture;
35 {
36 friend class Engine;
37 public:
39
44
45 // Non-copyable (RAII - owns GPU resources)
48
55
59 void setSceneManager( SceneManager* sceneManager );
60
64 void setAssetManager( AssetManager* assetManager );
65
69 void setRenderer( Renderer* renderer );
70
76 void onRenderableSpawned( MeshComponent* component );
77
82 void onRenderableDestroyed( MeshComponent* component );
83
88 void onMeshLoaded( MeshAsset* asset );
89
94 void onMeshUnloaded( MeshAsset* asset );
95
102 void onTextureLoaded( TextureAsset* textureAsset, const std::filesystem::path& texturePath );
103
108 void onTextureUnloaded( TextureAsset* textureAsset );
109
114 void onMaterialLoaded( MaterialAsset* materialAsset );
115
120 void onMaterialUnloaded( MaterialAsset* materialAsset );
121
126 [[nodiscard]] bool needsUpdate() const { return isDirty; }
127
134 [[nodiscard]] uint64_t getDataVersion() const { return dataVersion_; }
135
139 void clearDirty() { isDirty = false; }
140
148
154 void processCompletedMeshletGenerations(std::vector<Ecs::CompletedMeshletGeneration>&& completions);
155
160 bool updateIfDirty();
161
175 bool updateTransforms();
176
181 [[nodiscard]] std::vector<VulkanStagedBufferSyncObjects>& getPendingTransformSyncObjects() { return pendingTransformSyncObjects_; }
182
187
188 // Buffer getters for compute pipeline binding (returns device-local buffer)
189 [[nodiscard]] const VulkanBuffer& getPrimitiveCullingBuffer() const { return primitiveCullingData.value().getBuffer(); }
190 [[nodiscard]] const VulkanBuffer& getPrimitiveMeshletBuffer() const { return primitiveMeshletData.value().getBuffer(); }
191 [[nodiscard]] const VulkanBuffer& getPerObjectDataBuffer() const { return perObjectDataBuffer.value().getBuffer(); }
192 [[nodiscard]] const VulkanBuffer& getPrimitiveRenderDataBuffer() const { return primitiveRenderData.value().getBuffer(); }
193 [[nodiscard]] const VulkanBuffer& getLocalBoundsBuffer() const { return localBoundsBuffer.value().getBuffer(); }
194 [[nodiscard]] const VulkanBuffer& getMeshletBuffer() const { return meshletBuffer.value().getBuffer(); }
195 [[nodiscard]] const VulkanBuffer& getMeshletBoundsBuffer() const { return meshletBoundsData.value().getBuffer(); }
196 [[nodiscard]] const VulkanBuffer& getVertexBuffer() const { return vertexBuffer.value().getBuffer(); }
197 [[nodiscard]] const VulkanBuffer& getTriangleBuffer() const { return triangleBuffer.value().getBuffer(); }
198
199 // Instancing buffer getters (for geometry deduplication)
200 [[nodiscard]] const VulkanBuffer& getMeshGeometryDataBuffer() const { return meshGeometryDataBuffer.value().getBuffer(); }
201 [[nodiscard]] const VulkanBuffer& getInstanceDataBuffer() const { return instanceDataBuffer.value().getBuffer(); }
202 [[nodiscard]] const VulkanBuffer& getInstanceCullingDataBuffer() const { return instanceCullingDataBuffer.value().getBuffer(); }
203
204 // Vertex shader path buffer getters (for single-meshlet geometry)
205 [[nodiscard]] const VulkanBuffer& getVSIndexBuffer() const { return vsIndexBuffer_.value().getBuffer(); }
206 [[nodiscard]] const VulkanBuffer& getSingleMeshletGeometryBuffer() const { return singleMeshletGeometryBuffer_.value().getBuffer(); }
207 [[nodiscard]] uint32_t getSingleMeshletGeometryCount() const { return singleMeshletGeometryCount_; }
208 [[nodiscard]] uint32_t getMultiMeshletGeometryCount() const { return multiMeshletGeometryCount_; }
209 [[nodiscard]] bool hasVertexShaderPath() const { return singleMeshletGeometryCount_ > 0; }
210
211 // LOD buffer getters (for cluster-based LOD selection)
212 [[nodiscard]] const VulkanBuffer& getClusterLodDataBuffer() const { return clusterLodDataBuffer_.value().getBuffer(); }
213 [[nodiscard]] const VulkanBuffer& getClusterGroupDataBuffer() const { return clusterGroupDataBuffer_.value().getBuffer(); }
214 [[nodiscard]] uint32_t getClusterCount() const { return clusterCount_; }
215 [[nodiscard]] uint32_t getClusterGroupCount() const { return clusterGroupCount_; }
216 [[nodiscard]] bool hasLodData() const { return clusterCount_ > 0; }
217
221 [[nodiscard]] uint32_t getUniqueGeometryCount() const { return uniqueGeometryCount_; }
222
226 [[nodiscard]] uint32_t getInstanceCount() const { return instanceCount_; }
227
231 [[nodiscard]] bool isInstancingEnabled() const { return instancingEnabled_; }
232
237 void setInstancingEnabled(bool enabled) { instancingEnabled_ = enabled; markDirty(); }
238
244 [[nodiscard]] std::vector<VulkanStagedBufferSyncObjects>& getPendingSyncObjects() { return pendingSyncObjects_; }
245
250
256
260 [[nodiscard]] uint32_t getPrimitiveCount() const { return primitiveCount; }
261
265 [[nodiscard]] uint32_t getMeshletCount() const { return meshletCount; }
266
272
278 [[nodiscard]] PipelineNames getPipelineForPrimitive(primitive_rendering_id primitiveId) const;
279
285 void queueTextureForUpload(Texture* texture);
286
291 [[nodiscard]] bool hasTexturesToUpload() const;
292
297 [[nodiscard]] std::vector<Texture*> getTexturesToUpload() const;
298
303
308 [[nodiscard]] std::vector<VkDescriptorImageInfo> generateTextureDescriptorInfos() const;
309
314 [[nodiscard]] uint32_t getTextureCount() const;
315
321 [[nodiscard]] const VulkanBuffer& getMaterialBufferForPipeline(PipelineNames pipelineName) const;
322
333
338 [[nodiscard]] bool needsMaterialUpdate() const { return materialsDirty_; }
339
344
349 [[nodiscard]] const VulkanBuffer& getSHProbeBuffer() const;
350
356
369
382 [[nodiscard]] uint32_t getValidTextureIndex(uint32_t textureIndex, DefaultTextureType defaultType);
383
384 private:
385
390 bool updatePrimitiveData();
391
398
404
405 const Engine* engine = nullptr;
407
408 // Injected dependencies (used when Engine is null)
412
413 // GPU buffers indexed by primitive_rendering_id (using VulkanStagedBuffer for deferred deletion)
414 std::optional<VulkanStagedBuffer> primitiveCullingData;
415 std::optional<VulkanStagedBuffer> primitiveMeshletData;
416 std::optional<VulkanStagedBuffer> perObjectDataBuffer;
417 std::optional<VulkanStagedBuffer> primitiveRenderData;
418 std::optional<VulkanStagedBuffer> localBoundsBuffer;
419
420 // GPU buffers indexed by meshlet_rendering_id
421 std::optional<VulkanStagedBuffer> meshletBuffer;
422 std::optional<VulkanStagedBuffer> meshletBoundsData;
423
424 // Geometry data buffers
425 std::optional<VulkanStagedBuffer> vertexBuffer;
426 std::optional<VulkanStagedBuffer> triangleBuffer;
427
428 // Instancing buffers (for geometry deduplication)
429 std::optional<VulkanStagedBuffer> meshGeometryDataBuffer;
430 std::optional<VulkanStagedBuffer> instanceDataBuffer;
431 std::optional<VulkanStagedBuffer> instanceCullingDataBuffer;
432
433 // Vertex shader path buffers (for single-meshlet geometry - faster than mesh shader)
434 std::optional<VulkanStagedBuffer> vsIndexBuffer_;
435 std::optional<VulkanStagedBuffer> singleMeshletGeometryBuffer_;
436
437 // LOD buffers (for cluster-based LOD selection)
438 std::optional<VulkanStagedBuffer> clusterLodDataBuffer_;
439 std::optional<VulkanStagedBuffer> clusterGroupDataBuffer_;
440
441 // Pending sync objects for staged buffer uploads (structural updates)
442 std::vector<VulkanStagedBufferSyncObjects> pendingSyncObjects_;
443
444 // Pending sync objects for transform updates (separate from structural)
445 std::vector<VulkanStagedBufferSyncObjects> pendingTransformSyncObjects_;
446
447 // Counts for dispatch sizing
448 uint32_t primitiveCount = 0;
449 uint32_t meshletCount = 0;
450
452 bool isDirty = false;
453
456 uint64_t dataVersion_ = 0;
457
458 // Instancing state
459 bool instancingEnabled_ = true;
460 bool geometryDirty_ = false;
461 bool instancesDirty_ = false;
462
463 // Instancing counts
464 uint32_t uniqueGeometryCount_ = 0;
465 uint32_t instanceCount_ = 0;
466
467 // Incremental geometry update tracking
468 // These persist across updates to enable append-only geometry buffers
469 uint32_t nextGeometryId_ = 0;
478
479 // Vertex shader path counts (single-meshlet geometry classification)
482
483 // LOD counts
484 uint32_t clusterCount_ = 0;
485 uint32_t clusterGroupCount_ = 0;
486
492 {
495
496 bool operator==(const GeometryCacheKey& other) const {
497 return meshAsset == other.meshAsset && primitiveIndex == other.primitiveIndex;
498 }
499 };
500
502 {
503 std::size_t operator()(const GeometryCacheKey& key) const {
504 std::size_t h1 = std::hash<void*>{}(static_cast<void*>(key.meshAsset));
505 std::size_t h2 = std::hash<uint32_t>{}(key.primitiveIndex);
506 return h1 ^ (h2 << 1);
507 }
508 };
509
512 std::unordered_map<GeometryCacheKey, MeshGeometryMapping, GeometryCacheKeyHash> geometryCache_;
513
514 // Material tracking
515 std::unordered_map<primitive_rendering_id, PipelineNames> primitiveToPipeline;
516 std::unordered_map<PipelineNames, uint32_t> pipelinePrimitiveCounts;
517
518 // Transform dirty tracking for sparse GPU updates
519 // Maps ECS entity → primitive IDs owned by that entity's MeshComponents
520 std::unordered_map<entt::entity, std::vector<primitive_rendering_id>> entityToPrimitiveIds_;
521 // Maps primitive ID → MeshComponent (to retrieve transform for sparse updates)
522 std::unordered_map<primitive_rendering_id, MeshComponent*> primitiveIdToComponent_;
523
524 // Cached transforms for incremental updates
525 // Full rebuild populates this; subsequent frames only update dirty entries
526 std::vector<glm::mat4> cachedTransforms_;
527 // Flag indicating cachedTransforms_ needs full rebuild (set after structural changes)
529
530 // Texture upload tracking
531 std::vector<Texture*> texturesToUpload;
532 std::vector<Texture*> gpuTextures;
533
534 // Material buffers per pipeline type
535 std::unordered_map<PipelineNames, std::optional<VulkanBuffer>> materialBuffersByPipeline;
536
537 // Material tracking
538 bool materialsDirty_ = true;
542 std::unordered_map<std::string, uint32_t> materialPathToFlatColorIndex_;
543 std::unordered_map<std::string, uint32_t> materialPathToDiffuseIndex_;
544 std::unordered_map<std::string, uint32_t> materialPathToPbrIndex_;
545 std::unordered_map<std::string, uint32_t> materialPathToNormalsIndex_;
546
547 // SH Probe buffer for dynamic spherical harmonic lighting
548 std::optional<VulkanBuffer> shProbeBuffer_;
549 std::vector<SHProbeData> shProbeData_;
550
555 void markDirty();
556
561
567
573 [[nodiscard]] bool isMeshInSnapshot(MeshAsset* asset) const;
574
575 // Deferred mesh loading - meshes that finish loading are queued here
576 // and only acknowledged when processPendingMeshLoads() is called
577 std::vector<MeshAsset*> pendingMeshLoads_;
578
579 // Snapshot of render-ready meshes for the current update cycle
580 // This ensures updatePrimitiveData() and updateTransforms() see the same meshes
581 std::unordered_set<MeshAsset*> renderCycleMeshSnapshot_;
582
583 // ============================================================================
584 // Reusable working buffers (avoid per-frame heap allocations)
585 // These are cleared and reused each frame instead of being locally allocated
586 // ============================================================================
587
588 // Geometry buffers (cleared each dirty rebuild)
589 std::vector<MeshGeometryData> workingGeometryDataBuffer_;
590 std::vector<UnifiedMeshlet> workingMeshletDataBuffer_;
591 std::vector<MeshletBounds> workingMeshletBoundsBuffer_;
592 std::vector<Vertex> workingVertexBuffer_;
593 std::vector<Ecs::PackedTriangle> workingTriangleBuffer_;
594
595 // Vertex shader path buffers
596 std::vector<uint32_t> workingVsIndexBuffer_;
597 std::vector<SingleMeshletGeometryData> workingSingleMeshletGeoData_;
598
599 // LOD working buffers
600 std::vector<ClusterLodData> workingClusterLodData_;
601 std::vector<ClusterGroupData> workingClusterGroupData_;
602
603 // Instance buffers
604 std::vector<InstanceData> workingInstanceData_;
605 std::vector<InstanceCullingData> workingInstanceCullingData_;
606
607 // Legacy compatibility buffers
608 std::vector<ObjectCullingData> workingPrimitiveCullingBuffer_;
609 std::vector<LocalBoundsData> workingLocalBoundsDataBuffer_;
610 std::vector<PrimitiveMeshletData> workingPrimitiveMeshletBuffer_;
611 std::vector<glm::mat4> workingPerObjectData_;
612 std::vector<MeshPrimitiveRenderData> workingPrimitiveRenderData_;
613
614 // Material working buffers (per pipeline type, cleared on rebuild)
615 std::vector<GpuDiffuseFlatColorMaterial> workingFlatColorMaterials_;
616 std::vector<GpuDiffuseShaderMaterial> workingDiffuseMaterials_;
617 std::vector<GpuPbrMaterial> workingPbrMaterials_;
618 std::vector<GpuNormalsMaterial> workingNormalsMaterials_;
619
620 // Default texture paths for PBR fallbacks (resolved via AssetManager)
621 static constexpr const char* DEFAULT_NORMAL_TEXTURE_PATH = "Engine/textures/DefaultNormal.png";
622 static constexpr const char* DEFAULT_WHITE_TEXTURE_PATH = "Engine/textures/DefaultWhite.png";
623 static constexpr const char* DEFAULT_BLACK_TEXTURE_PATH = "Engine/textures/DefaultBlack.png";
625
626 };
627}
#define primitive_rendering_id
#define meshlet_rendering_id
The application context is the core class which stores the basic openxr and vulkan objects.
the material asset is another wrapper for asset data which is stored in entt. It has the EngineCore::...
The mesh asset stores geometry data and.
Definition MeshAsset.h:15
A component which can be attached as many times to an actor as one wants. It makes it possible to ren...
uint32_t getInstanceCount() const
Gets the current count of instances in the buffers.
bool defaultTexturesLoading_
True if loadEcsTexture has been called.
std::unordered_map< uint32_t, PipelineNames > primitiveToPipeline
Maps primitive IDs to their pipeline.
std::vector< VkDescriptorImageInfo > generateTextureDescriptorInfos() const
Generate descriptor infos for all GPU-uploaded textures.
size_t committedSingleMeshletGeoCount_
Single-meshlet geometries already on GPU.
std::vector< Texture * > getTexturesToUpload() const
Get the list of textures waiting for GPU upload.
std::optional< VulkanStagedBuffer > vertexBuffer
Optimized vertex data (Vertex structs)
std::vector< VulkanStagedBufferSyncObjects > & getPendingSyncObjects()
Get pending buffer sync objects for the transfer phase These need to be recorded in the transfer comm...
uint32_t getValidTextureIndex(uint32_t textureIndex, DefaultTextureType defaultType)
void processCompletedMeshletGenerations(std::vector< Ecs::CompletedMeshletGeneration > &&completions)
Process completed meshlet generations and write them to the registry. This should be called at a safe...
void processPendingMeshLoads()
Process pending mesh loads at a safe point in the frame. This should be called BEFORE updateIfDirty()...
bool instancesDirty_
Instance list changed (requires instance buffer update)
std::vector< MeshAsset * > pendingMeshLoads_
bool needsUpdate() const
Check if the rendering data needs to be rebuilt.
uint32_t instanceCount_
Number of instances in buffers.
std::unordered_map< PipelineNames, std::optional< VulkanBuffer > > materialBuffersByPipeline
std::optional< VulkanStagedBuffer > localBoundsBuffer
LocalBoundsData per primitive (static, uploaded once)
bool updatePrimitiveDataInstanced()
Instanced version of updatePrimitiveData using geometry deduplication. Separates geometry upload (onc...
void clearPendingSyncObjects()
Clear pending sync objects after they've been recorded.
size_t committedVertexCount_
Vertices already on GPU.
const VulkanBuffer & getSHProbeBuffer() const
Get the SH probe buffer for spherical harmonic lighting.
bool hasTexturesToUpload() const
Check if there are textures waiting to be uploaded to GPU.
uint32_t getUniqueGeometryCount() const
Gets the current count of unique geometries in the buffers.
uint32_t nextMeshletId_
Next meshlet ID to assign.
bool updatePrimitiveData()
Regenerates all buffers and the rendering ids of all objects, primitives and meshlets.
RenderingDataManager & operator=(const RenderingDataManager &)=delete
std::optional< VulkanStagedBuffer > instanceDataBuffer
InstanceData per visible instance.
uint32_t getTextureCount() const
Get the count of textures currently on the GPU.
std::vector< InstanceData > workingInstanceData_
void invalidateGeometryCache()
Clears the geometry cache and marks for full rebuild. Called when meshes are unloaded.
std::unordered_map< PipelineNames, uint32_t > pipelinePrimitiveCounts
Count of primitives per pipeline.
bool instancingEnabled_
Feature flag for instanced rendering.
void clearTexturesToUpload()
Clear the texture upload queue after upload is complete.
void clearDirty()
Clears the dirty flag after update is complete.
std::unordered_map< std::string, uint32_t > materialPathToDiffuseIndex_
const VulkanBuffer & getPerObjectDataBuffer() const
std::vector< VulkanStagedBufferSyncObjects > pendingTransformSyncObjects_
std::unordered_map< GeometryCacheKey, MeshGeometryMapping, GeometryCacheKeyHash > geometryCache_
RenderingDataManager(const RenderingDataManager &)=delete
std::unordered_set< MeshAsset * > renderCycleMeshSnapshot_
bool isDirty
a flag which defers the update of the buffer updates to the end of the frame.
void processPendingDeletions()
Process deferred buffer deletions Call this after all frames have completed and descriptor sets are u...
const VulkanBuffer & getMeshletBuffer() const
std::vector< Texture * > gpuTextures
Textures currently on GPU.
static constexpr const char * DEFAULT_NORMAL_TEXTURE_PATH
void initializeDefaultTextures()
Queue default textures for loading via the texture pipeline.
const VulkanBuffer & getClusterLodDataBuffer() const
void snapshotRenderableMeshes()
Take a snapshot of currently render-ready meshes. Called at the start of update cycle to ensure consi...
void setRenderer(Renderer *renderer)
Set the renderer for pipeline index lookups. Required when Engine is null.
void markDirty()
Flags the Rendering Data Manager as dirty so that all buffers managed by this manager are in need of ...
bool updateTransforms()
Updates only transform-related buffers (world matrices, bounding spheres)
std::optional< VulkanStagedBuffer > clusterGroupDataBuffer_
ClusterGroupData per LOD group.
uint64_t getDataVersion() const
Get the current data version Incremented each time buffers are updated. RenderProcesses use this to k...
std::optional< VulkanStagedBuffer > triangleBuffer
Triangle indices for meshlets.
void setSceneManager(SceneManager *sceneManager)
Set the scene manager for retrieving actors. Required when Engine is null.
std::vector< SingleMeshletGeometryData > workingSingleMeshletGeoData_
std::unordered_map< uint32_t, MeshComponent * > primitiveIdToComponent_
uint32_t clusterGroupCount_
Total cluster groups.
void clearPendingTransformSyncObjects()
Clear pending transform sync objects after they've been recorded.
std::vector< Ecs::PackedTriangle > workingTriangleBuffer_
std::vector< Texture * > texturesToUpload
Textures waiting for GPU upload.
uint32_t clusterCount_
Total clusters across all LOD levels.
const VulkanBuffer & getMeshletBoundsBuffer() const
std::vector< ClusterLodData > workingClusterLodData_
uint32_t multiMeshletGeometryCount_
Geometries with meshletCount > 1 (mesh shader path)
void onMeshLoaded(MeshAsset *asset)
Event hook which executes when an Mesh is loaded.
std::optional< VulkanStagedBuffer > primitiveRenderData
MeshPrimitiveRenderData per primitive (texture/material IDs)
size_t committedGeometryCount_
Geometries already on GPU.
std::vector< PrimitiveMeshletData > workingPrimitiveMeshletBuffer_
bool updateIfDirty()
Triggers an update of all GPU buffers if dirty.
std::vector< GpuDiffuseFlatColorMaterial > workingFlatColorMaterials_
DefaultTextureType
Get a valid texture index, substituting defaults for missing textures.
PipelineNames getPipelineForPrimitive(uint32_t primitiveId) const
Gets the pipeline ID (PipelineNames enum) for a given primitive.
uint32_t getPrimitiveCount() const
Gets the current count of primitives in the buffers.
void uploadMaterialBuffers()
Upload material data from MaterialAssets to GPU buffers.
void markMaterialsDirty()
Mark materials as dirty, requiring buffer re-upload.
std::optional< VulkanStagedBuffer > perObjectDataBuffer
mat4 world transform per primitive (matches shader PerObjectData)
std::vector< InstanceCullingData > workingInstanceCullingData_
void onMaterialUnloaded(MaterialAsset *materialAsset)
Event hook for when a material has been unloaded.
uint32_t uniqueGeometryCount_
Number of unique geometries in buffers.
std::unordered_map< std::string, uint32_t > materialPathToFlatColorIndex_
size_t committedVsIndexCount_
VS indices already on GPU.
std::vector< uint32_t > workingVsIndexBuffer_
RenderingDataManager(const Engine *engine, ApplicationContext *context)
std::vector< MeshGeometryData > workingGeometryDataBuffer_
const VulkanBuffer & getTriangleBuffer() const
const VulkanBuffer & getClusterGroupDataBuffer() const
std::vector< glm::mat4 > cachedTransforms_
bool isMeshInSnapshot(MeshAsset *asset) const
Check if a mesh asset is in the current render cycle snapshot.
std::vector< VulkanStagedBufferSyncObjects > pendingSyncObjects_
std::unordered_map< std::string, uint32_t > materialPathToNormalsIndex_
std::vector< glm::mat4 > workingPerObjectData_
bool needsMaterialUpdate() const
Check if material buffers need updating.
std::optional< VulkanStagedBuffer > primitiveCullingData
ObjectCullingData per primitive (unused after GPU transform optimization)
void setInstancingEnabled(bool enabled)
Enable or disable instancing mode.
~RenderingDataManager()
Destructor - cleans up all GPU buffers.
void collectMaterialsFromScene()
Collects all materials from loaded meshes and creates per-pipeline data This builds material-to-pipel...
void queueTextureForUpload(Texture *texture)
Queue a texture for GPU upload Called by AssetManager when a new texture is created and needs uploadi...
const VulkanBuffer & getPrimitiveCullingBuffer() const
std::optional< VulkanStagedBuffer > meshletBuffer
UnifiedMeshlet data.
void onRenderableSpawned(MeshComponent *component)
Event hook which is executed when a renderable component gets added to an actor and can thus be rende...
std::vector< ObjectCullingData > workingPrimitiveCullingBuffer_
std::vector< MeshletBounds > workingMeshletBoundsBuffer_
void onRenderableDestroyed(MeshComponent *component)
Event hook which is executed when a renderable component gets removed from an actor and thus has to b...
void initializeSHProbeBuffer()
Initialize default SH probe data Sets up a single default probe with hardcoded coefficients.
uint32_t getMeshletCount() const
Gets the current count of meshlets in the buffers.
std::optional< VulkanStagedBuffer > primitiveMeshletData
PrimitiveMeshletData per primitive.
std::optional< VulkanStagedBuffer > meshGeometryDataBuffer
MeshGeometryData per unique geometry.
std::optional< VulkanStagedBuffer > instanceCullingDataBuffer
InstanceCullingData per instance.
bool isInstancingEnabled() const
Check if instancing mode is enabled.
void onMaterialLoaded(MaterialAsset *materialAsset)
Event hook for when a material has been loaded.
std::unordered_map< entt::entity, std::vector< uint32_t > > entityToPrimitiveIds_
std::vector< GpuDiffuseShaderMaterial > workingDiffuseMaterials_
std::unordered_map< std::string, uint32_t > materialPathToPbrIndex_
bool geometryDirty_
Unique meshes changed (requires geometry buffer update)
const VulkanBuffer & getPrimitiveMeshletBuffer() const
void onTextureUnloaded(TextureAsset *textureAsset)
Event hook for when a texture has been unloaded.
const VulkanBuffer & getSingleMeshletGeometryBuffer() const
std::vector< LocalBoundsData > workingLocalBoundsDataBuffer_
std::vector< VulkanStagedBufferSyncObjects > & getPendingTransformSyncObjects()
Get pending transform sync objects for the transfer phase.
const VulkanBuffer & getVSIndexBuffer() const
std::vector< GpuPbrMaterial > workingPbrMaterials_
std::optional< VulkanStagedBuffer > singleMeshletGeometryBuffer_
SingleMeshletGeometryData per single-meshlet geometry.
std::optional< VulkanStagedBuffer > clusterLodDataBuffer_
ClusterLodData per cluster.
const VulkanBuffer & getVertexBuffer() const
const VulkanBuffer & getMaterialBufferForPipeline(PipelineNames pipelineName) const
Get the material buffer for a specific pipeline type.
static constexpr const char * DEFAULT_BLACK_TEXTURE_PATH
void onMeshUnloaded(MeshAsset *asset)
Event hook which executes when a Mesh is unloaded.
std::optional< VulkanStagedBuffer > vsIndexBuffer_
Contiguous uint32_t indices for vertex shader.
const VulkanBuffer & getMeshGeometryDataBuffer() const
const VulkanBuffer & getLocalBoundsBuffer() const
std::vector< ClusterGroupData > workingClusterGroupData_
std::vector< MeshPrimitiveRenderData > workingPrimitiveRenderData_
size_t committedTriangleCount_
Triangles already on GPU.
bool geometryNeedsFullRebuild_
True on startup or after mesh unload.
std::optional< VulkanStagedBuffer > meshletBoundsData
MeshletBounds for meshlet culling.
std::vector< GpuNormalsMaterial > workingNormalsMaterials_
void initializeMaterialBuffers()
Initialize material buffers for all pipeline types.
void setAssetManager(AssetManager *assetManager)
Set the asset manager for material lookups. Required when Engine is null.
std::vector< UnifiedMeshlet > workingMeshletDataBuffer_
std::vector< SHProbeData > shProbeData_
CPU-side SH probe data.
void onTextureLoaded(TextureAsset *textureAsset, const std::filesystem::path &texturePath)
Event hook for when a texture has been loaded by the asset pipeline. Creates a Vulkan Texture from th...
const VulkanBuffer & getInstanceDataBuffer() const
const VulkanBuffer & getInstanceCullingDataBuffer() const
uint32_t nextGeometryId_
Next geometry ID to assign.
static constexpr const char * DEFAULT_WHITE_TEXTURE_PATH
std::optional< VulkanBuffer > shProbeBuffer_
SHProbeData buffer at binding 18.
uint32_t singleMeshletGeometryCount_
Geometries with meshletCount == 1 (vertex shader path)
size_t committedMeshletCount_
Meshlets already on GPU.
const VulkanBuffer & getPrimitiveRenderDataBuffer() const
Manages game objects within a scene, handling registration, ID allocation, and GPU buffer synchroniza...
Wrapper for texture data.
RAII wrapper for Vulkan buffer and device memory.
Log category system implementation.
std::size_t operator()(const GeometryCacheKey &key) const
Key for geometry cache - uniquely identifies a primitive within a mesh. Uses MeshAsset pointer and pr...
bool operator==(const GeometryCacheKey &other) const