![]() |
VPP
0.8
A high-level modern C++ API for Vulkan
|
Storage (read-write) image binding point. More...
#include <vppLangIntImages.hpp>
Public Member Functions | |
ioImage (unsigned int set=0, int binding=-1) | |
Creates the binding point. More... | |
auto | operator= (const ImageViewT &view) |
Binds an image view to the binding point. More... | |
auto | operator= (bind(const ImageViewT &view, VkImageLayout layout)) |
Binds an image view to the binding point. More... | |
Pointer< scalar_type > | GetPointer (const pointer_coord_type &coords) |
Creates a pointer to specified texel within the image. More... | |
Pointer< scalar_type > | GetPointer (const pointer_coord_type &coords, const Int &nSample) |
Creates a pointer to specified texel sample within the image. More... | |
Public Attributes | |
typedef< implementation_defined > | scalar_type |
The type of the atomic variable which can be stored in the image. More... | |
typedef< implementation_defined > | pointer_coord_type |
Type of coordinates within the image used to locate texels for making pointers. More... | |
Storage (read-write) image binding point.
Place inside your custom PipelineConfig (or ComputePipelineConfig) derived class to define a binding point for storage image, which can be read or written to.
The binding point template is parameterized by the view type. In order to construct the proper type to be used as an argument here, you need to do two things.
The first thing is to define an image format. The recommended way is to make a typedef of vpp::format< ... > template. For example:
Having defined the format type, declare view type as follows:
Now you can use these types as follows:
MyStorageImage
as runtime image class,MyImageView
as runtime image view class, to bind views to binding points,MyImageView
as the parameter to the binding point.This binding point can be used in the following image functions: ImageLoad(), ImageStore(), ImageSize(), ImageQuerySamples(), ImageQueryLevels().
vpp::ioImage< ImageViewT, MEMFLAGS >::ioImage | ( | unsigned int | set = 0 , |
int | binding = -1 |
||
) |
Creates the binding point.
Typically you do not need to specify any arguments for the constructor.
Optionally you can force the set and binding index. This feature may be useful if you need to interface VPP binding point with externally supplied shader (written in GLSL and compiled externally to SPIR-V blob).
Pointer< scalar_type > vpp::ioImage< ImageViewT, MEMFLAGS >::GetPointer | ( | const pointer_coord_type & | coords | ) |
Creates a pointer to specified texel within the image.
This method allows to place atomic variables inside an image.
Caution: atomic variables can be quite slow.
Pointer< scalar_type > vpp::ioImage< ImageViewT, MEMFLAGS >::GetPointer | ( | const pointer_coord_type & | coords, |
const Int & | nSample | ||
) |
Creates a pointer to specified texel sample within the image.
This method allows to place atomic variables inside an image. The overload allows to specify sample index, and this way to access individual samples within multisampled images.
Caution: atomic variables can be quite slow.
auto vpp::ioImage< ImageViewT, MEMFLAGS >::operator= | ( | const ImageViewT & | view | ) |
Binds an image view to the binding point.
This operator returns a value that must be passed to ShaderDataBlock::update() method. You can also make a list of more assignments, joining them with comma operator. The update method accepts such a list.
The binding is stored inside ShaderDataBlock instance, immediately when update
is called. You select active ShaderDataBlock in your drawing command sequence by calling ShaderDataBlock::cmdBind(). Thus, actual resource binding (to the pipeline) occurs at command execution time, simultaneously for all bindings in that ShaderDataBlock instance.
This variant assumes the image is in VK_IMAGE_LAYOUT_GENERAL layout.
auto vpp::ioImage< ImageViewT, MEMFLAGS >::operator= | ( | bind(const ImageViewT &view, VkImageLayout layout) | ) |
Binds an image view to the binding point.
Same as the other assignment operator, but allows to explicitly specify the layout the image is in. For storage images however, Vulkan always requires VK_IMAGE_LAYOUT_GENERAL layout, hence using this overload is deprecated.
typedef<implementation_defined> vpp::ioImage< ImageViewT, MEMFLAGS >::pointer_coord_type |
typedef<implementation_defined> vpp::ioImage< ImageViewT, MEMFLAGS >::scalar_type |
The type of the atomic variable which can be stored in the image.
Caution: only scalar (single component) formats may support atomic variables. In fact the only formats that are required by Vulkan to support atomic variables are: vpp::format<int>
(VK_FORMAT_R32_SINT
) and vpp::format<unsigned int>
(VK_FORMAT_R32_UINT
).