LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::Backends::VulkanImage Class Reference

Implements a Vulkan IImage. More...

#include <image.h>

Inherits LiteFX::Rendering::Backends::IVulkanImage, LiteFX::Resource< VkImage >, and LiteFX::Rendering::StateResource.

Classes

class  VulkanImageImpl
 

Public Member Functions

 VulkanImage (const VulkanDevice &device, VkImage image, const Size3d &extent, const Format &format, const ImageDimensions &dimensions, const UInt32 &levels, const UInt32 &layers, const MultiSamplingLevel &samples, const bool &writable, const ResourceState &initialState, VmaAllocator allocator=nullptr, VmaAllocation allocation=nullptr, const String &name="")
 
 VulkanImage (VulkanImage &&)=delete
 
 VulkanImage (const VulkanImage &)=delete
 
virtual ~VulkanImage () noexcept
 
virtual const UInt32elements () const noexcept override
 Gets the number of sub-resources inside the memory chunk. More...
 
virtual size_t size () const noexcept override
 Gets the size (in bytes) of the aligned memory chunk. More...
 
virtual size_t elementSize () const noexcept override
 Returns the size of a single element within the buffer. If there is only one element, this is equal to size. More...
 
virtual size_t elementAlignment () const noexcept override
 Returns the alignment of a single element. More...
 
virtual size_t alignedElementSize () const noexcept override
 Returns the actual size of the element in device memory. More...
 
virtual const bool & writable () const noexcept override
 Returns true, if the resource can be bound to a read/write descriptor. More...
 
virtual const ResourceState & state (const UInt32 &subresource=0) const override
 Returns the current state of the resource. More...
 
virtual ResourceState & state (const UInt32 &subresource=0) override
 Returns a reference of the current state of the resource. More...
 
virtual size_t size (const UInt32 &level) const noexcept override
 Returns the size (in bytes) of an image at a specified mip map level. If the image does not contain the provided mip map level, the method returns 0. More...
 
virtual Size3d extent (const UInt32 &level=0) const noexcept override
 Gets the extent of the image at a certain mip-map level. More...
 
virtual const Format & format () const noexcept override
 Gets the internal format of the image. More...
 
virtual const ImageDimensions & dimensions () const noexcept override
 Gets the images dimensionality. More...
 
virtual const UInt32levels () const noexcept override
 Gets the number of mip-map levels of the image. More...
 
virtual const UInt32layers () const noexcept override
 Gets the number of layers (slices) of the image. More...
 
virtual const UInt32planes () const noexcept override
 Returns the number of planes of the image resource. More...
 
virtual const MultiSamplingLevel & samples () const noexcept override
 Gets the number of samples of the texture. More...
 
virtual VkImageAspectFlags aspectMask () const noexcept override
 Returns the image resource aspect mask for all sub-resources. More...
 
virtual VkImageAspectFlags aspectMask (const UInt32 &plane) const override
 Returns the image resource aspect mask for a single sub-resource. More...
 
virtual void resolveSubresource (const UInt32 &subresource, UInt32 &plane, UInt32 &layer, UInt32 &level) const override
 Computes the plane , layer and level indices from the subresource identifier. More...
 
virtual const VkImageView & imageView (const UInt32 &plane=0) const override
 Returns the image view for a sub-resource. More...
 
- Public Member Functions inherited from LiteFX::Rendering::Backends::IVulkanImage
virtual ~IVulkanImage () noexcept=default
 
virtual VkImageAspectFlags aspectMask () const noexcept=0
 Returns the image resource aspect mask for all sub-resources. More...
 
virtual VkImageAspectFlags aspectMask (const UInt32 &plane) const =0
 Returns the image resource aspect mask for a single sub-resource. More...
 
virtual void resolveSubresource (const UInt32 &subresource, UInt32 &plane, UInt32 &layer, UInt32 &level) const =0
 Computes the plane , layer and level indices from the subresource identifier. More...
 
virtual const VkImageView & imageView (const UInt32 &plane=0) const =0
 Returns the image view for a sub-resource. More...
 
