3#include <vulkan/vulkan.h>
5#include <unordered_map>
22 VkDeviceMemory
memory = VK_NULL_HANDLE;
30 VkFormat
format = VK_FORMAT_R8G8B8A8_SRGB;
154 const uint8_t* pixels,
int width,
int height,
163 void evictTexture(
const std::string& cacheKey, VkDevice device);
175 uint32_t
findMemoryType(VkPhysicalDevice physicalDevice, uint32_t typeFilter, VkMemoryPropertyFlags properties);
179 std::unordered_map<std::string, std::unique_ptr<Texture>>
textureCache;
TextureFilterMode
Definition Material.hpp:6
@ Nearest
Definition Material.hpp:7
@ Bilinear
Definition Material.hpp:8
void createDefaultTextures(VulkanRenderer &renderer)
Initializes default 1x1 textures (white, normal, metallic) for fallbacks.
Definition ResourceManager.cpp:350
Texture defaultMetallicTexture
Definition ResourceManager.hpp:185
void evictTexture(const std::string &cacheKey, VkDevice device)
Removes a texture from the cache and frees its GPU memory.
Definition ResourceManager.cpp:1863
void clearMeshCache(const std::string &path)
Clears the cached mesh for a specific path to force a re-import.
Definition ResourceManager.cpp:892
Texture * loadTexture(const std::string &path, VulkanRenderer &renderer, TextureFilterMode filterMode=TextureFilterMode::Bilinear)
Loads a texture from file, uploading it to the GPU and caching the resource.
Definition ResourceManager.cpp:253
uint32_t findMemoryType(VkPhysicalDevice physicalDevice, uint32_t typeFilter, VkMemoryPropertyFlags properties)
Finds a memory type matching properties in the physical GPU.
Definition ResourceManager.cpp:142
std::unordered_map< std::string, Mesh > meshCache
Cache of loaded meshes mapped by file path.
Definition ResourceManager.hpp:181
ResourceManager()=default
Construct a new Resource Manager object.
Texture defaultWhiteTexture
Fallback default 1x1 texture.
Definition ResourceManager.hpp:183
void createTextureSampler(VkDevice device, Texture &texture, TextureFilterMode filterMode)
Helper to configure texture samplers with the specified filter mode.
Definition ResourceManager.cpp:172
Texture * getDefaultWhiteTexture()
Retrieves the default fallback white texture pointer.
Definition ResourceManager.hpp:133
Texture * getDefaultNormalTexture()
Definition ResourceManager.hpp:134
Mesh loadMesh(const std::string &path, VulkanRenderer &renderer, int primitiveIndex=-1)
Loads a glTF mesh from file, uploading geometry buffers to the GPU and caching it.
Definition ResourceManager.cpp:903
std::unordered_map< std::string, std::unique_ptr< Texture > > textureCache
Cache of loaded textures mapped by file path.
Definition ResourceManager.hpp:179
bool loadBinarySkeletonAndAnimations(const std::string &path, SkeletonComponent &skeleton, AnimatorComponent &animator, bool append=false)
Loads skeletal skin and animations from a custom binary animation file (.anim).
Definition ResourceManager.cpp:1580
~ResourceManager()=default
Destroy the Resource Manager object.
Texture * createTextureFromPixels(const std::string &cacheKey, const uint8_t *pixels, int width, int height, VulkanRenderer &renderer, TextureFilterMode filterMode=TextureFilterMode::Nearest)
Creates and caches a Vulkan texture directly from raw RGBA pixel data. Used by TilesetAsset::buildAtl...
Definition ResourceManager.cpp:1793
bool saveBinarySkeletonAndAnimations(const std::string &path, const SkeletonComponent &skeleton, const AnimatorComponent &animator)
Saves skeletal skin and animations to a custom binary animation file (.anim).
Definition ResourceManager.cpp:1474
Texture * getDefaultMetallicTexture()
Definition ResourceManager.hpp:135
void updateTextureFilterMode(const std::string &path, VulkanRenderer &renderer, TextureFilterMode filterMode)
Updates an already loaded texture's filter settings live and recreates its Vulkan sampler.
Definition ResourceManager.cpp:1767
int getMeshPrimitiveCount(const std::string &path)
Scans a glTF file and returns the count of primitive submesh parts.
Definition ResourceManager.cpp:992
bool loadSkeletonAndAnimations(const std::string &path, SkeletonComponent &skeleton, AnimatorComponent &animator, bool append=false)
Loads skeletal skin and animations from a glTF file.
Definition ResourceManager.cpp:1091
Texture defaultNormalTexture
Definition ResourceManager.hpp:184
void createTextureImage(const std::string &path, VulkanRenderer &renderer, Texture &texture)
Helper to load pixel data, create a VkImage, and copy staging data onto the GPU.
Definition ResourceManager.cpp:208
void updateMaterialDescriptorSet(Material &mat, VulkanRenderer &renderer)
Dynamically updates or allocates a descriptor set for a Material, binding its diffuse,...
Definition ResourceManager.cpp:489
void cleanup(VkDevice device)
Safely frees all cached textures and meshes from GPU memory.
Definition ResourceManager.cpp:1028
void createTextureImageView(VkDevice device, Texture &texture)
Helper to create standard 2D image views.
Definition ResourceManager.cpp:154
Manages core Vulkan pipeline states, device interaction, frames, buffers, and command submissions.
Definition VulkanRenderer.hpp:127
Animator controller managing active clips and tracking playback timing.
Definition Animator.hpp:84
Represents a material component defining rendering properties.
Definition Material.hpp:17
Represents a mesh component that holds geometry data and its Vulkan buffers.
Definition Mesh.hpp:95
Component managing the list of joints and generating the offset matrices palette.
Definition Skeleton.hpp:37
Holds Vulkan handles and metadata for a loaded texture resource.
Definition ResourceManager.hpp:18
int width
Width in pixels.
Definition ResourceManager.hpp:32
VkSampler sampler
Sampler specifying filtering and wrapping modes.
Definition ResourceManager.hpp:26
VkDescriptorSet descriptorSet
Descriptor set updated for shader binding.
Definition ResourceManager.hpp:28
VkImageView imageView
View to read image data in shaders.
Definition ResourceManager.hpp:24
VkFormat format
Vulkan image format (e.g. UNORM or SRGB).
Definition ResourceManager.hpp:30
std::string path
Filepath from which texture was loaded.
Definition ResourceManager.hpp:37
VkImage image
Raw Vulkan image object.
Definition ResourceManager.hpp:20
int height
Height in pixels.
Definition ResourceManager.hpp:35
VkDeviceMemory memory
Allocated device memory backing the image.
Definition ResourceManager.hpp:22
TextureFilterMode filterMode
Filter mode used for this texture.
Definition ResourceManager.hpp:39