mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Declare vars individually when parsing struct declarations.
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.
This commit is contained in:
committed by
Alexandre Julliard
parent
62c891b796
commit
01800942a9
Notes:
Alexandre Julliard
2023-07-04 23:25:04 +02: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/250
@@ -4554,11 +4554,10 @@ static void validate_texture_format_type(struct hlsl_ctx *ctx, struct hlsl_type
|
|||||||
%type <list> shift_expr
|
%type <list> shift_expr
|
||||||
%type <list> statement
|
%type <list> statement
|
||||||
%type <list> statement_list
|
%type <list> statement_list
|
||||||
%type <list> struct_declaration
|
%type <list> struct_declaration_without_vars
|
||||||
%type <list> type_specs
|
%type <list> type_specs
|
||||||
%type <list> unary_expr
|
%type <list> unary_expr
|
||||||
%type <list> variables_def
|
%type <list> variables_def
|
||||||
%type <list> variables_def_optional
|
|
||||||
%type <list> variables_def_typed
|
%type <list> variables_def_typed
|
||||||
|
|
||||||
%token <name> VAR_IDENTIFIER
|
%token <name> VAR_IDENTIFIER
|
||||||
@@ -4691,47 +4690,19 @@ preproc_directive:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct_declaration:
|
struct_declaration_without_vars:
|
||||||
var_modifiers struct_spec variables_def_optional ';'
|
var_modifiers struct_spec ';'
|
||||||
{
|
{
|
||||||
struct parse_variable_def *v, *v_next;
|
if (!$2->name)
|
||||||
struct hlsl_type *type;
|
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
|
||||||
unsigned int modifiers = $1;
|
"Anonymous struct type must declare a variable.");
|
||||||
|
|
||||||
if (!$3)
|
if ($1)
|
||||||
{
|
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||||
if (!$2->name)
|
"Modifiers are not allowed on struct type declarations.");
|
||||||
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 (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
|
if (!($$ = make_empty_list(ctx)))
|
||||||
YYABORT;
|
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:
|
struct_spec:
|
||||||
@@ -5511,7 +5482,7 @@ type:
|
|||||||
|
|
||||||
declaration_statement:
|
declaration_statement:
|
||||||
declaration
|
declaration
|
||||||
| struct_declaration
|
| struct_declaration_without_vars
|
||||||
| typedef
|
| typedef
|
||||||
{
|
{
|
||||||
if (!($$ = make_empty_list(ctx)))
|
if (!($$ = make_empty_list(ctx)))
|
||||||
@@ -5579,13 +5550,6 @@ declaration:
|
|||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
variables_def_optional:
|
|
||||||
%empty
|
|
||||||
{
|
|
||||||
$$ = NULL;
|
|
||||||
}
|
|
||||||
| variables_def
|
|
||||||
|
|
||||||
variables_def:
|
variables_def:
|
||||||
variable_def
|
variable_def
|
||||||
{
|
{
|
||||||
@@ -5668,7 +5632,22 @@ variable_def:
|
|||||||
}
|
}
|
||||||
|
|
||||||
variable_def_typed:
|
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;
|
unsigned int modifiers = $1;
|
||||||
struct hlsl_type *type;
|
struct hlsl_type *type;
|
||||||
|
@@ -20,7 +20,7 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
float4 main() : sv_target
|
float4 main() : sv_target
|
||||||
{
|
{
|
||||||
struct apple {
|
struct apple {
|
||||||
@@ -32,11 +32,11 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo draw quad
|
draw quad
|
||||||
probe all rgba (7.2, 8.0, 7.2, 8.0)
|
probe all rgba (7.2, 8.0, 7.2, 8.0)
|
||||||
|
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
float4 main() : sv_target
|
float4 main() : sv_target
|
||||||
{
|
{
|
||||||
struct apple {
|
struct apple {
|
||||||
@@ -48,5 +48,5 @@ float4 main() : sv_target
|
|||||||
}
|
}
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
todo draw quad
|
draw quad
|
||||||
probe all rgba (5.2, 9.0, 5.2, 9.0)
|
probe all rgba (5.2, 9.0, 5.2, 9.0)
|
||||||
|
Reference in New Issue
Block a user