vkd3d-shader/hlsl: Make min16uint into a first-class type.

And properly implement translation into some binary enumerations.
This commit is contained in:
Elizabeth Figura
2025-01-27 16:34:22 -06:00
committed by Henri Verbeet
parent 16be9181a0
commit 18ca7affad
Notes: Henri Verbeet 2025-03-06 17:32:40 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1387
7 changed files with 151 additions and 31 deletions

View File

@@ -304,6 +304,7 @@ bool hlsl_base_type_is_integer(enum hlsl_base_type type)
{
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
return true;
@@ -516,6 +517,8 @@ static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, e
{
struct hlsl_type *type;
TRACE("New type %s.\n", name);
if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
if (!(type->name = hlsl_strdup(ctx, name)))
@@ -2908,6 +2911,7 @@ static void hlsl_dump_type(struct vkd3d_string_buffer *buffer, const struct hlsl
[HLSL_TYPE_HALF] = "half",
[HLSL_TYPE_DOUBLE] = "double",
[HLSL_TYPE_INT] = "int",
[HLSL_TYPE_MIN16UINT] = "min16uint",
[HLSL_TYPE_UINT] = "uint",
[HLSL_TYPE_BOOL] = "bool",
};
@@ -3375,6 +3379,7 @@ static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hl
vkd3d_string_buffer_printf(buffer, "%d ", value->i);
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
vkd3d_string_buffer_printf(buffer, "%u ", value->u);
break;
@@ -4401,17 +4406,17 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
static const char * const names[] =
{
[HLSL_TYPE_FLOAT] = "float",
[HLSL_TYPE_HALF] = "half",
[HLSL_TYPE_DOUBLE] = "double",
[HLSL_TYPE_INT] = "int",
[HLSL_TYPE_UINT] = "uint",
[HLSL_TYPE_BOOL] = "bool",
[HLSL_TYPE_FLOAT] = "float",
[HLSL_TYPE_HALF] = "half",
[HLSL_TYPE_DOUBLE] = "double",
[HLSL_TYPE_INT] = "int",
[HLSL_TYPE_UINT] = "uint",
[HLSL_TYPE_BOOL] = "bool",
[HLSL_TYPE_MIN16UINT] = "min16uint",
};
static const char *const variants_float[] = {"min10float", "min16float"};
static const char *const variants_int[] = {"min12int", "min16int"};
static const char *const variants_uint[] = {"min16uint"};
static const char *const sampler_names[] =
{
@@ -4502,11 +4507,6 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
n_variants = ARRAY_SIZE(variants_int);
break;
case HLSL_TYPE_UINT:
variants = variants_uint;
n_variants = ARRAY_SIZE(variants_uint);
break;
default:
n_variants = 0;
variants = NULL;

View File

@@ -103,6 +103,7 @@ enum hlsl_base_type
HLSL_TYPE_DOUBLE,
HLSL_TYPE_INT,
HLSL_TYPE_UINT,
HLSL_TYPE_MIN16UINT,
HLSL_TYPE_BOOL,
HLSL_TYPE_LAST_SCALAR = HLSL_TYPE_BOOL,
};

View File

@@ -1496,7 +1496,11 @@ static enum hlsl_base_type expr_common_base_type(enum hlsl_base_type t1, enum hl
return HLSL_TYPE_FLOAT;
if (t1 == HLSL_TYPE_UINT || t2 == HLSL_TYPE_UINT)
return HLSL_TYPE_UINT;
return HLSL_TYPE_INT;
if (t1 == HLSL_TYPE_INT || t2 == HLSL_TYPE_INT)
return HLSL_TYPE_INT;
if (t1 == HLSL_TYPE_MIN16UINT || t2 == HLSL_TYPE_MIN16UINT)
return HLSL_TYPE_MIN16UINT;
vkd3d_unreachable();
}
static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct hlsl_type *t2,
@@ -2836,6 +2840,7 @@ static enum hlsl_base_type hlsl_base_type_class(enum hlsl_base_type t)
return HLSL_TYPE_FLOAT;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
return HLSL_TYPE_INT;
@@ -2851,6 +2856,7 @@ static unsigned int hlsl_base_type_width(enum hlsl_base_type t)
switch (t)
{
case HLSL_TYPE_HALF:
case HLSL_TYPE_MIN16UINT:
return 16;
case HLSL_TYPE_FLOAT:

View File

@@ -246,13 +246,23 @@ static void validate_field_semantic(struct hlsl_ctx *ctx, struct hlsl_struct_fie
static enum hlsl_base_type base_type_get_semantic_equivalent(enum hlsl_base_type base)
{
if (base == HLSL_TYPE_BOOL)
return HLSL_TYPE_UINT;
if (base == HLSL_TYPE_INT)
return HLSL_TYPE_UINT;
if (base == HLSL_TYPE_HALF)
return HLSL_TYPE_FLOAT;
return base;
switch (base)
{
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
return HLSL_TYPE_UINT;
case HLSL_TYPE_HALF:
case HLSL_TYPE_FLOAT:
return HLSL_TYPE_FLOAT;
case HLSL_TYPE_DOUBLE:
return HLSL_TYPE_DOUBLE;
}
vkd3d_unreachable();
}
static bool types_are_semantic_equivalent(struct hlsl_ctx *ctx, const struct hlsl_type *type1,
@@ -3190,7 +3200,7 @@ static bool lower_casts_to_int(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
return false;
arg = expr->operands[0].node;
if (instr->data_type->e.numeric.type != HLSL_TYPE_INT && instr->data_type->e.numeric.type != HLSL_TYPE_UINT)
if (!hlsl_type_is_integer(instr->data_type) || instr->data_type->e.numeric.type == HLSL_TYPE_BOOL)
return false;
if (arg->data_type->e.numeric.type != HLSL_TYPE_FLOAT && arg->data_type->e.numeric.type != HLSL_TYPE_HALF)
return false;
@@ -4009,8 +4019,7 @@ static bool lower_int_dot(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, stru
if (expr->op != HLSL_OP2_DOT)
return false;
if (type->e.numeric.type == HLSL_TYPE_INT || type->e.numeric.type == HLSL_TYPE_UINT
|| type->e.numeric.type == HLSL_TYPE_BOOL)
if (hlsl_type_is_integer(type))
{
arg1 = expr->operands[0].node;
arg2 = expr->operands[1].node;
@@ -5099,6 +5108,7 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx,
f = value->i;
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
f = value->u;
break;
@@ -6674,6 +6684,7 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_prog
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
component_type = VKD3D_SHADER_COMPONENT_UINT;
break;
@@ -6763,6 +6774,22 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_prog
element->used_mask = use_mask;
if (program->shader_version.type == VKD3D_SHADER_TYPE_PIXEL && !output)
element->interpolation_mode = VKD3DSIM_LINEAR;
switch (var->data_type->e.numeric.type)
{
case HLSL_TYPE_BOOL:
case HLSL_TYPE_DOUBLE:
case HLSL_TYPE_FLOAT:
case HLSL_TYPE_HALF:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
element->min_precision = VKD3D_SHADER_MINIMUM_PRECISION_NONE;
break;
case HLSL_TYPE_MIN16UINT:
element->min_precision = VKD3D_SHADER_MINIMUM_PRECISION_UINT_16;
break;
}
}
static void generate_vsir_signature(struct hlsl_ctx *ctx,
@@ -6830,6 +6857,7 @@ static enum vkd3d_data_type vsir_data_type_from_hlsl_type(struct hlsl_ctx *ctx,
return VKD3D_DATA_INT;
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
return VKD3D_DATA_UINT;
}
}
@@ -7522,6 +7550,7 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
switch (src_type->e.numeric.type)
{
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
/* Integrals are internally represented as floats, so no change is necessary.*/
@@ -7543,8 +7572,9 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
break;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
switch(src_type->e.numeric.type)
switch (src_type->e.numeric.type)
{
case HLSL_TYPE_HALF:
case HLSL_TYPE_FLOAT:
@@ -7554,6 +7584,7 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
break;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MOV, 0, 0, true);
@@ -8251,6 +8282,10 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, bool is_comb
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
return D3DXPT_INT;
/* Minimum-precision types are not supported until 46, but at
* that point they do the same thing, and return sm4 types. */
case HLSL_TYPE_MIN16UINT:
return 0x39;
}
break;
@@ -8535,6 +8570,7 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe
uni.f = var->default_values[k].number.i;
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
uni.f = var->default_values[k].number.u;
@@ -8782,6 +8818,7 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_ITOF, 0, 0, true);
return true;
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_UTOF, 0, 0, true);
return true;
@@ -8805,6 +8842,7 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
return true;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MOV, 0, 0, true);
return true;
@@ -8819,6 +8857,7 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
}
break;
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
switch (src_type->e.numeric.type)
{
@@ -8828,6 +8867,7 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
return true;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MOV, 0, 0, true);
return true;
@@ -9025,6 +9065,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
return true;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_INEG, 0, 0, true);
return true;
@@ -9092,6 +9133,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
return true;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_IADD, 0, 0, true);
return true;
@@ -9123,6 +9165,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_DIV, 0, 0, true);
return true;
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
sm4_generate_vsir_expr_with_two_destinations(ctx, program, VKD3DSIH_UDIV, expr, 0);
return true;
@@ -9171,6 +9214,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_IEQ, 0, 0, true);
return true;
@@ -9195,6 +9239,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
return true;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_UGE, 0, 0, true);
return true;
@@ -9219,6 +9264,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
return true;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_ULT, 0, 0, true);
return true;
@@ -9253,6 +9299,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
return true;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_IMAD, 0, 0, true);
return true;
@@ -9273,6 +9320,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_IMAX, 0, 0, true);
return true;
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_UMAX, 0, 0, true);
return true;
@@ -9293,6 +9341,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_IMIN, 0, 0, true);
return true;
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_UMIN, 0, 0, true);
return true;
@@ -9305,6 +9354,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
case HLSL_OP2_MOD:
switch (dst_type->e.numeric.type)
{
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
sm4_generate_vsir_expr_with_two_destinations(ctx, program, VKD3DSIH_UDIV, expr, 1);
return true;
@@ -9322,6 +9372,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
return true;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
/* Using IMUL instead of UMUL because we're taking the low
* bits, and the native compiler generates IMUL. */
@@ -9344,6 +9395,7 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT: /* FIXME: Needs minimum-precision annotations. */
case HLSL_TYPE_UINT:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_INE, 0, 0, true);
return true;
@@ -10434,6 +10486,25 @@ static void generate_vsir_scan_required_features(struct hlsl_ctx *ctx, struct vs
* STENCIL_REF, and TYPED_UAV_LOAD_ADDITIONAL_FORMATS. */
}
static bool is_minimum_precision(enum hlsl_base_type type)
{
switch (type)
{
case HLSL_TYPE_BOOL:
case HLSL_TYPE_DOUBLE:
case HLSL_TYPE_FLOAT:
case HLSL_TYPE_HALF:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
return false;
case HLSL_TYPE_MIN16UINT:
return true;
}
vkd3d_unreachable();
}
static void generate_vsir_scan_global_flags(struct hlsl_ctx *ctx,
struct vsir_program *program, const struct hlsl_ir_function_decl *entry_func)
{
@@ -10471,7 +10542,7 @@ static void generate_vsir_scan_global_flags(struct hlsl_ctx *ctx,
/* Note that it doesn't matter if the semantic is unused or doesn't
* generate a signature element (e.g. SV_DispatchThreadID). */
if ((var->is_input_semantic || var->is_output_semantic)
&& type->is_minimum_precision)
&& (type->is_minimum_precision || is_minimum_precision(type->e.numeric.type)))
{
program->global_flags |= VKD3DSGF_ENABLE_MINIMUM_PRECISION;
break;
@@ -10608,6 +10679,7 @@ static enum vkd3d_data_type sm4_generate_vsir_get_format_type(const struct hlsl_
return VKD3D_DATA_INT;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
return VKD3D_DATA_UINT;
}
@@ -10902,6 +10974,7 @@ static enum D3D_RESOURCE_RETURN_TYPE sm4_data_type(const struct hlsl_type *type)
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
return D3D_RETURN_TYPE_UINT;
}
@@ -10987,6 +11060,8 @@ static D3D_SHADER_VARIABLE_TYPE sm4_base_type(const struct hlsl_type *type)
return D3D_SVT_INT;
case HLSL_TYPE_UINT:
return D3D_SVT_UINT;
case HLSL_TYPE_MIN16UINT:
return D3D_SVT_MIN16UINT;
}
vkd3d_unreachable();

