1 #ifndef DONUT_GRAPHICS_SHADER_PROGRAM_HPP
2 #define DONUT_GRAPHICS_SHADER_PROGRAM_HPP
18 class ShaderParameter;
377 uniformUploadQueue.clear();
384 textureBindings.clear();
396 return uniformUploadQueue;
408 [[nodiscard]] std::span<const std::pair<std::int32_t, const Texture*>>
getTextureBindings() const noexcept {
409 return textureBindings;
423 return program.
get();
427 struct ProgramDeleter {
428 void operator()(
Handle handle)
const noexcept;
432 ShaderStage vertexShader;
433 ShaderStage fragmentShader;
434 std::vector<std::pair<std::int32_t, UniformValue>> uniformUploadQueue{};
435 std::vector<std::pair<std::int32_t, const Texture*>> textureBindings{};
constexpr Handle get() const noexcept
Get the value of the underlying resource handle.
Definition: UniqueHandle.hpp:152
Tagged union value type that holds a value of one of the given types.
Definition: Variant.hpp:291
Identifier for a uniform shader variable inside a ShaderProgram.
Definition: ShaderParameter.hpp:17
Compiled and linked GPU shader program.
Definition: ShaderProgram.hpp:46
void setUniformIVec2(const ShaderParameter ¶meter, i32vec2 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec2.
void setUniformVec2(const ShaderParameter ¶meter, vec2 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type vec2.
void setUniformVec4(const ShaderParameter ¶meter, vec4 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type vec4.
void setUniformFloat(const ShaderParameter ¶meter, float value)
Enqueue a new value to be set for a uniform shader variable of GLSL type float.
Handle get() const noexcept
Get an opaque handle to the GPU representation of the shader program.
Definition: ShaderProgram.hpp:422
void setUniformMat2(const ShaderParameter ¶meter, const mat2 &value)
Enqueue a new value to be set for a uniform shader variable of GLSL type mat2.
ShaderProgram(const ShaderProgramOptions &options)
Compile and link a shader program.
std::span< const std::pair< std::int32_t, const Texture * > > getTextureBindings() const noexcept
Get the list of active texture bindings to be synchronized with the shader.
Definition: ShaderProgram.hpp:408
void setUniformMat3(const ShaderParameter ¶meter, const mat3 &value)
Enqueue a new value to be set for a uniform shader variable of GLSL type mat3.
void setUniformUVec2(const ShaderParameter ¶meter, u32vec2 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec2.
void setUniformSampler(const ShaderParameter ¶meter, const Texture *texture)
Insert a new texture to be bound for a uniform shader variable of a GLSL sampler type.
void setUniformIVec4(const ShaderParameter ¶meter, i32vec4 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec4.
void setUniformIVec3(const ShaderParameter ¶meter, i32vec3 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec3.
std::span< const std::pair< std::int32_t, UniformValue > > getUniformUploadQueue() const noexcept
Get the list of new uniform shader variable values to be uploaded to the shader.
Definition: ShaderProgram.hpp:395
void setUniformVec3(const ShaderParameter ¶meter, vec3 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type vec3.
void setUniformUVec3(const ShaderParameter ¶meter, u32vec3 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec3.
void setUniformUVec4(const ShaderParameter ¶meter, u32vec4 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec4.
void setUniformUint(const ShaderParameter ¶meter, u32 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type uint.
void setUniformMat4(const ShaderParameter ¶meter, const mat4 &value)
Enqueue a new value to be set for a uniform shader variable of GLSL type mat4.
void clearUniformUploadQueue() noexcept
Erase all entries from the queue of new uniform shader variable values.
Definition: ShaderProgram.hpp:376
void setUniformInt(const ShaderParameter ¶meter, i32 value)
Enqueue a new value to be set for a uniform shader variable of GLSL type int.
void clearTextureBindings() noexcept
Erase all entries from the list of active texture bindings.
Definition: ShaderProgram.hpp:383
Storage for multidimensional data, such as 2D images, on the GPU, combined with a sampler configurati...
Definition: Texture.hpp:75
std::uint32_t Handle
Generic GPU resource handle.
Definition: Handle.hpp:11
Configuration options for a ShaderProgram.
Definition: ShaderProgram.hpp:23
const char * definitions
Non-owning pointer to GLSL source code for constant definitions to add to the beginning of the source...
Definition: ShaderProgram.hpp:28
const char * fragmentShaderSourceCode
Non-owning pointer to the GLSL source code for the fragment shader stage, or nullptr to use the built...
Definition: ShaderProgram.hpp:40
const char * vertexShaderSourceCode
Non-owning pointer to the GLSL source code for the vertex shader stage, or nullptr to use the built-i...
Definition: ShaderProgram.hpp:34