VPP  0.8
A high-level modern C++ API for Vulkan
vpp::Img Class Reference

Class representing generic (untyped) Vulkan image. More...

#include <vppImage.hpp>

Inheritance diagram for vpp::Img:
vpp::Image< AttributesT >

Public Types

enum  EUsageFlags {
  SOURCE = VK_IMAGE_USAGE_TRANSFER_SRC_BIT, TARGET = VK_IMAGE_USAGE_TRANSFER_DST_BIT, SAMPLED = VK_IMAGE_USAGE_SAMPLED_BIT, STORAGE = VK_IMAGE_USAGE_STORAGE_BIT,
  COLOR = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, DEPTH = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, TRANSIENT = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, INPUT = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
}
 Enumeration specifying how an image may be used. More...
 

Public Member Functions

 Img ()
 Constructs null reference.
 
 Img (const ImageInfo &imageInfo, const MemProfile &memProfile, const Device &hDevice, VkImageLayout initialLayout=VK_IMAGE_LAYOUT_UNDEFINED, const std::vector< unsigned int > &queueFamilyIndices=std::vector< unsigned int >())
 Constructs an image with attributes defined by an ImageInfo structure. More...
 
 Img (const ImageInfo &imageInfo, const Device &hDevice, VkImage hImage)
 Constructs an image from already existing Vulkan image handle. More...
 
VkImage handle () const
 Retrieves the Vulkan handle.
 
bool valid () const
 Checks whether this is a valid image.
 
const Devicedevice () const
 Retrieves the device.
 
const ImageInfoinfo () const
 Retrieves all image attributes.
 
const VkExtent3D & extent () const
 Retrieves image size.
 
VkFormat format () const
 Retrieves image format.
 

Detailed Description

Class representing generic (untyped) Vulkan image.

This class represents an image without encoding image attributes (e.g. format) in the C++ type. This makes image handling easier.

Many VPP operations require only such untyped reference to an image. On the other hand, there are contexts (like binding points in shaders) that require typed image references, i.e. instances of Image template.

You can always cast from typed image reference (Image) to untyped (Img), as Img is the base class of all Image template instances.

As for deciding whether to create/pass Img or Image reference, choose the variant appropriate for the usage of the reference. If the image has to be bound to a shader binding point, Image will be required. If the image will be only supplied to a command (e.g. cmdCopyImage()), Img will suffice.

This object is reference-counted and may be passed by value.

Member Enumeration Documentation

◆ EUsageFlags

Enumeration specifying how an image may be used.

Every image has a parameter called usage which is a bitwise combination of values taken from EUsageFlags enumeration. It restricts possible usage of the image, but also allows performance optimization of it.

These values are identical to corresponding low-level Vulkan flags and may be used interchangeably.

Enumerator
SOURCE 

Allows to use an image as a source of transfer or blit operation.

TARGET 

Allows to use an image as a destination of transfer or blit operation.

SAMPLED 

Allows to use an image as a read-only texture.

STORAGE 

Allows to use an image as a mutable image (writable in the shader).

COLOR 

Allows to use an image as an attachment, to be used in a rendering process.

DEPTH 

Allows to use an image as an attachment, to be used in a rendering process as depth buffer.

TRANSIENT 

Allows to optimize memory allocation for an attachment image.

INPUT 

Allows to use an image as an input attachment, to provide data for a rendering process.

Constructor & Destructor Documentation

◆ Img() [1/2]

vpp::Img::Img ( const ImageInfo imageInfo,
const MemProfile memProfile,
const Device hDevice,
VkImageLayout  initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
const std::vector< unsigned int > &  queueFamilyIndices = std::vector< unsigned int >() 
)

Constructs an image with attributes defined by an ImageInfo structure.

The memProfile argument specifies what kind of physical memory is needed for the image. Typically use MemProfile::DEVICE_STATIC value to allocate the image memory on GPU side.

An example:

vpp::Device hDevice = ...;
vpp::ImageInfo myImgInfo (
vpp::IMG_TYPE_2D,
VK_FORMAT_R8G8B8A8_UINT,
{ 1024, 768, 1 },
1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL,
);
vpp::Img myImg = vpp::Img (
myImgInfo, MemProfile::DEVICE_STATIC, hDevice );
vpp::Img myImgWithLayout = vpp::Img (
myImgInfo, MemProfile::DEVICE_STATIC, hDevice,
VK_IMAGE_LAYOUT_GENERAL );

◆ Img() [2/2]

vpp::Img::Img ( const ImageInfo imageInfo,
const Device hDevice,
VkImage  hImage 
)

Constructs an image from already existing Vulkan image handle.

You must still provide image metadata, as Vulkan does not have queries for it.

An example:

VkImage hVulkanImg = ...;
vpp::Device hDevice = ...;
vpp::ImageInfo myImgInfo (
vpp::IMG_TYPE_2D,
VK_FORMAT_R8G8B8A8_UINT,
{ 1024, 768, 1 },
1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL,
);
vpp::Img myImg = vpp::Img ( myImgInfo, hDevice, hVulkanImg );

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