mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Validate that extern structs don't contain objects SM < 5.
It is worth noting that these checks should also be included for declarations inside cbuffers, once they are implemented.
This commit is contained in:
parent
3153ce3145
commit
2fa913ccaa
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
@ -1887,6 +1887,26 @@ static void initialize_var_components(struct hlsl_ctx *ctx, struct list *instrs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool type_has_object_components(struct hlsl_type *type, bool must_be_in_struct)
|
||||||
|
{
|
||||||
|
if (type->type == HLSL_CLASS_OBJECT)
|
||||||
|
return !must_be_in_struct;
|
||||||
|
if (type->type == HLSL_CLASS_ARRAY)
|
||||||
|
return type_has_object_components(type->e.array.type, must_be_in_struct);
|
||||||
|
|
||||||
|
if (type->type == HLSL_CLASS_STRUCT)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < type->e.record.field_count; ++i)
|
||||||
|
{
|
||||||
|
if (type_has_object_components(type->e.record.fields[i].type, false))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_type,
|
static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_type,
|
||||||
DWORD modifiers, struct list *var_list)
|
DWORD modifiers, struct list *var_list)
|
||||||
{
|
{
|
||||||
@ -2022,6 +2042,13 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
|
|||||||
if (!(modifiers & HLSL_STORAGE_STATIC))
|
if (!(modifiers & HLSL_STORAGE_STATIC))
|
||||||
var->modifiers |= HLSL_STORAGE_UNIFORM;
|
var->modifiers |= HLSL_STORAGE_UNIFORM;
|
||||||
|
|
||||||
|
if (ctx->profile->major_version < 5 && (var->modifiers & HLSL_STORAGE_UNIFORM) &&
|
||||||
|
type_has_object_components(var->data_type, true))
|
||||||
|
{
|
||||||
|
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||||
|
"Target profile doesn't support objects as struct members in uniform variables.\n");
|
||||||
|
}
|
||||||
|
|
||||||
if ((func = hlsl_get_func_decl(ctx, var->name)))
|
if ((func = hlsl_get_func_decl(ctx, var->name)))
|
||||||
{
|
{
|
||||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
|
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
|
||||||
|
Loading…
Reference in New Issue
Block a user