mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Store a pointer to the block's "value" instruction in the block.
This commit is contained in:
parent
799e6105a4
commit
8975933aff
Notes:
Henri Verbeet
2024-09-23 15:55:59 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1071
@ -361,6 +361,9 @@ struct hlsl_block
|
||||
{
|
||||
/* List containing instruction nodes; linked by the hlsl_ir_node.entry fields. */
|
||||
struct list instrs;
|
||||
/* Instruction representing the "value" of this block, if applicable.
|
||||
* This may point to an instruction outside of this block! */
|
||||
struct hlsl_ir_node *value;
|
||||
};
|
||||
|
||||
/* A reference to an instruction node (struct hlsl_ir_node), usable as a field in other structs.
|
||||
@ -1212,16 +1215,19 @@ static inline struct hlsl_ir_stateblock_constant *hlsl_ir_stateblock_constant(co
|
||||
static inline void hlsl_block_init(struct hlsl_block *block)
|
||||
{
|
||||
list_init(&block->instrs);
|
||||
block->value = NULL;
|
||||
}
|
||||
|
||||
static inline void hlsl_block_add_instr(struct hlsl_block *block, struct hlsl_ir_node *instr)
|
||||
{
|
||||
list_add_tail(&block->instrs, &instr->entry);
|
||||
block->value = (instr->data_type ? instr : NULL);
|
||||
}
|
||||
|
||||
static inline void hlsl_block_add_block(struct hlsl_block *block, struct hlsl_block *add)
|
||||
{
|
||||
list_move_tail(&block->instrs, &add->instrs);
|
||||
block->value = add->value;
|
||||
}
|
||||
|
||||
static inline void hlsl_src_from_node(struct hlsl_src *src, struct hlsl_ir_node *node)
|
||||
|
@ -147,7 +147,7 @@ static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const cha
|
||||
|
||||
static struct hlsl_ir_node *node_from_block(struct hlsl_block *block)
|
||||
{
|
||||
return LIST_ENTRY(list_tail(&block->instrs), struct hlsl_ir_node, entry);
|
||||
return block->value;
|
||||
}
|
||||
|
||||
static struct hlsl_block *make_empty_block(struct hlsl_ctx *ctx)
|
||||
@ -639,14 +639,14 @@ static struct hlsl_default_value evaluate_static_expression(struct hlsl_ctx *ctx
|
||||
return ret;
|
||||
hlsl_block_add_block(&expr, block);
|
||||
|
||||
if (!add_implicit_conversion(ctx, &expr, node_from_block(&expr), dst_type, loc))
|
||||
if (!(node = add_implicit_conversion(ctx, &expr, node_from_block(&expr), dst_type, loc)))
|
||||
{
|
||||
hlsl_block_cleanup(&expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Wrap the node into a src to allow the reference to survive the multiple const passes. */
|
||||
hlsl_src_from_node(&src, node_from_block(&expr));
|
||||
hlsl_src_from_node(&src, node);
|
||||
hlsl_run_const_passes(ctx, &expr);
|
||||
node = src.node;
|
||||
hlsl_src_remove(&src);
|
||||
|
Loading…
Reference in New Issue
Block a user