mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
vkd3d-shader/ir: Require signed source operands for signed integer comparison instructions.
This commit is contained in:
Notes:
Henri Verbeet
2025-09-18 11:44:24 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1733
@@ -7143,6 +7143,7 @@ struct sm6_cmp_info
|
||||
{
|
||||
enum vkd3d_shader_opcode handler_idx;
|
||||
bool src_swap;
|
||||
uint32_t type_flags;
|
||||
};
|
||||
|
||||
static const struct sm6_cmp_info *sm6_map_cmp2_op(uint64_t code)
|
||||
@@ -7172,10 +7173,10 @@ static const struct sm6_cmp_info *sm6_map_cmp2_op(uint64_t code)
|
||||
[ICMP_UGE] = {VSIR_OP_UGE},
|
||||
[ICMP_ULT] = {VSIR_OP_ULT},
|
||||
[ICMP_ULE] = {VSIR_OP_UGE, true},
|
||||
[ICMP_SGT] = {VSIR_OP_ILT, true},
|
||||
[ICMP_SGE] = {VSIR_OP_IGE},
|
||||
[ICMP_SLT] = {VSIR_OP_ILT},
|
||||
[ICMP_SLE] = {VSIR_OP_IGE, true},
|
||||
[ICMP_SGT] = {VSIR_OP_ILT, true, DXIL_TYPE_SIGNED},
|
||||
[ICMP_SGE] = {VSIR_OP_IGE, false, DXIL_TYPE_SIGNED},
|
||||
[ICMP_SLT] = {VSIR_OP_ILT, false, DXIL_TYPE_SIGNED},
|
||||
[ICMP_SLE] = {VSIR_OP_IGE, true, DXIL_TYPE_SIGNED},
|
||||
};
|
||||
|
||||
return (code < ARRAY_SIZE(cmp_op_table)) ? &cmp_op_table[code] : NULL;
|
||||
@@ -7276,8 +7277,8 @@ static void sm6_parser_emit_cmp2(struct sm6_parser *sm6, const struct dxil_recor
|
||||
|
||||
if (!(src_params = instruction_src_params_alloc(ins, 2, sm6)))
|
||||
return;
|
||||
src_param_init_from_value(&src_params[0 ^ cmp->src_swap], a, 0, sm6);
|
||||
src_param_init_from_value(&src_params[1 ^ cmp->src_swap], b, 0, sm6);
|
||||
src_param_init_from_value(&src_params[0 ^ cmp->src_swap], a, cmp->type_flags, sm6);
|
||||
src_param_init_from_value(&src_params[1 ^ cmp->src_swap], b, cmp->type_flags, sm6);
|
||||
|
||||
instruction_dst_param_init_ssa_scalar(ins, 0, sm6);
|
||||
}
|
||||
|
||||
@@ -11299,6 +11299,7 @@ static void vsir_validate_integer_elementwise_operation(struct validation_contex
|
||||
static const bool types[VSIR_DATA_TYPE_COUNT] =
|
||||
{
|
||||
[VSIR_DATA_I32] = true,
|
||||
[VSIR_DATA_I64] = true,
|
||||
[VSIR_DATA_U32] = true,
|
||||
[VSIR_DATA_U64] = true,
|
||||
};
|
||||
@@ -11399,6 +11400,18 @@ static void vsir_validate_integer_comparison_operation(struct validation_context
|
||||
vsir_validate_comparison_operation(ctx, instruction, types);
|
||||
}
|
||||
|
||||
static void vsir_validate_signed_integer_comparison_operation(struct validation_context *ctx,
|
||||
const struct vkd3d_shader_instruction *instruction)
|
||||
{
|
||||
static const bool types[VSIR_DATA_TYPE_COUNT] =
|
||||
{
|
||||
[VSIR_DATA_I32] = true,
|
||||
[VSIR_DATA_I64] = true,
|
||||
};
|
||||
|
||||
vsir_validate_comparison_operation(ctx, instruction, types);
|
||||
}
|
||||
|
||||
static void vsir_validate_cast_operation(struct validation_context *ctx,
|
||||
const struct vkd3d_shader_instruction *instruction,
|
||||
const bool src_types[VSIR_DATA_TYPE_COUNT], const bool dst_types[VSIR_DATA_TYPE_COUNT])
|
||||
@@ -12369,8 +12382,8 @@ static const struct vsir_validator_instruction_desc vsir_validator_instructions[
|
||||
[VSIR_OP_IEQ] = {1, 2, vsir_validate_integer_comparison_operation},
|
||||
[VSIR_OP_IF] = {0, 1, vsir_validate_if},
|
||||
[VSIR_OP_IFC] = {0, 2, vsir_validate_ifc},
|
||||
[VSIR_OP_IGE] = {1, 2, vsir_validate_integer_comparison_operation},
|
||||
[VSIR_OP_ILT] = {1, 2, vsir_validate_integer_comparison_operation},
|
||||
[VSIR_OP_IGE] = {1, 2, vsir_validate_signed_integer_comparison_operation},
|
||||
[VSIR_OP_ILT] = {1, 2, vsir_validate_signed_integer_comparison_operation},
|
||||
[VSIR_OP_IMAD] = {1, 3, vsir_validate_integer_elementwise_operation},
|
||||
[VSIR_OP_IMAX] = {1, 2, vsir_validate_integer_elementwise_operation},
|
||||
[VSIR_OP_IMIN] = {1, 2, vsir_validate_integer_elementwise_operation},
|
||||
|
||||
Reference in New Issue
Block a user