- Public Member Functions inherited from LiteFX::Rendering::IImage
virtual ~IImage () noexcept=default
 
virtual size_t size (const UInt32 &level) const noexcept=0
 Returns the size (in bytes) of an image at a specified mip map level. If the image does not contain the provided mip map level, the method returns 0. More...
 
virtual Size3d extent (const UInt32 &level=0) const noexcept=0
 Gets the extent of the image at a certain mip-map level. More...
 
virtual const Format & format () const noexcept=0
 Gets the internal format of the image. More...
 
virtual const ImageDimensions & dimensions () const noexcept=0
 Gets the images dimensionality. More...
 
virtual const UInt32levels () const noexcept=0
 Gets the number of mip-map levels of the image. More...
 
virtual const UInt32layers () const noexcept=0
 Gets the number of layers (slices) of the image. More...
 
virtual const UInt32planes () const noexcept=0
 Returns the number of planes of the image resource. More...
 
virtual const MultiSamplingLevel & samples () const noexcept=0
 Gets the number of samples of the texture. More...
 
virtual UInt32 subresourceId (const UInt32 &level, const UInt32 &layer, const UInt32 &plane) const noexcept
 
- Public Member Functions inherited from LiteFX::Rendering::IDeviceMemory
virtual ~IDeviceMemory () noexcept=default
 
virtual const UInt32elements () const noexcept=0
 Gets the number of sub-resources inside the memory chunk. More...
 
virtual size_t size () const noexcept=0
 Gets the size (in bytes) of the aligned memory chunk. More...
 
virtual size_t elementSize () const noexcept=0
 Returns the size of a single element within the buffer. If there is only one element, this is equal to size. More...
 
virtual size_t elementAlignment () const noexcept=0
 Returns the alignment of a single element. More...
 
virtual size_t alignedElementSize () const noexcept=0
 Returns the actual size of the element in device memory. More...
 
virtual const bool & writable () const noexcept=0
 Returns true, if the resource can be bound to a read/write descriptor. More...
 
virtual const ResourceState & state (const UInt32 &subresource=0) const =0
 Returns the current state of the resource. More...
 
virtual ResourceState & state (const UInt32 &subresource=0)=0
 Returns a reference of the current state of the resource. More...
 
- Public Member Functions inherited from LiteFX::Rendering::IStateResource
virtual ~IStateResource () noexcept=default
 
virtual const Stringname () const noexcept=0
 Returns the name of the resource. More...
 
- Public Member Functions inherited from LiteFX::IResource< VkImage >
virtual ~IResource () noexcept=default
 
virtual const VkImage & handle () const noexcept=0
 Returns the resource managed by the class. More...
 
- Public Member Functions inherited from LiteFX::Resource< VkImage >
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
virtual ~Resource () noexcept=default
 
const VkImage & handle () const noexcept override
 Returns the resource managed by the class. More...
 
- Public Member Functions inherited from LiteFX::Rendering::StateResource
 StateResource (StringView name)
 Initializes a new state resource instance. More...
 
 StateResource (StateResource &&)=delete
 
 StateResource (const StateResource &)=delete
 
virtual ~StateResource () noexcept
 
virtual const Stringname () const noexcept override
 Returns the name of the resource. More...
 

Static Public Member Functions

static UniquePtr< VulkanImageallocate (const VulkanDevice &device, const Size3d &extent, const Format &format, const ImageDimensions &dimensions, const UInt32 &levels, const UInt32 &layers, const MultiSamplingLevel &samples, const bool &writable, const ResourceState &initialState, VmaAllocator &allocator, const VkImageCreateInfo &createInfo, const VmaAllocationCreateInfo &allocationInfo, VmaAllocationInfo *allocationResult=nullptr)
 
static UniquePtr< VulkanImageallocate (const String &name, const VulkanDevice &device, const Size3d &extent, const Format &format, const ImageDimensions &dimensions, const UInt32 &levels, const UInt32 &layers, const MultiSamplingLevel &samples, const bool &writable, const ResourceState &initialState, VmaAllocator &allocator, const VkImageCreateInfo &createInfo, const VmaAllocationCreateInfo &allocationInfo, VmaAllocationInfo *allocationResult=nullptr)
 

