28#include <unordered_map>
29#include <unordered_set>
45 class ModelAssetManager;
54 class RenderingDataManager;
61 std::size_t
operator()(
const std::filesystem::path & p )
const noexcept
63 return std::hash<std::string>{}( p.string() );
83 float x = std::max( -1.0f, std::min( 1.0f, n.x ) );
84 float y = std::max( -1.0f, std::min( 1.0f, n.y ) );
85 float z = std::max( -1.0f, std::min( 1.0f, n.z ) );
88 int32_t ix =
static_cast<int32_t
>( std::round( x * 511.0f ) );
89 int32_t iy =
static_cast<int32_t
>( std::round( y * 511.0f ) );
90 int32_t iz =
static_cast<int32_t
>( std::round( z * 511.0f ) );
94 return (
static_cast<uint32_t
>( iz & 0x3FF ) << 20 ) | (
static_cast<uint32_t
>( iy & 0x3FF ) << 10 ) |
95 (
static_cast<uint32_t
>( ix & 0x3FF ) );
103 float r = std::max( 0.0f, std::min( 1.0f, c.x ) );
104 float g = std::max( 0.0f, std::min( 1.0f, c.y ) );
105 float b = std::max( 0.0f, std::min( 1.0f, c.z ) );
108 uint32_t ur =
static_cast<uint32_t
>( std::round( r * 255.0f ) );
109 uint32_t ug =
static_cast<uint32_t
>( std::round( g * 255.0f ) );
110 uint32_t ub =
static_cast<uint32_t
>( std::round( b * 255.0f ) );
114 return ( ua << 24 ) | ( ub << 16 ) | ( ug << 8 ) | ur;
122 return glm::packHalf2x16( tc );
138 std::shared_ptr<Assets::Texture>
texture =
nullptr;
140 template <
typename T>
143 return index > other.index;
146 template <
typename T>
149 return index < other.index;
167 template <
typename AssetClass,
typename Key>
170 if constexpr ( std::is_same_v<AssetClass, Assets::Mesh> )
174 "Mesh assets are keyed by Asset::MeshPath"
181 else if constexpr ( std::is_same_v<AssetClass, Assets::Audio> )
185 std::is_same_v<std::decay_t<Key>, std::filesystem::path>,
186 "Audio assets are keyed by Asset::Path"
191 else if constexpr ( std::is_same_v<AssetClass, Assets::Animation> )
195 "Animation assets are keyed by Asset::MeshPath"
205 else if constexpr ( std::is_same_v<AssetClass, Assets::Material> )
209 "Material assets are keyed by Asset::MeshPath"
214 else if constexpr ( std::is_same_v<AssetClass, Assets::Skin> )
218 "Skin assets are keyed by Asset::MeshPath"
228 else if constexpr ( std::is_same_v<AssetClass, Assets::Texture> )
232 std::is_same_v<std::decay_t<Key>, std::filesystem::path>,
233 "Texture assets are keyed by Asset::Path"
248 std::is_same_v<AssetClass, void>,
"Unsupported asset type for AssetManager::getAsset<T>()"
444 std::unordered_map<std::filesystem::path, Assets::RuntimeTexture *, PathHasher>
textures = {};
445 std::unordered_map<std::filesystem::path, std::unique_ptr<Assets::CubemapTexture>,
PathHasher>
constexpr uint32_t MAX_TEXTURE_COUNT
#define TRACY_LOCKABLE(type, varname, desc)
Maintains a one-to-one mapping that can be queried from either side.
Manages audio assets by filesystem path, providing dedup and lookup.
Holds decoded PCM audio data as an engine asset.
Owns Vulkan resources for a sampled cubemap texture.
Loads glTF files and converts tinygltf data into engine asset data.
Asset manager for materials keyed by source file path and material name.
the material asset is another wrapper for asset data which is stored in entt. It has the EngineCore::...
Stores mesh data with their primitives.
The mesh asset stores geometry data and.
Runtime-owned Vulkan texture resource.
Asset manager for texture assets keyed by filesystem path.
Wrapper for texture data.
Central registry for texture handles, providing O(1) descriptor index lookup.
The application context is the core class which stores the basic openxr and vulkan objects.
bool doesTextureAlreadyExist(const std::filesystem::path &path)
Checks if a texture has already been loaded.
Assets::ModelAssetManager * modelAssetManager
Assets::Mesh * getMeshAsset(const Asset::MeshPath &asset)
Get a mesh asset by path. If not loaded, requests its model and returns nullptr.
DescriptorIndexAllocator textureAllocator
void discardSceneLoadingData()
Drops any queued or in-flight scene asset loading work.
Assets::TextureAssetRef TextureAssetRef
Assets::MaterialAssetManager * materialAssetManager
Assets::Textures::TextureHandleRegistry * getTextureHandleRegistry()
Gets the texture handle registry for O(1) descriptor index lookups.
Rendering::Renderer * renderer
std::unordered_map< std::filesystem::path, std::unique_ptr< Assets::CubemapTexture >, PathHasher > cubemapTextures
Assets::SkinAssetManager * skinAssetManager_
Assets::MaterialAssetManager * getMaterialAssetManager() const
Gets the material asset manager for material lookups.
uint32_t getImageCount() const
auto getAsset(const Key &asset)
std::vector< TextureStorage > texturesToUpload
Assets::RuntimeTexture * replaceTextureFromPrepared(const std::filesystem::path &path, Assets::RuntimeTexture texture)
Replace an already registered texture while preserving its descriptor index.
Assets::AudioAssetRef AudioAssetRef
Assets::MeshAssetRef MeshAssetRef
void setRenderingDataManager(RenderingDataManager *renderingDataManager)
Sets the RenderingDataManager on asset pipelines for hook notifications.
Assets::Textures::TextureHandleRegistry textureHandleRegistry_
Registry for type-safe texture handles.
Ecs::AudioAssetPipeline & getAudioAssetPipeline()
void loadEcsTexture(const std::filesystem::path &path)
Loads a texture (.png / .jpg / .exr)
Assets::Loaders::GltfLoader gltfLoader
Assets::MeshAssetManager * meshAssetManager
std::vector< VkDescriptorImageInfo > getTextureDescriptorInfos() const
NamedThreadPool * threadPool_
Assets::AudioAssetManager * getAudioAssetManager() const
Gets the audio asset manager for direct access.
Assets::AudioAssetManager * audioAssetManager_
Assets::Audio * getAudioAsset(const Asset::Path &path)
Get a loaded audio asset by path.
Assets::AnimationAssetRef AnimationAssetRef
friend RenderingDataManager
AssetManager(ApplicationContext *context)
Ecs::TextureAssetPipeline texturePipeline
Assets::MaterialAssetRef MaterialAssetRef
Assets::AnimationAssetManager * animationAssetManager_
void unregisterTexture(Assets::RuntimeTexture *texture)
Assets::RuntimeTexture * registerTexture(const std::filesystem::path &path, Assets::RuntimeTexture texture)
Registers a texture with the texture manager which prevents the same texture from being loaded twice.
Assets::ModelAssetManager * getModelAssetManager() const
Gets the model asset manager for model/GLTF file loading state lookups.
Assets::RuntimeTexture * registerTextureFromPrepared(const std::filesystem::path &path, Assets::RuntimeTexture texture)
Register a texture whose Vulkan resources are already created. Skips createResources() — only allocat...
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...
Assets::TextureAssetManager * textureAssetManager
Ecs::AudioAssetPipeline audioAssetPipeline_
std::vector< Assets::RuntimeTexture * > texturesToCopyImageData
Ecs::TextureAssetPipeline & getTextureAssetPipeline()
NamedThreadPool * getAssetLoaderPool() const
void unloadRuntimeTextures()
NamedThreadPool * getCalculationPool() const
NamedThreadPool * threadedCalculation_
void attachToRenderer(Rendering::Renderer *renderer)
Sets what renderer the render process belongs to.
Assets::SkinAssetRef SkinAssetRef
friend ApplicationContext
Ecs::ModelAssetPipeline modelAssetPipeline
BidirectionalMap< uint32_t, Assets::RuntimeTexture * > textureIndexMap
uint32_t reserveRuntimeTextureDescriptorIndex()
Assets::CubemapTexture * loadEcsCubemap(const std::filesystem::path &path)
Loads a six-face cubemap asset from a directory.
void releaseRuntimeTextureDescriptorIndex(uint32_t descriptorIndex)
uint32_t getTextureDescriptorIndex(const std::filesystem::path &path)
Gets the descriptor index of a loaded texture by path.
Assets::AnimationAssetManager * getAnimationAssetManager() const
std::unordered_map< std::filesystem::path, Assets::RuntimeTexture *, PathHasher > textures
Assets::MeshAssetManager * getMeshAssetManager() const
Gets the mesh asset manager for mesh asset lookups.
ApplicationContext * context
std::unordered_set< uint32_t > runtimeTextureDescriptorIndices_
std::array< std::optional< Assets::RuntimeTexture >, MAX_TEXTURE_COUNT > textureData
Assets::SkinAssetManager * getSkinAssetManager() const
AudioAssetRef loadAudioAsset(const Asset::Path &path)
Submit an audio file for async loading through the pipeline.
Ecs::ModelAssetPipeline & getMeshAssetPipeline()
Use this class to manage a finite amount of memory. The idea is to have an array which stores objects...
Async pipeline for loading audio assets (WAV, FLAC, MP3)
The model asset pipeline loads a gltf scene and loads and loads the mesh and material data....
Infrastructure to load images into the ecs.
Utility class for spawning GLTF meshes into a scene.
The renderer is the main class for rendering. It owns all data which is used any time in any frame....
Tracy-named thread pool using BS_tracy::tracy_thread_pool.
@ LOADED
All components of the asset have been loaded, and it is ready to be used.
@ REQUESTED_LOAD
An asset has been requested to load and is waiting for an asset pipeline to start working on it.
@ LOADING
While the asset is currently being processed in the asset pipeline.
@ UNLOADED
When the asset is not loaded yet but the frame is already existing for the heavy data to be loaded in...
CpuLoadingState LoadState
Asset::Ref< Asset::MeshPath, Animation > AnimationAssetRef
Asset::Ref< Asset::Path, Audio > AudioAssetRef
Asset::Ref< Asset::Path, Texture > TextureAssetRef
Asset::Ref< Asset::MeshPath, Skin > SkinAssetRef
Asset::Ref< Asset::MeshPath, Mesh > MeshAssetRef
Asset::Ref< Asset::MeshPath, Material > MaterialAssetRef
Manages IBL (Image-Based Lighting) resources for specular reflections.
uint32_t packTexCoordR16G16_SFLOAT(const glm::vec2 &tc)
uint32_t packColorR8G8B8A8_UNORM(const glm::vec3 &c)
uint32_t packNormalA2B10G10R10_SNORM(const glm::vec3 &n)
Identifies a named mesh-like asset inside an asset file.
Identifies a single asset file on disk.
const std::filesystem::path & getFilePath() const
Compact vertex format used by mesh packing code.
Hash functor for filesystem paths used in unordered containers.
std::size_t operator()(const std::filesystem::path &p) const noexcept
Texture asset entry paired with its descriptor index.
std::shared_ptr< Assets::Texture > texture
Managed texture asset.
bool operator<(const T &other)
bool operator>(const T &other)
uint32_t index
Descriptor or storage index assigned to the texture.