From: Francisco Casas <fcasas(a)codeweavers.com> A struct declaration with variables is now absorbed into the 'declaration' rule, like any other variable declaration. A struct declaration without variables is now reduced to the 'struct_declaration_without_vars' rule. They both are reduced to a 'declaration_statement' in the end. --- libs/vkd3d-shader/hlsl.y | 75 +++++++++--------------- tests/hlsl-initializer-multi.shader_test | 8 +-- 2 files changed, 31 insertions(+), 52 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 0a468110b..c3d085c83 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -4451,11 +4451,10 @@ static void validate_texture_format_type(struct hlsl_ctx *ctx, struct hlsl_type %type <list> shift_expr %type <list> statement %type <list> statement_list -%type <list> struct_declaration +%type <list> struct_declaration_without_vars %type <list> type_specs %type <list> unary_expr %type <list> variables_def -%type <list> variables_def_optional %type <list> variables_def_typed %token <name> VAR_IDENTIFIER @@ -4588,47 +4587,19 @@ preproc_directive: } } -struct_declaration: - var_modifiers struct_spec variables_def_optional ';' +struct_declaration_without_vars: + var_modifiers struct_spec ';' { - struct parse_variable_def *v, *v_next; - struct hlsl_type *type; - unsigned int modifiers = $1; + if (!$2->name) + hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, + "Anonymous struct type must declare a variable."); - if (!$3) - { - if (!$2->name) - hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, - "Anonymous struct type must declare a variable."); - if (modifiers) - hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, - "Modifiers are not allowed on struct type declarations."); - } + if ($1) + hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + "Modifiers are not allowed on struct type declarations."); - if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1))) + if (!($$ = make_empty_list(ctx))) YYABORT; - - check_invalid_in_out_modifiers(ctx, modifiers, &@1); - - if ($3) - { - LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $3, struct parse_variable_def, entry) - { - v->basic_type = type; - v->modifiers = modifiers; - v->modifiers_loc = @1; - - declare_var(ctx, v); - } - - if (!($$ = initialize_vars(ctx, $3))) - YYABORT; - } - else - { - if (!($$ = make_empty_list(ctx))) - YYABORT; - } } struct_spec: @@ -5403,7 +5374,7 @@ type: declaration_statement: declaration - | struct_declaration + | struct_declaration_without_vars | typedef { if (!($$ = make_empty_list(ctx))) @@ -5471,13 +5442,6 @@ declaration: YYABORT; } -variables_def_optional: - %empty - { - $$ = NULL; - } - | variables_def - variables_def: variable_def { @@ -5560,7 +5524,22 @@ variable_def: } variable_def_typed: - var_modifiers type variable_def + var_modifiers struct_spec variable_def + { + unsigned int modifiers = $1; + struct hlsl_type *type; + + if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1))) + YYABORT; + + check_invalid_in_out_modifiers(ctx, modifiers, &@1); + + $$ = $3; + $$->basic_type = type; + $$->modifiers = modifiers; + $$->modifiers_loc = @1; + } + | var_modifiers type variable_def { unsigned int modifiers = $1; struct hlsl_type *type; diff --git a/tests/hlsl-initializer-multi.shader_test b/tests/hlsl-initializer-multi.shader_test index 73dd9f2ff..8f8a31e20 100644 --- a/tests/hlsl-initializer-multi.shader_test +++ b/tests/hlsl-initializer-multi.shader_test @@ -20,7 +20,7 @@ float4 main() : sv_target } -[pixel shader todo] +[pixel shader] float4 main() : sv_target { struct apple { @@ -32,11 +32,11 @@ float4 main() : sv_target } [test] -todo draw quad +draw quad probe all rgba (7.2, 8.0, 7.2, 8.0) -[pixel shader todo] +[pixel shader] float4 main() : sv_target { struct apple { @@ -48,5 +48,5 @@ float4 main() : sv_target } [test] -todo draw quad +draw quad probe all rgba (5.2, 9.0, 5.2, 9.0) -- GitLab https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/250