class Variation

Variation is a set of shading passes bindable to the GPU pipeline.

Each shader has at least one variation, but many have multiple. Each variation is typically compiled with different set of preprocessor defines enabling or disabling specific features of the shader. A shader may also have multiple variations for different rendering backends (e.g. DirectX, OpenGL, Vulkan, etc.).

Public

Constructors

Variation

Variation(const WeakSPtr<Shader> &owner, const String &language, const ShaderVariationParameters &variationParameters, const TOptional<PrecompiledVariationData> &precompiledData)

Methods

staticCreate

static SPtr<Variation> Create(const WeakSPtr<Shader> &owner, const String &language, const ShaderVariationParameters &variationParameters, const TOptional<PrecompiledVariationData> &precompiledData = {})

Creates a new variation.

owner
Shader that owns the variation.
language
Shading language used by the variation. The engine will not use this variation unless this language is supported by the render backend.
variationParameters
Variation parameters used for compiling this variation.
precompiledData
Optional set of precompiled variation data. If not provided, you must manually call Compile() on the variation before use.

Returns: Newly creted variation.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

~TVariation<IsRenderProxy>

virtual ~TVariation<IsRenderProxy>() = default

GetPass

SPtr<PassType> GetPass(u32 passIndex) const

Returns a pass with the specified index.

GetPassCount

u32 GetPassCount() const

Returns total number of passes.

Compile

TAsyncOp<bool> Compile()

Compiles the variation in case it was not initialized with precompiled data.

IsCompiled

bool IsCompiled() const

Returns true if the variation has been fully compiled.

Internal

Methods

SetCompiledPassData

void SetCompiledPassData(TInlineArray<SPtr<PassType>, 1> compiledPasses)

Assigns a set of compiled passes to the variation.

This should be called only when a variation has not been initialized with precompiled pass data, and compilation for the variation finished.

SetOwner

void SetOwner(const WeakSPtr<ShaderType> &owner)

Sets the shader that owns this variation.

Protected

Methods

CreateRenderProxy

SPtr<render::RenderProxy> CreateRenderProxy() const override

Creates an object that contains render thread specific data and methods for this object.

Can be null if such object is not required.

GetCoreDependencies

void GetCoreDependencies(Vector<CoreObject *> &dependencies) override

Populates the provided array with all core objects that this core object depends upon.

Dependencies are required for syncing to the render thread, so the system can be aware to update the dependant objects if a dependency is marked as dirty (for example updating a camera's viewport should also trigger an update on camera so it has a chance to potentially update its data).

MarkRenderProxyDirty

void MarkRenderProxyDirty(ShaderVariationDirtyFlags flags) override

Marks the contents as dirty, causing it to sync with the render thread object.

CreateRenderProxySyncPacket

RenderProxySyncPacket *CreateRenderProxySyncPacket(FrameAllocator &allocator, u32 flags) override

Creates a data packet that will be used for syncing the core object with it's render proxy.

Caller must free the retrieved packet using the provided allocator when done using it.

SyncToRenderProxy

void SyncToRenderProxy() override

Ensures all dirty syncable data is send to the render proxy (if any).

GetSelf

SPtr<Variation> GetSelf() override

Returns a reference to itself using the most derived type.

staticCreateEmpty

static SPtr<Variation> CreateEmpty()

Creates a new variation but doesn't initialize it.

Fields

mOwner

WeakSPtr<ShaderType> mOwner

mPasses

TInlineArray<SPtr<PassType>, 1> mPasses

mHasPassData

bool mHasPassData

mIsCompiled

bool mIsCompiled

Private

Constructors

Variation

Variation()

Serialization only constructor.