D3D11ShaderProgram class
Shader program of the Direct3D 11 backend (aliased as RHI::ShaderProgram).
Carries the offline ShaderCompiler reflection (set with SetReflection() like the OpenGL backend) from which it imports uniforms, uniform blocks and attributes, and creates real ID3D11VertexShader/ID3D11PixelShader objects from the reflection's precompiled DXBC bytecode (HlslVsDxbc/HlslFsDxbc, the normal case) — or, when only HLSL text is embedded, by runtime-compiling HlslVsSource/HlslFsSource (matrix packing forced column-major so the emitter's mul(M,v) column-vector algebra matches the engine's column-major uniform data verbatim; both paths use the same contract). It then reflects the constant buffers into D3D11CBufferSlot lists the device rebinds each draw, and keeps the VS bytecode for building the input layout of attribute-based (mesh/tilemap) shaders. Use() records the program as current on the device.
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
- D3D11ShaderProgram()
- D3D11ShaderProgram(QueryPhase queryPhase) explicit
- D3D11ShaderProgram(StringView vertexFile, StringView fragmentFile, Introspection introspection, QueryPhase queryPhase)
- D3D11ShaderProgram(StringView vertexFile, StringView fragmentFile, Introspection introspection)
- D3D11ShaderProgram(StringView vertexFile, StringView fragmentFile)
- ~D3D11ShaderProgram()
- D3D11ShaderProgram(const D3D11ShaderProgram&) deleted
Public functions
- auto operator=(const D3D11ShaderProgram&) -> D3D11ShaderProgram& 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 and compile HLSL.
- 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) -> D3D11VertexFormat::
Attribute* - void DefineVertexFormat(const D3D11BufferObject* vbo)
- void DefineVertexFormat(const D3D11BufferObject* vbo, const D3D11BufferObject* ibo)
-
void DefineVertexFormat(const D3D11BufferObject* vbo,
const D3D11BufferObject* ibo,
std::
uint32_t vboOffset) - void Reset()
- void SetObjectLabel(StringView label)
- auto GetLogOnErrors() const -> bool
- void SetLogOnErrors(bool shouldLogOnErrors)
-
void SetResolvedUniform(const char* name,
const std::
uint8_t* data) - Publishes a committed loose-uniform value pointer for the device to gather into
_Globals. -
auto ResolveUniform(const char* name) const -> const std::
uint8_t* - Returns the last published value pointer of the named loose uniform, or
nullptr. - auto GetVertexShader() const -> ID3D11VertexShader*
- Returns the compiled vertex shader, or
nullptrif not compiled (e.g. runtime shader with no HLSL). - auto GetPixelShader() const -> ID3D11PixelShader*
- Returns the compiled pixel shader, or
nullptr. - auto GetInputLayout() -> ID3D11InputLayout*
- Returns/creates the input layout for this program's attributes + bound vertex format;
nullptrforSV_VertexIDshaders. - auto HasVertexAttributes() const -> bool
- Returns
trueif the vertex shader reads vertex attributes (needs an input layout + vertex buffer). - auto GetBoundVbo() const -> const D3D11BufferObject*
- Returns the vertex buffer bound by DefineVertexFormat(), or
nullptr. - auto GetBoundIbo() const -> const D3D11BufferObject*
- Returns the index buffer bound by DefineVertexFormat(), or
nullptr. -
auto GetVertexStride() const -> std::
uint32_t - Returns the per-vertex byte stride (from the first enabled attribute of the bound vertex format).
- auto GetVsCBuffers() const -> const CBufferSlotList&
- Constant-buffer slots the vertex stage expects (rebuilt and bound each draw).
- auto GetPsCBuffers() const -> const CBufferSlotList&
- Constant-buffer slots the pixel stage expects.
-
auto GetVsTextureMask() const -> std::
uint32_t - Bitmask of the texture/sampler registers the vertex stage actually reads (bit N = slot tN/sN).
-
auto GetPsTextureMask() const -> std::
uint32_t - Bitmask of the texture/sampler registers the pixel stage actually reads.
Function documentation
void nCine:: RHI:: D3D11:: D3D11ShaderProgram:: SetProgramIdentity(const char* programName,
const char* variantName)
Records the true (program, variant) identity of the loaded shader.
Only the fixed-function console backends consume it (they resolve their generated effect tables from this identity instead of the object label); this backend runs real shaders and ignores it.