From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 15 +++++++-------- libs/vkd3d-shader/hlsl_codegen.c | 21 +++++++++------------ 3 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index e6745052..6a4e314d 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1049,7 +1049,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru struct vkd3d_string_buffer *hlsl_modifiers_to_string(struct hlsl_ctx *ctx, unsigned int modifiers); const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type);
-struct hlsl_ir_load *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *instrs, +struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *condition, struct hlsl_ir_node *if_true, struct hlsl_ir_node *if_false); void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl); bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var); diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index a7d780ae..90e2face 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2689,9 +2689,8 @@ static bool intrinsic_floor(struct hlsl_ctx *ctx, static bool intrinsic_fmod(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { - struct hlsl_ir_node *x, *y, *div, *abs, *frac, *neg_frac, *ge; + struct hlsl_ir_node *x, *y, *div, *abs, *frac, *neg_frac, *ge, *select; struct hlsl_ir_constant *zero; - struct hlsl_ir_load *select; unsigned int count, i;
if (!(x = intrinsic_float_convert_arg(ctx, params, params->args[0], loc))) @@ -2726,7 +2725,7 @@ static bool intrinsic_fmod(struct hlsl_ctx *ctx, const struct parse_initializer if (!(select = hlsl_add_conditional(ctx, params->instrs, ge, frac, neg_frac))) return false;
- return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, &select->node, y, loc); + return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, select, y, loc); }
static bool intrinsic_frac(struct hlsl_ctx *ctx, @@ -2817,12 +2816,12 @@ static struct hlsl_ir_node * add_pow_expr(struct hlsl_ctx *ctx, static bool intrinsic_lit(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { - struct hlsl_ir_node *n_l_neg, *n_h_neg, *specular_or, *specular_pow; + struct hlsl_ir_node *n_l_neg, *n_h_neg, *specular_or, *specular_pow, *load; struct hlsl_ir_node *n_l, *n_h, *m, *diffuse, *zero, *store; struct hlsl_ir_constant *init; + struct hlsl_ir_load *var_load; struct hlsl_deref var_deref; struct hlsl_type *ret_type; - struct hlsl_ir_load *load; struct hlsl_ir_var *var; struct hlsl_block block;
@@ -2889,13 +2888,13 @@ static bool intrinsic_lit(struct hlsl_ctx *ctx, if (!(load = hlsl_add_conditional(ctx, params->instrs, specular_or, zero, specular_pow))) return false;
- if (!hlsl_new_store_component(ctx, &block, &var_deref, 2, &load->node)) + if (!hlsl_new_store_component(ctx, &block, &var_deref, 2, load)) return false; list_move_tail(params->instrs, &block.instrs);
- if (!(load = hlsl_new_var_load(ctx, var, loc))) + if (!(var_load = hlsl_new_var_load(ctx, var, loc))) return false; - list_add_tail(params->instrs, &load->node.entry); + list_add_tail(params->instrs, &var_load->node.entry);
return true; } diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 79608b1e..638dab6e 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -2178,7 +2178,7 @@ static bool lower_casts_to_bool(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr return true; }
-struct hlsl_ir_load *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *instrs, +struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *condition, struct hlsl_ir_node *if_true, struct hlsl_ir_node *if_false) { struct hlsl_block then_block, else_block; @@ -2210,16 +2210,15 @@ struct hlsl_ir_load *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *ins return NULL; list_add_tail(instrs, &load->node.entry);
- return load; + return &load->node; }
static bool lower_int_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { - struct hlsl_ir_node *arg1, *arg2, *xor, *and, *abs1, *abs2, *div, *neg, *cast1, *cast2, *cast3; + struct hlsl_ir_node *arg1, *arg2, *xor, *and, *abs1, *abs2, *div, *neg, *cast1, *cast2, *cast3, *cond; struct hlsl_type *type = instr->data_type, *utype; struct hlsl_ir_constant *high_bit; struct hlsl_ir_expr *expr; - struct hlsl_ir_load *cond; unsigned int i;
if (instr->type != HLSL_IR_EXPR) @@ -2279,18 +2278,17 @@ static bool lower_int_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
if (!(cond = hlsl_add_conditional(ctx, &instr->entry, and, neg, cast3))) return false; - hlsl_replace_node(instr, &cond->node); + hlsl_replace_node(instr, cond);
return true; }
static bool lower_int_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { - struct hlsl_ir_node *arg1, *arg2, *and, *abs1, *abs2, *div, *neg, *cast1, *cast2, *cast3; + struct hlsl_ir_node *arg1, *arg2, *and, *abs1, *abs2, *div, *neg, *cast1, *cast2, *cast3, *cond; struct hlsl_type *type = instr->data_type, *utype; struct hlsl_ir_constant *high_bit; struct hlsl_ir_expr *expr; - struct hlsl_ir_load *cond; unsigned int i;
if (instr->type != HLSL_IR_EXPR) @@ -2346,7 +2344,7 @@ static bool lower_int_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
if (!(cond = hlsl_add_conditional(ctx, &instr->entry, and, neg, cast3))) return false; - hlsl_replace_node(instr, &cond->node); + hlsl_replace_node(instr, cond);
return true; } @@ -2382,10 +2380,9 @@ static bool lower_int_abs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void
static bool lower_float_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { - struct hlsl_ir_node *arg1, *arg2, *mul1, *neg1, *ge, *neg2, *div, *mul2, *frc; + struct hlsl_ir_node *arg1, *arg2, *mul1, *neg1, *ge, *neg2, *div, *mul2, *frc, *cond; struct hlsl_type *type = instr->data_type, *btype; struct hlsl_ir_constant *one; - struct hlsl_ir_load *cond; struct hlsl_ir_expr *expr; unsigned int i;
@@ -2428,7 +2425,7 @@ static bool lower_float_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr one->value.u[i].f = 1.0f; list_add_before(&instr->entry, &one->node.entry);
- if (!(div = hlsl_new_binary_expr(ctx, HLSL_OP2_DIV, &one->node, &cond->node))) + if (!(div = hlsl_new_binary_expr(ctx, HLSL_OP2_DIV, &one->node, cond))) return false; list_add_before(&instr->entry, &div->entry);
@@ -2444,7 +2441,7 @@ static bool lower_float_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr hlsl_src_remove(&expr->operands[0]); hlsl_src_remove(&expr->operands[1]); hlsl_src_from_node(&expr->operands[0], frc); - hlsl_src_from_node(&expr->operands[1], &cond->node); + hlsl_src_from_node(&expr->operands[1], cond);
return true; }