vkd3d-shader/hlsl: Turn hlsl_state_block_entry arguments into hlsl_src.

This allows to apply passes that replace instructions in
hlsl_state_block_entry.instrs.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Francisco Casas 2024-04-19 15:15:19 -04:00 committed by Alexandre Julliard
parent cefd6f9de6
commit 68483d070f
Notes: Alexandre Julliard 2024-05-08 22:49:51 +02:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/802
3 changed files with 12 additions and 2 deletions

View File

@ -136,7 +136,11 @@ struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name)
static void free_state_block_entry(struct hlsl_state_block_entry *entry) static void free_state_block_entry(struct hlsl_state_block_entry *entry)
{ {
unsigned int i;
vkd3d_free(entry->name); vkd3d_free(entry->name);
for (i = 0; i < entry->args_count; ++i)
hlsl_src_remove(&entry->args[i]);
vkd3d_free(entry->args); vkd3d_free(entry->args);
hlsl_block_cleanup(entry->instrs); hlsl_block_cleanup(entry->instrs);
vkd3d_free(entry->instrs); vkd3d_free(entry->instrs);

View File

@ -483,7 +483,7 @@ struct hlsl_state_block_entry
struct hlsl_block *instrs; struct hlsl_block *instrs;
/* For assignments, arguments of the rhs initializer. */ /* For assignments, arguments of the rhs initializer. */
struct hlsl_ir_node **args; struct hlsl_src *args;
unsigned int args_count; unsigned int args_count;
}; };

View File

@ -6912,6 +6912,7 @@ state_block:
| state_block stateblock_lhs_identifier state_block_index_opt '=' complex_initializer ';' | state_block stateblock_lhs_identifier state_block_index_opt '=' complex_initializer ';'
{ {
struct hlsl_state_block_entry *entry; struct hlsl_state_block_entry *entry;
unsigned int i;
if (!(entry = hlsl_alloc(ctx, sizeof(*entry)))) if (!(entry = hlsl_alloc(ctx, sizeof(*entry))))
YYABORT; YYABORT;
@ -6921,8 +6922,13 @@ state_block:
entry->lhs_index = $3.index; entry->lhs_index = $3.index;
entry->instrs = $5.instrs; entry->instrs = $5.instrs;
entry->args = $5.args;
entry->args_count = $5.args_count; entry->args_count = $5.args_count;
if (!(entry->args = hlsl_alloc(ctx, sizeof(*entry->args) * entry->args_count)))
YYABORT;
for (i = 0; i < entry->args_count; ++i)
hlsl_src_from_node(&entry->args[i], $5.args[i]);
vkd3d_free($5.args);
$$ = $1; $$ = $1;
state_block_add_entry($$, entry); state_block_add_entry($$, entry);