From: Zebediah Figura zfigura@codeweavers.com
The extra argument is not very easy to intuit. Since all we're trying to do here is check whether the type is a struct with object components in it, write that out explicitly. --- libs/vkd3d-shader/hlsl.y | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 17bb565db..9cc64da02 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2091,12 +2091,12 @@ static void initialize_var_components(struct hlsl_ctx *ctx, struct hlsl_block *i } }
-static bool type_has_object_components(struct hlsl_type *type, bool must_be_in_struct) +static bool type_has_object_components(struct hlsl_type *type) { if (type->class == HLSL_CLASS_OBJECT) - return !must_be_in_struct; + return true; if (type->class == HLSL_CLASS_ARRAY) - return type_has_object_components(type->e.array.type, must_be_in_struct); + return type_has_object_components(type->e.array.type);
if (type->class == HLSL_CLASS_STRUCT) { @@ -2104,7 +2104,7 @@ static bool type_has_object_components(struct hlsl_type *type, bool must_be_in_s
for (i = 0; i < type->e.record.field_count; ++i) { - if (type_has_object_components(type->e.record.fields[i].type, false)) + if (type_has_object_components(type->e.record.fields[i].type)) return true; } } @@ -2271,8 +2271,8 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v) if (!(modifiers & HLSL_STORAGE_STATIC)) var->storage_modifiers |= HLSL_STORAGE_UNIFORM;
- if (ctx->profile->major_version < 5 && (var->storage_modifiers & HLSL_STORAGE_UNIFORM) && - type_has_object_components(var->data_type, true)) + if (ctx->profile->major_version < 5 && (var->storage_modifiers & HLSL_STORAGE_UNIFORM) + && var->data_type->class == HLSL_CLASS_STRUCT && type_has_object_components(var->data_type)) { hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Target profile doesn't support objects as struct members in uniform variables."); @@ -2312,7 +2312,7 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v) }
if ((var->storage_modifiers & HLSL_STORAGE_STATIC) && type_has_numeric_components(var->data_type) - && type_has_object_components(var->data_type, false)) + && type_has_object_components(var->data_type)) { hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Static variables cannot have both numeric and resource components."); @@ -2400,7 +2400,7 @@ static struct hlsl_block *initialize_vars(struct hlsl_ctx *ctx, struct list *var
/* Initialize statics to zero by default. */
- if (type_has_object_components(var->data_type, false)) + if (type_has_object_components(var->data_type)) { free_parse_variable_def(v); continue;