Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Assets::RuntimeTexture Class Reference

#include <Texture.h>

Collaboration diagram for Engine::Assets::RuntimeTexture:

Public Member Functions

 RuntimeTexture ()=default
void setupImageFormat (const tinygltf::Image &imageData)
 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
 RuntimeTexture (const RuntimeTexture &)=delete
RuntimeTextureoperator= (const RuntimeTexture &)=delete
 RuntimeTexture (RuntimeTexture &&other) noexcept
RuntimeTextureoperator= (RuntimeTexture &&other) noexcept
VkImage getVkImage () const
VkDeviceMemory getVkImageMemory () const
VkImageView getVkImageView () const
VkSampler getVkImageSampler () const
bool isDescriptorIndexInitialized () const
uint32_t getDescriptorIndex () const
void createDataUploadCommand (VkCommandBuffer commandBuffer, Rendering::Renderer *renderer) const
VkFormat getTextureFormat () const
TextureType getTextureType () const
 Get the semantic texture type.
uint32_t getMipLevels () const
uint32_t getSourceMipLevels () const
uint32_t getSourceBaseMip () const
uint32_t getSourceWidth () const
uint32_t getSourceHeight () const
bool hasPrecomputedMipmaps () const
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)

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::Ktx2TextureDataktx2Data_
Core::ApplicationContextcontext = nullptr

Detailed Description

Definition at line 25 of file Texture.h.

Constructor & Destructor Documentation

◆ RuntimeTexture() [1/6]

Engine::Assets::RuntimeTexture::RuntimeTexture ( )
default

Referenced by operator=(), operator=(), RuntimeTexture(), and RuntimeTexture().

Here is the caller graph for this function:

◆ RuntimeTexture() [2/6]

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:

  • BaseColor/Emissive use SRGB formats for gamma-correct rendering
  • Normal/MetallicRoughness use LINEAR formats for correct data interpretation
  • Lightmap uses floating-point formats for HDR data
Parameters
imageDataThe image data from tinygltf
typeThe semantic texture type (determines VkFormat)
contextThe application context for Vulkan operations

References context, and imageData.

◆ RuntimeTexture() [3/6]

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.

Parameters
ktx2DataThe loaded KTX2 texture data including all mip levels
typeThe semantic texture type
contextThe application context for Vulkan operations

References context.

◆ RuntimeTexture() [4/6]

Engine::Assets::RuntimeTexture::RuntimeTexture ( const tinygltf::Image & imageData,
Core::ApplicationContext * context )

Construct a texture with default type (BaseColor/SRGB)

Deprecated
Use the constructor with explicit TextureType for correct format selection. This constructor defaults to SRGB which is incorrect for normal maps and other linear data textures.

References context, and imageData.

◆ ~RuntimeTexture()

Engine::Assets::RuntimeTexture::~RuntimeTexture ( )
default

◆ RuntimeTexture() [5/6]

Engine::Assets::RuntimeTexture::RuntimeTexture ( const RuntimeTexture & )
delete

References RuntimeTexture().

Here is the call graph for this function:

◆ RuntimeTexture() [6/6]

Engine::Assets::RuntimeTexture::RuntimeTexture ( RuntimeTexture && other)
noexcept

References RuntimeTexture().

Here is the call graph for this function:

Member Function Documentation

◆ addPaddingHelper()

template<typename T>
void Engine::Assets::RuntimeTexture::addPaddingHelper ( )
private

Definition at line 195 of file Texture.h.

References imageData.

◆ addPaddingToImage()

void Engine::Assets::RuntimeTexture::addPaddingToImage ( )
private

◆ calculateMipLevels()

uint32_t Engine::Assets::RuntimeTexture::calculateMipLevels ( uint32_t width,
uint32_t height )
static

◆ cleanup()

void Engine::Assets::RuntimeTexture::cleanup ( ) const
private

◆ createDataUploadCommand()

void Engine::Assets::RuntimeTexture::createDataUploadCommand ( VkCommandBuffer commandBuffer,
Rendering::Renderer * renderer ) const

◆ createResources()

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.

◆ dilateLightmapImage()

void Engine::Assets::RuntimeTexture::dilateLightmapImage ( )
private

◆ discardPreparedResources()

void Engine::Assets::RuntimeTexture::discardPreparedResources ( )

Destroy Vulkan resources without registering the texture.

Used when async preparation completes after the owning scene has been unloaded.

◆ generateMipmaps()

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.

Parameters
commandBufferThe graphics command buffer to record blit commands into
Author
Konstantin Passig
Date
2026-02-12

◆ getDescriptorIndex()

uint32_t Engine::Assets::RuntimeTexture::getDescriptorIndex ( ) const
nodiscard

◆ getMipLevels()

uint32_t Engine::Assets::RuntimeTexture::getMipLevels ( ) const
inlinenodiscard

Definition at line 102 of file Texture.h.

References mipLevels_.

◆ getSourceBaseMip()

uint32_t Engine::Assets::RuntimeTexture::getSourceBaseMip ( ) const
inlinenodiscard

Definition at line 112 of file Texture.h.

References sourceBaseMip_.

◆ getSourceHeight()

uint32_t Engine::Assets::RuntimeTexture::getSourceHeight ( ) const
inlinenodiscard

Definition at line 122 of file Texture.h.

References sourceHeight_.

◆ getSourceMipLevels()

uint32_t Engine::Assets::RuntimeTexture::getSourceMipLevels ( ) const
inlinenodiscard

Definition at line 107 of file Texture.h.

References sourceMipLevels_.

