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

Resource that represents a 2D image. More...

#include <Image2D.hpp>

Inheritance diagram for PixelBullet::Image2D:
PixelBullet::Image PixelBullet::Resource PixelBullet::Descriptor

Public Member Functions

 Image2D (const VirtualPath &filename, VkFilter filter=VK_FILTER_LINEAR, VkSamplerAddressMode addressMode=VK_SAMPLER_ADDRESS_MODE_REPEAT, bool anisotropic=true, bool mipmap=true, bool load=true)
 
 Image2D (const glm::uvec2 &extent, VkFormat format=VK_FORMAT_R8G8B8A8_UNORM, VkImageLayout layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VkImageUsageFlags usage=VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_STORAGE_BIT, VkFilter filter=VK_FILTER_LINEAR, VkSamplerAddressMode addressMode=VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VkSampleCountFlagBits samples=VK_SAMPLE_COUNT_1_BIT, bool anisotropic=false, bool mipmap=false)
 
 Image2D (std::unique_ptr< Bitmap > &&bitmap, VkFormat format=VK_FORMAT_R8G8B8A8_UNORM, VkImageLayout layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VkImageUsageFlags usage=VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_STORAGE_BIT, VkFilter filter=VK_FILTER_LINEAR, VkSamplerAddressMode addressMode=VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VkSampleCountFlagBits samples=VK_SAMPLE_COUNT_1_BIT, bool anisotropic=false, bool mipmap=false)
 
void SetPixels (const uint8_t *pixels, uint32_t layerCount, uint32_t baseArrayLayer)
 
std::type_index GetTypeIndex () const override
 Returns the type index of the resource.
 
const VirtualPathGetFilename () const
 
bool IsAnisotropic () const
 
bool IsMipmap () const
 
uint32_t GetComponents () const
 
- Public Member Functions inherited from PixelBullet::Image
 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
- Public Member Functions inherited from PixelBullet::Resource

Static Public Member Functions

static std::shared_ptr< Image2DCreate (const Node &node)
 
static std::shared_ptr< Image2DCreate (const VirtualPath &filename, VkFilter filter=VK_FILTER_LINEAR, VkSamplerAddressMode addressMode=VK_SAMPLER_ADDRESS_MODE_REPEAT, bool anisotropic=true, bool mipmap=true)
 
- Static Public Member Functions inherited from PixelBullet::Image
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)
 

Friends

const Nodeoperator>> (const Node &node, Image2D &image)
 
Nodeoperator<< (Node &node, const Image2D &image)
 

Additional Inherited Members

- Protected Attributes inherited from PixelBullet::Image
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

Resource that represents a 2D image.

Constructor & Destructor Documentation

◆ Image2D() [1/3]

PixelBullet::Image2D::Image2D ( const VirtualPath & filename,
VkFilter filter = VK_FILTER_LINEAR,
VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_REPEAT,
bool anisotropic = true,
bool mipmap = true,
bool load = true )
explicit

Creates a new 2D image.

Parameters
filenameThe file to load the image from.
filterThe magnification/minification filter to apply to lookups.
addressModeThe addressing mode for outside [0..1] range.
anisotropicIf anisotropic filtering is enabled.
mipmapIf mipmaps will be generated.
loadIf this resource will be loaded immediately, otherwise Image2d#Load can be called later.

◆ Image2D() [2/3]

PixelBullet::Image2D::Image2D ( const glm::uvec2 & extent,
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM,
VkImageLayout layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
VkImageUsageFlags usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT,
VkFilter filter = VK_FILTER_LINEAR,
VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT,
bool anisotropic = false,
bool mipmap = false )
explicit

Creates a new 2D image.

Parameters
extentThe image's extent in pixels.
formatThe format and type of the texel blocks that will be contained in the image.
layoutThe layout that the image subresources are accessible from.
usageThe intended usage of the image.
filterThe magnification/minification filter to apply to lookups.
addressModeThe addressing mode for outside [0..1] range.
samplesThe number of samples per texel.
anisotropicIf anisotropic filtering is enabled.
mipmapIf mipmaps will be generated.

◆ Image2D() [3/3]

PixelBullet::Image2D::Image2D ( std::unique_ptr< Bitmap > && bitmap,
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM,
VkImageLayout layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
VkImageUsageFlags usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT,
VkFilter filter = VK_FILTER_LINEAR,
VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT,
bool anisotropic = false,
bool mipmap = false )
explicit

Creates a new 2D image.

Parameters
bitmapThe bitmap to load from.
formatThe format and type of the texel blocks that will be contained in the image.
layoutThe layout that the image subresources are accessible from.
usageThe intended usage of the image.
filterThe magnification/minification filter to apply to lookups.
addressModeThe addressing mode for outside [0..1] range.
samplesThe number of samples per texel.
anisotropicIf anisotropic filtering is enabled.
mipmapIf mipmaps will be generated.

Member Function Documentation

◆ Create() [1/2]

std::shared_ptr< Image2D > PixelBullet::Image2D::Create ( const Node & node)
static

Creates a new 2D image, or finds one with the same values.

Parameters
nodeThe node to decode values from.
Returns
The 2D image with the requested values.

◆ Create() [2/2]

std::shared_ptr< Image2D > PixelBullet::Image2D::Create ( const VirtualPath & filename,
VkFilter filter = VK_FILTER_LINEAR,
VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_REPEAT,
bool anisotropic = true,
bool mipmap = true )
static

Creates a new 2D image, or finds one with the same values.

Parameters
filenameThe file to load the image from.
filterThe magnification/minification filter to apply to lookups.
addressModeThe addressing mode for outside [0..1] range.
anisotropicIf anisotropic filtering is enabled.
mipmapIf mipmaps will be generated.
Returns
The 2D image with the requested values.

◆ GetTypeIndex()

std::type_index PixelBullet::Image2D::GetTypeIndex ( ) const
inlineoverridevirtual

Returns the type index of the resource.

Implements PixelBullet::Resource.

◆ SetPixels()

void PixelBullet::Image2D::SetPixels ( const uint8_t * pixels,
uint32_t layerCount,
uint32_t baseArrayLayer )

Sets the pixels of this image.

Parameters
pixelsThe pixels to copy from.
layerCountThe amount of layers contained in the pixels.
baseArrayLayerThe first layer to copy into.

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