Protected Member Functions

virtual VmaAllocator & allocator () const noexcept
 
virtual VmaAllocation & allocationInfo () const noexcept
 
virtual VkImageView & imageView (const UInt32 &plane=0)
 
virtual VkImage & handle () noexcept=0
 Returns the resource managed by the class. More...
 
- Protected Member Functions inherited from LiteFX::Resource< VkImage >
 Resource (const VkImage handle) noexcept
 Initializes the managed resource. More...
 
VkImage & handle () noexcept override
 Returns the resource managed by the class. More...
 
- Protected Member Functions inherited from LiteFX::Rendering::StateResource
 StateResource () noexcept
 
Stringname () noexcept
 

Detailed Description

Implements a Vulkan IImage.

Constructor & Destructor Documentation

◆ VulkanImage() [1/3]

VulkanImage::VulkanImage ( const VulkanDevice device,
VkImage  image,
const Size3d extent,
const Format &  format,
const ImageDimensions &  dimensions,
const UInt32 levels,
const UInt32 layers,
const MultiSamplingLevel &  samples,
const bool &  writable,
const ResourceState &  initialState,
VmaAllocator  allocator = nullptr,
VmaAllocation  allocation = nullptr,
const String name = "" 
)
explicit

◆ VulkanImage() [2/3]

LiteFX::Rendering::Backends::VulkanImage::VulkanImage ( VulkanImage &&  )
delete

◆ VulkanImage() [3/3]

LiteFX::Rendering::Backends::VulkanImage::VulkanImage ( const VulkanImage )
delete

◆ ~VulkanImage()

VulkanImage::~VulkanImage ( )
virtualnoexcept

Member Function Documentation

◆ alignedElementSize()

size_t VulkanImage::alignedElementSize ( ) const
overridevirtualnoexcept

Returns the actual size of the element in device memory.

Implements LiteFX::Rendering::IDeviceMemory.

◆ allocate() [1/2]

UniquePtr< VulkanImage > VulkanImage::allocate ( const String name,
const VulkanDevice device,
const Size3d extent,
const Format &  format,
const ImageDimensions &  dimensions,
const UInt32 levels,
const UInt32 layers,
const MultiSamplingLevel &  samples,
const bool &  writable,
const ResourceState &  initialState,
VmaAllocator &  allocator,
const VkImageCreateInfo &  createInfo,
const VmaAllocationCreateInfo &  allocationInfo,
VmaAllocationInfo *  allocationResult = nullptr 
)
static

◆ allocate() [2/2]

UniquePtr< VulkanImage > VulkanImage::allocate ( const VulkanDevice device,
const Size3d extent,
const Format &  format,
const ImageDimensions &  dimensions,
const UInt32 levels,
const UInt32 layers,
const MultiSamplingLevel &  samples,
const bool &  writable,
const ResourceState &  initialState,
VmaAllocator &  allocator,
const VkImageCreateInfo &  createInfo,
const VmaAllocationCreateInfo &  allocationInfo,
VmaAllocationInfo *  allocationResult = nullptr 
)
static

◆ allocationInfo()

VmaAllocation & VulkanImage::allocationInfo ( ) const
protectedvirtualnoexcept

◆ allocator()

VmaAllocator & VulkanImage::allocator ( ) const
protectedvirtualnoexcept

◆ aspectMask() [1/2]

VkImageAspectFlags VulkanImage::aspectMask ( ) const
overridevirtualnoexcept

Returns the image resource aspect mask for all sub-resources.

Returns
The image resource aspect mask.

Implements LiteFX::Rendering::Backends::IVulkanImage.

◆ aspectMask() [2/2]

VkImageAspectFlags VulkanImage::aspectMask ( const UInt32 plane) const
overridevirtual

Returns the image resource aspect mask for a single sub-resource.

Parameters
planeThe sub-resource identifier to query the aspect mask from.
Returns
The image resource aspect mask.

Implements LiteFX::Rendering::Backends::IVulkanImage.

◆ dimensions()

