Lluvia
ll::Image Class Reference

Objects to manage images. More...

#include <Image.h>

Inheritance diagram for ll::Image:
Collaboration diagram for ll::Image:

Public Member Functions

 Image ()=delete
 
 Image (const Image &)=delete
 
 Image (Image &&)=delete
 
 ~Image ()
 
Imageoperator= (const Image &)=delete
 
Imageoperator= (Image &&)=delete
 
ll::ObjectType getType () const noexcept override
 Gets the object type. More...
 
ll::MemoryAllocationInfo getAllocationInfo () const noexcept
 Gets the allocation information. More...
 
const std::shared_ptr< ll::Memory > & getMemory () const noexcept
 Gets the memory this image was allocated from. More...
 
uint64_t getSize () const noexcept
 Gets the memory allocation size in bytes. More...
 
uint64_t getMinimumSize () const noexcept
 Gets the minimum number of bytes to store the image contiguously in memory. More...
 
const ll::ImageDescriptorgetDescriptor () const noexcept
 Gets the descriptor. More...
 
ll::ImageUsageFlags getUsageFlags () const noexcept
 Gets the Vulkan image usage flags. More...
 
uint32_t getUsageFlagsUnsafe () const noexcept
 Gets the usage flags casted to an integer type. More...
 
ll::ImageLayout getLayout () const noexcept
 Gets the Vulkan image layout. More...
 
ll::ImageTiling getTiling () const noexcept
 Gets the vulkan image tiling. More...
 
ll::ChannelType getChannelType () const noexcept
 Gets the channel type. More...
 
uint64_t getChannelTypeSize () const noexcept
 Gets the channel type size. More...
 
template<typename T = ll::ChannelCount>
getChannelCount () const noexcept
 Gets the channel count. More...
 
uint32_t getWidth () const noexcept
 Gets the image width in pixels. More...
 
uint32_t getHeight () const noexcept
 Gets the image height in pixels. More...
 
uint32_t getDepth () const noexcept
 Gets the image depth in pixels. More...
 
ll::vec3ui getShape () const noexcept
 Gets the shape of the image. More...
 
std::shared_ptr< ll::ImageViewcreateImageView (const ll::ImageViewDescriptor &tDescriptor)
 Creates an image view from this image. More...
 
void changeImageLayout (const ll::ImageLayout newLayout)
 Immediately changes the image layout. More...
 
void clear ()
 Immediately clears the image pixels to zero. More...
 
void copyTo (ll::Image &dst)
 Immediately copies the content of this image into the destination. More...
 
- Public Member Functions inherited from ll::Object
 Object ()=default
 Default constructor. More...
 
 Object (const Object &)=delete
 Copy constructor. More...
 
 Object (Object &&)=delete
 Move constructor. More...
 
virtual ~Object ()=default
 
Objectoperator= (const Object &)=delete
 Copy assignment. More...
 
Objectoperator= (Object &&)=delete
 Move assignment. More...
 

Friends

class ll::CommandBuffer
 
class ll::ComputeNode
 
class ll::ComputeGraph
 
class ll::ImageView
 
class ll::Memory
 
class ll::Session
 

Detailed Description

Objects to manage images.

Image objects are created by calling ll::Memory::createImage using a valid ll::ImageDescriptor.

auto session = ll::Session::create();
// device-local memory with page size of 2048 bytes
auto memory = session->createMemory(vk::MemoryPropertyFlagBits::eDeviceLocal, 2048);
// 8-bit unsigned, 4-channel, 640x480 image.
auto desc = ll::ImageDescriptor{}
.setWidth(640)
.setHeight(480)
auto image = memory->createImage(desc);
Stores all relevant information for creating ll::Image objects.
Definition: ImageDescriptor.h:189
ImageDescriptor & setHeight(const uint32_t height) noexcept
Sets the height.
ImageDescriptor & setWidth(const uint32_t width) noexcept
Sets the width.
ImageDescriptor & setChannelType(const ll::ChannelType type) noexcept
Sets the channel type.
ImageDescriptor & setChannelCount(const ll::ChannelCount count) noexcept
Sets the channel count.
static std::shared_ptr< ll::Session > create()
Creates a new ll::Session object.

Images can be passed directly to compute nodes or through ll::ImageView objects. In the first case, the object is mapped to a GLSL image type while in the second case, it is mapped to sampler type.

TODO

  • Example of compute node using image objects.
  • Explain image layout transitions.

Constructor & Destructor Documentation

◆ Image() [1/3]

ll::Image::Image ( )
delete

◆ Image() [2/3]

ll::Image::Image ( const Image )
delete

◆ Image() [3/3]

ll::Image::Image ( Image &&  )
delete

◆ ~Image()

ll::Image::~Image ( )

Member Function Documentation

◆ changeImageLayout()

void ll::Image::changeImageLayout ( const ll::ImageLayout  newLayout)

Immediately changes the image layout.

This method creates a command buffer and submits it to change the layout of the image. Execution is blocked until the layout change is completed.

Parameters
[in]newLayoutThe new layout

◆ clear()

void ll::Image::clear ( )

Immediately clears the image pixels to zero.

This method creates a command buffer and sumbits it to clear all the pixels in the underlying image to zero. Execution is blocked until the operation is completed.

◆ copyTo()

