From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d-shader/spirv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index e39e27a66..7a3357533 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -8005,8 +8005,9 @@ static void spirv_compiler_emit_discard(struct spirv_compiler *compiler, * a mismatch between the VSIR structure and the SPIR-V one, which would cause problems if * structurisation is necessary. Therefore we emit it as a function call. */ condition_id = spirv_compiler_emit_load_src(compiler, src, VKD3DSP_WRITEMASK_0); - condition_id = spirv_compiler_emit_int_to_bool(compiler, - instruction->flags, src->reg.data_type, 1, condition_id); + if (src->reg.data_type != VKD3D_DATA_BOOL) + condition_id = spirv_compiler_emit_int_to_bool(compiler, + instruction->flags, src->reg.data_type, 1, condition_id); void_id = vkd3d_spirv_get_op_type_void(builder); vkd3d_spirv_build_op_function_call(builder, void_id, spirv_compiler_get_discard_function_id(compiler), &condition_id, 1);
From: Conor McCarthy cmccarthy@codeweavers.com
--- 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 7f9a74fa7..99004c6db 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, @@ -4273,6 +4274,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) { @@ -5086,6 +5099,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 3c003f1f5..1ebc06871 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 dba1b9b8e..a5c210f03 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)
This merge request was approved by Giovanni Mascellani.
This merge request was approved by Henri Verbeet.