22#include <unordered_map>
43 std::size_t
operator()(
const std::filesystem::path & p )
const noexcept
45 return std::hash<std::string>{}( p.string() );
62 float x = std::max( -1.0f, std::min( 1.0f, n.x ) );
63 float y = std::max( -1.0f, std::min( 1.0f, n.y ) );
64 float z = std::max( -1.0f, std::min( 1.0f, n.z ) );
67 int32_t ix =
static_cast<int32_t
>( std::round( x * 511.0f ) );
68 int32_t iy =
static_cast<int32_t
>( std::round( y * 511.0f ) );
69 int32_t iz =
static_cast<int32_t
>( std::round( z * 511.0f ) );
73 return (
static_cast<uint32_t
>( iz & 0x3FF ) << 20 ) | (
static_cast<uint32_t
>( iy & 0x3FF ) << 10 ) |
74 (
static_cast<uint32_t
>( ix & 0x3FF ) );
82 float r = std::max( 0.0f, std::min( 1.0f, c.x ) );
83 float g = std::max( 0.0f, std::min( 1.0f, c.y ) );
84 float b = std::max( 0.0f, std::min( 1.0f, c.z ) );
87 uint32_t ur =
static_cast<uint32_t
>( std::round( r * 255.0f ) );
88 uint32_t ug =
static_cast<uint32_t
>( std::round( g * 255.0f ) );
89 uint32_t ub =
static_cast<uint32_t
>( std::round( b * 255.0f ) );
93 return ( ua << 24 ) | ( ub << 16 ) | ( ug << 8 ) | ur;
101 return glm::packHalf2x16( tc );
109 template <
typename T>
112 return index > other.index;
115 template <
typename T>
118 return index < other.index;
157 void loadEcsModel(
const std::filesystem::path & path );
196 [[nodiscard]] std::vector<const Mesh *>
getAllMeshes()
const;
224 std::vector<MaterialShader *>
getShaders()
const;
322 std::vector<const MeshPrimitive *>
341 template <
typename T>
347 template <
typename T>
354 template <
typename MaterialDataType>
360 [[nodiscard]] std::vector<MaterialDataType>
getData()
const;
372 std::vector<MaterialDataType>
data{};
388 std::unordered_map<std::filesystem::path, Texture *, PathHasher>
textures = {};
424 std::unordered_map<std::filesystem::path, Mesh *, PathHasher>
meshes = {};
433 template <
typename T>
438 const size_t bufferSize =
sizeof( T ) * materialCount;
443 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
444 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
448 PLOGI <<
"Created material storage buffer with size " << bufferSize <<
" bytes and a count of "
452 template <
typename T>
470 template <
typename T>
476 template <
typename T>
482 template <
typename T>
488 template <
typename T>
491 uint32_t freeIndex =
allocator.allocate();
492 data[freeIndex] = materialData;
496 template <
typename T>
499 return allocator.getUsedIndices().size();
502 template <
typename T>
506 data[materialIndex] = {};
509 template <
typename T>
#define FUNCTION_DEPRECATED_RETURN
constexpr uint32_t MAX_MESH_COUNT
constexpr uint32_t MAX_TEXTURE_COUNT
#define TRACY_LOCKABLE(type, varname, desc)
The model asset pipeline loads a gltf scene and loads and loads the mesh and material data....
Infrastructure to load images into the ecs.
std::vector< MaterialDataType > data
const DescriptorIndexAllocator & getIndexAllocator() const
std::vector< MaterialDataType > getData() const
DescriptorIndexAllocator allocator
size_t getCapacity() const
uint32_t addMaterialData(MaterialDataType materialData)
MaterialData(uint32_t materialCount)
size_t getMaterialCount() const
void removeFromIndex(uint32_t materialIndex)
NamedThreadPool * threadedCalculation
uint32_t getMeshletCount(const std::vector< const Mesh * > &meshes) const
uint32_t getMeshOffset(Mesh *mesh) const
std::unordered_map< Mesh *, uint32_t > getMeshOffsets() const
std::unordered_map< MaterialShader *, uint32_t > shaderOffsets
MaterialShader * registerShader(MaterialShader shader, const PipelineNames &materialName)
BidirectionalMap< uint32_t, Mesh * > meshIndexMap
MeshAssetManager * getMeshAssetManager() const
Gets the mesh asset manager for mesh asset lookups.
Ecs::ModelAssetPipeline & getMeshAssetPipeline()
std::vector< UnifiedMeshlet > meshlets
NamedThreadPool * getAssetLoaderPool() const
uint32_t addMaterialData(T data)
std::vector< CpuMeshData > cpuMeshData
uint32_t getTextureDescriptorIndex(const std::filesystem::path &path)
Gets the descriptor index of a loaded texture by path.
DescriptorIndexAllocator textureAllocator
std::vector< MaterialShader * > shaders
std::unordered_map< PipelineNames, VulkanBuffer > materialStorageBuffers
void unregisterMesh(Mesh *mesh)
BidirectionalMap< uint32_t, Texture * > textureIndexMap
MeshAsset * getMeshAsset(const Asset::Path &asset)
Get a mesh from the asset manager. If it does not exist it requests the asset from the asset loader.
std::vector< PrimitiveMeshletData > objectMeshletData
DescriptorIndexAllocator shaderAllocator
DescriptorIndexAllocator meshAllocator
void unregisterTexture(Texture *texture)
friend RenderingDataManager
std::unordered_map< PipelineNames, MaterialShader * > shadersByName
ApplicationContext * context
std::unordered_map< std::filesystem::path, Texture *, PathHasher > textures
void unregisterShader(MaterialShader *shader)
MeshAssetManager * meshAssetManager
MaterialShader * getShaderByName(const std::string &shaderName)
Ecs::TextureAssetPipeline texturePipeline
VulkanBuffer & getMaterialStorageBufferByName(PipelineNames name)
std::unordered_map< Mesh *, uint32_t > meshOffsets
bool doesTextureAlreadyExist(const std::filesystem::path &path)
Checks if a texture has already been loaded.
TextureAssetManager * textureAssetManager
NamedThreadPool * threadPool
std::vector< const Mesh * > getAllMeshes() const
Gets a copy of all meshes which are currently loaded in the asset manager.
std::vector< Texture * > texturesToCopyImageData
std::array< std::optional< Mesh >, MAX_MESH_COUNT > meshData
uint32_t getTotalPrimitiveCount() const
Mesh * registerMesh(const std::filesystem::path &path, GltfLoader::GltfMeshData &gltfMeshData)
TextureHandleRegistry textureHandleRegistry_
Registry for type-safe texture handles.
void setRenderingDataManager(RenderingDataManager *renderingDataManager)
Sets the RenderingDataManager on asset pipelines for hook notifications.
void attachToRenderer(Renderer *renderer)
Sets what renderer the render process belongs to.
std::vector< const MeshPrimitive * > getMeshPrimitivesFromMeshes(const std::vector< const Mesh * > &meshes) const
PipelineNames materialNameFromString(const std::string &string)
uint32_t getImageCount() const
std::vector< MeshletBounds > meshletBounds
Ecs::ModelAssetPipeline modelAssetPipeline
MaterialAssetManager * materialAssetManager
std::unordered_map< std::filesystem::path, Mesh *, PathHasher > meshes
std::vector< ObjectCullingData > objectCullingData
friend ApplicationContext
ModelAssetManager * modelAssetManager
MaterialAssetManager * getMaterialAssetManager() const
Gets the material asset manager for material lookups.
std::array< std::optional< MaterialShader >, 100 > shaderData
Ecs::TextureAssetPipeline & getTextureAssetPipeline()
void loadEcsModel(const std::filesystem::path &path)
Submits a gltf model for loading. You provide the path of the model to load. This can include 3D data...
void unloadAllData() const
ModelAssetManager * getModelAssetManager() const
Gets the model asset manager for model/GLTF file loading state lookups.
std::vector< VkDescriptorImageInfo > getTextureDescriptorInfos() const
void logAllLoadedAssets() const
void loadEcsTexture(const std::filesystem::path &path)
Loads a texture (.png / .jpg / .exr)
std::vector< TextureStorage > texturesToUpload
NamedThreadPool * getCalculationPool() const
TextureHandleRegistry * getTextureHandleRegistry()
Gets the texture handle registry for O(1) descriptor index lookups.
uint32_t getShaderCount() const
std::vector< MaterialShader * > getShaders() const
std::vector< Texture * > getTexturesToUpload()
void initMaterialStorageBuffer(PipelineNames name, uint32_t materialCount)
Texture * registerTexture(const std::filesystem::path &path, Texture texture)
Registers a texture with the texture manager which prevents the same texture from being loaded twice.
std::array< std::optional< Texture >, MAX_TEXTURE_COUNT > textureData
bool doesMeshAlreadyExist(const std::filesystem::path &meshPath) const
Checks if a mesh is already present in the loaded meshes in RAM.
Use this class to manage a finite amount of memory. The idea is to have an array which stores objects...
Stores mesh data with their primitives.
The mesh asset stores geometry data and.
The render process class consolidates all the resources that needs to be duplicated for each frame th...
The renderer is the main class for rendering. It owns all data which is used any time in any frame....
The rendering data manager is supposed to hold all methods to update the contents of the buffers whic...
Wrapper for texture data.
Central registry for texture handles, providing O(1) descriptor index lookup.
RAII wrapper for Vulkan buffer and device memory.
Tracy-named thread pool using BS_tracy::tracy_thread_pool.
Log category system implementation.
uint32_t packTexCoordR16G16_SFLOAT(const glm::vec2 &tc)
uint32_t packNormalA2B10G10R10_SNORM(const glm::vec3 &n)
uint32_t packColorR8G8B8A8_UNORM(const glm::vec3 &c)
static std::string getPipelineNameFromString(PipelineNames pipelineName)
Gets the pipeline name as string.
std::size_t operator()(const std::filesystem::path &p) const noexcept
std::shared_ptr< Texture > texture
bool operator<(const T &other)
bool operator>(const T &other)
Information about the wereabouts of a meshlet in memory on the gpu.