vkd3d-shader: Factor out hlsl_new_load().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-03-18 00:22:20 -05:00 committed by Alexandre Julliard
parent 3ac20487f8
commit 6d10d887d0
3 changed files with 12 additions and 6 deletions

View File

@ -497,17 +497,24 @@ struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shad
return iff;
}
struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd3d_shader_location loc)
struct hlsl_ir_load *hlsl_new_load(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_type *type, const struct vkd3d_shader_location loc)
{
struct hlsl_ir_load *load;
if (!(load = vkd3d_calloc(1, sizeof(*load))))
return NULL;
init_node(&load->node, HLSL_IR_LOAD, var->data_type, loc);
init_node(&load->node, HLSL_IR_LOAD, type, loc);
load->src.var = var;
hlsl_src_from_node(&load->src.offset, offset);
return load;
}
struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd3d_shader_location loc)
{
return hlsl_new_load(var, NULL, var->data_type, loc);
}
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *val, struct vkd3d_shader_location *loc)
{

View File

@ -530,6 +530,8 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl
struct list *parameters, const char *semantic, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_jump *hlsl_new_jump(enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_load *hlsl_new_load(struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type,
struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_loop *hlsl_new_loop(struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *hlsl_new_simple_assignment(struct hlsl_ir_var *lhs,
struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;

View File

@ -610,11 +610,8 @@ static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, struct list *instrs,
list_add_tail(instrs, &assign->node.entry);
}
if (!(load = vkd3d_malloc(sizeof(*load))))
if (!(load = hlsl_new_load(var, offset, data_type, loc)))
return NULL;
init_node(&load->node, HLSL_IR_LOAD, data_type, loc);
load->src.var = var;
hlsl_src_from_node(&load->src.offset, offset);
list_add_tail(instrs, &load->node.entry);
return load;
}