View File

@@ -51,6 +51,7 @@ static bool fold_abs(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
dst->u[k].i = abs(src->value.u[k].i);
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = src->value.u[k].u;
break;
@@ -126,6 +127,7 @@ static bool fold_bit_not(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
switch (type)
{
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
dst->u[k].u = ~src->value.u[k].u;
@@ -175,6 +177,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
break;
case HLSL_TYPE_UINT:
case HLSL_TYPE_MIN16UINT:
u = src->value.u[k].u;
i = src->value.u[k].u;
f = src->value.u[k].u;
@@ -205,6 +208,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
break;
case HLSL_TYPE_UINT:
case HLSL_TYPE_MIN16UINT:
dst->u[k].u = u;
break;
@@ -395,6 +399,7 @@ static bool fold_neg(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
break;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = -src->value.u[k].u;
break;
@@ -612,6 +617,7 @@ static bool fold_add(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
/* Handling HLSL_TYPE_INT through the unsigned field to avoid
* undefined behavior with signed integers in C. */
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = src1->value.u[k].u + src2->value.u[k].u;
break;
@@ -638,6 +644,7 @@ static bool fold_and(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
switch (type)
{
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
dst->u[k].u = src1->value.u[k].u & src2->value.u[k].u;
@@ -665,6 +672,7 @@ static bool fold_or(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const
switch (type)
{
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
dst->u[k].u = src1->value.u[k].u | src2->value.u[k].u;
@@ -692,6 +700,7 @@ static bool fold_bit_xor(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
switch (type)
{
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = src1->value.u[k].u ^ src2->value.u[k].u;
break;
@@ -813,6 +822,7 @@ static bool fold_div(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
dst->u[k].i = src1->value.u[k].i / src2->value.u[k].i;
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
if (src2->value.u[k].u == 0)
{
@@ -855,6 +865,7 @@ static bool fold_equal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, co
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
dst->u[k].u = src1->value.u[k].u == src2->value.u[k].u;
break;
}
@@ -891,6 +902,7 @@ static bool fold_gequal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
dst->u[k].u = src1->value.u[k].u >= src2->value.u[k].u;
break;
}
@@ -927,6 +939,7 @@ static bool fold_less(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, con
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
dst->u[k].u = src1->value.u[k].u < src2->value.u[k].u;
break;
}
@@ -951,6 +964,7 @@ static bool fold_lshift(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
switch (src1->node.data_type->e.numeric.type)
{
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = src1->value.u[k].u << shift;
break;
@@ -989,6 +1003,7 @@ static bool fold_max(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
dst->u[k].i = max(src1->value.u[k].i, src2->value.u[k].i);
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = max(src1->value.u[k].u, src2->value.u[k].u);
break;
@@ -1027,6 +1042,7 @@ static bool fold_min(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
dst->u[k].i = min(src1->value.u[k].i, src2->value.u[k].i);
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = min(src1->value.u[k].u, src2->value.u[k].u);
break;
@@ -1065,6 +1081,7 @@ static bool fold_mod(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
dst->u[k].i = src1->value.u[k].i % src2->value.u[k].i;
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
if (src2->value.u[k].u == 0)
{
@@ -1105,6 +1122,7 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
break;
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = src1->value.u[k].u * src2->value.u[k].u;
break;
@@ -1141,6 +1159,7 @@ static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
dst->u[k].u = src1->value.u[k].u != src2->value.u[k].u;
break;
}
@@ -1183,6 +1202,7 @@ static bool fold_rshift(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
dst->u[k].i = src1->value.u[k].i >> shift;
break;
case HLSL_TYPE_MIN16UINT:
case HLSL_TYPE_UINT:
dst->u[k].u = src1->value.u[k].u >> shift;
break;
@@ -1399,6 +1419,7 @@ static bool constant_is_zero(struct hlsl_ir_constant *const_arg)
case HLSL_TYPE_UINT:
case HLSL_TYPE_INT:
case HLSL_TYPE_BOOL:
case HLSL_TYPE_MIN16UINT:
if (const_arg->value.u[k].u != 0)
return false;
break;
@@ -1429,6 +1450,7 @@ static bool constant_is_one(struct hlsl_ir_constant *const_arg)
case HLSL_TYPE_UINT:
case HLSL_TYPE_INT:
case HLSL_TYPE_MIN16UINT:
if (const_arg->value.u[k].u != 1)
return false;
break;
@@ -1524,7 +1546,7 @@ static bool is_op_associative(enum hlsl_ir_expr_op op, enum hlsl_base_type type)
{
case HLSL_OP2_ADD:
case HLSL_OP2_MUL:
return type == HLSL_TYPE_INT || type == HLSL_TYPE_UINT;
return hlsl_base_type_is_integer(type);
case HLSL_OP2_BIT_AND:
case HLSL_OP2_BIT_OR:
@@ -1574,7 +1596,7 @@ static bool is_op_left_distributive(enum hlsl_ir_expr_op opl, enum hlsl_ir_expr_
case HLSL_OP2_DOT:
case HLSL_OP2_MUL:
return opr == HLSL_OP2_ADD && (type == HLSL_TYPE_INT || type == HLSL_TYPE_UINT);
return opr == HLSL_OP2_ADD && hlsl_base_type_is_integer(type);
case HLSL_OP2_MAX:
return opr == HLSL_OP2_MIN;