Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::Texture Class Reference

#include <Texture.h>

Collaboration diagram for EngineCore::Texture:

Public Member Functions

 Texture ()=default
void setupImageFormat (const tinygltf::Image &imageData)
 Texture (const tinygltf::Image &imageData, TextureType type, ApplicationContext *context)
 Construct a texture with explicit type for correct format selection.
 Texture (const tinygltf::Image &imageData, ApplicationContext *context)
 Construct a texture with default type (BaseColor/SRGB)
 ~Texture ()
 Texture (const Texture &)=delete
Textureoperator= (const Texture &)=delete
 Texture (Texture &&other) noexcept
Textureoperator= (Texture &&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, Renderer *renderer) const
VkFormat getTextureFormat () const
TextureType getTextureType () const
 Get the semantic texture type.

Static Public Member Functions

static std::string createTexturePath (const std::filesystem::path &assetPath, const GltfLoader::GltfMeshPrimitiveData &primitiveData)

Public Attributes

friend AssetManager

Private Member Functions

void addPaddingToImage ()
template<typename T>
void addPaddingHelper ()
void setDebugName (const std::string &debugName)
void createResources ()
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
tinygltf::Image imageData
ApplicationContextcontext = nullptr

Detailed Description

Definition at line 20 of file Texture.h.

Constructor & Destructor Documentation

◆ Texture() [1/5]

EngineCore::Texture::Texture ( )
default

References context, and imageData.

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

Here is the caller graph for this function:

◆ Texture() [2/5]

