![]() |
VPP
0.7
A high-level modern C++ API for Vulkan
|
Base class for uniform data structures. More...
#include <vppLangIntUniform.hpp>
Base class for uniform data structures.
Inherit from this class to define your uniform data structure template. The first template argument should be passed from your template. The second one should be the name of your template which is being derived.
Use UniformFld template to define fields inside the structure.
Instantiating the template with GPU tag argument gives GPU-side version of the structure, while CPU tag gives the host version. The CPU version can be directly used to fill data buffers meant to be transfered to GPU.
Unlike VertexStruct and InstanceStruct, CPU flavor of UniformStruct does not use Vulkan format to specify the data layout. You provide directly the data type. This is because Vulkan does not need to interpret uniform data as thoroughly as in case of vertex and instance streams.
Example of type definition:
The glm::mat4
type in the code above is an example of custom matrix data type. GLM types are supported by VPP. You can add your own types support by defining the StructMemberTraits template specializations.
Using the CPU-side flavor to create and fill the vector:
Example of CPU-side data binding for the defined type:
Inside shader code, use UniformVar or UniformArray to access the fields. The GPU-level type to represent the value is inferred from CPU-level type with help of StructMemberTraits specialization. In this case, VPP knows that GPU counterpart of glm::mat4
is Mat4.
Example: