Zebediah Figura (@zfigura) commented about libs/vkd3d-shader/hlsl_codegen.c:
if (load->sampler.var)
{
if (!hlsl_component_index_range_from_deref(ctx, &load->sampler, &start, &count))
{
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF,
"Resource load sampler from \"%s\" must be determinable at compile time.",
load->sampler.var->name);
note_non_static_deref_expressions(ctx, &load->sampler, "resource load sampler");
}
else if (load->sampler.var->modifiers & HLSL_STORAGE_STATIC)
{
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF,
"Loaded sampler from static variable \"%s\" must be initialized.",
load->sampler.var->name);
}
Hmm, is this the right condition, though? Should we be checking for !HLSL_STORAGE_UNIFORM instead? Since we want to fail in almost exactly the same way for uninitialized function-scoped variables.
It's perhaps worth mentioning that as written, this will also catch static (or function-scoped) variables that have a non-uniform initialization. IIRC that's forbidden in native too, but it maybe means the compiler message should be adjusted? Like "loads from resource objects must have a single uniform source"? Or maybe we should run liveness analysis before this and check var->last_write.