RenderEffect
Description
- Derived from
-
Disposable abstract
IRenderEffectParameters - Extended by
-
RenderEffectGeneric abstract
Non-generic abstract base class of RenderEffectGeneric.
From a high-level perspective, a render effect object provides an abstraction that makes it possible to use the effect in a uniform way, regardless of the actual GPU/API-specific implementation underneath:
-
Demarcation methods for activating any of the render effect passes:
IBeginEnd.Begin, IRenderEffectBase.Pass, IBeginEnd.End. -
Accessor methods for setting the render effect parameters and updating them during rendering:
IRenderEffect.Parameters, IRenderEffectBase.Apply.
Seen from a low-level perspective, a render effect object encapsulates the following GPU entities:
-
One or more shader programs of different types (e.g. pixel shader, vertex shader). Usually written in a shading language (e.g. HLSL, GLSL), shader programs are compiled into shader binaries at build-time using an external tool (e.g.
fxc
,dxc
,glslc
) or at run-time using some compiler service of the API (e.g. OpenGL). The shader binaries are loaded by the render effect object. -
Management of logical parameter slots, based on the parameters that are defined in the shader programs. For example, the same parameter definition in a Direct3D9 shader program may be mapped to different shader types (VS, PS) and passes.
-
GPU render states for each render effect pass (e.g. state block management for Direct3D 9).
-
Handling of render effect parameter values (e.g. constant buffer management for Direct3D 11).
-
Handling of input resources, such as textures and samplers.
Protected / Methods
BuildComponents
Builds the common render effect components by calling RenderEffectParameters.EffectComponents.
This method will be called automatically (with flags opt = 0) when RenderEffectParameters.Declare is called at the end of the concrete implementations constructor. Calling this method multiply times is allowed, but has no further effect.
- RenderException
-
If a graphics subsystem error has occurred.
DoBuildComponents
Returns a IRenderEffectComponents object for building the common parts of this render effect.
DoParameterDeclare
Declares a render effect parameter.
- RenderException
-
If a graphics subsystem error has occurred.
DoShaderCreate
Creates a shader object.
- IOException
-
If an error has occurred while loading the shader binary and/or metadata.
- ValidatingException
-
If the shader metadata has an unsupported format and cannot be decoded.
- RenderException
-
If a graphics subsystem error has occurred.
PassCreate
Creates a render effect pass.
After calling this method, IRenderEffectBase.PassAvailable will return true
and IRenderEffectBase.PassCount will be equal to or greater than pass in + 1. Calling this method multiple times for the same pass in is allowed but has no effect.
ShaderAssign
Assigns a shader object to an effect pass.
The given render effect pass in must have been created with PassCreate before this method may be called.
ShaderCreate
Creates a shader object.
- IOException
-
If an error has occurred while loading the shader binary and/or metadata.
- ValidatingException
-
If the shader metadata has an unsupported format and cannot be decoded.
- RenderException
-
If a graphics subsystem error has occurred.