![]() |
VPP
0.7
A high-level modern C++ API for Vulkan
|
Class representing typed Vulkan image. More...
#include <vppImage.hpp>
Public Types | |
typedef AttributesT | attributes_type |
Image attributes. | |
typedef AttributesT::format_type | format_type |
Image format. | |
![]() | |
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... | |
![]() | |
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 Device & | device () const |
Retrieves the device. | |
const ImageInfo & | info () const |
Retrieves all image attributes. | |
const VkExtent3D & | extent () const |
Retrieves image size. | |
VkFormat | format () const |
Retrieves image format. | |
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:
Another example:
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).
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).
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).
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).
|
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.