Module: vkd3d Branch: master Commit: 6767b7abbf0cf8ea1be170ca2df6c9c6f98f2ea4 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/6767b7abbf0cf8ea1be170ca2df6c9...
Author: Zebediah Figura zfigura@codeweavers.com Date: Wed Apr 6 13:55:34 2022 -0500
vkd3d-shader/hlsl: Avoid warning for each variable when in/out modifiers are specified on non-parameters.
---
libs/vkd3d-shader/hlsl.y | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index e158f1de..eec76a6a 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1940,10 +1940,11 @@ static bool type_has_numeric_components(struct hlsl_type *type) }
static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_type, - DWORD modifiers, struct list *var_list) + unsigned int modifiers, const struct vkd3d_shader_location *modifiers_loc, struct list *var_list) { struct parse_variable_def *v, *v_next; struct hlsl_ir_function_decl *func; + unsigned int invalid_modifiers; struct list *statements_list; struct hlsl_ir_var *var; struct hlsl_type *type; @@ -1963,6 +1964,17 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t if (!var_list) return statements_list;
+ invalid_modifiers = modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT); + if (invalid_modifiers) + { + struct vkd3d_string_buffer *string; + + if ((string = hlsl_modifiers_to_string(ctx, invalid_modifiers))) + hlsl_error(ctx, modifiers_loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + "Modifiers '%s' are not allowed on non-parameter variables.", string->buffer); + hlsl_release_string_buffer(ctx, string); + } + LIST_FOR_EACH_ENTRY_SAFE(v, v_next, var_list, struct parse_variable_def, entry) { bool unbounded_res_array = false; @@ -2039,16 +2051,6 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t } vkd3d_free(v->arrays.sizes);
- if (modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)) - { - struct vkd3d_string_buffer *string; - - if ((string = hlsl_modifiers_to_string(ctx, modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)))) - hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, - "Modifiers '%s' are not allowed on non-parameter variables.", string->buffer); - hlsl_release_string_buffer(ctx, string); - } - if (!(var = hlsl_new_var(ctx, v->name, type, v->loc, &v->semantic, modifiers, &v->reg_reservation))) { free_parse_variable_def(v); @@ -3862,7 +3864,7 @@ struct_declaration:
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT; - $$ = declare_vars(ctx, type, modifiers, $3); + $$ = declare_vars(ctx, type, modifiers, &@1, $3); }
struct_spec: @@ -4585,7 +4587,7 @@ declaration:
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT; - $$ = declare_vars(ctx, type, modifiers, $3); + $$ = declare_vars(ctx, type, modifiers, &@1, $3); }
variables_def_optional: