stride3d/stride · error · NotImplementedException
SamplerState parameter
Error message
SamplerState parameter '{parameter.Name}' not implemented What it means
The SDSL-to-SPIR-V compiler supports only a fixed set of inline SamplerState parameters (e.g. MinLOD, MaxLOD, BorderColor). Any other parameter name hits Compile's switch default and throws NotImplementedException, meaning that sampler state option has no SPIR-V translation yet.
Solutions
- Remove the unsupported inline parameter and configure that state at runtime via Parameters.Set().
- Use only the parameter names supported by the compiler (see the switch in ShaderElements.MethodOrMember.cs).
- Implement the equivalent behavior in shader code if no parameter equivalent exists.
Example fix
// before SamplerState Sampler : MaxAnisotropy(8); // after SamplerState Sampler; // configure at runtime via Parameters.Set()
Defensive patterns
Strategy: validation
Validate before calling
var supported = new HashSet<string> { "MinLOD", "MaxLOD", "BorderColor" };
foreach (var p in sampler.Parameters)
if (!supported.Contains(p.Name)) Console.WriteLine($"Unsupported sampler parameter: {p.Name}"); Try / catch
try { sampler.Compile(); }
catch (NotImplementedException ex) when (ex.Message.StartsWith("SamplerState parameter"))
{
// move that state to runtime Parameters.Set() and recompile
} Prevention
- Use only inline sampler parameters supported by the SPIR-V backend.
- Configure exotic sampler state at runtime via Parameters.Set() rather than inline declarations.
When it happens
Trigger: Declaring a sampler with an inline parameter that has no case in Compile's switch, e.g. `SamplerState Sampler : AddressU(CLAMP);` or MaxAnisotropy.
Common situations: Porting D3D11_SAMPLER_DESC fields (Filter, ComparisonFunc, MaxAnisotropy, addressing modes) into SDSL inline parameters unsupported by the SPIR-V backend.
Related errors
- Assign back to matrix swizzle is not implemented yet
- Unsupported interlocked operation
- BorderColor must be float4(r, g, b, a)
- Can't parse method attribute
- Exception of type 'System.NotImplementedException' was…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/e977770edb85fa67.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/ShaderElements.MethodOrMember.cs:115
break;
case "MinLOD":
minLOD = BitConverter.SingleToInt32Bits((float)((FloatLiteral)parameter.Value).Value);
break;
case "MaxLOD":
maxLOD = BitConverter.SingleToInt32Bits((float)((FloatLiteral)parameter.Value).Value);
break;
case "BorderColor":
{
if (parameter.Value is not VectorLiteral { TypeName.Name: "float4", Values: { Count: 4 } args })
throw new NotSupportedException($"BorderColor must be float4(r, g, b, a)");
borderR = BitConverter.SingleToInt32Bits((float)((NumberLiteral)args[0]).DoubleValue);
borderG = BitConverter.SingleToInt32Bits((float)((NumberLiteral)args[1]).DoubleValue);
borderB = BitConverter.SingleToInt32Bits((float)((NumberLiteral)args[2]).DoubleValue);
borderA = BitConverter.SingleToInt32Bits((float)((NumberLiteral)args[3]).DoubleValue);
break;
}
default:
throw new NotImplementedException($"SamplerState parameter '{parameter.Name}' not implemented");
}
}
// Only emit immutable sampler state when the declaration has explicit parameters.
// Samplers without inline state (e.g. "stage SamplerState Sampler;") are dynamic
// and set at runtime via Parameters.Set().
if (Parameters.Count > 0)
{
context.Add(new OpDecorate(variableId, Specification.Decoration.SamplerStateSDSL, [
filter, addressU, addressV, addressW, mipLODBias, maxAnisotropy, comparisonFunc, minLOD, maxLOD,
borderR, borderG, borderB, borderA
]));
}
var variable = builder.Insert(new OpVariableSDSL(registeredType, variableId, Specification.StorageClass.UniformConstant, IsStaged ? Specification.VariableFlagsMask.Stage : Specification.VariableFlagsMask.None, null));
context.AddName(variable.ResultId, Name);
Symbol!.IdRef = variableId;
RGroup.DecorateVariableLinkInfo(table, shader, context, Info, Name, Attributes, variable);View on GitHub (pinned to 96fad776d2)