mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/fx: Decompose function-style state assignments to individual states.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
committed by
Henri Verbeet
parent
d4c2a7f22b
commit
a3f4785720
Notes:
Henri Verbeet
2024-08-05 16:17:24 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/978
@@ -134,7 +134,7 @@ struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name)
|
||||
return hlsl_get_var(scope->upper, name);
|
||||
}
|
||||
|
||||
static void free_state_block_entry(struct hlsl_state_block_entry *entry)
|
||||
void hlsl_free_state_block_entry(struct hlsl_state_block_entry *entry)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@@ -153,7 +153,7 @@ void hlsl_free_state_block(struct hlsl_state_block *state_block)
|
||||
|
||||
VKD3D_ASSERT(state_block);
|
||||
for (k = 0; k < state_block->count; ++k)
|
||||
free_state_block_entry(state_block->entries[k]);
|
||||
hlsl_free_state_block_entry(state_block->entries[k]);
|
||||
vkd3d_free(state_block->entries);
|
||||
vkd3d_free(state_block);
|
||||
}
|
||||
@@ -2081,6 +2081,43 @@ static struct hlsl_ir_node *clone_stateblock_constant(struct hlsl_ctx *ctx,
|
||||
return hlsl_new_stateblock_constant(ctx, constant->name, &constant->node.loc);
|
||||
}
|
||||
|
||||
struct hlsl_state_block_entry *clone_stateblock_entry(struct hlsl_ctx *ctx,
|
||||
struct hlsl_state_block_entry *src, const char *name, bool lhs_has_index,
|
||||
unsigned int lhs_index, unsigned int arg_index)
|
||||
{
|
||||
struct hlsl_state_block_entry *entry;
|
||||
struct clone_instr_map map = { 0 };
|
||||
|
||||
if (!(entry = hlsl_alloc(ctx, sizeof(*entry))))
|
||||
return NULL;
|
||||
entry->name = hlsl_strdup(ctx, name);
|
||||
entry->lhs_has_index = lhs_has_index;
|
||||
entry->lhs_index = lhs_index;
|
||||
if (!(entry->instrs = hlsl_alloc(ctx, sizeof(*entry->instrs))))
|
||||
{
|
||||
hlsl_free_state_block_entry(entry);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry->args_count = 1;
|
||||
if (!(entry->args = hlsl_alloc(ctx, sizeof(*entry->args) * entry->args_count)))
|
||||
{
|
||||
hlsl_free_state_block_entry(entry);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hlsl_block_init(entry->instrs);
|
||||
if (!clone_block(ctx, entry->instrs, src->instrs, &map))
|
||||
{
|
||||
hlsl_free_state_block_entry(entry);
|
||||
return NULL;
|
||||
}
|
||||
clone_src(&map, entry->args, &src->args[arg_index]);
|
||||
vkd3d_free(map.instrs);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void hlsl_free_ir_switch_case(struct hlsl_ir_switch_case *c)
|
||||
{
|
||||
hlsl_block_cleanup(&c->body);
|
||||
|
Reference in New Issue
Block a user