From 11ee92ed7eb1287e0be7acf8d082b5d77a6c09eb Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Wed, 20 Mar 2024 14:54:18 +1000 Subject: [PATCH] vkd3d-shader/dxil: Implement DX intrinsic Discard. --- libs/vkd3d-shader/dxil.c | 14 ++++++++++++++ tests/hlsl/clip.shader_test | 8 ++++---- tests/hlsl/discard.shader_test | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 1a795172..0787ee13 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -401,6 +401,7 @@ enum dx_intrinsic_opcode DX_ATOMIC_BINOP = 78, DX_ATOMIC_CMP_XCHG = 79, DX_BARRIER = 80, + DX_DISCARD = 82, DX_DERIV_COARSEX = 83, DX_DERIV_COARSEY = 84, DX_DERIV_FINEX = 85, @@ -4460,6 +4461,18 @@ static void sm6_parser_emit_dx_create_handle(struct sm6_parser *sm6, enum dx_int ins->handler_idx = VKD3DSIH_NOP; } +static void sm6_parser_emit_dx_discard(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_param; + + vsir_instruction_init(ins, &sm6->p.location, VKD3DSIH_DISCARD); + + if ((src_param = instruction_src_params_alloc(ins, 1, sm6))) + src_param_init_from_value(src_param, operands[0]); +} + static void sm6_parser_emit_dx_fabs(struct sm6_parser *sm6, enum dx_intrinsic_opcode op, const struct sm6_value **operands, struct function_emission_state *state) { @@ -5315,6 +5328,7 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] = [DX_DERIV_COARSEY ] = {"e", "R", sm6_parser_emit_dx_unary}, [DX_DERIV_FINEX ] = {"e", "R", sm6_parser_emit_dx_unary}, [DX_DERIV_FINEY ] = {"e", "R", sm6_parser_emit_dx_unary}, + [DX_DISCARD ] = {"v", "1", sm6_parser_emit_dx_discard}, [DX_EXP ] = {"g", "R", sm6_parser_emit_dx_unary}, [DX_FABS ] = {"g", "R", sm6_parser_emit_dx_fabs}, [DX_FIRST_BIT_HI ] = {"i", "m", sm6_parser_emit_dx_unary}, diff --git a/tests/hlsl/clip.shader_test b/tests/hlsl/clip.shader_test index 3c003f1f..1ebc0687 100644 --- a/tests/hlsl/clip.shader_test +++ b/tests/hlsl/clip.shader_test @@ -9,14 +9,14 @@ float4 main() : sv_target [test] uniform 0 float4 1 2 3 4 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (1, 2, 3, 4) uniform 0 float4 9 8 7 6 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (9, 8, 7, 6) uniform 0 float4 -1 8 7 6 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (9, 8, 7, 6) uniform 0 float4 9 0 7 6 -todo(sm>=6 | glsl) draw quad +todo(glsl) draw quad probe all rgba (9, 0, 7, 6) diff --git a/tests/hlsl/discard.shader_test b/tests/hlsl/discard.shader_test index dba1b9b8..a5c210f0 100644 --- a/tests/hlsl/discard.shader_test +++ b/tests/hlsl/discard.shader_test @@ -9,8 +9,8 @@ float4 main() : sv_target [test] uniform 0 float4 1 2 3 4 -todo(sm<4 | sm>=6 | glsl) draw quad +todo(sm<4 | glsl) draw quad probe all rgba (1, 2, 3, 4) uniform 0 float4 9 8 7 6 -todo(sm<4 | sm>=6 | glsl) draw quad +todo(sm<4 | glsl) draw quad probe all rgba (1, 2, 3, 4)