Owns a pair of SDL GPU shaders (vertex + fragment) tied to one SDL_GPUDevice.
More...
#include <flint/graphics/shaders.h>
|
| | Shader (SDL_GPUDevice *device, ShaderFormat format) |
| | Construct a Shader bound to device and configured for format binaries.
|
| |
| bool | loadFromMemory (ShaderStage stage, const void *data, size_t size, Uint32 numSamplers=0, Uint32 numStorageTextures=0, Uint32 numStorageBuffers=0, Uint32 numUniformBuffers=0) |
| | Compile and upload a shader stage from bytecode already present in memory.
|
| |
| SDL_GPUShader * | getVertexShader () const |
| | Return the vertex shader handle tracked by this object (nullptr if absent).
|
| |
| SDL_GPUShader * | getFragmentShader () const |
| | Return the fragment shader handle tracked by this object (nullptr if absent).
|
| |
| SDL_GPUDevice * | getDevice () const |
| | Return the SDL GPU device that owns these shaders (may be nullptr before init).
|
| |
| void | cleanup () |
| | Release both shader stages, if present, and reset their handles to nullptr.
|
| |
Owns a pair of SDL GPU shaders (vertex + fragment) tied to one SDL_GPUDevice.
Shaders are loaded from precompiled bytecode via loadFromMemory() and stay alive until cleanup() or destruction, guaranteeing GPU resources are reclaimed even if only one stage was created.
Definition at line 86 of file shaders.h.
◆ Shader()
| Flint::Shader::Shader |
( |
SDL_GPUDevice * | device, |
|
|
ShaderFormat | format ) |
|
inline |
Construct a Shader bound to device and configured for format binaries.
- Parameters
-
| device | SDL GPU device that will own the shader objects. |
| format | Shader bytecode format used to set entry points and SDL formats. |
Definition at line 94 of file shaders.h.
◆ ~Shader()
| virtual Flint::Shader::~Shader |
( |
| ) |
|
|
inlinevirtual |
◆ cleanup()
| void Flint::Shader::cleanup |
( |
| ) |
|
|
inline |
Release both shader stages, if present, and reset their handles to nullptr.
Safe to call multiple times and invoked automatically by the destructor.
Definition at line 192 of file shaders.h.
◆ getDevice()
| SDL_GPUDevice * Flint::Shader::getDevice |
( |
| ) |
const |
|
inline |
Return the SDL GPU device that owns these shaders (may be nullptr before init).
Definition at line 183 of file shaders.h.
◆ getFragmentShader()
| SDL_GPUShader * Flint::Shader::getFragmentShader |
( |
| ) |
const |
|
inline |
Return the fragment shader handle tracked by this object (nullptr if absent).
Definition at line 178 of file shaders.h.
◆ getVertexShader()
| SDL_GPUShader * Flint::Shader::getVertexShader |
( |
| ) |
const |
|
inline |
Return the vertex shader handle tracked by this object (nullptr if absent).
Definition at line 173 of file shaders.h.
◆ loadFromMemory()
| bool Flint::Shader::loadFromMemory |
( |
ShaderStage | stage, |
|
|
const void * | data, |
|
|
size_t | size, |
|
|
Uint32 | numSamplers = 0, |
|
|
Uint32 | numStorageTextures = 0, |
|
|
Uint32 | numStorageBuffers = 0, |
|
|
Uint32 | numUniformBuffers = 0 ) |
|
inline |
Compile and upload a shader stage from bytecode already present in memory.
The supplied data must remain valid for the duration of the call. Reloading a stage replaces any existing SDL shader of the same type after releasing it.
- Parameters
-
| stage | Which stage to load (Vertex or Fragment). |
| data | Pointer to shader bytecode. |
| size | Size of data in bytes. |
| numSamplers | Number of texture samplers declared in the shader. |
| numStorageTextures | Number of storage textures declared in the shader. |
| numStorageBuffers | Number of storage buffers declared in the shader. |
| numUniformBuffers | Number of uniform buffers declared in the shader. |
- Returns
- true if creation succeeded; false if SDL reports an error.
Definition at line 119 of file shaders.h.
◆ m_device
| SDL_GPUDevice* Flint::Shader::m_device = nullptr |
|
protected |
◆ m_format
| ShaderFormat Flint::Shader::m_format |
|
protected |
◆ m_fragmentShader
| SDL_GPUShader* Flint::Shader::m_fragmentShader = nullptr |
|
protected |
◆ m_vertexShader
| SDL_GPUShader* Flint::Shader::m_vertexShader = nullptr |
|
protected |
The documentation for this class was generated from the following file: