10#include <utility/graphic/texture.hpp>
12#include "utility/logging/logger.hpp"
13#include "utility/logging/default_logger.hpp"
15#include "EvanPlatform.hpp"
17#include "DeviceContext.hpp"
45 protected utility::logging::Loggable<GPUTexture,
46 utility::logging::DefaultLogger>
222 const utility::graphic::Texture &texture,
290 VkImageView
view = VK_NULL_HANDLE;
343 const utility::graphic::Texture &texture,
344 VkCommandPool commandPool, VkQueue graphicsQueue);
385 VkSamplerCreateInfo samplerInfo,
487 void applySamplerSettings(VkSamplerCreateInfo &samplerInfo,
491 getDefaultSamplerInfo(
const VkPhysicalDeviceProperties &properties);
Abstract base class for Vulkan device backends.
static uint32_t computeMipLevels(uint32_t width, uint32_t height)
Computes the number of mipmap levels for a texture of the given dimensions.
void destroy(VkDevice device)
Destroys the Vulkan resources associated with this GPUTexture, including the image,...
~GPUTexture()
Destructs the GPUTexture object by cleaning up Vulkan resources such as the image,...
TextureType type
The type of texture represented by this GPUTexture instance, such as albedo, normal,...
void createSampler(const ADeviceBackend &deviceBackend, VkSamplerCreateInfo samplerInfo, const SamplerSettings &settings=SamplerSettings {})
Creates a Vulkan sampler for the Vulkan image associated with this GPUTexture, defining how the textu...
void createImage(const ADeviceBackend &deviceBackend, const utility::graphic::Texture &texture, VkCommandPool commandPool, VkQueue graphicsQueue)
Creates a Vulkan image based on the provided texture data and type, and allocates memory for it.
VkSampler sampler
The Vulkan sampler associated with this GPUTexture, which defines how the texture is sampled in shade...
uint32_t _mipLevel
The number of mipmap levels generated for the Vulkan image associated with this GPUTexture,...
void cleanup()
Releases every Vulkan resource owned by this texture.
VkImage _image
The Vulkan image associated with this GPUTexture, which holds the texture data in GPU memory for use ...
TextureType
Enum class representing different types of textures that can be associated with a material,...
uint32_t getMipLevels() const
Retrieves the number of mipmap levels generated for this texture.
std::shared_ptr< DeviceContext > _deviceContext
The device context used to create this texture, kept alive for the lifetime of the texture so that cl...
GPUTexture(std::shared_ptr< DeviceContext > deviceContext, const utility::graphic::Texture &texture, TextureType type=TextureType::Albedo, const SamplerSettings &settings=SamplerSettings {})
Constructs a GPUTexture object by creating a Vulkan image, image view, and sampler based on the provi...
VkImageView view
The Vulkan image view associated with this GPUTexture.
VkDeviceMemory _memory
The Vulkan device memory allocated for the image associated with this GPUTexture, which is used to st...
void createImageView(const ADeviceBackend &deviceBackend)
Creates a Vulkan image view for the Vulkan image associated with this GPUTexture, allowing shader acc...
static float computeMaxLod(uint32_t mipLevels)
Computes the maximum sampleable LOD for a texture with the given number of mipmap levels.
Holds properties required for generating mipmaps for a Vulkan image.
uint32_t _texHeight
The height of the Vulkan image in pixels.
uint32_t _texWidth
The width of the Vulkan image in pixels.
VkCommandPool _commandPool
Consumer-overridable sampler parameters.
VkSamplerAddressMode addressModeW
Addressing mode for the W (depth) axis.
float maxLod
Maximum LOD that can be sampled.
VkSamplerAddressMode addressModeU
Addressing mode for the U (width) axis.
float maxAnisotropy
Maximum anisotropy value.
VkSamplerAddressMode addressModeV
Addressing mode for the V (height) axis.
SamplerSettings()
Constructs sampler settings with the default values.
VkBool32 anisotropyEnable
Whether anisotropic filtering is enabled.
float minLod
Minimum LOD that can be sampled.