Struct that contains all the parameters that Kanzi needs to create a ShaderProgram. More...
#include <kanzi/core.ui/platform/graphics_backend/gl/shader_create_info.hpp>
Classes | |
struct | BinaryShaderStage |
One shader stage in binary format. More... | |
struct | ShaderStage |
One shader stage in source code format. More... | |
Public Types | |
using | BindingContainer = ShaderProgram::BindingContainer |
Binding container type. More... | |
using | BindingInfo = ShaderProgram::BindingInfo |
Binding info. More... | |
enum | Status { StatusUnsupportedFormat, StatusCompileError, StatusLinkError, StatusInvalidAttributeLocation, StatusMissingShaderStage, StatusValid } |
Status tells if shader creation parameters can be used to create a shader. More... | |
Public Member Functions | |
void | addBinaryShader (ShaderType type, ConstByteSpan binary) |
Adds a binary shader to the program. More... | |
void | addFixedUniform (string_view name) |
Adds a fixed uniform to a shader. More... | |
void | addFixedUniform (string_view name, ShaderProgram::UniformTransformation transformation) |
Adds a fixed uniform to a shader. More... | |
void | addFixedUniform (string_view name, ShaderProgram::FixedUniform uniform) |
Adds a fixed uniform to a shader. More... | |
void | addFixedUniform (string_view name, ShaderProgram::FixedUniform uniform, ShaderProgram::UniformTransformation transformation) |
Adds a fixed uniform to a shader. More... | |
void | addSourceShader (ShaderType type, string_view source) |
Adds a source shader to the program. More... | |
void | addSourceShader (ShaderType type, const char *source) |
Adds a source shader to the program. More... | |
void | addUniform (string_view name, PropertyDataType dataType, unsigned int elementCount, optional< AbstractPropertyType > propertyType, UniformBindingType bindingType, optional< FixedUniform > fixedOperation, FixedUniformFunction func, UniformTransformation transform) |
Adds an uniform to shader. More... | |
void | addUniform (AbstractPropertyType propertyType, PropertyDataType dataType, unsigned int elementCount, ShaderProgram::UniformTransformation transformation) |
Adds a property type uniform to shader. More... | |
void | addUniform (AbstractPropertyType propertyType, PropertyDataType dataType, unsigned int elementCount) |
Adds a property type uniform to shader. More... | |
void | addUniform (AbstractPropertyType propertyType, ShaderProgram::UniformTransformation transformation) |
Adds a property type uniform to shader. More... | |
void | addUniform (AbstractPropertyType propertyType) |
Adds a property type uniform to shader. More... | |
void | addUniformAndBinding (AbstractPropertyType propertyType, ShaderProgram::UniformTransformation transformation) |
Adds a property type uniform to a shader with a given uniform transformation and creates for that uniform a default render value binding. More... | |
void | addUniformAndBinding (AbstractPropertyType propertyType) |
Adds a property type uniform to a shader and creates for that uniform a default render value binding. More... | |
CreateInfo () | |
Constructs empty create info structure for shader program creation. More... | |
Status | validate (const Renderer &renderer) const |
Perform validation of shader creation parameters. More... | |
Public Attributes | |
BindingContainer | bindings |
Bindings. More... | |
bool | blendingControl |
Indicates whether ShaderProgram created from this createInfo should be able to change blending mode. More... | |
vector< byte > | combinedShaderBinaryData |
Combined shader binary data. More... | |
unsigned int | combinedShaderBinaryFormat |
Format for combined shader binary. More... | |
vector< byte > | programBinaryData |
Program binary data. More... | |
unsigned int | programBinaryFormat |
Format for program binary. More... | |
unsigned int | separateShaderBinaryFormat |
Format for separate shader binaries. More... | |
vector< BinaryShaderStage > | shaderBinaries |
All shader stages in binary format. More... | |
vector< ShaderStage > | shaderSources |
All shader stages in source code format. More... | |
UniformContainer | uniforms |
Uniforms. More... | |
ShaderAttributeCollection | vertexFormat |
Shader vertex attributes. More... | |
Struct that contains all the parameters that Kanzi needs to create a ShaderProgram.
Kanzi loads ShaderProgram::CreateInfo from the kzb file as part of shader creation. You can also use ShaderProgram::CreateInfo to create shaders manually in code.
To define a shader, you must set these fields of the CreateInfo struct:
To create a shader whose bindings are in the default state:
When you want to override binding information, instead of relying on the default states for the bindings, create the bindings manually. To manually create bindings for shaders:
Binding container type.
Status tells if shader creation parameters can be used to create a shader.
If status is not StatusValid, create info must not be passed to ShaderProgram::create().
Enumerator | |
---|---|
StatusUnsupportedFormat |
Shader binary format is not supported. |
StatusCompileError |
Shader fails compilation. |
StatusLinkError |
Shader fails linking. |
StatusInvalidAttributeLocation |
Shader has invalid vertex attribute locations. |
StatusMissingShaderStage |
Shader is missing required shader stage. |
StatusValid |
CreateInfo is valid and can be used to create Shader. |
|
explicit |
Constructs empty create info structure for shader program creation.
Members of the structure must be filled in before the structure can be used in ShaderProgram::create().
Perform validation of shader creation parameters.
You can call validate() to see if shader creation parameters are valid before you pass create info to ShaderProgram::create().
renderer | Renderer to validate with. |
|
inline |
Adds an uniform to shader.
All properties are listed.
name | Uniform name. |
dataType | Uniform data type. |
elementCount | Number of elements in the uniform. |
propertyType | Optional property type. |
bindingType | The type of binding associated with the shader uniform. |
fixedOperation | Optional fixed uniform id. |
func | Fixed function for the uniform, may be nullptr. |
transform | Uniform transformation. See UniformTransformation. |
|
inline |
Adds a property type uniform to shader.
propertyType | Optional property type. |
dataType | Uniform data type. |
elementCount | Number of elements in the uniform. |
transformation | Uniform transformation. |
|
inline |
Adds a property type uniform to shader.
Uniform transformation is set to pass-through.
propertyType | Optional property type. |
dataType | Uniform data type. |
elementCount | Number of elements in the uniform. |
|
inline |
Adds a property type uniform to shader.
Data type is inferred from property. Element count is set to one.
propertyType | Property type. |
transformation | Uniform transformation. |
|
inline |
Adds a property type uniform to shader.
Data type is inferred from property. Element count is set to one. Uniform transformation is set to pass-through.
propertyType | Property type. |
void kanzi::ShaderProgram::CreateInfo::addUniformAndBinding | ( | AbstractPropertyType | propertyType, |
ShaderProgram::UniformTransformation | transformation | ||
) |
Adds a property type uniform to a shader with a given uniform transformation and creates for that uniform a default render value binding.
Infers the data type from the property type. Sets the element count to one.
propertyType | Property type. |
transformation | Uniform transformation. |
|
inline |
Adds a property type uniform to a shader and creates for that uniform a default render value binding.
Infers the data type from the property type. Sets the element count to one. Sets the uniform transformation to pass-through.
propertyType | Property type. |
|
inline |
Adds a fixed uniform to a shader.
name | The name of the uniform. |
void kanzi::ShaderProgram::CreateInfo::addFixedUniform | ( | string_view | name, |
ShaderProgram::UniformTransformation | transformation | ||
) |
Adds a fixed uniform to a shader.
name | The name of the uniform. |
transformation | Uniform transformation. |
|
inline |
Adds a fixed uniform to a shader.
name | The name of the uniform. |
uniform | The fixed uniform to use. |
void kanzi::ShaderProgram::CreateInfo::addFixedUniform | ( | string_view | name, |
ShaderProgram::FixedUniform | uniform, | ||
ShaderProgram::UniformTransformation | transformation | ||
) |
Adds a fixed uniform to a shader.
name | The name of the uniform. |
uniform | The fixed uniform to use. |
transformation | Uniform transformation. |
|
inline |
Adds a source shader to the program.
type | Shader type. |
source | Shader source code. |
|
inline |
Adds a source shader to the program.
type | Shader type. |
source | Shader source code. |
|
inline |
Adds a binary shader to the program.
type | Shader type. |
binary | Shader binary data. |
vector<ShaderStage> kanzi::ShaderProgram::CreateInfo::shaderSources |
All shader stages in source code format.
unsigned int kanzi::ShaderProgram::CreateInfo::programBinaryFormat |
Format for program binary.
vector<byte> kanzi::ShaderProgram::CreateInfo::programBinaryData |
Program binary data.
unsigned int kanzi::ShaderProgram::CreateInfo::combinedShaderBinaryFormat |
Format for combined shader binary.
vector<byte> kanzi::ShaderProgram::CreateInfo::combinedShaderBinaryData |
Combined shader binary data.
unsigned int kanzi::ShaderProgram::CreateInfo::separateShaderBinaryFormat |
Format for separate shader binaries.
vector<BinaryShaderStage> kanzi::ShaderProgram::CreateInfo::shaderBinaries |
All shader stages in binary format.
UniformContainer kanzi::ShaderProgram::CreateInfo::uniforms |
Uniforms.
ShaderAttributeCollection kanzi::ShaderProgram::CreateInfo::vertexFormat |
Shader vertex attributes.
BindingContainer kanzi::ShaderProgram::CreateInfo::bindings |
Bindings.
bool kanzi::ShaderProgram::CreateInfo::blendingControl |
Indicates whether ShaderProgram created from this createInfo should be able to change blending mode.
When blending control is enabled, materials using a ShaderProgram can set renderer blend mode. If blending control is disabled, materials using a ShaderProgram will leave blend mode unchanged.