SwShaderProgram class
Shader program of the software backend (aliased as RHI::ShaderProgram).
Does not compile or link GLSL. Instead it carries the offline ShaderCompiler reflection (set with SetReflection() exactly like the OpenGL backend) from which it imports uniforms, uniform blocks and attributes, and a SwEffect identity derived from its object label that tells the device which hand-written C++ effect to run. Use() records the program as current on the device; committed loose-uniform values are published back here so the effect can read them.
Public types
- enum class Introspection { Enabled, NoUniformsInBlocks, Disabled }
- enum class Status { NotLinked, CompilationFailed, LinkingFailed, Linked, LinkedWithDeferredQueries, LinkedWithIntrospection }
- enum class QueryPhase { Immediate, Deferred }
Public static variables
-
static std::
int32_t DefaultBatchSize constexpr - Default batch size, indicating the shader is not batched.
Constructors, destructors, conversion operators
- SwShaderProgram()
- SwShaderProgram(QueryPhase queryPhase) explicit
- SwShaderProgram(StringView vertexFile, StringView fragmentFile, Introspection introspection, QueryPhase queryPhase)
- SwShaderProgram(StringView vertexFile, StringView fragmentFile, Introspection introspection)
- SwShaderProgram(StringView vertexFile, StringView fragmentFile)
- ~SwShaderProgram()
- SwShaderProgram(const SwShaderProgram&) deleted
Public functions
- auto operator=(const SwShaderProgram&) -> SwShaderProgram& deleted
-
auto GetUniqueId() const -> std::
uint32_t - Returns a backend-neutral identifier uniquely identifying the program (feeds material sort keys).
- auto GetStatus() const -> Status
- auto GetIntrospection() const -> Introspection
- auto GetQueryPhase() const -> QueryPhase
-
auto GetBatchSize() const -> std::
uint32_t -
void SetBatchSize(std::
uint32_t value) - auto IsLinked() const -> bool
-
auto RetrieveInfoLogLength() const -> std::
uint32_t -
void RetrieveInfoLog(std::
string& infoLog) const -
auto GetUniformsSize() const -> std::
uint32_t -
auto GetUniformBlocksSize() const -> std::
uint32_t - auto AttachShaderFromFile(ShaderStage stage, StringView filename) -> bool
- auto AttachShaderFromString(ShaderStage stage, StringView string) -> bool
- auto AttachShaderFromStrings(ShaderStage stage, ArrayView<const StringView> strings) -> bool
- auto AttachShaderFromStringsAndFile(ShaderStage stage, ArrayView<const StringView> strings, StringView filename) -> bool
-
void SetReflection(const ShaderCompiler::
ProgramVariant* reflection) - Sets the offline reflection consumed by Link() to import uniforms/blocks/attributes.
- auto Link(Introspection introspection) -> bool
- void Use()
- auto Validate() -> bool
- auto FinalizeAfterLinking(Introspection introspection) -> bool
-
auto GetAttributeCount() const -> std::
uint32_t - auto HasAttribute(const char* name) const -> bool
-
auto GetAttribute(const char* name) -> SwVertexFormat::
Attribute* - void DefineVertexFormat(const SwBuffer* vbo)
- void DefineVertexFormat(const SwBuffer* vbo, const SwBuffer* ibo)
-
void DefineVertexFormat(const SwBuffer* vbo,
const SwBuffer* ibo,
std::
uint32_t vboOffset) - void Reset()
- void SetObjectLabel(StringView label)
- auto GetLogOnErrors() const -> bool
- void SetLogOnErrors(bool shouldLogOnErrors)
- auto GetEffect() const -> SwEffect
- Returns the C++ effect this program dispatches to.
- auto GetObjectLabel() const -> const char*
- Returns the object label the program was tagged with (the shader name), or an empty string.
- auto IsDitherVariant() const -> bool
- Returns
trueif the program is the dithering variant of its effect (derived from the label). -
auto GetReflection() const -> const ShaderCompiler::
ProgramVariant* - Returns the offline reflection last set on the program (kept for the effects to read).
- auto FindBlock(const char* name) const -> const SwUniformBlock*
- Returns the imported metadata of the uniform block with the given name, or
nullptr. -
void SetResolvedUniform(const char* name,
const std::
uint8_t* data) - Publishes a committed loose-uniform value pointer for the effects to read.
-
auto ResolveUniform(const char* name) const -> const std::
uint8_t* - Returns the last published value pointer of the named loose uniform, or
nullptr.