VPP  0.8
A high-level modern C++ API for Vulkan
vpp::inTexture< ImageViewT > Class Template Reference

Texture (read-only) image binding point. More...

#include <vppLangIntImages.hpp>

Public Member Functions

 inTexture (unsigned int set=0, int binding=-1)
 Creates the binding point. More...
 
auto operator= (const ImageViewT &value)
 Binds an image view to the binding point. More...
 
auto operator= (vpp::bind(const ImageViewT &view, VkImageLayout layout))
 Binds an image view to the binding point. More...
 

Detailed Description

template<class ImageViewT>
class vpp::inTexture< ImageViewT >

Texture (read-only) image binding point.

This variant of texture binding point is meant to be sampled, but is not associated with a sampler. You must manually associate it with a sampler in the shader code, by means of MakeSampledTexture() function. It will convert the pure texture to texture-sampler pair. The pair can be provided to sampling functions, e.g. Texture(), TextureLod(), etc.

Otherwise the raw texture may only be used for functions: MakeSampledTexture(), ImageSize(), TextureSize(), ImageQuerySamples(), ImageQueryLevels(), TexelFetch(), TexelFetchLod(), TexelFetchOffset().

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:

typedef vpp::format<
vpp::unorm8_t,
vpp::unorm8_t,
vpp::unorm8_t,
vpp::unorm8_t > MyImageFormat;

However, in case of textures the format is often not known at compile time (especially when the texture is in compressed format). In such case, use the special vpp::texture_format tag:

typedef vpp::format< vpp::texture_format > MyImageFormat;

The difference is that you should provide format code at runtime to the image constructor. Otherwise VPP will create an image of unknown format, which may (or may not) be supported by the device.

Having defined the format type, declare view type as follows:

MyImageFormat, // your defined format
RENDER, // always use RENDER for textures
IMG_TYPE_2D, // number of dimensions
// for textures, always include SAMPLED, other flags are optional
VK_IMAGE_TILING_OPTIMAL, // most of the time use OPTIMAL
VK_SAMPLE_COUNT_1_BIT, // usually textures have 1 sample per pixel
true, // whether mip-mapped
false // whether arrayed
> MyTextureAttr;
typedef vpp::Image< MyTextureAttr > MyTextureImage;

Now you can use these types as follows:

  • MyTextureImage as runtime image class,
  • MyTextureView as runtime image view class, to bind views to binding points
  • also MyTextureView as the parameter to the binding point.
class MyPipelineConfig : public vpp::PipelineConfig
{
// ...
// ...
};

Constructor & Destructor Documentation

◆ inTexture()

template<class ImageViewT>
vpp::inTexture< ImageViewT >::inTexture ( 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).

Member Function Documentation

◆ operator=() [1/2]

template<class ImageViewT>
auto vpp::inTexture< ImageViewT >::operator= ( const ImageViewT &  value)

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 overload assumes the image is in VK_IMAGE_LAYOUT_GENERAL layout.

◆ operator=() [2/2]

template<class ImageViewT>
auto vpp::inTexture< ImageViewT >::operator= ( vpp::bind(const ImageViewT &view, VkImageLayout layout)  )

Binds an image view to the binding point.

This overload allows to specify the layout the image is in when accessing the binding point. For that purpose, use vpp::bind construct.


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