unoplatform/uno · error · Exception

{type} compile failed: {infoLog}

Error message

{type} compile failed: {infoLog}

What it means

CompileShader in IntegerTexturesGlCanvasElement throws the shader info log on compile failure. Integer-texture GLSL constructs (usampler2D, uvec4 outputs, integer built-in conversions) require ES 3.00 / GL 330+, so compile errors here are almost always version-related.

Source

Thrown at src/SamplesApp/SamplesApp.Samples/Windows_UI_Composition/IntegerTexturesGlCanvasElement.cs:268

			{
				throw new Exception("Program link failed: " + gl.GetProgramInfoLog(prog));
			}
			gl.DetachShader(prog, vs);
			gl.DetachShader(prog, fs);
			gl.DeleteShader(vs);
			gl.DeleteShader(fs);
			return prog;
		}

		private static uint CompileShader(GL gl, ShaderType type, string source)
		{
			var sh = gl.CreateShader(type);
			gl.ShaderSource(sh, source);
			gl.CompileShader(sh);
			gl.GetShader(sh, ShaderParameterName.CompileStatus, out int status);
			if (status != (int)GLEnum.True)
			{
				throw new Exception($"{type} compile failed: " + gl.GetShaderInfoLog(sh));
			}
			return sh;
		}
	}
}
#endif

View on GitHub (pinned to 0418340488)

Solutions

  1. Read the info log and fix the flagged token/line.
  2. Declare #version 300 es (or 330) for unsigned integer types and samplers.
  3. Add required #extension directives for image load/store if used.
  4. Add precision qualifiers (highp) for integer fragment types where required.

Example fix

// before — unsigned types under old version
#version 120
uniform usampler2D uTex; out uvec4 frag; // unsupported

// after
#version 300 es
precision highp int;
uniform usampler2D uTex; layout(location=0) out uvec4 frag;
Defensive patterns

Strategy: try-catch

Validate before calling

if ((source.Contains("usampler") || source.Contains("uvec")) && !source.Contains("#version 300"))
    throw new InvalidOperationException("Unsigned integer GLSL requires #version 300 es / GL 330.");

Try / catch

try { return CompileShader(gl, type, source); }
catch (Exception ex) { throw new InvalidOperationException($"{type} compile failed: {ex.Message}\n{source}", ex); }

Prevention

When it happens

Trigger: `uvec4`/`usampler2D`/`uint` used under #version 100 or 110; integer output declaration syntax invalid for the version; `imageStore`/`imageLoad` without the matching extension; missing precision on integer types in fragment.

Common situations: Sample auto-selected on a WebGL1 canvas; shader written for GL 330 desktop run on ES; missing `#extension` for image load/store.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/952c5e56e112078a. Report an issue: GitHub.