PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
PixelBullet::Image Class Reference

A representation of a Vulkan image, sampler, and view. More...

#include <Image.hpp>

Inheritance diagram for PixelBullet::Image:
PixelBullet::Descriptor PixelBullet::Image2D PixelBullet::Image2DArray PixelBullet::ImageCube PixelBullet::ImageDepth

Public Member Functions

 Image (VkFilter filter, VkSamplerAddressMode addressMode, VkSampleCountFlagBits samples, VkImageLayout layout, VkImageUsageFlags usage, VkFormat format, uint32_t mipLevels, uint32_t arrayLayers, const VkExtent3D &extent)
 
WriteDescriptorSet GetWriteDescriptor (uint32_t binding, VkDescriptorType descriptorType, const std::optional< OffsetSize > &offsetSize) const override
 
std::unique_ptr< BitmapGetBitmap (uint32_t mipLevel=0, uint32_t arrayLayer=0) const
 
const VkExtent3D & GetExtent () const
 
glm::uvec2 GetSize () const
 
VkFormat GetFormat () const
 
VkSampleCountFlagBits GetSamples () const
 
VkImageUsageFlags GetUsage () const
 
uint32_t GetMipLevels () const
 
uint32_t GetArrayLevels () const
 
VkFilter GetFilter () const
 
VkSamplerAddressMode GetAddressMode () const
 
VkImageLayout GetLayout () const
 
const VkImage & GetImage ()
 
const VkDeviceMemory & GetMemory ()
 
const VkSampler & GetSampler () const
 
const VkImageView & GetView () const
 
- Public Member Functions inherited from PixelBullet::Descriptor

Static Public Member Functions

static VkDescriptorSetLayoutBinding GetDescriptorSetLayout (uint32_t binding, VkDescriptorType descriptorType, VkShaderStageFlags stage, uint32_t count)
 
static uint32_t GetMipLevels (const VkExtent3D &extent)
 
static VkFormat FindSupportedFormat (const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features)
 
static bool HasDepth (VkFormat format)
 
static bool HasStencil (VkFormat format)
 
static void CreateImage (VkImage &image, VkDeviceMemory &memory, const VkExtent3D &extent, VkFormat format, VkSampleCountFlagBits samples, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, uint32_t mipLevels, uint32_t arrayLayers, VkImageType type)
 
static void CreateImageSampler (VkSampler &sampler, VkFilter filter, VkSamplerAddressMode addressMode, bool anisotropic, uint32_t mipLevels)
 
static void CreateImageView (const VkImage &image, VkImageView &imageView, VkImageViewType type, VkFormat format, VkImageAspectFlags imageAspect, uint32_t mipLevels, uint32_t baseMipLevel, uint32_t layerCount, uint32_t baseArrayLayer)
 
static void CreateMipmaps (const VkImage &image, const VkExtent3D &extent, VkFormat format, VkImageLayout dstImageLayout, uint32_t mipLevels, uint32_t baseArrayLayer, uint32_t layerCount)
 
static void TransitionImageLayout (const VkImage &image, VkFormat format, VkImageLayout srcImageLayout, VkImageLayout dstImageLayout, VkImageAspectFlags imageAspect, uint32_t mipLevels, uint32_t baseMipLevel, uint32_t layerCount, uint32_t baseArrayLayer)
 
static void InsertImageMemoryBarrier (const CommandBuffer &commandBuffer, const VkImage &image, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageAspectFlags imageAspect, uint32_t mipLevels, uint32_t baseMipLevel, uint32_t layerCount, uint32_t baseArrayLayer)
 
static void CopyBufferToImage (const VkBuffer &buffer, const VkImage &image, const VkExtent3D &extent, uint32_t layerCount, uint32_t baseArrayLayer)
 
static bool CopyImage (const VkImage &srcImage, VkImage &dstImage, VkDeviceMemory &dstImageMemory, VkFormat srcFormat, const VkExtent3D &extent, VkImageLayout srcImageLayout, uint32_t mipLevel, uint32_t arrayLayer)
 

Protected Attributes

VkExtent3D m_Extent
 
VkSampleCountFlagBits m_Samples
 
VkImageUsageFlags m_Usage
 
VkFormat m_Format = VK_FORMAT_UNDEFINED
 
uint32_t m_MIPLevels = 0
 
uint32_t m_ArrayLayers
 
VkFilter m_Filter
 
VkSamplerAddressMode m_AddressMode
 
VkImageLayout m_Layout
 
VkImage m_Image = VK_NULL_HANDLE
 
VkDeviceMemory m_Memory = VK_NULL_HANDLE
 
VkSampler m_Sampler = VK_NULL_HANDLE
 
VkImageView m_View = VK_NULL_HANDLE
 

Detailed Description

A representation of a Vulkan image, sampler, and view.

Constructor & Destructor Documentation

◆ Image()

PixelBullet::Image::Image ( VkFilter filter,
VkSamplerAddressMode addressMode,
VkSampleCountFlagBits samples,
VkImageLayout layout,
VkImageUsageFlags usage,
VkFormat format,
uint32_t mipLevels,
uint32_t arrayLayers,
const VkExtent3D & extent )

Creates a new image object.

Parameters
filterThe magnification/minification filter to apply to lookups.
addressModeThe addressing mode for outside [0..1] range.
samplesThe number of samples per texel.
layoutThe layout that the image subresources accessible from.
usageThe intended usage of the image.
formatThe format and type of the texel blocks that will be contained in the image.
mipLevelsThe number of levels of detail available for minified sampling of the image.
arrayLayersThe number of layers in the image.
extentThe number of data elements in each dimension of the base level.

Member Function Documentation

◆ FindSupportedFormat()

VkFormat PixelBullet::Image::FindSupportedFormat ( const std::vector< VkFormat > & candidates,
VkImageTiling tiling,
VkFormatFeatureFlags features )
static

Find a format in the candidates list that fits the tiling and features required.

Parameters
candidatesFormats that are tested for features, in order of preference.
tilingTiling mode to test features in.
featuresThe features to test for.
Returns
The format found, or VK_FORMAT_UNDEFINED.

◆ GetBitmap()

std::unique_ptr< Bitmap > PixelBullet::Image::GetBitmap ( uint32_t mipLevel = 0,
uint32_t arrayLayer = 0 ) const

Copies the images pixels from memory to a bitmap. If this method is called from multiple threads at the same time Vulkan will crash!

Parameters
mipLevelThe mipmap level index to sample.
arrayLayerThe array level to sample.
Returns
A copy of the images pixels.

◆ GetWriteDescriptor()

WriteDescriptorSet PixelBullet::Image::GetWriteDescriptor ( uint32_t binding,
VkDescriptorType descriptorType,
const std::optional< OffsetSize > & offsetSize ) const
overridevirtual

◆ HasDepth()

bool PixelBullet::Image::HasDepth ( VkFormat format)
static

Gets if a format has a depth component.

Parameters
formatThe format to check.
Returns
If the format has a depth component.

◆ HasStencil()

bool PixelBullet::Image::HasStencil ( VkFormat format)
static

Gets if a format has a depth component.

Parameters
formatThe format to check.
Returns
If the format has a depth component.

The documentation for this class was generated from the following files: