mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Parse state blocks in variable definitions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
committed by
Alexandre Julliard
parent
04bb6c395f
commit
efab7c82a5
@@ -469,6 +469,8 @@ struct hlsl_ctx
|
||||
size_t count, size;
|
||||
} constant_defs;
|
||||
uint32_t temp_count;
|
||||
|
||||
uint32_t in_state_block : 1;
|
||||
};
|
||||
|
||||
enum hlsl_error_level
|
||||
|
@@ -2558,6 +2558,23 @@ variable_decl:
|
||||
$$->reg_reservation = $3.reg_reservation;
|
||||
}
|
||||
|
||||
state:
|
||||
any_identifier '=' expr ';'
|
||||
{
|
||||
vkd3d_free($1);
|
||||
hlsl_free_instr_list($3);
|
||||
}
|
||||
|
||||
state_block_start:
|
||||
%empty
|
||||
{
|
||||
ctx->in_state_block = 1;
|
||||
}
|
||||
|
||||
state_block:
|
||||
%empty
|
||||
| state_block state
|
||||
|
||||
variable_def:
|
||||
variable_decl
|
||||
| variable_decl '=' complex_initializer
|
||||
@@ -2565,6 +2582,11 @@ variable_def:
|
||||
$$ = $1;
|
||||
$$->initializer = $3;
|
||||
}
|
||||
| variable_decl '{' state_block_start state_block '}'
|
||||
{
|
||||
$$ = $1;
|
||||
ctx->in_state_block = 0;
|
||||
}
|
||||
|
||||
arrays:
|
||||
%empty
|
||||
@@ -2861,13 +2883,10 @@ primary_expr:
|
||||
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable \"%s\" is not defined.", $1);
|
||||
YYABORT;
|
||||
}
|
||||
if ((load = hlsl_new_var_load(ctx, var, @1)))
|
||||
{
|
||||
if (!($$ = make_list(ctx, &load->node)))
|
||||
YYABORT;
|
||||
}
|
||||
else
|
||||
$$ = NULL;
|
||||
if (!(load = hlsl_new_var_load(ctx, var, @1)))
|
||||
YYABORT;
|
||||
if (!($$ = make_list(ctx, &load->node)))
|
||||
YYABORT;
|
||||
}
|
||||
| '(' expr ')'
|
||||
{
|
||||
@@ -2878,6 +2897,27 @@ primary_expr:
|
||||
if (!($$ = add_call(ctx, $1, &$3, @1)))
|
||||
YYABORT;
|
||||
}
|
||||
| NEW_IDENTIFIER
|
||||
{
|
||||
if (ctx->in_state_block)
|
||||
{
|
||||
struct hlsl_ir_load *load;
|
||||
struct hlsl_ir_var *var;
|
||||
|
||||
if (!(var = hlsl_new_synthetic_var(ctx, "<state-block-expr>",
|
||||
ctx->builtin_types.scalar[HLSL_TYPE_INT], @1)))
|
||||
YYABORT;
|
||||
if (!(load = hlsl_new_var_load(ctx, var, @1)))
|
||||
YYABORT;
|
||||
if (!($$ = make_list(ctx, &load->node)))
|
||||
YYABORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Identifier \"%s\" is not declared.\n", $1);
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
|
||||
postfix_expr:
|
||||
primary_expr
|
||||
|
Reference in New Issue
Block a user