mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Add a hlsl_block_add_expr() helper.
This commit is contained in:
committed by
Henri Verbeet
parent
f24cc55c14
commit
662d60ad6b
Notes:
Henri Verbeet
2025-03-03 18:05:08 +01:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1394
@ -1684,6 +1684,13 @@ struct hlsl_ir_node *hlsl_new_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op
|
|||||||
return &expr->node;
|
return &expr->node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct hlsl_ir_node *hlsl_block_add_expr(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||||
|
enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
|
||||||
|
struct hlsl_type *data_type, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
return append_new_instr(ctx, block, hlsl_new_expr(ctx, op, operands, data_type, loc));
|
||||||
|
}
|
||||||
|
|
||||||
static struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
|
static struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
|
||||||
struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc)
|
struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
|
@ -1509,6 +1509,9 @@ struct hlsl_ir_node *hlsl_block_add_binary_expr(struct hlsl_ctx *ctx, struct hls
|
|||||||
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2);
|
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2);
|
||||||
struct hlsl_ir_node *hlsl_block_add_cast(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
struct hlsl_ir_node *hlsl_block_add_cast(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||||
struct hlsl_ir_node *arg, struct hlsl_type *type, const struct vkd3d_shader_location *loc);
|
struct hlsl_ir_node *arg, struct hlsl_type *type, const struct vkd3d_shader_location *loc);
|
||||||
|
struct hlsl_ir_node *hlsl_block_add_expr(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||||
|
enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
|
||||||
|
struct hlsl_type *data_type, const struct vkd3d_shader_location *loc);
|
||||||
struct hlsl_ir_node *hlsl_block_add_float_constant(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
struct hlsl_ir_node *hlsl_block_add_float_constant(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||||
float f, const struct vkd3d_shader_location *loc);
|
float f, const struct vkd3d_shader_location *loc);
|
||||||
struct hlsl_ir_node *hlsl_block_add_int_constant(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
struct hlsl_ir_node *hlsl_block_add_int_constant(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||||
|
@ -1588,7 +1588,6 @@ static struct hlsl_ir_node *add_expr(struct hlsl_ctx *ctx, struct hlsl_block *bl
|
|||||||
enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
|
enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
|
||||||
struct hlsl_type *type, const struct vkd3d_shader_location *loc)
|
struct hlsl_type *type, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *expr;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (type->class == HLSL_CLASS_MATRIX)
|
if (type->class == HLSL_CLASS_MATRIX)
|
||||||
@ -1637,11 +1636,7 @@ static struct hlsl_ir_node *add_expr(struct hlsl_ctx *ctx, struct hlsl_block *bl
|
|||||||
return &var_load->node;
|
return &var_load->node;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(expr = hlsl_new_expr(ctx, op, operands, type, loc)))
|
return hlsl_block_add_expr(ctx, block, op, operands, type, loc);
|
||||||
return NULL;
|
|
||||||
hlsl_block_add_instr(block, expr);
|
|
||||||
|
|
||||||
return expr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool type_is_integer(enum hlsl_base_type type)
|
static bool type_is_integer(enum hlsl_base_type type)
|
||||||
@ -5233,17 +5228,13 @@ static bool intrinsic_GetRenderTargetSampleCount(struct hlsl_ctx *ctx,
|
|||||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0};
|
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0};
|
||||||
struct hlsl_ir_node *expr;
|
|
||||||
|
|
||||||
if (ctx->profile->type != VKD3D_SHADER_TYPE_PIXEL || hlsl_version_lt(ctx, 4, 1))
|
if (ctx->profile->type != VKD3D_SHADER_TYPE_PIXEL || hlsl_version_lt(ctx, 4, 1))
|
||||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INCOMPATIBLE_PROFILE,
|
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INCOMPATIBLE_PROFILE,
|
||||||
"GetRenderTargetSampleCount() can only be used from a pixel shader using version 4.1 or higher.");
|
"GetRenderTargetSampleCount() can only be used from a pixel shader using version 4.1 or higher.");
|
||||||
|
|
||||||
if (!(expr = hlsl_new_expr(ctx, HLSL_OP0_RASTERIZER_SAMPLE_COUNT,
|
hlsl_block_add_expr(ctx, params->instrs, HLSL_OP0_RASTERIZER_SAMPLE_COUNT,
|
||||||
operands, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc)))
|
operands, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(params->instrs, expr);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2777,7 +2777,7 @@ static bool lower_nonconstant_vector_derefs(struct hlsl_ctx *ctx, struct hlsl_ir
|
|||||||
|
|
||||||
if (type->class == HLSL_CLASS_VECTOR && idx->type != HLSL_IR_CONSTANT)
|
if (type->class == HLSL_CLASS_VECTOR && idx->type != HLSL_IR_CONSTANT)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *eq, *swizzle, *dot, *c, *operands[HLSL_MAX_OPERANDS] = {0};
|
struct hlsl_ir_node *eq, *swizzle, *c, *operands[HLSL_MAX_OPERANDS] = {0};
|
||||||
unsigned int width = type->e.numeric.dimx;
|
unsigned int width = type->e.numeric.dimx;
|
||||||
struct hlsl_constant_value value;
|
struct hlsl_constant_value value;
|
||||||
struct hlsl_ir_load *vector_load;
|
struct hlsl_ir_load *vector_load;
|
||||||
@ -2801,11 +2801,8 @@ static bool lower_nonconstant_vector_derefs(struct hlsl_ctx *ctx, struct hlsl_ir
|
|||||||
|
|
||||||
operands[0] = swizzle;
|
operands[0] = swizzle;
|
||||||
operands[1] = c;
|
operands[1] = c;
|
||||||
if (!(eq = hlsl_new_expr(ctx, HLSL_OP2_EQUAL, operands,
|
eq = hlsl_block_add_expr(ctx, block, HLSL_OP2_EQUAL, operands,
|
||||||
hlsl_get_vector_type(ctx, HLSL_TYPE_BOOL, width), &instr->loc)))
|
hlsl_get_vector_type(ctx, HLSL_TYPE_BOOL, width), &instr->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(block, eq);
|
|
||||||
|
|
||||||
eq = hlsl_block_add_cast(ctx, block, eq, type, &instr->loc);
|
eq = hlsl_block_add_cast(ctx, block, eq, type, &instr->loc);
|
||||||
|
|
||||||
op = HLSL_OP2_DOT;
|
op = HLSL_OP2_DOT;
|
||||||
@ -2816,10 +2813,7 @@ static bool lower_nonconstant_vector_derefs(struct hlsl_ctx *ctx, struct hlsl_ir
|
|||||||
* LOGIC_OR + LOGIC_AND. */
|
* LOGIC_OR + LOGIC_AND. */
|
||||||
operands[0] = &vector_load->node;
|
operands[0] = &vector_load->node;
|
||||||
operands[1] = eq;
|
operands[1] = eq;
|
||||||
if (!(dot = hlsl_new_expr(ctx, op, operands, instr->data_type, &instr->loc)))
|
hlsl_block_add_expr(ctx, block, op, operands, instr->data_type, &instr->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(block, dot);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2930,9 +2924,7 @@ static bool lower_nonconstant_array_loads(struct hlsl_ctx *ctx, struct hlsl_ir_n
|
|||||||
|
|
||||||
operands[0] = cut_index;
|
operands[0] = cut_index;
|
||||||
operands[1] = const_i;
|
operands[1] = const_i;
|
||||||
if (!(equals = hlsl_new_expr(ctx, HLSL_OP2_EQUAL, operands, btype, &cut_index->loc)))
|
equals = hlsl_block_add_expr(ctx, block, HLSL_OP2_EQUAL, operands, btype, &cut_index->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(block, equals);
|
|
||||||
|
|
||||||
if (!(equals = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, X, X, X),
|
if (!(equals = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, X, X, X),
|
||||||
var->data_type->e.numeric.dimx, equals, &cut_index->loc)))
|
var->data_type->e.numeric.dimx, equals, &cut_index->loc)))
|
||||||
@ -2960,9 +2952,7 @@ static bool lower_nonconstant_array_loads(struct hlsl_ctx *ctx, struct hlsl_ir_n
|
|||||||
operands[0] = equals;
|
operands[0] = equals;
|
||||||
operands[1] = &specific_load->node;
|
operands[1] = &specific_load->node;
|
||||||
operands[2] = &var_load->node;
|
operands[2] = &var_load->node;
|
||||||
if (!(ternary = hlsl_new_expr(ctx, HLSL_OP3_TERNARY, operands, instr->data_type, &cut_index->loc)))
|
ternary = hlsl_block_add_expr(ctx, block, HLSL_OP3_TERNARY, operands, instr->data_type, &cut_index->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(block, ternary);
|
|
||||||
|
|
||||||
if (!(var_store = hlsl_new_simple_store(ctx, var, ternary)))
|
if (!(var_store = hlsl_new_simple_store(ctx, var, ternary)))
|
||||||
return false;
|
return false;
|
||||||
@ -3325,10 +3315,7 @@ static bool lower_casts_to_int(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
|||||||
|
|
||||||
memset(operands, 0, sizeof(operands));
|
memset(operands, 0, sizeof(operands));
|
||||||
operands[0] = res;
|
operands[0] = res;
|
||||||
if (!(res = hlsl_new_expr(ctx, HLSL_OP1_REINTERPRET, operands, instr->data_type, &instr->loc)))
|
hlsl_block_add_expr(ctx, block, HLSL_OP1_REINTERPRET, operands, instr->data_type, &instr->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(block, res);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3385,7 +3372,7 @@ static bool lower_sqrt(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct
|
|||||||
/* Lower DP2 to MUL + ADD */
|
/* Lower DP2 to MUL + ADD */
|
||||||
static bool lower_dot(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
static bool lower_dot(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *arg1, *arg2, *mul, *replacement, *add_x, *add_y;
|
struct hlsl_ir_node *arg1, *arg2, *mul, *add_x, *add_y;
|
||||||
struct hlsl_ir_expr *expr;
|
struct hlsl_ir_expr *expr;
|
||||||
|
|
||||||
if (instr->type != HLSL_IR_EXPR)
|
if (instr->type != HLSL_IR_EXPR)
|
||||||
@ -3406,9 +3393,7 @@ static bool lower_dot(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct h
|
|||||||
operands[1] = arg2;
|
operands[1] = arg2;
|
||||||
operands[2] = hlsl_block_add_float_constant(ctx, block, 0.0f, &expr->node.loc);
|
operands[2] = hlsl_block_add_float_constant(ctx, block, 0.0f, &expr->node.loc);
|
||||||
|
|
||||||
if (!(replacement = hlsl_new_expr(ctx, HLSL_OP3_DP2ADD, operands, instr->data_type, &expr->node.loc)))
|
hlsl_block_add_expr(ctx, block, HLSL_OP3_DP2ADD, operands, instr->data_type, &expr->node.loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(block, replacement);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3617,8 +3602,8 @@ static bool lower_trig(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct
|
|||||||
|
|
||||||
static bool lower_logic_not(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
static bool lower_logic_not(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
||||||
{
|
{
|
||||||
|
struct hlsl_ir_node *arg, *arg_cast, *neg, *one, *sub;
|
||||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
|
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
|
||||||
struct hlsl_ir_node *arg, *arg_cast, *neg, *one, *sub, *res;
|
|
||||||
struct hlsl_constant_value one_value;
|
struct hlsl_constant_value one_value;
|
||||||
struct hlsl_type *float_type;
|
struct hlsl_type *float_type;
|
||||||
struct hlsl_ir_expr *expr;
|
struct hlsl_ir_expr *expr;
|
||||||
@ -3651,18 +3636,15 @@ static bool lower_logic_not(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, st
|
|||||||
|
|
||||||
memset(operands, 0, sizeof(operands));
|
memset(operands, 0, sizeof(operands));
|
||||||
operands[0] = sub;
|
operands[0] = sub;
|
||||||
if (!(res = hlsl_new_expr(ctx, HLSL_OP1_REINTERPRET, operands, instr->data_type, &instr->loc)))
|
hlsl_block_add_expr(ctx, block, HLSL_OP1_REINTERPRET, operands, instr->data_type, &instr->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(block, res);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lower TERNARY to CMP for SM1. */
|
/* Lower TERNARY to CMP for SM1. */
|
||||||
static bool lower_ternary(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
static bool lower_ternary(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = { 0 }, *replacement;
|
|
||||||
struct hlsl_ir_node *cond, *first, *second, *float_cond, *neg;
|
struct hlsl_ir_node *cond, *first, *second, *float_cond, *neg;
|
||||||
|
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0};
|
||||||
struct hlsl_ir_expr *expr;
|
struct hlsl_ir_expr *expr;
|
||||||
struct hlsl_type *type;
|
struct hlsl_type *type;
|
||||||
|
|
||||||
@ -3694,10 +3676,7 @@ static bool lower_ternary(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, stru
|
|||||||
operands[0] = neg;
|
operands[0] = neg;
|
||||||
operands[1] = second;
|
operands[1] = second;
|
||||||
operands[2] = first;
|
operands[2] = first;
|
||||||
if (!(replacement = hlsl_new_expr(ctx, HLSL_OP3_CMP, operands, first->data_type, &instr->loc)))
|
hlsl_block_add_expr(ctx, block, HLSL_OP3_CMP, operands, first->data_type, &instr->loc);
|
||||||
return false;
|
|
||||||
|
|
||||||
hlsl_block_add_instr(block, replacement);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3749,7 +3728,7 @@ static bool lower_resource_load_bias(struct hlsl_ctx *ctx, struct hlsl_ir_node *
|
|||||||
static bool lower_comparison_operators(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
static bool lower_comparison_operators(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
||||||
struct hlsl_block *block)
|
struct hlsl_block *block)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *arg1, *arg1_cast, *arg2, *arg2_cast, *slt, *res, *ret;
|
struct hlsl_ir_node *arg1, *arg1_cast, *arg2, *arg2_cast, *slt, *res;
|
||||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
|
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
|
||||||
struct hlsl_type *float_type;
|
struct hlsl_type *float_type;
|
||||||
struct hlsl_ir_expr *expr;
|
struct hlsl_ir_expr *expr;
|
||||||
@ -3832,10 +3811,7 @@ static bool lower_comparison_operators(struct hlsl_ctx *ctx, struct hlsl_ir_node
|
|||||||
* and casts to BOOL have already been lowered to "!= 0". */
|
* and casts to BOOL have already been lowered to "!= 0". */
|
||||||
memset(operands, 0, sizeof(operands));
|
memset(operands, 0, sizeof(operands));
|
||||||
operands[0] = res;
|
operands[0] = res;
|
||||||
if (!(ret = hlsl_new_expr(ctx, HLSL_OP1_REINTERPRET, operands, instr->data_type, &instr->loc)))
|
hlsl_block_add_expr(ctx, block, HLSL_OP1_REINTERPRET, operands, instr->data_type, &instr->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(block, ret);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3978,7 +3954,6 @@ struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_bloc
|
|||||||
{
|
{
|
||||||
struct hlsl_type *cond_type = condition->data_type;
|
struct hlsl_type *cond_type = condition->data_type;
|
||||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
|
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
|
||||||
struct hlsl_ir_node *cond;
|
|
||||||
|
|
||||||
VKD3D_ASSERT(hlsl_types_are_equal(if_true->data_type, if_false->data_type));
|
VKD3D_ASSERT(hlsl_types_are_equal(if_true->data_type, if_false->data_type));
|
||||||
|
|
||||||
@ -3992,11 +3967,7 @@ struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_bloc
|
|||||||
operands[0] = condition;
|
operands[0] = condition;
|
||||||
operands[1] = if_true;
|
operands[1] = if_true;
|
||||||
operands[2] = if_false;
|
operands[2] = if_false;
|
||||||
if (!(cond = hlsl_new_expr(ctx, HLSL_OP3_TERNARY, operands, if_true->data_type, &condition->loc)))
|
return hlsl_block_add_expr(ctx, instrs, HLSL_OP3_TERNARY, operands, if_true->data_type, &condition->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(instrs, cond);
|
|
||||||
|
|
||||||
return cond;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool lower_int_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
static bool lower_int_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
||||||
@ -4174,9 +4145,7 @@ static bool lower_float_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
|
|||||||
ge->data_type = btype;
|
ge->data_type = btype;
|
||||||
|
|
||||||
neg2 = hlsl_block_add_unary_expr(ctx, block, HLSL_OP1_NEG, arg2, &instr->loc);
|
neg2 = hlsl_block_add_unary_expr(ctx, block, HLSL_OP1_NEG, arg2, &instr->loc);
|
||||||
|
cond = hlsl_add_conditional(ctx, block, ge, arg2, neg2);
|
||||||
if (!(cond = hlsl_add_conditional(ctx, block, ge, arg2, neg2)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (i = 0; i < type->e.numeric.dimx; ++i)
|
for (i = 0; i < type->e.numeric.dimx; ++i)
|
||||||
one_value.u[i].f = 1.0f;
|
one_value.u[i].f = 1.0f;
|
||||||
@ -4218,9 +4187,7 @@ static bool lower_discard_neg(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
|||||||
operands[1] = zero;
|
operands[1] = zero;
|
||||||
cmp_type = hlsl_get_numeric_type(ctx, arg_type->class, HLSL_TYPE_BOOL,
|
cmp_type = hlsl_get_numeric_type(ctx, arg_type->class, HLSL_TYPE_BOOL,
|
||||||
arg_type->e.numeric.dimx, arg_type->e.numeric.dimy);
|
arg_type->e.numeric.dimx, arg_type->e.numeric.dimy);
|
||||||
if (!(cmp = hlsl_new_expr(ctx, HLSL_OP2_LESS, operands, cmp_type, &instr->loc)))
|
cmp = hlsl_block_add_expr(ctx, &block, HLSL_OP2_LESS, operands, cmp_type, &instr->loc);
|
||||||
return false;
|
|
||||||
hlsl_block_add_instr(&block, cmp);
|
|
||||||
|
|
||||||
if (!(bool_false = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL), &zero_value, &instr->loc)))
|
if (!(bool_false = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL), &zero_value, &instr->loc)))
|
||||||
return false;
|
return false;
|
||||||
|
@ -1595,7 +1595,6 @@ static struct hlsl_ir_node *collect_exprs(struct hlsl_ctx *ctx, struct hlsl_bloc
|
|||||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0};
|
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0};
|
||||||
struct hlsl_ir_expr *e1, *e2;
|
struct hlsl_ir_expr *e1, *e2;
|
||||||
enum hlsl_ir_expr_op opl;
|
enum hlsl_ir_expr_op opl;
|
||||||
struct hlsl_ir_node *res;
|
|
||||||
|
|
||||||
if (!node1 || !node2 || node1->type != HLSL_IR_EXPR || node2->type != HLSL_IR_EXPR)
|
if (!node1 || !node2 || node1->type != HLSL_IR_EXPR || node2->type != HLSL_IR_EXPR)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1612,10 +1611,7 @@ static struct hlsl_ir_node *collect_exprs(struct hlsl_ctx *ctx, struct hlsl_bloc
|
|||||||
|
|
||||||
operands[0] = e1->operands[0].node;
|
operands[0] = e1->operands[0].node;
|
||||||
operands[1] = hlsl_block_add_binary_expr(ctx, block, opr, e1->operands[1].node, e2->operands[1].node);
|
operands[1] = hlsl_block_add_binary_expr(ctx, block, opr, e1->operands[1].node, e2->operands[1].node);
|
||||||
if (!(res = hlsl_new_expr(ctx, opl, operands, instr->data_type, &instr->loc)))
|
return hlsl_block_add_expr(ctx, block, opl, operands, instr->data_type, &instr->loc);
|
||||||
return NULL;
|
|
||||||
hlsl_block_add_instr(block, res);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||||
@ -1734,19 +1730,13 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
|
|||||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {arg1, arg2};
|
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {arg1, arg2};
|
||||||
struct hlsl_ir_node *res;
|
struct hlsl_ir_node *res;
|
||||||
|
|
||||||
if (!(res = hlsl_new_expr(ctx, op, operands, instr->data_type, &instr->loc)))
|
res = hlsl_block_add_expr(ctx, &block, op, operands, instr->data_type, &instr->loc);
|
||||||
goto fail;
|
|
||||||
hlsl_block_add_instr(&block, res);
|
|
||||||
|
|
||||||
list_move_before(&instr->entry, &block.instrs);
|
list_move_before(&instr->entry, &block.instrs);
|
||||||
hlsl_replace_node(instr, res);
|
hlsl_replace_node(instr, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
return progress;
|
return progress;
|
||||||
|
|
||||||
fail:
|
|
||||||
hlsl_block_cleanup(&block);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
bool hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||||
|
Reference in New Issue
Block a user