Table of Contents

Class SkslUniform

Namespace
ShadowDusk.Compiler.Sksl
Assembly
ShadowDusk.Compiler.dll

One non-child uniform of an SkslConversion (see Uniforms).

public sealed record SkslUniform : IEquatable<SkslUniform>
Inheritance
SkslUniform
Implements
Inherited Members

Constructors

SkslUniform(string, string, int)

One non-child uniform of an SkslConversion (see Uniforms).

public SkslUniform(string Name, string SkslType, int ArrayLength)

Parameters

Name string

The SkSL uniform name, the key for SKRuntimeEffectUniforms: the HLSL global's name, or the synthesized uniform's (ShadowDusk_Color, ShadowDusk_Resolution, in_var_<SEMANTIC>). A global whose name GLSL cannot take comes out of SPIRV-Cross renamed (input is _input, a__b is a_b, gl_X is _RESERVED_IDENTIFIER_FIXUP_gl_X), and that is the name listed here, with the renamed global's default (paired through the SPIR-V member names, never guessed from the spelling).

SkslType string

The declared type as emitted, e.g. float, vec4, mat4, int.

ArrayLength int

The element count of an array uniform, or 0 for a non-array.

Properties

ArrayLength

The element count of an array uniform, or 0 for a non-array.

public int ArrayLength { get; init; }

Property Value

int

DefaultValue

The default the HLSL declaration gives this uniform (float Thickness = 1.0;), or null when it is unknown: the same values, in the same layout, as DefaultValue on the MGFX route for the same source (issue #435).

public IReadOnlyList<float>? DefaultValue { get; init; }

Property Value

IReadOnlyList<float>

Remarks

Layout. Array element after array element, each element in logical row-major order (the HLSL cell at row r, column c of a floatRxC is at r * C + c), no padding. This is exactly the float list to hand Skia: SkSL packs uniforms tightly, and DXC declares an HLSL floatRxC as a matRxC whose column i is HLSL row i, so Skia's column-major matrix data is the HLSL rows in order, whatever the HLSL packing (row_major or not). So uniforms[u.Name] = u.DefaultValue.ToArray() sets the declared default for a vecN or matN uniform and arrays of them (SkiaSharp takes a scalar uniform as the single value, u.DefaultValue[0]); an int or ivecN uniform takes the same values as integers.

Values. int values converted to floats, uint values by their unsigned value (so one beyond 2^24 is not exact), bool as 0 or 1 (SkSL itself has no uint or bool uniforms, which Skia's compiler rejects). The converter compiles with the OpenGL macro set, so this is the MGFX route's value for an OpenGL build; a default chosen under #if OPENGL can differ on DirectX.

Degenerate shapes. The shape is the converted uniform's: float1 F = 0.5; is a float uniform with [0.5] (the MGFX route reports none, with SD0017), while float1x1, float1xN and floatNx1 come out of DXC as a scalar, a vector or an array and are null with SD0017 (the MGFX route has a value).

When it is null. The global has no initializer; the initializer could not be evaluated, or its shape does not match the uniform (the conversion then carries the MGFX route's SD0017 warning); or the uniform has no HLSL declaration (a synthesized uniform). A global with a default that no listed uniform could be paired with is an SD0017 warning too. Child shaders (textures and samplers) are not listed.

Name

The SkSL uniform name, the key for SKRuntimeEffectUniforms: the HLSL global's name, or the synthesized uniform's (ShadowDusk_Color, ShadowDusk_Resolution, in_var_<SEMANTIC>). A global whose name GLSL cannot take comes out of SPIRV-Cross renamed (input is _input, a__b is a_b, gl_X is _RESERVED_IDENTIFIER_FIXUP_gl_X), and that is the name listed here, with the renamed global's default (paired through the SPIR-V member names, never guessed from the spelling).

public string Name { get; init; }

Property Value

string

SkslType

The declared type as emitted, e.g. float, vec4, mat4, int.

public string SkslType { get; init; }

Property Value

string

Methods

Equals(SkslUniform?)

Value equality, comparing DefaultValue element by element.

public bool Equals(SkslUniform? other)

Parameters

other SkslUniform

The uniform to compare with.

Returns

bool

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.