10#include "components/ErrorUtils.hpp"
12#include "components/ThreadPool.hpp"
15#include <components/Types.hpp>
65 return defaultTextureName;
78 bool loadTexture(
const std::string& path,
const std::string& name) ;
106 if (frameIndex >= m_descriptorSets.size()) {
108 "Invalid frame index %u (Max %zu)",
109 frameIndex, m_descriptorSets.size());
110 return VK_NULL_HANDLE;
112 return m_descriptorSets[frameIndex];
119 if (frameIndex >= m_descriptorSets.size()) {
121 "Invalid frame index %u (Max %zu). Returning nullptr.",
122 frameIndex, m_descriptorSets.size());
125 return &m_descriptorSets[frameIndex];
142 return m_textures.find(name) != m_textures.end();
161 VkDescriptorSetLayout
getBindlessLayout()
const {
return m_r_context.bindlessDescriptorSetLayout; }
167 if (frameIndex >= m_particleDescriptorSets.size()) {
169 "Invalid frame index %u for particle descriptor set (Max %zu)",
170 frameIndex, m_particleDescriptorSets.size());
171 return VK_NULL_HANDLE;
173 return m_particleDescriptorSets[frameIndex];
180 if (frameIndex >= m_particleMappedData.size()) {
182 "Invalid frame index %u for particle mapped data (Max %zu)",
183 frameIndex, m_particleMappedData.size());
186 return m_particleMappedData[frameIndex];
196 const std::string defaultTextureName =
"default";
201 std::vector<VkBuffer> m_sceneBuffers;
202 std::vector<VkBuffer> m_lightBuffers;
203 std::vector<VmaAllocation> m_sceneAllocs;
204 std::vector<VmaAllocation> m_lightAllocs;
206 std::vector<VkBuffer> m_particleSSBOs;
207 std::vector<VmaAllocation> m_particleAllocs;
208 std::vector<void*> m_particleMappedData;
209 VkDescriptorPool m_particleDescriptorPool = VK_NULL_HANDLE;
210 std::vector<VkDescriptorSet> m_particleDescriptorSets;
212 VkDescriptorSetLayout m_descriptorSetLayout;
213 std::vector<VkDescriptorSet> m_descriptorSets;
214 VkDescriptorPool m_descriptorPool;
215 std::vector<VkDescriptorSet> m_textureDescriptorSets;
217 vex_map<std::string, VkImageView> m_textures;
218 VkSampler m_textureSampler;
220 vex_map<std::string, VkImage> m_textureImages;
221 vex_map<std::string, VmaAllocation> m_textureAllocations;
222 vex_map<std::string, VkImageView> m_textureViews;
224 std::vector<std::string> m_ignoredTexturePaths;
Particle emitter component.
This file defines VirtualFileSystem and VPKStream classes.
This class provides abstraction of file system needed for loading packed and unpacked assets.
void * getParticleMappedData(uint32_t frameIndex) const
Returns the mapped data for the particle SSBO for the given frame index.
VkDescriptorSet getUBODescriptorSet(uint32_t frameIndex) const
Returns the uniform buffer descriptor set for the given frame index.
void createPerMeshTextureSets()
Internal function to create per-mesh texture sets.
const std::string & getDefaultTextureName() const
Returns the default texture name.
VkDescriptorSetLayout getBindlessLayout() const
Returns the bindless descriptor set layout.
void updateSceneUBO(const SceneUBO &data)
Updates the scene uniform buffer.
bool loadTexture(const std::string &path, const std::string &name)
Loads a texture from a file.
void createTextureSampler()
Internal function to create texture sampler.
uint32_t getTextureIndex(const std::string &name)
Returns the index of a texture with the given name.
VulkanResources(VulkanContext &context, VirtualFileSystem *vfs)
Simple constructor.
void updateTextureDescriptor(uint32_t frameIndex, VkImageView textureView, uint32_t textureIndex)
Updates the texture descriptor.
void unloadTexture(const std::string &name)
Unloads a texture.
VkDescriptorSetLayout getDescriptorLayout() const
Returns a descriptor set layout.
~VulkanResources()
Simple destructor.
VkDescriptorSet getParticleDescriptorSet(uint32_t frameIndex) const
Returns the particle descriptor set for the given frame index.
VkDescriptorSet getBindlessDescriptorSet() const
Returns the bindless descriptor set.
void createParticleSSBOs()
Internal function to create particle SSBOs.
bool textureExists(const std::string &name) const
Returns if a texture with the given name exists.
void updateLightUBO(uint32_t frameIndex, uint32_t modelIndex, const SceneLightsUBO &data)
Updates the light uniform buffer for a specific model.
VkDescriptorSet getTextureDescriptorSet(uint32_t frameIndex, uint32_t textureIndex) const
Returns a descriptor set for the given frame index and texture index.
void createDefaultTexture()
Creates a default texture.
VkDescriptorSet getDescriptorSet(uint32_t frameIndex) const
Returns the descriptor set for the given frame index.
void loadTexturesBatched(const std::vector< std::string > &paths)
Loads multiple textures in batches.
void createTextureFromRaw(const std::vector< unsigned char > &rgba, int w, int h, const std::string &name)
Creates a texture from raw data.
VkDescriptorSet * getDescriptorSetPtr(uint32_t frameIndex)
Returns a pointer to the descriptor set for the given frame index.
VkSampler getTextureSampler() const
Returns the texture sampler.
void createDescriptorResources()
Internal function to create descriptor resources.
void createUniformBuffers()
Creates uniform buffers.
void createColorLUT()
Generates and uploads a 32x32x32 3D Lookup Texture (LUT) to the GPU. Bakes PS1 5-bit color quantizati...
VkImageView getTextureView(const std::string &name) const
Returns the texture view for the given texture name.
This file defines struct holding all vulkan data, like device, surface, swapchain,...
void VEX_EXPORT log(const char *fmt,...)
Logs a formatted message.
Scene lights uniform buffer object.
Scene uniform buffer object. Holds data that is bind once per scene.
Struct holding all vulkan data, like device, surface, swapchain, images, views, and more.
Represents an RGBA color value. Used mainly for fancy rendering in editor.