From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/dxil.c | 47 +++++++++++++++++++ tests/hlsl/arithmetic-int-uniform.shader_test | 6 +-- tests/hlsl/clamp.shader_test | 2 +- tests/hlsl/max.shader_test | 4 +- 4 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 83e79bfde..6efe4d1b3 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -342,6 +342,12 @@ enum dx_intrinsic_opcode DX_FIRST_BIT_LO = 32, DX_FIRST_BIT_HI = 33, DX_FIRST_BIT_SHI = 34, + DX_FMAX = 35, + DX_FMIN = 36, + DX_IMAX = 37, + DX_IMIN = 38, + DX_UMAX = 39, + DX_UMIN = 40, DX_CREATE_HANDLE = 57, DX_CBUFFER_LOAD_LEGACY = 59, DX_BUFFER_LOAD = 68, @@ -3546,6 +3552,41 @@ static void sm6_parser_emit_dx_unary(struct sm6_parser *sm6, enum dx_intrinsic_o instruction_dst_param_init_ssa_scalar(ins, sm6); }
+static enum vkd3d_shader_opcode map_dx_binary_op(enum dx_intrinsic_opcode op, const struct sm6_type *type) +{ + switch (op) + { + case DX_FMAX: + return type->u.width == 64 ? VKD3DSIH_DMAX : VKD3DSIH_MAX; + case DX_FMIN: + return type->u.width == 64 ? VKD3DSIH_DMIN : VKD3DSIH_MIN; + case DX_IMAX: + return VKD3DSIH_IMAX; + case DX_IMIN: + return VKD3DSIH_IMIN; + case DX_UMAX: + return VKD3DSIH_UMAX; + case DX_UMIN: + return VKD3DSIH_UMIN; + default: + vkd3d_unreachable(); + } +} + +static void sm6_parser_emit_dx_binary(struct sm6_parser *sm6, enum dx_intrinsic_opcode op, + const struct sm6_value **operands, struct function_emission_state *state) +{ + struct vkd3d_shader_instruction *ins = state->ins; + struct vkd3d_shader_src_param *src_params; + + vsir_instruction_init(ins, &sm6->p.location, map_dx_binary_op(op, operands[0]->type)); + src_params = instruction_src_params_alloc(ins, 2, sm6); + src_param_init_from_value(&src_params[0], operands[0]); + src_param_init_from_value(&src_params[1], operands[1]); + + instruction_dst_param_init_ssa_scalar(ins, sm6); +} + static void sm6_parser_emit_dx_cbuffer_load(struct sm6_parser *sm6, enum dx_intrinsic_opcode op, const struct sm6_value **operands, struct function_emission_state *state) { @@ -3793,7 +3834,11 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] = [DX_FIRST_BIT_HI ] = {"i", "m", sm6_parser_emit_dx_unary}, [DX_FIRST_BIT_LO ] = {"i", "m", sm6_parser_emit_dx_unary}, [DX_FIRST_BIT_SHI ] = {"i", "m", sm6_parser_emit_dx_unary}, + [DX_FMAX ] = {"g", "RR", sm6_parser_emit_dx_binary}, + [DX_FMIN ] = {"g", "RR", sm6_parser_emit_dx_binary}, [DX_FRC ] = {"g", "R", sm6_parser_emit_dx_unary}, + [DX_IMAX ] = {"m", "RR", sm6_parser_emit_dx_binary}, + [DX_IMIN ] = {"m", "RR", sm6_parser_emit_dx_binary}, [DX_LEGACY_F16TOF32 ] = {"f", "i", sm6_parser_emit_dx_unary}, [DX_LEGACY_F32TOF16 ] = {"i", "f", sm6_parser_emit_dx_unary}, [DX_LOAD_INPUT ] = {"o", "ii8i", sm6_parser_emit_dx_load_input}, @@ -3805,6 +3850,8 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] = [DX_RSQRT ] = {"g", "R", sm6_parser_emit_dx_unary}, [DX_SQRT ] = {"g", "R", sm6_parser_emit_dx_unary}, [DX_STORE_OUTPUT ] = {"v", "ii8o", sm6_parser_emit_dx_store_output}, + [DX_UMAX ] = {"m", "RR", sm6_parser_emit_dx_binary}, + [DX_UMIN ] = {"m", "RR", sm6_parser_emit_dx_binary}, };
static bool sm6_parser_validate_operand_type(struct sm6_parser *sm6, const struct sm6_value *value, char info_type, diff --git a/tests/hlsl/arithmetic-int-uniform.shader_test b/tests/hlsl/arithmetic-int-uniform.shader_test index bb83eb76e..fe6ad7e9f 100644 --- a/tests/hlsl/arithmetic-int-uniform.shader_test +++ b/tests/hlsl/arithmetic-int-uniform.shader_test @@ -98,7 +98,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 5.0 -7.0 0.0 -10.0 -todo(sm>=6) draw quad +draw quad probe all rgba (5.0, 7.0, 0.0, 10.0)
[pixel shader] @@ -194,5 +194,5 @@ float4 main() : SV_TARGET
[test] uniform 0 int64_t2 5000000000 -7000000000 -todo draw quad -probe all rgba (5.0, 7.0, 0.0, 0.0) +draw quad +probe all rgba (5.0e9, 7.0e9, 0.0, 0.0) diff --git a/tests/hlsl/clamp.shader_test b/tests/hlsl/clamp.shader_test index 3d797ec3f..40d0294bd 100644 --- a/tests/hlsl/clamp.shader_test +++ b/tests/hlsl/clamp.shader_test @@ -8,7 +8,7 @@ float4 main() : sv_target
[test] uniform 0 float4 -0.3 -0.1 0.7 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (-0.1, 0.7, -0.3, 0.3)
diff --git a/tests/hlsl/max.shader_test b/tests/hlsl/max.shader_test index e2763df46..09f4a882c 100644 --- a/tests/hlsl/max.shader_test +++ b/tests/hlsl/max.shader_test @@ -8,7 +8,7 @@ float4 main() : sv_target
[test] uniform 0 float4 0.7 -0.1 0.0 0.0 -todo(sm>=6) draw quad +draw quad probe all rgba (0.7, 2.1, 2.0, -1.0)
@@ -24,7 +24,7 @@ float4 main() : sv_target
[test] uniform 0 float4 0.7 -0.1 0.4 0.8 -todo(sm>=6) draw quad +draw quad probe all rgba (0.7, 0.8, 0.7, 0.2)