void ll::Image::copyTo ( ll::Image dst)

Immediately copies the content of this image into the destination.

This method creates a command buffer and sumbits it to copy the content of this image into dst. No valiation of destination image shape is performed. Execution is blocked until the operation is completed.

Parameters
[in]dstThe destination image.

◆ createImageView()

std::shared_ptr<ll::ImageView> ll::Image::createImageView ( const ll::ImageViewDescriptor tDescriptor)

Creates an image view from this image.

Parameters
[in]tDescriptorThe image view descriptor
Returns
A new image view object.

◆ getAllocationInfo()

ll::MemoryAllocationInfo ll::Image::getAllocationInfo ( ) const
noexcept

Gets the allocation information.

Returns
The allocation information.

◆ getChannelCount()

template<typename T = ll::ChannelCount>
T ll::Image::getChannelCount ( ) const
inlinenoexcept

Gets the channel count.

Template Parameters
TType of the return value. Defaults to ll::ChannelCount.
Returns
The channel count.

◆ getChannelType()

ll::ChannelType ll::Image::getChannelType ( ) const
noexcept

Gets the channel type.

Returns
The channel type.

◆ getChannelTypeSize()

uint64_t ll::Image::getChannelTypeSize ( ) const
noexcept

Gets the channel type size.

Returns
The channel type size.

◆ getDepth()

uint32_t ll::Image::getDepth ( ) const
noexcept

Gets the image depth in pixels.

Returns
The image depth in pixels.

◆ getDescriptor()

const ll::ImageDescriptor& ll::Image::getDescriptor ( ) const
noexcept

Gets the descriptor.

Returns
The descriptor.

◆ getHeight()

uint32_t ll::Image::getHeight ( ) const
noexcept

Gets the image height in pixels.

Returns
The image height in pixels.

◆ getLayout()

ll::ImageLayout ll::Image::getLayout ( ) const
noexcept

Gets the Vulkan image layout.

The layout is changed through invocations of Session::changeImageLayout or CommandBuffer::changeImageLayout.

See https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#_vkimagelayout_3

Returns
The image layout.

◆ getMemory()

const std::shared_ptr<ll::Memory>& ll::Image::getMemory ( ) const
noexcept

Gets the memory this image was allocated from.

Returns
The memory.

◆ getMinimumSize()

uint64_t ll::Image::getMinimumSize ( ) const
noexcept

Gets the minimum number of bytes to store the image contiguously in memory.

This methods is equivalent to:

uint64_t minimumSize = getWidth() *
                       getHeight() *
                       getDepth() *
                       getChannelTypeSize() *
                       static_cast<uint64_t>(getChannelCount())
Returns
The minimum image size in bytes.

◆ getShape()

ll::vec3ui ll::Image::getShape ( ) const
noexcept

Gets the shape of the image.

The vec3ui object returned must be interpreted as follows:

x : width
y : height
z : depth
Returns
The shape.

◆ getSize()

uint64_t ll::Image::getSize ( ) const
noexcept

Gets the memory allocation size in bytes.

This methods is equivalent to calling getAllocationInfo().size.

The size reported by this method includes any row stride and padding needed to store the image in memory according to the device. Use :getMinimumSize: to get the minimum amount of memory to allocate all pixels contiguously in memory without any stride.

Returns
The image size in bytes.

◆ getTiling()

ll::ImageTiling ll::Image::getTiling ( ) const
noexcept

Gets the vulkan image tiling.

Returns
The image tiling.

◆ getType()

ll::ObjectType ll::Image::getType ( ) const
overridevirtualnoexcept

Gets the object type.

This method can be used for safely down-casting pointers of ll::Object type to its children.

ll::Object* ptr = ...
auto bufferPtr = static_cast<ll::Buffer*>(ptr);
}
Objects to manage raw portions of allocated memory.
Definition: Buffer.h:57
Base class for all types that can be used in computer shaders.
Definition: Object.h:94
virtual ll::ObjectType getType() const noexcept=0
Gets the object type.
Returns
The object type.

Implements ll::Object.

◆ getUsageFlags()

ll::ImageUsageFlags ll::Image::getUsageFlags ( ) const
noexcept

Gets the Vulkan image usage flags.

See https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VkImageUsageFlagBits for more information.

Returns
The usage flags.

◆ getUsageFlagsUnsafe()

uint32_t ll::Image::getUsageFlagsUnsafe ( ) const
noexcept

Gets the usage flags casted to an integer type.

Please do not use this method. It's for internal use only.

Returns
The usage flags unsafe.

◆ getWidth()

uint32_t ll::Image::getWidth ( ) const
noexcept

Gets the image width in pixels.

Returns
The image width in pixels.

◆ operator=() [1/2]

Image& ll::Image::operator= ( const Image )
delete

◆ operator=() [2/2]

Image& ll::Image::operator= ( Image &&  )
delete

Friends And Related Function Documentation

◆ ll::CommandBuffer

friend class ll::CommandBuffer
friend

◆ ll::ComputeGraph

friend class ll::ComputeGraph
friend

◆ ll::ComputeNode

friend class ll::ComputeNode
friend

◆ ll::ImageView

friend class ll::ImageView
friend

◆ ll::Memory

friend class ll::Memory
friend

◆ ll::Session

friend class ll::Session
friend

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