VPP  0.7
A high-level modern C++ API for Vulkan
Public Types | Public Member Functions | List of all members
vpp::Image< AttributesT > Class Template Reference

Class representing typed Vulkan image. More...

#include <vppImage.hpp>

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

Public Types

typedef AttributesT attributes_type
 Image attributes.
 
typedef AttributesT::format_type format_type
 Image format.
 
- Public Types inherited from vpp::Img
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

 Image ()
 Constructs null reference.
 
 Image (const VkExtent3D &extent, const MemProfile &memProfile, const Device &hDevice, unsigned int mipLevels=1u, unsigned int arrayLevels=1u, VkImageLayout initialLayout=VK_IMAGE_LAYOUT_UNDEFINED, const std::vector< unsigned int > &queueFamilyIndices=std::vector< unsigned int >())
 Construct a typed image. More...
 
 Image (VkFormat format, const VkExtent3D &extent, const MemProfile &memProfile, const Device &hDevice, unsigned int mipLevels=1u, unsigned int arrayLevels=1u, VkImageLayout initialLayout=VK_IMAGE_LAYOUT_UNDEFINED, const std::vector< unsigned int > &queueFamilyIndices=std::vector< unsigned int >())
 Construct a typed image using dynamic format. More...
 
 Image (const VkExtent3D &extent, const Device &hDevice, VkImage hImage, unsigned int mipLevels=1u, unsigned int arrayLevels=1u)
 Construct a typed image from existing Vulkan image handle. More...
 
 Image (VkFormat format, const VkExtent3D &extent, const Device &hDevice, VkImage hImage, unsigned int mipLevels=1u, unsigned int arrayLevels=1u)
 Construct a typed image using dynamic format from existing Vulkan image handle. More...
 
 Image (const Img &rawImage)
 Constructs typed image from untyped image. More...
 
- Public Member Functions inherited from vpp::Img
 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

template<class AttributesT>
class vpp::Image< AttributesT >

Class representing typed Vulkan image.

This image class template accepts an instance of ImageAttributes template, so it has compile-time knowledge of various image attributes. This is required if the image has to be accessed in a shader.

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

An example:

typedef vpp::format< vpp::unorm8_t, vpp::unorm8_t, vpp::unorm8_t, vpp::unorm8_t > MyColorFormat;
MyColorFormat,
vpp::IMG_TYPE_2D,
VK_IMAGE_TILING_OPTIMAL,
VK_SAMPLE_COUNT_1_BIT,
false,
false
> MyColorImageAttr;
// ...
// Creates the image.
MyImage hMyImage = MyImage (
{ 1280, 960, 1 },
hDevice
);
// ...

Another example:

typedef vpp::format< vpp::texture_format > MyTextureFormat;
MyTextureFormat,
vpp::IMG_TYPE_2D,
VK_IMAGE_TILING_OPTIMAL,
VK_SAMPLE_COUNT_1_BIT,
true,
true
> MyTextureArrayAttr;
typedef vpp::Image< MyTextureArrayAttr > MyTextureArrayImage;
// ...
// Creates the image.
MyTextureArrayImage hMyTextureArray = MyImage (
VK_FORMAT_BC7_UNORM_BLOCK,
{ 1024, 1024, 1 },
hDevice,
11, // mip levels
8 // array layers
);
// ...

Constructor & Destructor Documentation

◆ Image() [1/5]

template<class AttributesT >
vpp::Image< AttributesT >::Image ( const VkExtent3D &  extent,
const MemProfile memProfile,
const Device hDevice,
unsigned int  mipLevels = 1u,
unsigned int  arrayLevels = 1u,
VkImageLayout  initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
const std::vector< unsigned int > &  queueFamilyIndices = std::vector< unsigned int >() 
)

Construct a typed image.

Provide image size and the target device.

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.

Optional arguments include number of mip maps and array levels (applicable only for mip-mapped and/or arrayed images). Also you can specify starting layout of the image. Finally there is queueFamilyIndices parameter, applicable only for images shared between queues (rare usage).

◆ Image() [2/5]

template<class AttributesT >
vpp::Image< AttributesT >::Image ( VkFormat  format,
const VkExtent3D &  extent,
const MemProfile memProfile,
const Device hDevice,
unsigned int  mipLevels = 1u,
unsigned int  arrayLevels = 1u,
VkImageLayout  initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
const std::vector< unsigned int > &  queueFamilyIndices = std::vector< unsigned int >() 
)

Construct a typed image using dynamic format.

This constructor allows to specify a format as an argument, which overrides the format encoded in image type. This is meant mainly for compressed texture formats, which have general texture_format format statically encoded, but real format (e.g. VK_FORMAT_BC1_RGB_UNORM_BLOCK ) is not known at compile time and may vary for different textures.

To make handling such images simpler, you can specify the format in the constructor after checking at runtime what the format really is. The drawback of such approach is that the image usage is limited to be read-only texture image.

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.

Also specify image size and the target device.

Optional arguments include number of mip maps and array levels (applicable only for mip-mapped and/or arrayed images). Also you can specify starting layout of the image. Finally there is queueFamilyIndices parameter, applicable only for images shared between queues (rare usage).

◆ Image() [3/5]

template<class AttributesT >
vpp::Image< AttributesT >::Image ( const VkExtent3D &  extent,
const Device hDevice,
VkImage< AttributesT >  hImage,
unsigned int  mipLevels = 1u,
unsigned int  arrayLevels = 1u 
)

Construct a typed image from existing Vulkan image handle.

This constructor makes an Image object for already existing Vulkan image represented by a handle. Also specify image size and the target device.

Optional arguments include number of mip maps and array levels (applicable only for mip-mapped and/or arrayed images).

◆ Image() [4/5]

template<class AttributesT >
vpp::Image< AttributesT >::Image ( VkFormat  format,
const VkExtent3D &  extent,
const Device hDevice,
VkImage< AttributesT >  hImage,
unsigned int  mipLevels = 1u,
unsigned int  arrayLevels = 1u 
)

Construct a typed image using dynamic format from existing Vulkan image handle.

This constructor makes an Image object for already existing Vulkan image represented by a handle. Also specify image size and the target device.

This constructor allows to specify a format as an argument, which overrides the format encoded in image type. This is meant mainly for compressed texture formats, which have general texture_format format statically encoded, but real format (e.g. VK_FORMAT_BC1_RGB_UNORM_BLOCK ) is not known at compile time and may vary for different textures.

To make handling such images simpler, you can specify the format in the constructor after checking at runtime what the format really is. The drawback of such approach is that the image usage is limited to be read-only texture image.

Optional arguments include number of mip maps and array levels (applicable only for mip-mapped and/or arrayed images).

◆ Image() [5/5]

template<class AttributesT >
vpp::Image< AttributesT >::Image ( const Img rawImage)
explicit

Constructs typed image from untyped image.

This allows to convert untyped Img object to a typed image. This operation is potentially unsafe, as there is no checking whether attributes actually match. Use only when you are sure that the actual image is compatible with the type.


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