13#include <unordered_map>
15#include <utility/ressource_provider.hpp>
16#include <utility/graphic/material.hpp>
17#include <utility/graphic/texture.hpp>
19#include <utility/logging/loggable.hpp>
20#include <utility/logging/default_logger.hpp>
22#include "GPUMaterial.hpp"
23#include "GPUTexture.hpp"
24#include "GPUShader.hpp"
39 protected utility::logging::Loggable<RessourceManager,
40 utility::logging::DefaultLogger>
59 std::shared_ptr<DeviceContext> deviceContext);
163 std::shared_ptr<GPUShader>> &
201 std::unordered_map<uint32_t, std::shared_ptr<GPUMaterial>>
_materials;
207 std::unordered_map<uint32_t, std::shared_ptr<GPUTexture>>
_textures;
213 std::unordered_map<uint32_t, std::shared_ptr<GPUShader>>
_shaders;
The RessourceManager class is responsible for managing GPU resources such as materials and textures.
std::unordered_map< uint32_t, std::shared_ptr< GPUShader > > _shaders
Internal map to store GPU shaders for efficient retrieval based on their unique IDs.
std::shared_ptr< utility::RessourceProvider > _ressourceProvider
Internal method to retrieve the next unique ID for a resource.
std::shared_ptr< DeviceContext > _deviceContext
Shared pointer to the DeviceContext used for creating GPU resources.
std::shared_ptr< GPUMaterial > getMaterial(uint32_t id) const
Retrieves a shared pointer to the GPUMaterial associated with the given material ID.
const std::unordered_map< uint32_t, std::shared_ptr< GPUShader > > & getShaders() const
Retrieves the map of all GPUShaders managed by the RessourceManager.
void cleanup()
Releases every cached GPU wrapper owned by this manager.
std::shared_ptr< GPUTexture > getTexture(uint32_t id) const
Retrieves a shared pointer to the GPUTexture associated with the given texture ID.
std::unordered_map< uint32_t, std::shared_ptr< GPUTexture > > _textures
Internal map to store GPU textures for efficient retrieval based on their unique IDs.
void init(std::shared_ptr< Renderer > renderer)
Initializes the RessourceManager by synchronizing GPU resources with the materials and textures loade...
uint64_t _syncedVersion
Version of the provider at the last full synchronization pass.
std::unordered_map< uint32_t, std::shared_ptr< GPUMaterial > > _materials
Internal maps to store GPU materials and textures for efficient retrieval based on their unique IDs.
RessourceManager(std::shared_ptr< utility::RessourceProvider > ressourceProvider, std::shared_ptr< DeviceContext > deviceContext)
Constructs a RessourceManager instance with the given resource provider, device context,...
bool _synchronized
Whether at least one full synchronization pass has completed.
~RessourceManager()
Destructs the RessourceManager instance and cleans up GPU resources.
void sync(bool refresh=false)
Synchronizes the GPU resources with the materials and textures loaded from the resource provider.
std::weak_ptr< Renderer > _renderer
Weak pointer to the Renderer instance.
std::shared_ptr< GPUShader > getShader(uint32_t id) const
Retrieves a shared pointer to the GPUShader associated with the given shader ID.
Small result wrapper used by helpers that must return both a status and a value (e....