mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Validate that non-uniform objects are not referenced.
Note that in the future we should call validate_static_object_references() after DCE and pruning branches, because shaders such as these compile (at least in more modern versions of the native compiler): Branch pruning: ``` static RWTexture2D<float> tex; float4 main() : sv_target { if (0) { tex[int2(0, 0)] = 2; } return 0; } ``` DCE: ``` static Texture2D tex; uniform uint i; float4 main() : sv_target { float4 unused = tex.Load(int3(0, 1, 2)); return 0; } ``` These are "todo" tests in hlsl-static-initializer.shader_test that depend on this.
This commit is contained in:
parent
97c9669544
commit
17d6a4411e
Notes:
Alexandre Julliard
2023-01-19 22:45:10 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/54
@ -1009,26 +1009,45 @@ static bool validate_static_object_references(struct hlsl_ctx *ctx, struct hlsl_
|
||||
{
|
||||
struct hlsl_ir_resource_load *load = hlsl_ir_resource_load(instr);
|
||||
|
||||
if (!hlsl_component_index_range_from_deref(ctx, &load->resource, &start, &count))
|
||||
if (!(load->resource.var->storage_modifiers & HLSL_STORAGE_UNIFORM))
|
||||
{
|
||||
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF,
|
||||
"Loaded resource must have a single uniform source.");
|
||||
}
|
||||
else if (!hlsl_component_index_range_from_deref(ctx, &load->resource, &start, &count))
|
||||
{
|
||||
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF,
|
||||
"Loaded resource from \"%s\" must be determinable at compile time.",
|
||||
load->resource.var->name);
|
||||
note_non_static_deref_expressions(ctx, &load->resource, "loaded resource");
|
||||
}
|
||||
if (load->sampler.var && !hlsl_component_index_range_from_deref(ctx, &load->sampler, &start, &count))
|
||||
|
||||
if (load->sampler.var)
|
||||
{
|
||||
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");
|
||||
if (!(load->sampler.var->storage_modifiers & HLSL_STORAGE_UNIFORM))
|
||||
{
|
||||
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF,
|
||||
"Resource load sampler must have a single uniform source.");
|
||||
}
|
||||
else 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 (instr->type == HLSL_IR_RESOURCE_STORE)
|
||||
{
|
||||
struct hlsl_ir_resource_store *store = hlsl_ir_resource_store(instr);
|
||||
|
||||
if (!hlsl_component_index_range_from_deref(ctx, &store->resource, &start, &count))
|
||||
if (!(store->resource.var->storage_modifiers & HLSL_STORAGE_UNIFORM))
|
||||
{
|
||||
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF,
|
||||
"Accessed resource must have a single uniform source.");
|
||||
}
|
||||
else if (!hlsl_component_index_range_from_deref(ctx, &store->resource, &start, &count))
|
||||
{
|
||||
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF,
|
||||
"Accessed resource from \"%s\" must be determinable at compile time.",
|
||||
|
@ -157,7 +157,7 @@ todo draw quad
|
||||
todo probe (0, 0) rgba (11.0, 12.0, 13.0, 11.0)
|
||||
|
||||
|
||||
[pixel shader fail todo]
|
||||
[pixel shader fail]
|
||||
float4 main(Texture2D tex2) : sv_target
|
||||
{
|
||||
Texture2D tex1;
|
||||
|
Loading…
Reference in New Issue
Block a user