Class EffectInstance
Represents an instance of an Effect, including its values and Graphics Resources to bind (such as Textures, Buffers, or SamplerStates).
public class EffectInstance : DisposeBase, IDisposable, IReferencable
- Inheritance
-
objectEffectInstance
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
EffectInstance(Effect, ParameterCollection?)
Represents an instance of an Effect, including its values and Graphics Resources to bind (such as Textures, Buffers, or SamplerStates).
public EffectInstance(Effect effect, ParameterCollection? parameters = null)
Parameters
effectEffectThe Effect that will be used by the Effect instance.
parametersParameterCollectionAn optional collection of parameters that can be used to customize the Effect instance. Specify null to use the default parameters.
Fields
permutationCounter
protected int permutationCounter
Field Value
Properties
DescriptorReflection
Gets a reflection object that describes the Descriptor Sets and their layouts for the Effect
used by this instance.
This includes the bindings for Graphics Resources such as Textures, Buffers,
and SamplerStates.
public EffectDescriptorSetReflection DescriptorReflection { get; }
Property Value
Effect
Gets the Effect currently used by this instance.
public Effect Effect { get; protected set; }
Property Value
Parameters
Gets the collection of parameters used by this Effect instance.
public ParameterCollection Parameters { get; }
Property Value
RootSignature
Gets the Root Signature associated with the current graphics pipeline.
public RootSignature RootSignature { get; }
Property Value
Remarks
A Root Signature is used to specify how Graphics Resources, such as Textures and Buffers, are bound to the graphics pipeline (i.e. how DescriptorSet will be bound together).
Methods
Apply(GraphicsContext)
Applies the current parameters set for this Effect instance to the provided graphics context, updating bound Graphics Resources, uploading Constant Buffers, etc.
public void Apply(GraphicsContext graphicsContext)
Parameters
graphicsContextGraphicsContextThe graphics context to which the Effect parameters will be applied. This context must be valid and initialized before calling this method.
Exceptions
- ArgumentNullException
graphicsContextis null.
ChooseEffect()
Selects and compiles the appropriate Effect based on the current parameters.
protected virtual void ChooseEffect()
Remarks
When overridden in a derived class, this method should implement the logic to select and compile the Effect based on the current set of parameters, for example, by using the permutation parameters set in Parameters to compile a specific version of the Effect.
Destroy()
Disposes the object's resources.
protected override void Destroy()
Remarks
Override in a derived class to implement disposal logic specific to it.
This method is automatically called whenever a call to Dispose() (or to Release()) has decreased the internal reference count to zero, meaning no other objects (hopefully) hold a reference to this one and its resources can be safely released.
UpdateEffect(GraphicsDevice)
Updates the Effect associated with this instance.
public bool UpdateEffect(GraphicsDevice graphicsDevice)
Parameters
graphicsDeviceGraphicsDeviceThe Graphics Device to which the Effect is applied.
Returns
Remarks
This method checks if the Effect needs to be updated based on changes in the permutation parameters or the source of the Effect. If an update is necessary, it reinitializes the Effect, updates the reflection information, and prepares the necessary Graphics Resources and data.