Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 92dcb3f2a..1e85e390c 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1806,10 +1806,13 @@ static bool intrinsic_min(struct hlsl_ctx *ctx, static bool intrinsic_pow(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { - struct hlsl_ir_node *log, *exp; + struct hlsl_ir_node *log, *exp, *arg; struct hlsl_ir_expr *mul;
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], *loc))) + if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc))) + return false; + + if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, arg, *loc))) return false; list_add_tail(params->instrs, &log->entry);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 536 +++++++++++++++++++---------------- 1 file changed, 289 insertions(+), 247 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 6996bb2d5..6dda22ab3 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1407,350 +1407,392 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
-static void write_sm4_expr(struct hlsl_ctx *ctx, +static bool type_is_float(const struct hlsl_type *type) +{ + return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF; +} + +static void write_sm4_cast(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr) { const struct hlsl_ir_node *arg1 = expr->operands[0].node; - const struct hlsl_ir_node *arg2 = expr->operands[1].node; + const struct hlsl_type *dst_type = expr->node.data_type; + const struct hlsl_type *src_type = arg1->data_type;
- assert(expr->node.reg.allocated); + /* Narrowing casts were already lowered. */ + assert(src_type->dimx == dst_type->dimx);
- switch (expr->node.data_type->base_type) + switch (dst_type->base_type) { case HLSL_TYPE_FLOAT: - { - switch (expr->op) + switch (src_type->base_type) { - case HLSL_OP1_ABS: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_ABS); + case HLSL_TYPE_HALF: + case HLSL_TYPE_FLOAT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0); break;
- case HLSL_OP1_CAST: - { - const struct hlsl_type *src_type = arg1->data_type; + case HLSL_TYPE_INT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_ITOF, &expr->node, arg1, 0); + break;
- /* Narrowing casts were already lowered. */ - assert(src_type->dimx == expr->node.data_type->dimx); + case HLSL_TYPE_UINT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_UTOF, &expr->node, arg1, 0); + break;
- switch (src_type->base_type) - { - case HLSL_TYPE_HALF: - case HLSL_TYPE_FLOAT: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0); - break; + case HLSL_TYPE_BOOL: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to float."); + break;
- case HLSL_TYPE_INT: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_ITOF, &expr->node, arg1, 0); - break; + case HLSL_TYPE_DOUBLE: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to float."); + break;
- case HLSL_TYPE_UINT: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_UTOF, &expr->node, arg1, 0); - break; + default: + break; + } + break;
- case HLSL_TYPE_BOOL: - hlsl_fixme(ctx, &expr->node.loc, "Casts from bool to float are not implemented.\n"); - break; + case HLSL_TYPE_INT: + switch (src_type->base_type) + { + case HLSL_TYPE_HALF: + case HLSL_TYPE_FLOAT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOI, &expr->node, arg1, 0); + break;
- case HLSL_TYPE_DOUBLE: - hlsl_fixme(ctx, &expr->node.loc, "Casts from double to float are not implemented.\n"); - break; + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0); + break;
- default: - break; - } + case HLSL_TYPE_BOOL: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int."); break; - }
- case HLSL_OP1_EXP2: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0); + case HLSL_TYPE_DOUBLE: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int."); break;
- case HLSL_OP1_FLOOR: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NI, &expr->node, arg1, 0); + default: break; + } + break;
- case HLSL_OP1_LOG2: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0); + case HLSL_TYPE_UINT: + switch (src_type->base_type) + { + case HLSL_TYPE_HALF: + case HLSL_TYPE_FLOAT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOU, &expr->node, arg1, 0); break;
- case HLSL_OP1_NEG: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_NEGATE); + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0); + break; + + case HLSL_TYPE_BOOL: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n"); + break; + + case HLSL_TYPE_DOUBLE: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n"); + break; + + default: + break; + } + break; + + case HLSL_TYPE_HALF: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to half.\n"); + break; + + case HLSL_TYPE_DOUBLE: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to double.\n"); + break; + + case HLSL_TYPE_BOOL: + hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to bool.\n"); + break; + + default: + assert(0); + } +} + +static void write_sm4_expr(struct hlsl_ctx *ctx, + struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr) +{ + const struct hlsl_ir_node *arg1 = expr->operands[0].node; + const struct hlsl_ir_node *arg2 = expr->operands[1].node; + const struct hlsl_type *dst_type = expr->node.data_type; + struct vkd3d_string_buffer *dst_type_string; + + assert(expr->node.reg.allocated); + + if (!(dst_type_string = hlsl_type_to_string(ctx, dst_type))) + return; + + switch (expr->op) + { + case HLSL_OP1_ABS: + switch (dst_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_ABS); break;
- case HLSL_OP1_ROUND: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0); + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s absolute value expression.", dst_type_string->buffer); + } + break; + + case HLSL_OP1_CAST: + write_sm4_cast(ctx, buffer, expr); + break; + + case HLSL_OP1_EXP2: + assert(type_is_float(dst_type)); + write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0); + break; + + case HLSL_OP1_FLOOR: + assert(type_is_float(dst_type)); + write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NI, &expr->node, arg1, 0); + break; + + case HLSL_OP1_LOG2: + assert(type_is_float(dst_type)); + write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0); + break; + + case HLSL_OP1_NEG: + switch (dst_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_NEGATE); break;
- case HLSL_OP1_SAT: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV - | (VKD3D_SM4_INSTRUCTION_FLAG_SATURATE << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT), - &expr->node, arg1, 0); + case HLSL_TYPE_INT: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_INEG, &expr->node, arg1, 0); break;
- case HLSL_OP2_ADD: + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s negation expression.", dst_type_string->buffer); + } + break; + + case HLSL_OP1_ROUND: + assert(type_is_float(dst_type)); + write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0); + break; + + case HLSL_OP1_SAT: + assert(type_is_float(dst_type)); + write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV + | (VKD3D_SM4_INSTRUCTION_FLAG_SATURATE << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT), + &expr->node, arg1, 0); + break; + + case HLSL_OP2_ADD: + switch (dst_type->base_type) + { + case HLSL_TYPE_FLOAT: write_sm4_binary_op(buffer, VKD3D_SM4_OP_ADD, &expr->node, arg1, arg2); break;
- case HLSL_OP2_DIV: + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s addition expression.", dst_type_string->buffer); + } + break; + + case HLSL_OP2_DIV: + switch (dst_type->base_type) + { + case HLSL_TYPE_FLOAT: write_sm4_binary_op(buffer, VKD3D_SM4_OP_DIV, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MAX: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_MAX, &expr->node, arg1, arg2); - break; + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s division expression.", dst_type_string->buffer); + } + break;
- case HLSL_OP2_MIN: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_MIN, &expr->node, arg1, arg2); + case HLSL_OP2_EQUAL: + { + const struct hlsl_type *src_type = arg1->data_type; + + assert(dst_type->base_type == HLSL_TYPE_BOOL); + + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_EQ, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MUL: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_MUL, &expr->node, arg1, arg2); + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IEQ, &expr->node, arg1, arg2); break;
default: - hlsl_fixme(ctx, &expr->node.loc, "SM4 float "%s" expression.", debug_hlsl_expr_op(expr->op)); + hlsl_fixme(ctx, &expr->node.loc, "SM4 equality between "%s" operands.", + debug_hlsl_type(ctx, src_type)); break; } break; }
- case HLSL_TYPE_INT: + case HLSL_OP2_GEQUAL: { - switch (expr->op) + const struct hlsl_type *src_type = arg1->data_type; + + assert(dst_type->base_type == HLSL_TYPE_BOOL); + + switch (src_type->base_type) { - case HLSL_OP1_CAST: - { - const struct hlsl_type *src_type = arg1->data_type; - - /* Narrowing casts were already lowered. */ - assert(src_type->dimx == expr->node.data_type->dimx); - - switch (src_type->base_type) - { - case HLSL_TYPE_HALF: - case HLSL_TYPE_FLOAT: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOI, &expr->node, arg1, 0); - break; - - case HLSL_TYPE_INT: - case HLSL_TYPE_UINT: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0); - break; - - case HLSL_TYPE_BOOL: - hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int."); - break; - - case HLSL_TYPE_DOUBLE: - hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int."); - break; - - default: - break; - } + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_GE, &expr->node, arg1, arg2); break; - }
- case HLSL_OP1_NEG: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_INEG, &expr->node, arg1, 0); + case HLSL_TYPE_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MAX: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMAX, &expr->node, arg1, arg2); + case HLSL_TYPE_BOOL: + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_UGE, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MIN: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMIN, &expr->node, arg1, arg2); + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 greater-than-or-equal between "%s" operands.", + debug_hlsl_type(ctx, src_type)); + break; + } + break; + } + + case HLSL_OP2_LESS: + { + const struct hlsl_type *src_type = arg1->data_type; + + assert(dst_type->base_type == HLSL_TYPE_BOOL); + + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_LT, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_BOOL: + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_ULT, &expr->node, arg1, arg2); break;
default: - hlsl_fixme(ctx, &expr->node.loc, "SM4 int "%s" expression.", debug_hlsl_expr_op(expr->op)); + hlsl_fixme(ctx, &expr->node.loc, "SM4 less-than between "%s" operands.", + debug_hlsl_type(ctx, src_type)); break; } break; }
- case HLSL_TYPE_UINT: - { - switch (expr->op) + case HLSL_OP2_MAX: + switch (dst_type->base_type) { - case HLSL_OP1_CAST: - { - const struct hlsl_type *src_type = arg1->data_type; - - /* Narrowing casts were already lowered. */ - assert(src_type->dimx == expr->node.data_type->dimx); - - switch (src_type->base_type) - { - case HLSL_TYPE_HALF: - case HLSL_TYPE_FLOAT: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOU, &expr->node, arg1, 0); - break; - - case HLSL_TYPE_INT: - case HLSL_TYPE_UINT: - write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0); - break; - - case HLSL_TYPE_BOOL: - hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n"); - break; - - case HLSL_TYPE_DOUBLE: - hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n"); - break; - - default: - break; - } + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_MAX, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMAX, &expr->node, arg1, arg2); break; - }
- case HLSL_OP2_MAX: + case HLSL_TYPE_UINT: write_sm4_binary_op(buffer, VKD3D_SM4_OP_UMAX, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MIN: + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s maximum expression.", dst_type_string->buffer); + } + break; + + case HLSL_OP2_MIN: + switch (dst_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_MIN, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMIN, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_UINT: write_sm4_binary_op(buffer, VKD3D_SM4_OP_UMIN, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MUL: + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s minimum expression.", dst_type_string->buffer); + } + break; + + case HLSL_OP2_MUL: + switch (dst_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_MUL, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_UINT: /* Using IMUL instead of UMUL because we're taking the low * bits, and the native compiler generates IMUL. */ write_sm4_binary_op_with_two_destinations(buffer, VKD3D_SM4_OP_IMUL, &expr->node, 1, arg1, arg2); break;
default: - hlsl_fixme(ctx, &expr->node.loc, "SM4 uint "%s" expression.\n", debug_hlsl_expr_op(expr->op)); - break; + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s multiplication expression.", dst_type_string->buffer); } break; - }
- case HLSL_TYPE_BOOL: + case HLSL_OP2_NEQUAL: { - switch (expr->op) - { - case HLSL_OP2_EQUAL: - { - const struct hlsl_type *src_type = arg1->data_type; - - switch (src_type->base_type) - { - case HLSL_TYPE_FLOAT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_EQ, &expr->node, arg1, arg2); - break; - - case HLSL_TYPE_BOOL: - case HLSL_TYPE_INT: - case HLSL_TYPE_UINT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_IEQ, &expr->node, arg1, arg2); - break; - - default: - hlsl_fixme(ctx, &expr->node.loc, "SM4 equality between "%s" operands.", - debug_hlsl_type(ctx, src_type)); - break; - } - break; - } + const struct hlsl_type *src_type = arg1->data_type;
- case HLSL_OP2_NEQUAL: - { - const struct hlsl_type *src_type = arg1->data_type; - - switch (src_type->base_type) - { - case HLSL_TYPE_FLOAT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_NE, &expr->node, arg1, arg2); - break; - - case HLSL_TYPE_BOOL: - case HLSL_TYPE_INT: - case HLSL_TYPE_UINT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_INE, &expr->node, arg1, arg2); - break; - - default: - hlsl_fixme(ctx, &expr->node.loc, "SM4 inequality between "%s" operands.", - debug_hlsl_type(ctx, src_type)); - break; - } - break; - } + assert(dst_type->base_type == HLSL_TYPE_BOOL);
- case HLSL_OP2_LESS: - { - const struct hlsl_type *src_type = arg1->data_type; - - switch (src_type->base_type) - { - case HLSL_TYPE_FLOAT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_LT, &expr->node, arg1, arg2); - break; - - case HLSL_TYPE_INT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg1, arg2); - break; - - case HLSL_TYPE_BOOL: - case HLSL_TYPE_UINT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_ULT, &expr->node, arg1, arg2); - break; - - default: - hlsl_fixme(ctx, &expr->node.loc, "SM4 less-than between "%s" operands.", - debug_hlsl_type(ctx, src_type)); - break; - } + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_NE, &expr->node, arg1, arg2); break; - }
- case HLSL_OP2_GEQUAL: - { - const struct hlsl_type *src_type = arg1->data_type; - - switch (src_type->base_type) - { - case HLSL_TYPE_FLOAT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_GE, &expr->node, arg1, arg2); - break; - - case HLSL_TYPE_INT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg1, arg2); - break; - - case HLSL_TYPE_BOOL: - case HLSL_TYPE_UINT: - write_sm4_binary_op(buffer, VKD3D_SM4_OP_UGE, &expr->node, arg1, arg2); - break; - - default: - hlsl_fixme(ctx, &expr->node.loc, "SM4 greater-than-or-equal between "%s" operands.", - debug_hlsl_type(ctx, src_type)); - break; - } + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_INE, &expr->node, arg1, arg2); break; - }
default: - hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.", debug_hlsl_expr_op(expr->op)); + hlsl_fixme(ctx, &expr->node.loc, "SM4 inequality between "%s" operands.", + debug_hlsl_type(ctx, src_type)); break; } break; }
default: - { - struct vkd3d_string_buffer *string; - - if ((string = hlsl_type_to_string(ctx, expr->node.data_type))) - hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", string->buffer); - hlsl_release_string_buffer(ctx, string); - break; - } + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", debug_hlsl_expr_op(expr->op)); } + + hlsl_release_string_buffer(ctx, dst_type_string); }
static void write_sm4_if(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_if *iff)
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 8, 2022 9:14 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 536 +++++++++++++++++++---------------- 1 file changed, 289 insertions(+), 247 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 6996bb2d5..6dda22ab3 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1407,350 +1407,392 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
-static void write_sm4_expr(struct hlsl_ctx *ctx, +static bool type_is_float(const struct hlsl_type *type) +{
- return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
+}
+static void write_sm4_cast(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr) { const struct hlsl_ir_node *arg1 = expr->operands[0].node;
- const struct hlsl_ir_node *arg2 = expr->operands[1].node;
- const struct hlsl_type *dst_type = expr->node.data_type;
- const struct hlsl_type *src_type = arg1->data_type;
- assert(expr->node.reg.allocated);
- /* Narrowing casts were already lowered. */
- assert(src_type->dimx == dst_type->dimx);
- switch (expr->node.data_type->base_type)
- switch (dst_type->base_type)
{ case HLSL_TYPE_FLOAT:
- {
- switch (expr->op)
- switch (src_type->base_type)
{
- case HLSL_OP1_ABS:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_ABS);
- case HLSL_TYPE_HALF:
- case HLSL_TYPE_FLOAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
break;
- case HLSL_OP1_CAST:
- {
- const struct hlsl_type *src_type = arg1->data_type;
- case HLSL_TYPE_INT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_ITOF, &expr->node, arg1, 0);
- break;
- /* Narrowing casts were already lowered. */
- assert(src_type->dimx == expr->node.data_type->dimx);
- case HLSL_TYPE_UINT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_UTOF, &expr->node, arg1, 0);
- break;
- switch (src_type->base_type)
- {
- case HLSL_TYPE_HALF:
- case HLSL_TYPE_FLOAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
- break;
- case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to float.");
- break;
- case HLSL_TYPE_INT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_ITOF, &expr->node, arg1, 0);
- break;
- case HLSL_TYPE_DOUBLE:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to float.");
- break;
- case HLSL_TYPE_UINT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_UTOF, &expr->node, arg1, 0);
- break;
- default:
- break;
- }
- break;
- case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "Casts from bool to float are not implemented.\n");
- break;
- case HLSL_TYPE_INT:
- switch (src_type->base_type)
- {
- case HLSL_TYPE_HALF:
- case HLSL_TYPE_FLOAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOI, &expr->node, arg1, 0);
- break;
- case HLSL_TYPE_DOUBLE:
- hlsl_fixme(ctx, &expr->node.loc, "Casts from double to float are not implemented.\n");
- break;
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
- break;
- default:
- break;
- }
- case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int.");
break;
}
case HLSL_OP1_EXP2:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0);
- case HLSL_TYPE_DOUBLE:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int.");
break;
- case HLSL_OP1_FLOOR:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NI, &expr->node, arg1, 0);
- default:
break;
- }
- break;
- case HLSL_OP1_LOG2:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0);
- case HLSL_TYPE_UINT:
- switch (src_type->base_type)
- {
- case HLSL_TYPE_HALF:
- case HLSL_TYPE_FLOAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOU, &expr->node, arg1, 0);
break;
- case HLSL_OP1_NEG:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1,
VKD3D_SM4_REGISTER_MODIFIER_NEGATE);
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
- break;
- case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n");
- break;
- case HLSL_TYPE_DOUBLE:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n");
- break;
- default:
- break;
- }
- break;
- case HLSL_TYPE_HALF:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to half.\n");
- break;
- case HLSL_TYPE_DOUBLE:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to double.\n");
- break;
- case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to bool.\n");
- break;
- default:
- assert(0);
- }
+}
+static void write_sm4_expr(struct hlsl_ctx *ctx,
- struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr)
+{
- const struct hlsl_ir_node *arg1 = expr->operands[0].node;
- const struct hlsl_ir_node *arg2 = expr->operands[1].node;
- const struct hlsl_type *dst_type = expr->node.data_type;
- struct vkd3d_string_buffer *dst_type_string;
- assert(expr->node.reg.allocated);
- if (!(dst_type_string = hlsl_type_to_string(ctx, dst_type)))
- return;
- switch (expr->op)
- {
- case HLSL_OP1_ABS:
- switch (dst_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_ABS);
break;
- case HLSL_OP1_ROUND:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0);
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s absolute value expression.", dst_type_string->buffer);
- }
- break;
- case HLSL_OP1_CAST:
- write_sm4_cast(ctx, buffer, expr);
- break;
- case HLSL_OP1_EXP2:
- assert(type_is_float(dst_type));
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0);
- break;
- case HLSL_OP1_FLOOR:
- assert(type_is_float(dst_type));
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NI, &expr->node, arg1, 0);
- break;
- case HLSL_OP1_LOG2:
- assert(type_is_float(dst_type));
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0);
- break;
- case HLSL_OP1_NEG:
- switch (dst_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1,
VKD3D_SM4_REGISTER_MODIFIER_NEGATE); break;
- case HLSL_OP1_SAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV
- | (VKD3D_SM4_INSTRUCTION_FLAG_SATURATE << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT),
- &expr->node, arg1, 0);
- case HLSL_TYPE_INT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_INEG, &expr->node, arg1, 0);
break;
- case HLSL_OP2_ADD:
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s negation expression.", dst_type_string->buffer);
- }
- break;
- case HLSL_OP1_ROUND:
- assert(type_is_float(dst_type));
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0);
- break;
- case HLSL_OP1_SAT:
- assert(type_is_float(dst_type));
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV
- | (VKD3D_SM4_INSTRUCTION_FLAG_SATURATE << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT),
- &expr->node, arg1, 0);
- break;
- case HLSL_OP2_ADD:
- switch (dst_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_ADD, &expr->node, arg1, arg2); break;
- case HLSL_OP2_DIV:
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s addition expression.", dst_type_string->buffer);
- }
- break;
- case HLSL_OP2_DIV:
- switch (dst_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_DIV, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MAX:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_MAX, &expr->node, arg1, arg2);
- break;
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s division expression.", dst_type_string->buffer);
- }
- break;
- case HLSL_OP2_MIN:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_MIN, &expr->node, arg1, arg2);
- case HLSL_OP2_EQUAL:
- {
- const struct hlsl_type *src_type = arg1->data_type;
- assert(dst_type->base_type == HLSL_TYPE_BOOL);
- switch (src_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_EQ, &expr->node, arg1, arg2);
break;
- case HLSL_OP2_MUL:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_MUL, &expr->node, arg1, arg2);
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_IEQ, &expr->node, arg1, arg2);
break;
default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 float "%s" expression.", debug_hlsl_expr_op(expr->op));
- hlsl_fixme(ctx, &expr->node.loc, "SM4 equality between "%s" operands.",
- debug_hlsl_type(ctx, src_type));
break; } break; }
- case HLSL_TYPE_INT:
- case HLSL_OP2_GEQUAL:
{
- switch (expr->op)
- const struct hlsl_type *src_type = arg1->data_type;
- assert(dst_type->base_type == HLSL_TYPE_BOOL);
- switch (src_type->base_type)
{
- case HLSL_OP1_CAST:
- {
- const struct hlsl_type *src_type = arg1->data_type;
- /* Narrowing casts were already lowered. */
- assert(src_type->dimx == expr->node.data_type->dimx);
- switch (src_type->base_type)
- {
- case HLSL_TYPE_HALF:
- case HLSL_TYPE_FLOAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOI, &expr->node, arg1, 0);
- break;
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
- break;
- case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int.");
- break;
- case HLSL_TYPE_DOUBLE:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int.");
- break;
- default:
- break;
- }
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_GE, &expr->node, arg1, arg2);
break;
}
case HLSL_OP1_NEG:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_INEG, &expr->node, arg1, 0);
- case HLSL_TYPE_INT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg1, arg2);
break;
- case HLSL_OP2_MAX:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMAX, &expr->node, arg1, arg2);
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_UINT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_UGE, &expr->node, arg1, arg2);
break;
- case HLSL_OP2_MIN:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMIN, &expr->node, arg1, arg2);
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 greater-than-or-equal between "%s" operands.",
- debug_hlsl_type(ctx, src_type));
- break;
- }
- break;
- }
- case HLSL_OP2_LESS:
- {
- const struct hlsl_type *src_type = arg1->data_type;
- assert(dst_type->base_type == HLSL_TYPE_BOOL);
- switch (src_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_LT, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_INT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_UINT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_ULT, &expr->node, arg1, arg2);
break;
default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 int "%s" expression.", debug_hlsl_expr_op(expr->op));
- hlsl_fixme(ctx, &expr->node.loc, "SM4 less-than between "%s" operands.",
- debug_hlsl_type(ctx, src_type));
break; } break; }
- case HLSL_TYPE_UINT:
- {
- switch (expr->op)
- case HLSL_OP2_MAX:
- switch (dst_type->base_type)
{
- case HLSL_OP1_CAST:
- {
- const struct hlsl_type *src_type = arg1->data_type;
- /* Narrowing casts were already lowered. */
- assert(src_type->dimx == expr->node.data_type->dimx);
- switch (src_type->base_type)
- {
- case HLSL_TYPE_HALF:
- case HLSL_TYPE_FLOAT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOU, &expr->node, arg1, 0);
- break;
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
- break;
- case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n");
- break;
- case HLSL_TYPE_DOUBLE:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n");
- break;
- default:
- break;
- }
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_MAX, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_INT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMAX, &expr->node, arg1, arg2);
break;
}
case HLSL_OP2_MAX:
- case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_UMAX, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MIN:
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s maximum expression.", dst_type_string->buffer);
- }
- break;
- case HLSL_OP2_MIN:
- switch (dst_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_MIN, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_INT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMIN, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_UMIN, &expr->node, arg1, arg2); break;
- case HLSL_OP2_MUL:
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s minimum expression.", dst_type_string->buffer);
- }
- break;
- case HLSL_OP2_MUL:
- switch (dst_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_MUL, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_UINT:
/* Using IMUL instead of UMUL because we're taking the low
- bits, and the native compiler generates IMUL. */
write_sm4_binary_op_with_two_destinations(buffer, VKD3D_SM4_OP_IMUL, &expr->node, 1, arg1, arg2); break;
default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 uint "%s" expression.\n", debug_hlsl_expr_op(expr->op));
- break;
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s multiplication expression.", dst_type_string->buffer);
} break;
}
case HLSL_TYPE_BOOL:
- case HLSL_OP2_NEQUAL:
{
- switch (expr->op)
- {
- case HLSL_OP2_EQUAL:
- {
- const struct hlsl_type *src_type = arg1->data_type;
- switch (src_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_EQ, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_IEQ, &expr->node, arg1, arg2);
- break;
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 equality between "%s" operands.",
- debug_hlsl_type(ctx, src_type));
- break;
- }
- break;
- }
- const struct hlsl_type *src_type = arg1->data_type;
- case HLSL_OP2_NEQUAL:
- {
- const struct hlsl_type *src_type = arg1->data_type;
- switch (src_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_NE, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_INE, &expr->node, arg1, arg2);
- break;
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 inequality between "%s" operands.",
- debug_hlsl_type(ctx, src_type));
- break;
- }
- break;
- }
- assert(dst_type->base_type == HLSL_TYPE_BOOL);
- case HLSL_OP2_LESS:
- {
- const struct hlsl_type *src_type = arg1->data_type;
- switch (src_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_LT, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_INT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg1, arg2);
- break;
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_UINT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_ULT, &expr->node, arg1, arg2);
- break;
- default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 less-than between "%s" operands.",
- debug_hlsl_type(ctx, src_type));
- break;
- }
- switch (src_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_NE, &expr->node, arg1, arg2);
break;
}
case HLSL_OP2_GEQUAL:
{
const struct hlsl_type *src_type = arg1->data_type;
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_GE, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_INT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_UGE, &expr->node, arg1, arg2);
break;
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 greater-than-or-equal between "%s" operands.",
debug_hlsl_type(ctx, src_type));
break;
}
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_INE, &expr->node, arg1, arg2);
break;
- }
default:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.", debug_hlsl_expr_op(expr->op));
- hlsl_fixme(ctx, &expr->node.loc, "SM4 inequality between "%s" operands.",
- debug_hlsl_type(ctx, src_type));
break; } break; }
default:
- {
- struct vkd3d_string_buffer *string;
- if ((string = hlsl_type_to_string(ctx, expr->node.data_type)))
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", string->buffer);
- hlsl_release_string_buffer(ctx, string);
- break;
- }
- hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", debug_hlsl_expr_op(expr->op));
}
- hlsl_release_string_buffer(ctx, dst_type_string);
}
static void write_sm4_if(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_if *iff) -- 2.35.1
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 09/03/22 00:58, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 536 +++++++++++++++++++---------------- 1 file changed, 289 insertions(+), 247 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 6996bb2d5..6dda22ab3 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1407,350 +1407,392 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
-static void write_sm4_expr(struct hlsl_ctx *ctx, +static bool type_is_float(const struct hlsl_type *type) +{
- return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
+}
+static void write_sm4_cast(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr) { const struct hlsl_ir_node *arg1 = expr->operands[0].node;
- const struct hlsl_ir_node *arg2 = expr->operands[1].node;
- const struct hlsl_type *dst_type = expr->node.data_type;
- const struct hlsl_type *src_type = arg1->data_type;
- assert(expr->node.reg.allocated);
- /* Narrowing casts were already lowered. */
- assert(src_type->dimx == dst_type->dimx);
- switch (expr->node.data_type->base_type)
- switch (dst_type->base_type) { case HLSL_TYPE_FLOAT:
{
switch (expr->op)
switch (src_type->base_type) {
case HLSL_OP1_ABS:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_ABS);
case HLSL_TYPE_HALF:
case HLSL_TYPE_FLOAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0); break;
case HLSL_OP1_CAST:
{
const struct hlsl_type *src_type = arg1->data_type;
case HLSL_TYPE_INT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_ITOF, &expr->node, arg1, 0);
break;
/* Narrowing casts were already lowered. */
assert(src_type->dimx == expr->node.data_type->dimx);
case HLSL_TYPE_UINT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_UTOF, &expr->node, arg1, 0);
break;
switch (src_type->base_type)
{
case HLSL_TYPE_HALF:
case HLSL_TYPE_FLOAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to float.");
break;
case HLSL_TYPE_INT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_ITOF, &expr->node, arg1, 0);
break;
case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to float.");
break;
case HLSL_TYPE_UINT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_UTOF, &expr->node, arg1, 0);
break;
default:
break;
}
break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, &expr->node.loc, "Casts from bool to float are not implemented.\n");
break;
case HLSL_TYPE_INT:
switch (src_type->base_type)
{
case HLSL_TYPE_HALF:
case HLSL_TYPE_FLOAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOI, &expr->node, arg1, 0);
break;
case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, &expr->node.loc, "Casts from double to float are not implemented.\n");
break;
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
break;
default:
break;
}
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int."); break;
}
case HLSL_OP1_EXP2:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0);
case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int."); break;
case HLSL_OP1_FLOOR:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NI, &expr->node, arg1, 0);
default: break;
}
break;
case HLSL_OP1_LOG2:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0);
case HLSL_TYPE_UINT:
switch (src_type->base_type)
{
case HLSL_TYPE_HALF:
case HLSL_TYPE_FLOAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOU, &expr->node, arg1, 0); break;
case HLSL_OP1_NEG:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_NEGATE);
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n");
break;
case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n");
break;
default:
break;
}
break;
case HLSL_TYPE_HALF:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to half.\n");
break;
case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to double.\n");
break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to bool.\n");
break;
default:
assert(0);
- }
+}
+static void write_sm4_expr(struct hlsl_ctx *ctx,
struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr)
+{
- const struct hlsl_ir_node *arg1 = expr->operands[0].node;
- const struct hlsl_ir_node *arg2 = expr->operands[1].node;
- const struct hlsl_type *dst_type = expr->node.data_type;
- struct vkd3d_string_buffer *dst_type_string;
- assert(expr->node.reg.allocated);
- if (!(dst_type_string = hlsl_type_to_string(ctx, dst_type)))
return;
- switch (expr->op)
- {
case HLSL_OP1_ABS:
switch (dst_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_ABS); break;
case HLSL_OP1_ROUND:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0);
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s absolute value expression.", dst_type_string->buffer);
}
break;
case HLSL_OP1_CAST:
write_sm4_cast(ctx, buffer, expr);
break;
case HLSL_OP1_EXP2:
assert(type_is_float(dst_type));
write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0);
break;
case HLSL_OP1_FLOOR:
assert(type_is_float(dst_type));
write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NI, &expr->node, arg1, 0);
break;
case HLSL_OP1_LOG2:
assert(type_is_float(dst_type));
write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0);
break;
case HLSL_OP1_NEG:
switch (dst_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_NEGATE); break;
case HLSL_OP1_SAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV
| (VKD3D_SM4_INSTRUCTION_FLAG_SATURATE << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT),
&expr->node, arg1, 0);
case HLSL_TYPE_INT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_INEG, &expr->node, arg1, 0); break;
case HLSL_OP2_ADD:
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s negation expression.", dst_type_string->buffer);
}
break;
case HLSL_OP1_ROUND:
assert(type_is_float(dst_type));
write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0);
break;
case HLSL_OP1_SAT:
assert(type_is_float(dst_type));
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV
| (VKD3D_SM4_INSTRUCTION_FLAG_SATURATE << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT),
&expr->node, arg1, 0);
break;
case HLSL_OP2_ADD:
switch (dst_type->base_type)
{
case HLSL_TYPE_FLOAT: write_sm4_binary_op(buffer, VKD3D_SM4_OP_ADD, &expr->node, arg1, arg2); break;
case HLSL_OP2_DIV:
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s addition expression.", dst_type_string->buffer);
}
break;
case HLSL_OP2_DIV:
switch (dst_type->base_type)
{
case HLSL_TYPE_FLOAT: write_sm4_binary_op(buffer, VKD3D_SM4_OP_DIV, &expr->node, arg1, arg2); break;
case HLSL_OP2_MAX:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_MAX, &expr->node, arg1, arg2);
break;
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s division expression.", dst_type_string->buffer);
}
break;
case HLSL_OP2_MIN:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_MIN, &expr->node, arg1, arg2);
case HLSL_OP2_EQUAL:
{
const struct hlsl_type *src_type = arg1->data_type;
assert(dst_type->base_type == HLSL_TYPE_BOOL);
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_EQ, &expr->node, arg1, arg2); break;
case HLSL_OP2_MUL:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_MUL, &expr->node, arg1, arg2);
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IEQ, &expr->node, arg1, arg2); break; default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 float \"%s\" expression.", debug_hlsl_expr_op(expr->op));
hlsl_fixme(ctx, &expr->node.loc, "SM4 equality between \"%s\" operands.",
debug_hlsl_type(ctx, src_type)); break; } break; }
case HLSL_TYPE_INT:
case HLSL_OP2_GEQUAL: {
switch (expr->op)
const struct hlsl_type *src_type = arg1->data_type;
assert(dst_type->base_type == HLSL_TYPE_BOOL);
switch (src_type->base_type) {
case HLSL_OP1_CAST:
{
const struct hlsl_type *src_type = arg1->data_type;
/* Narrowing casts were already lowered. */
assert(src_type->dimx == expr->node.data_type->dimx);
switch (src_type->base_type)
{
case HLSL_TYPE_HALF:
case HLSL_TYPE_FLOAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOI, &expr->node, arg1, 0);
break;
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int.");
break;
case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to int.");
break;
default:
break;
}
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_GE, &expr->node, arg1, arg2); break;
}
case HLSL_OP1_NEG:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_INEG, &expr->node, arg1, 0);
case HLSL_TYPE_INT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg1, arg2); break;
case HLSL_OP2_MAX:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMAX, &expr->node, arg1, arg2);
case HLSL_TYPE_BOOL:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_UGE, &expr->node, arg1, arg2); break;
case HLSL_OP2_MIN:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMIN, &expr->node, arg1, arg2);
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 greater-than-or-equal between \"%s\" operands.",
debug_hlsl_type(ctx, src_type));
break;
}
break;
}
case HLSL_OP2_LESS:
{
const struct hlsl_type *src_type = arg1->data_type;
assert(dst_type->base_type == HLSL_TYPE_BOOL);
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_LT, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_INT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_ULT, &expr->node, arg1, arg2); break; default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 int \"%s\" expression.", debug_hlsl_expr_op(expr->op));
hlsl_fixme(ctx, &expr->node.loc, "SM4 less-than between \"%s\" operands.",
debug_hlsl_type(ctx, src_type)); break; } break; }
case HLSL_TYPE_UINT:
{
switch (expr->op)
case HLSL_OP2_MAX:
switch (dst_type->base_type) {
case HLSL_OP1_CAST:
{
const struct hlsl_type *src_type = arg1->data_type;
/* Narrowing casts were already lowered. */
assert(src_type->dimx == expr->node.data_type->dimx);
switch (src_type->base_type)
{
case HLSL_TYPE_HALF:
case HLSL_TYPE_FLOAT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_FTOU, &expr->node, arg1, 0);
break;
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, 0);
break;
case HLSL_TYPE_BOOL:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.\n");
break;
case HLSL_TYPE_DOUBLE:
hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from double to uint.\n");
break;
default:
break;
}
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_MAX, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_INT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMAX, &expr->node, arg1, arg2); break;
}
case HLSL_OP2_MAX:
case HLSL_TYPE_UINT: write_sm4_binary_op(buffer, VKD3D_SM4_OP_UMAX, &expr->node, arg1, arg2); break;
case HLSL_OP2_MIN:
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s maximum expression.", dst_type_string->buffer);
}
break;
case HLSL_OP2_MIN:
switch (dst_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_MIN, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_INT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IMIN, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_UINT: write_sm4_binary_op(buffer, VKD3D_SM4_OP_UMIN, &expr->node, arg1, arg2); break;
case HLSL_OP2_MUL:
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s minimum expression.", dst_type_string->buffer);
}
break;
case HLSL_OP2_MUL:
switch (dst_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_MUL, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_UINT: /* Using IMUL instead of UMUL because we're taking the low * bits, and the native compiler generates IMUL. */ write_sm4_binary_op_with_two_destinations(buffer, VKD3D_SM4_OP_IMUL, &expr->node, 1, arg1, arg2); break; default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 uint \"%s\" expression.\n", debug_hlsl_expr_op(expr->op));
break;
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s multiplication expression.", dst_type_string->buffer); } break;
}
case HLSL_TYPE_BOOL:
case HLSL_OP2_NEQUAL: {
switch (expr->op)
{
case HLSL_OP2_EQUAL:
{
const struct hlsl_type *src_type = arg1->data_type;
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_EQ, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IEQ, &expr->node, arg1, arg2);
break;
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 equality between \"%s\" operands.",
debug_hlsl_type(ctx, src_type));
break;
}
break;
}
const struct hlsl_type *src_type = arg1->data_type;
case HLSL_OP2_NEQUAL:
{
const struct hlsl_type *src_type = arg1->data_type;
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_NE, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_INE, &expr->node, arg1, arg2);
break;
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 inequality between \"%s\" operands.",
debug_hlsl_type(ctx, src_type));
break;
}
break;
}
assert(dst_type->base_type == HLSL_TYPE_BOOL);
case HLSL_OP2_LESS:
{
const struct hlsl_type *src_type = arg1->data_type;
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_LT, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_INT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_ULT, &expr->node, arg1, arg2);
break;
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 less-than between \"%s\" operands.",
debug_hlsl_type(ctx, src_type));
break;
}
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_NE, &expr->node, arg1, arg2); break;
}
case HLSL_OP2_GEQUAL:
{
const struct hlsl_type *src_type = arg1->data_type;
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_GE, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_INT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_UGE, &expr->node, arg1, arg2);
break;
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 greater-than-or-equal between \"%s\" operands.",
debug_hlsl_type(ctx, src_type));
break;
}
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_INE, &expr->node, arg1, arg2); break;
} default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 bool \"%s\" expression.", debug_hlsl_expr_op(expr->op));
hlsl_fixme(ctx, &expr->node.loc, "SM4 inequality between \"%s\" operands.",
debug_hlsl_type(ctx, src_type)); break; } break; } default:
{
struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, expr->node.data_type)))
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", string->buffer);
hlsl_release_string_buffer(ctx, string);
break;
}
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s expression.", debug_hlsl_expr_op(expr->op)); }
hlsl_release_string_buffer(ctx, dst_type_string); }
static void write_sm4_if(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_if *iff)
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 6dda22ab3..c4cfcac08 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -100,6 +100,7 @@ bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semant {"sv_depth", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_DEPTH},
{"sv_position", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_UNDEFINED}, + {"sv_vertexid", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_VERTEX_ID},
{"position", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_POSITION}, {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_POSITION},
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 8, 2022 9:14 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 6dda22ab3..c4cfcac08 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -100,6 +100,7 @@ bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semant {"sv_depth", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_DEPTH},
{"sv_position", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_UNDEFINED},
- {"sv_vertexid", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_VERTEX_ID},
{"position", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_POSITION}, {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_POSITION}, -- 2.35.1
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 09/03/22 00:58, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 6dda22ab3..c4cfcac08 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -100,6 +100,7 @@ bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semant {"sv_depth", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_DEPTH},
{"sv_position", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_UNDEFINED},
{"sv_vertexid", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_VERTEX_ID}, {"position", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_POSITION}, {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_POSITION},
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index c4cfcac08..f635bfb0b 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1408,6 +1408,20 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
+static bool type_is_integer(const struct hlsl_type *type) +{ + switch (type->base_type) + { + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + return true; + + default: + return false; + } +} + static bool type_is_float(const struct hlsl_type *type) { return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF; @@ -1609,6 +1623,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, } break;
+ case HLSL_OP2_BIT_AND: + assert(type_is_integer(dst_type)); + write_sm4_binary_op(buffer, VKD3D_SM4_OP_AND, &expr->node, arg1, arg2); + break; + case HLSL_OP2_DIV: switch (dst_type->base_type) {
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 8, 2022 9:14 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index c4cfcac08..f635bfb0b 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1408,6 +1408,20 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
+static bool type_is_integer(const struct hlsl_type *type) +{
- switch (type->base_type)
- {
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- return true;
- default:
- return false;
- }
+}
static bool type_is_float(const struct hlsl_type *type) { return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF; @@ -1609,6 +1623,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, } break;
- case HLSL_OP2_BIT_AND:
- assert(type_is_integer(dst_type));
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_AND, &expr->node, arg1, arg2);
- break;
case HLSL_OP2_DIV: switch (dst_type->base_type) { -- 2.35.1
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- Though it feels a little bit funny that type_is_integer() and type_is_float() are written with inconsistent styles. Any particular reason? If not, I would express a mild preference to have them written in a more consistent way, following the principle of least surprise.
Il 09/03/22 00:58, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index c4cfcac08..f635bfb0b 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1408,6 +1408,20 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
+static bool type_is_integer(const struct hlsl_type *type) +{
- switch (type->base_type)
- {
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
return true;
default:
return false;
- }
+}
- static bool type_is_float(const struct hlsl_type *type) { return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
@@ -1609,6 +1623,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, } break;
case HLSL_OP2_BIT_AND:
assert(type_is_integer(dst_type));
write_sm4_binary_op(buffer, VKD3D_SM4_OP_AND, &expr->node, arg1, arg2);
break;
case HLSL_OP2_DIV: switch (dst_type->base_type) {
On 3/15/22 07:52, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Though it feels a little bit funny that type_is_integer() and type_is_float() are written with inconsistent styles. Any particular reason? If not, I would express a mild preference to have them written in a more consistent way, following the principle of least surprise.
Different number of chained conditionals, and it didn't really feel worth worrying about.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index f635bfb0b..2918b8b71 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1724,6 +1724,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_OP2_LSHIFT: + assert(type_is_integer(dst_type)); + write_sm4_binary_op(buffer, VKD3D_SM4_OP_ISHL, &expr->node, arg1, arg2); + break; + case HLSL_OP2_MAX: switch (dst_type->base_type) {
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 8, 2022 9:14 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index f635bfb0b..2918b8b71 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1724,6 +1724,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
- case HLSL_OP2_LSHIFT:
- assert(type_is_integer(dst_type));
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_ISHL, &expr->node, arg1, arg2);
- break;
case HLSL_OP2_MAX: switch (dst_type->base_type) { -- 2.35.1
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 09/03/22 00:58, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index f635bfb0b..2918b8b71 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1724,6 +1724,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
case HLSL_OP2_LSHIFT:
assert(type_is_integer(dst_type));
write_sm4_binary_op(buffer, VKD3D_SM4_OP_ISHL, &expr->node, arg1, arg2);
break;
case HLSL_OP2_MAX: switch (dst_type->base_type) {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- tests/shader_runner_d3d11.c | 55 ++++++------------------------------- 1 file changed, 9 insertions(+), 46 deletions(-)
diff --git a/tests/shader_runner_d3d11.c b/tests/shader_runner_d3d11.c index 79f98640e..6290ac290 100644 --- a/tests/shader_runner_d3d11.c +++ b/tests/shader_runner_d3d11.c @@ -62,9 +62,7 @@ struct d3d11_shader_context ID3D11RenderTargetView *rtv; ID3D11DeviceContext *immediate_context;
- ID3D11InputLayout *input_layout; ID3D11VertexShader *vs; - ID3D11Buffer *vb; };
static struct d3d11_shader_context *d3d11_shader_context(struct shader_context *c) @@ -325,12 +323,8 @@ static void destroy_test_context(struct d3d11_shader_context *context) { ULONG ref;
- if (context->input_layout) - ID3D11InputLayout_Release(context->input_layout); if (context->vs) ID3D11VertexShader_Release(context->vs); - if (context->vb) - ID3D11Buffer_Release(context->vb);
ID3D11DeviceContext_Release(context->immediate_context); ID3D11RenderTargetView_Release(context->rtv); @@ -411,28 +405,15 @@ static void d3d11_runner_destroy_texture(struct shader_context *c, struct textur
static void d3d11_runner_draw_quad(struct shader_context *c) { - static const D3D11_INPUT_ELEMENT_DESC default_layout_desc[] = - { - {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, - }; - static const char vs_source[] = - "float4 main(float4 position : POSITION) : sv_position\n" + "void main(uint id : SV_VertexID, out float4 position : SV_Position)\n" "{\n" - " return position;\n" + " float2 coords = float2((id << 1) & 2, id & 2);\n" + " position = float4(coords * float2(2, -2) + float2(-1, 1), 0, 1);\n" "}";
- static const struct vec2 quad[] = - { - {-1.0f, -1.0f}, - {-1.0f, 1.0f}, - { 1.0f, -1.0f}, - { 1.0f, 1.0f}, - }; - struct d3d11_shader_context *context = d3d11_shader_context(c); ID3D11Device *device = context->device; - unsigned int stride, offset; ID3D11Buffer *cb = NULL; ID3D11PixelShader *ps; ID3D10Blob *ps_code; @@ -451,30 +432,16 @@ static void d3d11_runner_draw_quad(struct shader_context *c) if (!(ps_code = compile_shader(context->c.ps_source, ps_profiles[context->c.minimum_shader_model]))) return;
- if (!context->input_layout || !context->vs) + if (!context->vs) { ID3D10Blob *vs_code = compile_shader(vs_source, "vs_4_0");
- if (!context->input_layout) - { - hr = ID3D11Device_CreateInputLayout(device, default_layout_desc, ARRAY_SIZE(default_layout_desc), - ID3D10Blob_GetBufferPointer(vs_code), ID3D10Blob_GetBufferSize(vs_code), &context->input_layout); - ok(hr == S_OK, "Failed to create input layout, hr %#lx.\n", hr); - } - - if (!context->vs) - { - hr = ID3D11Device_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code), - ID3D10Blob_GetBufferSize(vs_code), NULL, &context->vs); - ok(hr == S_OK, "Failed to create vertex shader, hr %#lx.\n", hr); - } - + hr = ID3D11Device_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code), + ID3D10Blob_GetBufferSize(vs_code), NULL, &context->vs); + ok(hr == S_OK, "Failed to create vertex shader, hr %#lx.\n", hr); ID3D10Blob_Release(vs_code); }
- if (!context->vb) - context->vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(quad), quad); - hr = ID3D11Device_CreatePixelShader(device, ID3D10Blob_GetBufferPointer(ps_code), ID3D10Blob_GetBufferSize(ps_code), NULL, &ps); ok(hr == S_OK, "Failed to create pixel shader, hr %#lx.\n", hr); @@ -514,15 +481,11 @@ static void d3d11_runner_draw_quad(struct shader_context *c) ID3D11SamplerState_Release(d3d11_sampler); }
- ID3D11DeviceContext_IASetInputLayout(context->immediate_context, context->input_layout); - ID3D11DeviceContext_IASetPrimitiveTopology(context->immediate_context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - stride = sizeof(*quad); - offset = 0; - ID3D11DeviceContext_IASetVertexBuffers(context->immediate_context, 0, 1, &context->vb, &stride, &offset); + ID3D11DeviceContext_IASetPrimitiveTopology(context->immediate_context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); ID3D11DeviceContext_VSSetShader(context->immediate_context, context->vs, NULL, 0); ID3D11DeviceContext_PSSetShader(context->immediate_context, ps, NULL, 0);
- ID3D11DeviceContext_Draw(context->immediate_context, 4, 0); + ID3D11DeviceContext_Draw(context->immediate_context, 3, 0);
ID3D11PixelShader_Release(ps); if (cb)
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 09/03/22 00:58, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
tests/shader_runner_d3d11.c | 55 ++++++------------------------------- 1 file changed, 9 insertions(+), 46 deletions(-)
diff --git a/tests/shader_runner_d3d11.c b/tests/shader_runner_d3d11.c index 79f98640e..6290ac290 100644 --- a/tests/shader_runner_d3d11.c +++ b/tests/shader_runner_d3d11.c @@ -62,9 +62,7 @@ struct d3d11_shader_context ID3D11RenderTargetView *rtv; ID3D11DeviceContext *immediate_context;
ID3D11InputLayout *input_layout; ID3D11VertexShader *vs;
ID3D11Buffer *vb; };
static struct d3d11_shader_context *d3d11_shader_context(struct shader_context *c)
@@ -325,12 +323,8 @@ static void destroy_test_context(struct d3d11_shader_context *context) { ULONG ref;
if (context->input_layout)
ID3D11InputLayout_Release(context->input_layout); if (context->vs) ID3D11VertexShader_Release(context->vs);
if (context->vb)
ID3D11Buffer_Release(context->vb); ID3D11DeviceContext_Release(context->immediate_context); ID3D11RenderTargetView_Release(context->rtv);
@@ -411,28 +405,15 @@ static void d3d11_runner_destroy_texture(struct shader_context *c, struct textur
static void d3d11_runner_draw_quad(struct shader_context *c) {
- static const D3D11_INPUT_ELEMENT_DESC default_layout_desc[] =
- {
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
- };
static const char vs_source[] =
"float4 main(float4 position : POSITION) : sv_position\n"
"void main(uint id : SV_VertexID, out float4 position : SV_Position)\n" "{\n"
" return position;\n"
" float2 coords = float2((id << 1) & 2, id & 2);\n"
" position = float4(coords * float2(2, -2) + float2(-1, 1), 0, 1);\n" "}";
- static const struct vec2 quad[] =
- {
{-1.0f, -1.0f},
{-1.0f, 1.0f},
{ 1.0f, -1.0f},
{ 1.0f, 1.0f},
- };
struct d3d11_shader_context *context = d3d11_shader_context(c); ID3D11Device *device = context->device;
- unsigned int stride, offset; ID3D11Buffer *cb = NULL; ID3D11PixelShader *ps; ID3D10Blob *ps_code;
@@ -451,30 +432,16 @@ static void d3d11_runner_draw_quad(struct shader_context *c) if (!(ps_code = compile_shader(context->c.ps_source, ps_profiles[context->c.minimum_shader_model]))) return;
- if (!context->input_layout || !context->vs)
- if (!context->vs) { ID3D10Blob *vs_code = compile_shader(vs_source, "vs_4_0");
if (!context->input_layout)
{
hr = ID3D11Device_CreateInputLayout(device, default_layout_desc, ARRAY_SIZE(default_layout_desc),
ID3D10Blob_GetBufferPointer(vs_code), ID3D10Blob_GetBufferSize(vs_code), &context->input_layout);
ok(hr == S_OK, "Failed to create input layout, hr %#lx.\n", hr);
}
if (!context->vs)
{
hr = ID3D11Device_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code),
ID3D10Blob_GetBufferSize(vs_code), NULL, &context->vs);
ok(hr == S_OK, "Failed to create vertex shader, hr %#lx.\n", hr);
}
hr = ID3D11Device_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code),
ID3D10Blob_GetBufferSize(vs_code), NULL, &context->vs);
ok(hr == S_OK, "Failed to create vertex shader, hr %#lx.\n", hr); ID3D10Blob_Release(vs_code); }
- if (!context->vb)
context->vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(quad), quad);
hr = ID3D11Device_CreatePixelShader(device, ID3D10Blob_GetBufferPointer(ps_code), ID3D10Blob_GetBufferSize(ps_code), NULL, &ps); ok(hr == S_OK, "Failed to create pixel shader, hr %#lx.\n", hr);
@@ -514,15 +481,11 @@ static void d3d11_runner_draw_quad(struct shader_context *c) ID3D11SamplerState_Release(d3d11_sampler); }
- ID3D11DeviceContext_IASetInputLayout(context->immediate_context, context->input_layout);
- ID3D11DeviceContext_IASetPrimitiveTopology(context->immediate_context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
- stride = sizeof(*quad);
- offset = 0;
- ID3D11DeviceContext_IASetVertexBuffers(context->immediate_context, 0, 1, &context->vb, &stride, &offset);
- ID3D11DeviceContext_IASetPrimitiveTopology(context->immediate_context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); ID3D11DeviceContext_VSSetShader(context->immediate_context, context->vs, NULL, 0); ID3D11DeviceContext_PSSetShader(context->immediate_context, ps, NULL, 0);
- ID3D11DeviceContext_Draw(context->immediate_context, 4, 0);
ID3D11DeviceContext_Draw(context->immediate_context, 3, 0);
ID3D11PixelShader_Release(ps); if (cb)
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 8, 2022 8:58 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.y | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 92dcb3f2a..1e85e390c 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1806,10 +1806,13 @@ static bool intrinsic_min(struct hlsl_ctx *ctx, static bool intrinsic_pow(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) {
- struct hlsl_ir_node *log, *exp;
- struct hlsl_ir_node *log, *exp, *arg;
struct hlsl_ir_expr *mul;
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], *loc)))
- if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
- return false;
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, arg, *loc)))
return false; list_add_tail(params->instrs, &log->entry);
-- 2.35.1
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 09/03/22 00:58, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.y | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 92dcb3f2a..1e85e390c 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1806,10 +1806,13 @@ static bool intrinsic_min(struct hlsl_ctx *ctx, static bool intrinsic_pow(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) {
- struct hlsl_ir_node *log, *exp;
- struct hlsl_ir_node *log, *exp, *arg; struct hlsl_ir_expr *mul;
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], *loc)))
- if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
return false;
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, arg, *loc))) return false; list_add_tail(params->instrs, &log->entry);