25#include <unordered_map>
41 class ModelAssetManager;
50 class RenderingDataManager;
54 std::size_t
operator()(
const std::filesystem::path & p )
const noexcept
56 return std::hash<std::string>{}( p.string() );
73 float x = std::max( -1.0f, std::min( 1.0f, n.x ) );
74 float y = std::max( -1.0f, std::min( 1.0f, n.y ) );
75 float z = std::max( -1.0f, std::min( 1.0f, n.z ) );
78 int32_t ix =
static_cast<int32_t
>( std::round( x * 511.0f ) );
79 int32_t iy =
static_cast<int32_t
>( std::round( y * 511.0f ) );
80 int32_t iz =
static_cast<int32_t
>( std::round( z * 511.0f ) );
84 return (
static_cast<uint32_t
>( iz & 0x3FF ) << 20 ) | (
static_cast<uint32_t
>( iy & 0x3FF ) << 10 ) |
85 (
static_cast<uint32_t
>( ix & 0x3FF ) );
93 float r = std::max( 0.0f, std::min( 1.0f, c.x ) );
94 float g = std::max( 0.0f, std::min( 1.0f, c.y ) );
95 float b = std::max( 0.0f, std::min( 1.0f, c.z ) );
98 uint32_t ur =
static_cast<uint32_t
>( std::round( r * 255.0f ) );
99 uint32_t ug =
static_cast<uint32_t
>( std::round( g * 255.0f ) );
100 uint32_t ub =
static_cast<uint32_t
>( std::round( b * 255.0f ) );
104 return ( ua << 24 ) | ( ub << 16 ) | ( ug << 8 ) | ur;
112 return glm::packHalf2x16( tc );
118 std::shared_ptr<Assets::Texture>
texture =
nullptr;
120 template <
typename T>
123 return index > other.index;
126 template <
typename T>
129 return index < other.index;
145 template <
typename AssetClass,
typename Key>
148 if constexpr ( std::is_same_v<AssetClass, Assets::Mesh> )
152 "Mesh assets are keyed by Asset::Path"
159 else if constexpr ( std::is_same_v<AssetClass, Assets::Audio> )
162 std::is_same_v<std::decay_t<Key>, std::filesystem::path>,
163 "Audio assets are keyed by std::filesystem::path"
168 else if constexpr ( std::is_same_v<AssetClass, Assets::Material> )
172 "Material assets are keyed by Asset::Path"
177 else if constexpr ( std::is_same_v<AssetClass, Assets::Texture> )
180 std::is_same_v<std::decay_t<Key>, std::filesystem::path>,
181 "Texture assets are keyed by std::filesystem::path"
195 std::is_same_v<AssetClass, void>,
196 "Unsupported asset type for AssetManager::getAsset<T>()"
368 std::unordered_map<std::filesystem::path, Assets::RuntimeTexture *, PathHasher>
textures = {};
constexpr uint32_t MAX_TEXTURE_COUNT
#define TRACY_LOCKABLE(type, varname, desc)
Manages audio assets by filesystem path, providing dedup and lookup.
Holds decoded PCM audio data as an engine asset.
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.
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
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::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.
AudioAssetRef loadAudioAsset(const std::filesystem::path &path)
Submit an audio file for async loading through the pipeline.
Ecs::AudioAssetPipeline & getAudioAssetPipeline()
void loadEcsTexture(const std::filesystem::path &path)
Loads a texture (.png / .jpg / .exr)
Assets::Loaders::GltfLoader gltfLoader
Assets::Mesh * getMeshAsset(const Asset::Path &asset)
Get a mesh asset by path. If not loaded, requests its model and returns nullptr.
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_
friend RenderingDataManager
AssetManager(ApplicationContext *context)
Ecs::TextureAssetPipeline texturePipeline
Assets::MaterialAssetRef MaterialAssetRef
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.
friend ApplicationContext
Ecs::ModelAssetPipeline modelAssetPipeline
BidirectionalMap< uint32_t, Assets::RuntimeTexture * > textureIndexMap
Assets::CubemapTexture * loadEcsCubemap(const std::filesystem::path &path)
Loads a six-face cubemap asset from a directory.
uint32_t getTextureDescriptorIndex(const std::filesystem::path &path)
Gets the descriptor index of a loaded texture by path.
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
Assets::Audio * getAudioAsset(const std::filesystem::path &path)
Get a loaded audio asset by path.
std::array< std::optional< Assets::RuntimeTexture >, MAX_TEXTURE_COUNT > textureData
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.
CpuLoadingState LoadState
Asset::Ref< Asset::Path, Mesh > MeshAssetRef
Asset::Ref< std::filesystem::path, Texture > TextureAssetRef
Asset::Ref< Asset::Path, Material > MaterialAssetRef
Asset::Ref< std::filesystem::path, Audio > AudioAssetRef
Core audio subsystem owning the miniaudio engine and managing playback.
uint32_t packTexCoordR16G16_SFLOAT(const glm::vec2 &tc)
uint32_t packColorR8G8B8A8_UNORM(const glm::vec3 &c)
uint32_t packNormalA2B10G10R10_SNORM(const glm::vec3 &n)
std::size_t operator()(const std::filesystem::path &p) const noexcept
std::shared_ptr< Assets::Texture > texture
bool operator<(const T &other)
bool operator>(const T &other)