EngineCore::Texture::Texture ( const tinygltf::Image & imageData,
TextureType type,
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
Author
Konstantin Passig
Date
2026-01-22

Definition at line 44 of file Texture.cpp.

References addPaddingToImage(), context, format, EngineCore::getVkFormat(), imageData, and textureType_.

Here is the call graph for this function:

◆ Texture() [3/5]

EngineCore::Texture::Texture ( const tinygltf::Image & imageData,
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.

Definition at line 56 of file Texture.cpp.

References addPaddingToImage(), EngineCore::BaseColor, context, imageData, setupImageFormat(), and textureType_.

Here is the call graph for this function:

◆ ~Texture()

EngineCore::Texture::~Texture ( )

Definition at line 218 of file Texture.cpp.

◆ Texture() [4/5]

EngineCore::Texture::Texture ( const Texture & )
delete

References Texture().

Here is the call graph for this function:

◆ Texture() [5/5]

EngineCore::Texture::Texture ( Texture && other)
noexcept

Definition at line 69 of file Texture.cpp.

References addPaddingToImage(), EngineCore::BaseColor, context, descriptorIndex, format, imageData, Texture(), textureAllocation_, textureType_, vkTexture, vkTextureSampler, and vkTextureView.

Here is the call graph for this function:

Member Function Documentation

◆ addPaddingHelper()

template<typename T>
void EngineCore::Texture::addPaddingHelper ( )
private

Definition at line 109 of file Texture.h.

References imageData.

Referenced by addPaddingToImage().

Here is the caller graph for this function:

◆ addPaddingToImage()

void EngineCore::Texture::addPaddingToImage ( )
private

Definition at line 388 of file Texture.cpp.

References addPaddingHelper(), and imageData.

Referenced by Texture(), Texture(), and Texture().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

void EngineCore::Texture::cleanup ( ) const
private

Definition at line 227 of file Texture.cpp.

References context, textureAllocation_, vkTexture, vkTextureSampler, and vkTextureView.

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

Here is the caller graph for this function:

◆ createDataUploadCommand()

void EngineCore::Texture::createDataUploadCommand ( VkCommandBuffer commandBuffer,
Renderer * renderer ) const

◆ createResources()

void EngineCore::Texture::createResources ( )
private

Definition at line 127 of file Texture.cpp.

References context, format, imageData, setDebugName(), textureAllocation_, TRACY_ZONE_SCOPED_FUNCTION, vkTexture, vkTextureSampler, and vkTextureView.

Referenced by EngineCore::AssetManager::registerTexture().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createTexturePath()

std::string EngineCore::Texture::createTexturePath ( const std::filesystem::path & assetPath,
const GltfLoader::GltfMeshPrimitiveData & primitiveData )
static

Definition at line 219 of file Texture.cpp.

References EngineCore::GltfLoader::GltfTextureData::getImage(), EngineCore::GltfLoader::GltfMeshPrimitiveData::getMaterialData(), and EngineCore::GltfLoader::GltfMaterialData::getTextureData().

Here is the call graph for this function:

◆ getDescriptorIndex()

uint32_t EngineCore::Texture::getDescriptorIndex ( ) const
nodiscard

Definition at line 278 of file Texture.cpp.

References descriptorIndex.

Referenced by EngineCore::RenderingDataManager::onTextureLoaded().

Here is the caller graph for this function:

◆ getTextureFormat()

VkFormat EngineCore::Texture::getTextureFormat ( ) const
nodiscard

Definition at line 383 of file Texture.cpp.

References format.

◆ getTextureType()

TextureType EngineCore::Texture::getTextureType ( ) const
inlinenodiscard

Get the semantic texture type.

Returns
The TextureType used to determine the VkFormat

Definition at line 82 of file Texture.h.

References textureType_.

◆ getVkImage()

VkImage EngineCore::Texture::getVkImage ( ) const
nodiscard

Definition at line 249 of file Texture.cpp.

References vkTexture.

Referenced by EngineCore::Material::operator==().

Here is the caller graph for this function:

◆ getVkImageMemory()

VkDeviceMemory EngineCore::Texture::getVkImageMemory ( ) const
nodiscard

Definition at line 254 of file Texture.cpp.

References context, and textureAllocation_.

◆ getVkImageSampler()

VkSampler EngineCore::Texture::getVkImageSampler ( ) const
nodiscard

Definition at line 270 of file Texture.cpp.

References vkTextureSampler.

◆ getVkImageView()

VkImageView EngineCore::Texture::getVkImageView ( ) const
nodiscard

Definition at line 265 of file Texture.cpp.

References vkTextureView.

◆ isDescriptorIndexInitialized()

bool EngineCore::Texture::isDescriptorIndexInitialized ( ) const
nodiscard

Definition at line 274 of file Texture.cpp.

References descriptorIndex.

◆ operator=() [1/2]

Texture & EngineCore::Texture::operator= ( const Texture & )
delete

References Texture().

Here is the call graph for this function:

◆ operator=() [2/2]

Texture & EngineCore::Texture::operator= ( Texture && other)
noexcept

Definition at line 95 of file Texture.cpp.

References EngineCore::BaseColor, cleanup(), context, descriptorIndex, format, imageData, Texture(), textureAllocation_, textureType_, vkTexture, vkTextureSampler, and vkTextureView.

Here is the call graph for this function:

◆ reset()

void EngineCore::Texture::reset ( )
private

Definition at line 239 of file Texture.cpp.

References cleanup(), descriptorIndex, textureAllocation_, vkTexture, vkTextureSampler, and vkTextureView.

Here is the call graph for this function:

◆ setDebugName()

void EngineCore::Texture::setDebugName ( const std::string & debugName)
private

Definition at line 207 of file Texture.cpp.

References context, VulkanHelper::setObjectName(), textureAllocation_, vkTexture, vkTextureSampler, and vkTextureView.

Referenced by createResources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setupImageFormat()

void EngineCore::Texture::setupImageFormat ( const tinygltf::Image & imageData)

Definition at line 13 of file Texture.cpp.

References format, and imageData.

Referenced by Texture().

Here is the caller graph for this function:

Member Data Documentation

◆ AssetManager

friend EngineCore::Texture::AssetManager

Definition at line 23 of file Texture.h.

◆ context

ApplicationContext* EngineCore::Texture::context = nullptr
private

◆ descriptorIndex

uint32_t EngineCore::Texture::descriptorIndex = std::numeric_limits<uint32_t>::max()
private

◆ format

VkFormat EngineCore::Texture::format = VK_FORMAT_R8G8B8A8_SRGB
private

◆ imageData

tinygltf::Image EngineCore::Texture::imageData
private

◆ textureAllocation_

VmaAllocation EngineCore::Texture::textureAllocation_ = VK_NULL_HANDLE
private

VMA allocation for texture memory.

Definition at line 95 of file Texture.h.

Referenced by cleanup(), createResources(), getVkImageMemory(), operator=(), reset(), setDebugName(), and Texture().

◆ textureType_

TextureType EngineCore::Texture::textureType_ = TextureType::BaseColor
private

Definition at line 102 of file Texture.h.

Referenced by getTextureType(), operator=(), Texture(), Texture(), and Texture().

◆ vkTexture

VkImage EngineCore::Texture::vkTexture {}
private

◆ vkTextureSampler

VkSampler EngineCore::Texture::vkTextureSampler {}
private

◆ vkTextureView

VkImageView EngineCore::Texture::vkTextureView {}
private

Definition at line 96 of file Texture.h.

Referenced by cleanup(), createResources(), getVkImageView(), operator=(), reset(), setDebugName(), and Texture().


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