From 127bcf90e4f7c5455e2ae82924860b48f440d9b5 Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Thu, 4 Apr 2024 14:29:57 +1000 Subject: [PATCH] vkd3d-shader/dxil: Implement DX intrinsic Coverage. --- libs/vkd3d-shader/dxil.c | 8 ++++++++ tests/hlsl/coverage.shader_test | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 96c8aba9..ccba66af 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -414,6 +414,7 @@ enum dx_intrinsic_opcode DX_DERIV_COARSEY = 84, DX_DERIV_FINEX = 85, DX_DERIV_FINEY = 86, + DX_COVERAGE = 91, DX_THREAD_ID = 93, DX_GROUP_ID = 94, DX_THREAD_ID_IN_GROUP = 95, @@ -4817,6 +4818,12 @@ static void sm6_parser_emit_dx_input_register_mov(struct sm6_parser *sm6, instruction_dst_param_init_ssa_scalar(ins, sm6); } +static void sm6_parser_emit_dx_coverage(struct sm6_parser *sm6, enum dx_intrinsic_opcode op, + const struct sm6_value **operands, struct function_emission_state *state) +{ + sm6_parser_emit_dx_input_register_mov(sm6, state->ins, VKD3DSPR_COVERAGE, VKD3D_DATA_UINT); +} + static const struct sm6_descriptor_info *sm6_parser_get_descriptor(struct sm6_parser *sm6, enum vkd3d_shader_descriptor_type type, unsigned int id, const struct sm6_value *address) { @@ -5935,6 +5942,7 @@ static const struct sm6_dx_opcode_info sm6_dx_op_table[] = [DX_CBUFFER_LOAD_LEGACY ] = {"o", "Hi", sm6_parser_emit_dx_cbuffer_load}, [DX_COS ] = {"g", "R", sm6_parser_emit_dx_sincos}, [DX_COUNT_BITS ] = {"i", "m", sm6_parser_emit_dx_unary}, + [DX_COVERAGE ] = {"i", "", sm6_parser_emit_dx_coverage}, [DX_CREATE_HANDLE ] = {"H", "ccib", sm6_parser_emit_dx_create_handle}, [DX_DERIV_COARSEX ] = {"e", "R", sm6_parser_emit_dx_unary}, [DX_DERIV_COARSEY ] = {"e", "R", sm6_parser_emit_dx_unary}, diff --git a/tests/hlsl/coverage.shader_test b/tests/hlsl/coverage.shader_test index ac098761..3a188da5 100644 --- a/tests/hlsl/coverage.shader_test +++ b/tests/hlsl/coverage.shader_test @@ -24,15 +24,15 @@ float4 main(float4 position : SV_Position, uint coverage : SV_Coverage) : SV_Tar [test] sample mask 0x01 -todo draw quad +todo(sm<6) draw quad probe all rgba (0.0, 0.25, 0.0, 0.25) probe uav 1 all rui (0x01) sample mask 0x03 -todo draw quad +todo(sm<6) draw quad probe all rgba (0.0, 0.5, 0.0, 0.5) probe uav 1 all rui (0x03) sample mask 0x07 -todo draw quad +todo(sm<6) draw quad probe all rgba (0.0, 0.75, 0.0, 0.75) probe uav 1 all rui (0x07) @@ -47,10 +47,10 @@ size (2d, 4, 4) [test] clear rtv 0 0.0 0.0 0.0 0.0 sample mask 0x09 -todo draw quad +todo(sm<6) draw quad probe all rgba (0.0, 0.5, 0.0, 0.5) probe uav 1 all rui (0x09) sample mask 0x0f -todo draw quad +todo(sm<6) draw quad probe all rgba (0.0, 1.0, 0.0, 1.0) probe uav 1 all rui (0x0f)