canvaskit-wasm 0.39 build 2026-04-29

SkSLUniform

Metadata describing one uniform declared in a RuntimeEffect's SkSL source. Returned by effect.getUniform(i) — pair with effect.getUniformName(i) to walk a program's uniform layout at runtime.

const effect = CK.RuntimeEffect.Make(`
  uniform float u_time;
  uniform float2 u_resolution;
  uniform half3x3 u_color_xform;
  half4 main(float2 xy) { return half4(0.0, 0.0, 0.0, 1.0); }
`);

for (let i = 0; i < effect.getUniformCount(); i++) {
  const u = effect.getUniform(i);
  console.log(effect.getUniformName(i), u);
  // u_time         { columns:1, rows:1, slot:0, isInteger:false }
  // u_resolution   { columns:2, rows:1, slot:1, isInteger:false }
  // u_color_xform  { columns:3, rows:3, slot:3, isInteger:false }
}

columns × rows = number of float slots one uniform consumes (float = 1×1, float2 = 2×1, mat3 = 3×3 = 9). slot is the offset into the flat uniforms array you pass to makeShader; slot + columns*rows is where the next uniform begins. getUniformFloatCount() returns the total float count across all uniforms.

Fields

FieldTypeNotes
columnsnumberVector width / matrix column count.
rowsnumberMatrix row count (1 for scalars and vectors).
slotnumberIndex into the flat uniforms array where this uniform starts.
isIntegerbooleanTrue for int / int2 etc.; false for floats.

See also