stride3d/stride · error · NotImplementedException
Variable initializer is not supported on streams variable
Error message
Variable initializer is not supported on streams variable
What it means
StreamAnalyzer.Analyze collects stream (interface) variables. A stream variable with an initializer would imply the interface variable has a default value, which SPIR-V interface variables don't support, so a VariableFlagsMask.Stream variable with MethodOrConstantInitializer set throws NotImplementedException.
Solutions
- Remove the initializer from the stream/interface variable declaration
- Initialize the value inside the stage function body instead (e.g. assign at the start of the shader)
- Ensure no compiler transformation attaches initializers to stream-flagged variables
Example fix
// before (SDSL) stage float3 Normal = float3(0, 1, 0); // after stage float3 Normal; // assign inside the stage body instead
Defensive patterns
Strategy: validation
Validate before calling
if (variable.Flags.HasFlag(VariableFlagsMask.Stream) && variable.MethodOrConstantInitializer != null)
throw new NotSupportedException($"Stream variable {variable.ResultId} must not have an initializer"); Type guard
bool IsPlainStreamVariable(VariableInfo v) => v.Flags.HasFlag(VariableFlagsMask.Stream) && v.MethodOrConstantInitializer is null;
Try / catch
try { analyzer.Analyze(module); } catch (NotImplementedException ex) { logger.LogError(ex, "Stream variable with initializer"); throw; } Prevention
- Declare stream/interface variables without initializers
- Move default values into the shader body
- Audit transformations for initializer propagation onto stream variables
When it happens
Trigger: Declaring a `streams` input/output variable with an initializer (e.g. `float3 Normal = float3(0,1,0);` on a stream variable) so the SPIR-V OpVariable carries an Initializer operand while flagged Stream.
Common situations: SDSL shader giving a default value to an in/out interface variable; a transformation copying a constant initializer onto a stream variable.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Can't write value on input or output struct
- OpAccessChain on PatchType/array-of-Streams can have only 1…
- 64bit integers
- Can't add type
- Could not load shader
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/f366457735f14e98.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Spirv/Processing/Interfaces/Analysis/StreamAnalyzer.cs:105
if (i.Op == Op.OpVariableSDSL && ((OpVariableSDSL)i) is
{
StorageClass: StorageClass.Private or StorageClass.Workgroup or StorageClass.Uniform,
ResultId: int
} variable
&& context.ReverseTypes[variable.ResultType] is PointerType { BaseType: not ConstantBufferSymbol })
{
var name = nameTable.TryGetValue(variable.ResultId, out var nameId)
? nameId
: $"unnamed_{variable.ResultId}";
var type = (PointerType)context.ReverseTypes[variable.ResultType];
if (variable.Flags.HasFlag(VariableFlagsMask.Stream))
{
semanticTable.TryGetValue(variable.ResultId, out var semantic);
if (variable.MethodOrConstantInitializer != null)
throw new NotImplementedException("Variable initializer is not supported on streams variable");
streams.Add(variable.ResultId, new StreamVariableInfo(semantic, name, type, variable.ResultId) { Patch = patchVariables.Contains(variable.ResultId) });
}
else
{
variables.Add(variable.ResultId, new VariableInfo(name, type, variable.ResultId)
{
VariableMethodInitializerId = variable.MethodOrConstantInitializer,
});
}
}
if (i.Op == Op.OpVariableSDSL && ((OpVariableSDSL)i) is
{
StorageClass: StorageClass.UniformConstant or StorageClass.StorageBuffer,
ResultId: int
} resource)
{View on GitHub (pinned to 96fad776d2)