◆ getSourceWidth()

uint32_t Engine::Assets::RuntimeTexture::getSourceWidth ( ) const
inlinenodiscard

Definition at line 117 of file Texture.h.

References sourceWidth_.

◆ getTextureFormat()

VkFormat Engine::Assets::RuntimeTexture::getTextureFormat ( ) const
nodiscard

◆ getTextureType()

TextureType Engine::Assets::RuntimeTexture::getTextureType ( ) const
inlinenodiscard

Get the semantic texture type.

Returns
The TextureType used to determine the VkFormat

Definition at line 97 of file Texture.h.

References textureType_.

◆ getVkImage()

VkImage Engine::Assets::RuntimeTexture::getVkImage ( ) const
nodiscard

◆ getVkImageMemory()

VkDeviceMemory Engine::Assets::RuntimeTexture::getVkImageMemory ( ) const
nodiscard

◆ getVkImageSampler()

VkSampler Engine::Assets::RuntimeTexture::getVkImageSampler ( ) const
nodiscard

◆ getVkImageView()

VkImageView Engine::Assets::RuntimeTexture::getVkImageView ( ) const
nodiscard

◆ hasPrecomputedMipmaps()

bool Engine::Assets::RuntimeTexture::hasPrecomputedMipmaps ( ) const
inlinenodiscard

Definition at line 127 of file Texture.h.

References hasPrecomputedMipmaps_.

◆ isDescriptorIndexInitialized()

bool Engine::Assets::RuntimeTexture::isDescriptorIndexInitialized ( ) const
nodiscard

◆ operator=() [1/2]

RuntimeTexture & Engine::Assets::RuntimeTexture::operator= ( const RuntimeTexture & )
delete

References RuntimeTexture().

Here is the call graph for this function:

◆ operator=() [2/2]

RuntimeTexture & Engine::Assets::RuntimeTexture::operator= ( RuntimeTexture && other)
noexcept

References RuntimeTexture().

Here is the call graph for this function:

◆ reset()

void Engine::Assets::RuntimeTexture::reset ( )
private

◆ setDebugName()

void Engine::Assets::RuntimeTexture::setDebugName ( const std::string & debugName) const
private

◆ setupImageFormat()

void Engine::Assets::RuntimeTexture::setupImageFormat ( const tinygltf::Image & imageData)

References imageData.

Member Data Documentation

◆ context

Core::ApplicationContext* Engine::Assets::RuntimeTexture::context = nullptr
private

Definition at line 191 of file Texture.h.

Referenced by RuntimeTexture(), RuntimeTexture(), and RuntimeTexture().

◆ descriptorIndex

uint32_t Engine::Assets::RuntimeTexture::descriptorIndex = std::numeric_limits<uint32_t>::max()
private

Definition at line 178 of file Texture.h.

◆ format

VkFormat Engine::Assets::RuntimeTexture::format = VK_FORMAT_R8G8B8A8_SRGB
private

Definition at line 180 of file Texture.h.

◆ hasPrecomputedMipmaps_

bool Engine::Assets::RuntimeTexture::hasPrecomputedMipmaps_ = false
private

Definition at line 187 of file Texture.h.

Referenced by hasPrecomputedMipmaps().

◆ imageData

tinygltf::Image Engine::Assets::RuntimeTexture::imageData
private

Definition at line 189 of file Texture.h.

Referenced by addPaddingHelper(), RuntimeTexture(), RuntimeTexture(), and setupImageFormat().

◆ ktx2Data_

std::optional<Textures::Ktx2TextureData> Engine::Assets::RuntimeTexture::ktx2Data_
private

Definition at line 190 of file Texture.h.

◆ mipLevels_

uint32_t Engine::Assets::RuntimeTexture::mipLevels_ = 1
private

Definition at line 182 of file Texture.h.

Referenced by getMipLevels().

◆ sourceBaseMip_

uint32_t Engine::Assets::RuntimeTexture::sourceBaseMip_ = 0
private

Definition at line 184 of file Texture.h.

Referenced by getSourceBaseMip().

◆ sourceHeight_

uint32_t Engine::Assets::RuntimeTexture::sourceHeight_ = 1
private

Definition at line 186 of file Texture.h.

Referenced by getSourceHeight().

◆ sourceMipLevels_

uint32_t Engine::Assets::RuntimeTexture::sourceMipLevels_ = 1
private

Definition at line 183 of file Texture.h.

Referenced by getSourceMipLevels().

◆ sourceWidth_

uint32_t Engine::Assets::RuntimeTexture::sourceWidth_ = 1
private

Definition at line 185 of file Texture.h.

Referenced by getSourceWidth().

◆ textureAllocation_

VmaAllocation Engine::Assets::RuntimeTexture::textureAllocation_ = VK_NULL_HANDLE
private

VMA allocation for texture memory.

Definition at line 174 of file Texture.h.

◆ textureType_

TextureType Engine::Assets::RuntimeTexture::textureType_ = TextureType::BaseColor
private

Definition at line 181 of file Texture.h.

Referenced by getTextureType().

◆ vkTexture

VkImage Engine::Assets::RuntimeTexture::vkTexture {}
private

Definition at line 173 of file Texture.h.

◆ vkTextureSampler

VkSampler Engine::Assets::RuntimeTexture::vkTextureSampler {}
private

Definition at line 176 of file Texture.h.

◆ vkTextureView

VkImageView Engine::Assets::RuntimeTexture::vkTextureView {}
private

Definition at line 175 of file Texture.h.


The documentation for this class was generated from the following file:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Texture/Texture.h