|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
Runtime-owned Vulkan texture resource. More...
#include <Texture.h>
Public Member Functions | |
| RuntimeTexture ()=default | |
| Creates an empty texture with no image data or Vulkan resources. | |
| void | setupImageFormat (const tinygltf::Image &imageData) |
| Selects a Vulkan format from tinygltf image bit depth and component count. | |
| RuntimeTexture (const tinygltf::Image &imageData, TextureType type, Core::ApplicationContext *context) | |
| Construct a texture with explicit type for correct format selection. | |
| RuntimeTexture (Textures::Ktx2TextureData ktx2Data, TextureType type, Core::ApplicationContext *context) | |
| Construct a texture from KTX2 data with pre-computed mipmaps. | |
| RuntimeTexture (const tinygltf::Image &imageData, Core::ApplicationContext *context) | |
| Construct a texture with default type (BaseColor/SRGB) | |
| ~RuntimeTexture ()=default | |
| Destroys the C++ object without automatically releasing Vulkan resources. | |
| RuntimeTexture (const RuntimeTexture &)=delete | |
| Runtime textures are move-only because they own Vulkan handles. | |
| RuntimeTexture & | operator= (const RuntimeTexture &)=delete |
| Runtime textures are move-only because they own Vulkan handles. | |
| RuntimeTexture (RuntimeTexture &&other) noexcept | |
| Move-constructs a texture and transfers Vulkan handles and prepared upload data. | |
| RuntimeTexture & | operator= (RuntimeTexture &&other) noexcept |
| Move-assigns a texture and transfers Vulkan handles and prepared upload data. | |
| VkImage | getVkImage () const |
| Gets the Vulkan image handle. | |
| VkDeviceMemory | getVkImageMemory () const |
| Gets the device memory backing the VMA image allocation. | |
| VkImageView | getVkImageView () const |
| Gets the Vulkan image view used for sampling. | |
| VkSampler | getVkImageSampler () const |
| Gets the sampler used for shader reads. | |
| bool | isDescriptorIndexInitialized () const |
| Checks whether this texture has a descriptor array slot. | |
| uint32_t | getDescriptorIndex () const |
| Gets the descriptor array slot assigned by the asset manager. | |
| void | createDataUploadCommand (VkCommandBuffer commandBuffer, Rendering::Renderer *renderer) const |
| Records commands that upload prepared image data into the Vulkan texture. | |
| VkFormat | getTextureFormat () const |
| Gets the Vulkan image format selected for this texture. | |
| TextureType | getTextureType () const |
| Get the semantic texture type. | |
| uint32_t | getMipLevels () const |
| Gets the number of mip levels in the Vulkan image. | |
| uint32_t | getSourceMipLevels () const |
| Gets the number of mip levels present in the source texture data. | |
| uint32_t | getSourceBaseMip () const |
| Gets the base mip represented by the source texture data. | |
| uint32_t | getSourceWidth () const |
| Gets the original source texture width. | |
| uint32_t | getSourceHeight () const |
| Gets the original source texture height. | |
| bool | hasPrecomputedMipmaps () const |
| Checks whether source data already contains mipmaps. | |
| void | generateMipmaps (VkCommandBuffer commandBuffer) const |
| Generate mipmaps for this texture using vkCmdBlitImage. | |
| void | createResources () |
| Create Vulkan resources (VkImage, VkImageView, VkSampler) for this texture. Safe to call from worker threads when VMA is configured for thread safety. | |
| void | discardPreparedResources () |
| Destroy Vulkan resources without registering the texture. | |
Static Public Member Functions | |
| static uint32_t | calculateMipLevels (uint32_t width, uint32_t height) |
| Calculates the full mip chain length for a texture size. | |
Private Member Functions | |
| void | addPaddingToImage () |
| void | dilateLightmapImage () |
| template<typename T> | |
| void | addPaddingHelper () |
| void | setDebugName (const std::string &debugName) const |
| void | cleanup () const |
| void | reset () |
Private Attributes | |
| VkImage | vkTexture {} |
| VmaAllocation | textureAllocation_ = VK_NULL_HANDLE |
| VMA allocation for texture memory. | |
| VkImageView | vkTextureView {} |
| VkSampler | vkTextureSampler {} |
| uint32_t | descriptorIndex = std::numeric_limits<uint32_t>::max() |
| VkFormat | format = VK_FORMAT_R8G8B8A8_SRGB |
| TextureType | textureType_ = TextureType::BaseColor |
| uint32_t | mipLevels_ = 1 |
| uint32_t | sourceMipLevels_ = 1 |
| uint32_t | sourceBaseMip_ = 0 |
| uint32_t | sourceWidth_ = 1 |
| uint32_t | sourceHeight_ = 1 |
| bool | hasPrecomputedMipmaps_ = false |
| tinygltf::Image | imageData |
| std::optional< Textures::Ktx2TextureData > | ktx2Data_ |
| Core::ApplicationContext * | context = nullptr |
Runtime-owned Vulkan texture resource.
RuntimeTexture stores decoded image data or prepared KTX2 data, creates the Vulkan image, image view, and sampler, and records upload commands for the renderer. It owns the image and VMA allocation. Samplers are shared through the application sampler cache.
|
default |
Creates an empty texture with no image data or Vulkan resources.
Referenced by operator=(), operator=(), RuntimeTexture(), and RuntimeTexture().
| Engine::Assets::RuntimeTexture::RuntimeTexture | ( | const tinygltf::Image & | imageData, |
| TextureType | type, | ||
| Core::ApplicationContext * | context ) |
Construct a texture with explicit type for correct format selection.
This constructor uses the TextureType to determine the correct VkFormat:
| imageData | The image data from tinygltf |
| type | The semantic texture type (determines VkFormat) |
| context | The application context for Vulkan operations |
| Engine::Assets::RuntimeTexture::RuntimeTexture | ( | Textures::Ktx2TextureData | ktx2Data, |
| TextureType | type, | ||
| Core::ApplicationContext * | context ) |
Construct a texture from KTX2 data with pre-computed mipmaps.
Used for BC6H-compressed lightmaps loaded from KTX2 files. Skips dilation and padding since data is already compressed.
| ktx2Data | The loaded KTX2 texture data including all mip levels |
| type | The semantic texture type |
| context | The application context for Vulkan operations |
References context.
| Engine::Assets::RuntimeTexture::RuntimeTexture | ( | const tinygltf::Image & | imageData, |
| Core::ApplicationContext * | context ) |
Construct a texture with default type (BaseColor/SRGB)
|
default |
Destroys the C++ object without automatically releasing Vulkan resources.
RuntimeTexture resources are released explicitly by AssetManager paths through reset(), discardPreparedResources(), or move assignment cleanup.
|
delete |
Runtime textures are move-only because they own Vulkan handles.
References RuntimeTexture().
|
noexcept |
Move-constructs a texture and transfers Vulkan handles and prepared upload data.
| other | Texture to move from. |
References RuntimeTexture().
|
private |
|
private |
|
static |
|
private |
| void Engine::Assets::RuntimeTexture::createDataUploadCommand | ( | VkCommandBuffer | commandBuffer, |
| Rendering::Renderer * | renderer ) const |
Records commands that upload prepared image data into the Vulkan texture.
For KTX2 textures this uploads all precomputed mip levels. For regular images this uploads the base level and schedules generated mipmaps when needed.
| commandBuffer | Command buffer to record transfer commands into. |
| renderer | Renderer that owns temporary staging buffer cleanup for the current frame. |
| void Engine::Assets::RuntimeTexture::createResources | ( | ) |
Create Vulkan resources (VkImage, VkImageView, VkSampler) for this texture. Safe to call from worker threads when VMA is configured for thread safety.
|
private |
| void Engine::Assets::RuntimeTexture::discardPreparedResources | ( | ) |
Destroy Vulkan resources without registering the texture.
Used when async preparation completes after the owning scene has been unloaded.
| void Engine::Assets::RuntimeTexture::generateMipmaps | ( | VkCommandBuffer | commandBuffer | ) | const |
Generate mipmaps for this texture using vkCmdBlitImage.
Must be called after the base mip level has been uploaded. All mip levels must be in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL before calling. After calling, mip levels 0..N-2 are in TRANSFER_SRC_OPTIMAL and mip level N-1 is in TRANSFER_DST_OPTIMAL.
| commandBuffer | The graphics command buffer to record blit commands into |
|
nodiscard |
Gets the descriptor array slot assigned by the asset manager.
|
inlinenodiscard |
Gets the number of mip levels in the Vulkan image.
Definition at line 184 of file Texture.h.
References mipLevels_.
|
inlinenodiscard |
Gets the base mip represented by the source texture data.
Definition at line 202 of file Texture.h.
References sourceBaseMip_.
|
inlinenodiscard |
Gets the original source texture height.
Definition at line 220 of file Texture.h.
References sourceHeight_.
|
inlinenodiscard |
Gets the number of mip levels present in the source texture data.
Definition at line 193 of file Texture.h.
References sourceMipLevels_.
|
inlinenodiscard |
Gets the original source texture width.
Definition at line 211 of file Texture.h.
References sourceWidth_.
|
nodiscard |
|
inlinenodiscard |
Get the semantic texture type.
Definition at line 175 of file Texture.h.
References textureType_.
|
nodiscard |
Gets the Vulkan image handle.
|
nodiscard |
Gets the device memory backing the VMA image allocation.
|
nodiscard |
Gets the sampler used for shader reads.
|
nodiscard |
Gets the Vulkan image view used for sampling.
|
inlinenodiscard |
Checks whether source data already contains mipmaps.
Definition at line 229 of file Texture.h.
References hasPrecomputedMipmaps_.
|
nodiscard |
Checks whether this texture has a descriptor array slot.
|
delete |
Runtime textures are move-only because they own Vulkan handles.
References RuntimeTexture().
|
noexcept |
Move-assigns a texture and transfers Vulkan handles and prepared upload data.
| other | Texture to move from. |
References RuntimeTexture().
|
private |
|
private |
| void Engine::Assets::RuntimeTexture::setupImageFormat | ( | const tinygltf::Image & | imageData | ) |
|
private |
Definition at line 299 of file Texture.h.
Referenced by RuntimeTexture(), RuntimeTexture(), and RuntimeTexture().
|
private |
|
private |
|
private |
Definition at line 295 of file Texture.h.
Referenced by hasPrecomputedMipmaps().
|
private |
Definition at line 297 of file Texture.h.
Referenced by addPaddingHelper(), RuntimeTexture(), RuntimeTexture(), and setupImageFormat().
|
private |
|
private |
Definition at line 290 of file Texture.h.
Referenced by getMipLevels().
|
private |
Definition at line 292 of file Texture.h.
Referenced by getSourceBaseMip().
|
private |
Definition at line 294 of file Texture.h.
Referenced by getSourceHeight().
|
private |
Definition at line 291 of file Texture.h.
Referenced by getSourceMipLevels().
|
private |
Definition at line 293 of file Texture.h.
Referenced by getSourceWidth().
|
private |
|
private |
Definition at line 289 of file Texture.h.
Referenced by getTextureType().
|
private |
|
private |
|
private |