const ImageDimensions & VulkanImage::dimensions ( ) const
overridevirtualnoexcept

Gets the images dimensionality.

Implements LiteFX::Rendering::IImage.

◆ elementAlignment()

size_t VulkanImage::elementAlignment ( ) const
overridevirtualnoexcept

Returns the alignment of a single element.

Implements LiteFX::Rendering::IDeviceMemory.

◆ elements()

const UInt32 & VulkanImage::elements ( ) const
overridevirtualnoexcept

Gets the number of sub-resources inside the memory chunk.

Implements LiteFX::Rendering::IDeviceMemory.

◆ elementSize()

size_t VulkanImage::elementSize ( ) const
overridevirtualnoexcept

Returns the size of a single element within the buffer. If there is only one element, this is equal to size.

Implements LiteFX::Rendering::IDeviceMemory.

◆ extent()

Size3d VulkanImage::extent ( const UInt32 level = 0) const
overridevirtualnoexcept

Gets the extent of the image at a certain mip-map level.

Implements LiteFX::Rendering::IImage.

◆ format()

const Format & VulkanImage::format ( ) const
overridevirtualnoexcept

Gets the internal format of the image.

Implements LiteFX::Rendering::IImage.

◆ imageView() [1/2]

VkImageView & VulkanImage::imageView ( const UInt32 plane = 0)
protectedvirtual

◆ imageView() [2/2]

const VkImageView & VulkanImage::imageView ( const UInt32 plane = 0) const
overridevirtual

Returns the image view for a sub-resource.

Parameters
planeThe sub-resource index to return the image view for.
Returns
The image view for the sub-resource.

Implements LiteFX::Rendering::Backends::IVulkanImage.

◆ layers()

const UInt32 & VulkanImage::layers ( ) const
overridevirtualnoexcept

Gets the number of layers (slices) of the image.

Implements LiteFX::Rendering::IImage.

◆ levels()

const UInt32 & VulkanImage::levels ( ) const
overridevirtualnoexcept

Gets the number of mip-map levels of the image.

Implements LiteFX::Rendering::IImage.

◆ planes()

const UInt32 & VulkanImage::planes ( ) const
overridevirtualnoexcept

Returns the number of planes of the image resource.

Implements LiteFX::Rendering::IImage.

◆ resolveSubresource()

void VulkanImage::resolveSubresource ( const UInt32 subresource,
UInt32 plane,
UInt32 layer,
UInt32 level 
) const
overridevirtual

Computes the plane , layer and level indices from the subresource identifier.

Parameters
subresourceThe identifier of the sub-resource.
planeThe plane of the sub-resource.
layerThe layer of the sub-resource.
levelThe level of the sub-resource.

Implements LiteFX::Rendering::Backends::IVulkanImage.

◆ samples()

const MultiSamplingLevel & VulkanImage::samples ( ) const
overridevirtualnoexcept

Gets the number of samples of the texture.

Implements LiteFX::Rendering::IImage.

◆ size() [1/2]

size_t VulkanImage::size ( ) const
overridevirtualnoexcept

Gets the size (in bytes) of the aligned memory chunk.

Implements LiteFX::Rendering::IDeviceMemory.

◆ size() [2/2]

size_t VulkanImage::size ( const UInt32 level) const
overridevirtualnoexcept

Returns the size (in bytes) of an image at a specified mip map level. If the image does not contain the provided mip map level, the method returns 0.

Implements LiteFX::Rendering::IImage.

◆ state() [1/2]

const ResourceState & VulkanImage::state ( const UInt32 subresource = 0) const
overridevirtual

Returns the current state of the resource.

Implements LiteFX::Rendering::IDeviceMemory.

◆ state() [2/2]

ResourceState & VulkanImage::state ( const UInt32 subresource = 0)
overridevirtual

Returns a reference of the current state of the resource.

Implements LiteFX::Rendering::IDeviceMemory.

◆ writable()

const bool & VulkanImage::writable ( ) const
overridevirtualnoexcept

Returns true, if the resource can be bound to a read/write descriptor.

Implements LiteFX::Rendering::IDeviceMemory.