nCine::RHI::GX::GxShaderProgram class

Shader program of the GX 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 the true (program, variant) identity plumbed by the loaders with SetProgramIdentity(), from which the generated fixed-function effect of the program is resolved (see GetGeneratedEffect()) - the object label is kept for logging only. 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

GxShaderProgram()
GxShaderProgram(QueryPhase queryPhase) explicit
GxShaderProgram(StringView vertexFile, StringView fragmentFile, Introspection introspection, QueryPhase queryPhase)
GxShaderProgram(StringView vertexFile, StringView fragmentFile, Introspection introspection)
GxShaderProgram(StringView vertexFile, StringView fragmentFile)
~GxShaderProgram()
GxShaderProgram(const GxShaderProgram&) deleted

Public functions

auto operator=(const GxShaderProgram&) -> GxShaderProgram& 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.
void SetProgramIdentity(const char* programName, const char* variantName)
Records the true (program, variant) identity of the loaded shader.
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) -> GxVertexFormat::Attribute*
void DefineVertexFormat(const GxBuffer* vbo)
void DefineVertexFormat(const GxBuffer* vbo, const GxBuffer* ibo)
void DefineVertexFormat(const GxBuffer* vbo, const GxBuffer* ibo, std::uint32_t vboOffset)
auto GetBoundVbo() const -> const GxBuffer*
Returns the vertex buffer last bound by DefineVertexFormat(), or nullptr.
auto GetBoundVboOffset() const -> std::uint32_t
Returns the byte offset into GetBoundVbo() the vertex data starts at.
void Reset()
void SetObjectLabel(StringView label)
auto FetchUnsupportedWarned() -> bool
Returns whether the "unsupported effect" warning was already emitted for this program, and marks it emitted.
auto GetLogOnErrors() const -> bool
void SetLogOnErrors(bool shouldLogOnErrors)
auto GetGeneratedEffect() const -> const FixedFunctionGeneratedEffect*
Returns the generated fixed-function effect of this program variant, or nullptr.
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 true if the program was compiled as the DITHER variant of its shader.
auto UsesPalette() const -> bool
Returns true if the program samples indexed textures through the palette texture (its reflection binds uTexturePalette).
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 GxUniformBlock*
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.
auto GetResolvedProjectionMatrix() const -> const std::uint8_t*
Returns the last published uProjectionMatrix value pointer without the by-name scan (read per draw).
auto GetResolvedViewMatrix() const -> const std::uint8_t*
Returns the last published uViewMatrix value pointer without the by-name scan (read per draw).

Function documentation

void nCine::RHI::GX::GxShaderProgram::SetProgramIdentity(const char* programName, const char* variantName)

Records the true (program, variant) identity of the loaded shader.

programName is the .shader program name and variantName the variant define it was compiled with (empty/null for the base variant) - the exact key of the generated fixed-function tables, plumbed by ContentResolver and RenderResources. Set it together with SetReflection(), before Link(); the table lookup runs at link time.

const FixedFunctionGeneratedEffect* nCine::RHI::GX::GxShaderProgram::GetGeneratedEffect() const

Returns the generated fixed-function effect of this program variant, or nullptr.

Resolved once at link time from the (program, variant) identity set with SetProgramIdentity() against the table the ShaderCompiler transpiled from the shaders' fixed_function blocks. The dispatch runs its function (or the backend pipeline stage its pipeline intrinsic names); a null entry is skipped with a one-time warning.