mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Validate that statics don't contain both resources and numerics.
This commit is contained in:
parent
2fa913ccaa
commit
6873b71304
Notes:
Alexandre Julliard
2022-11-10 22:56:31 +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/42
@ -1907,6 +1907,26 @@ static bool type_has_object_components(struct hlsl_type *type, bool must_be_in_s
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool type_has_numeric_components(struct hlsl_type *type)
|
||||
{
|
||||
if (type->type <= HLSL_CLASS_LAST_NUMERIC)
|
||||
return true;
|
||||
if (type->type == HLSL_CLASS_ARRAY)
|
||||
return type_has_numeric_components(type->e.array.type);
|
||||
|
||||
if (type->type == HLSL_CLASS_STRUCT)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < type->e.record.field_count; ++i)
|
||||
{
|
||||
if (type_has_numeric_components(type->e.record.fields[i].type))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_type,
|
||||
DWORD modifiers, struct list *var_list)
|
||||
{
|
||||
@ -2076,6 +2096,13 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
|
||||
"Semantics are not allowed on local variables.");
|
||||
}
|
||||
|
||||
if ((var->modifiers & HLSL_STORAGE_STATIC) && type_has_numeric_components(var->data_type)
|
||||
&& type_has_object_components(var->data_type, false))
|
||||
{
|
||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
"Static variables cannot have both numeric and resource components.");
|
||||
}
|
||||
|
||||
if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count
|
||||
&& !(modifiers & (HLSL_STORAGE_STATIC | HLSL_STORAGE_UNIFORM)))
|
||||
{
|
||||
|
@ -250,3 +250,17 @@ float4 main() : sv_target
|
||||
a.a = 1;
|
||||
return a.a;
|
||||
}
|
||||
|
||||
[pixel shader fail]
|
||||
struct apple
|
||||
{
|
||||
sampler sam;
|
||||
float4 aa;
|
||||
};
|
||||
|
||||
static struct apple a;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user