From 59f770214a5e040eb9c7b185c03539d8ed229cd8 Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Tue, 18 Jun 2024 23:52:38 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Implement output SV_Coverage. --- libs/vkd3d-shader/tpf.c | 2 ++ tests/hlsl/coverage.shader_test | 7 ++++--- tests/hlsl_d3d12.c | 13 ++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 0c4d93dc..a7c37215 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -2762,6 +2762,7 @@ bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_sem {"depth", true, VKD3D_SHADER_TYPE_PIXEL, VKD3DSPR_DEPTHOUT, false}, {"sv_depth", true, VKD3D_SHADER_TYPE_PIXEL, VKD3DSPR_DEPTHOUT, false}, {"sv_target", true, VKD3D_SHADER_TYPE_PIXEL, VKD3DSPR_OUTPUT, true}, + {"sv_coverage", true, VKD3D_SHADER_TYPE_PIXEL, VKD3DSPR_SAMPLEMASK, false}, }; for (i = 0; i < ARRAY_SIZE(register_table); ++i) @@ -2817,6 +2818,7 @@ bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semant {"depth", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_DEPTH}, {"sv_target", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_TARGET}, {"sv_depth", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_DEPTH}, + {"sv_coverage", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_COVERAGE}, {"sv_position", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_UNDEFINED}, {"sv_vertexid", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_VERTEX_ID}, diff --git a/tests/hlsl/coverage.shader_test b/tests/hlsl/coverage.shader_test index d75b244f..661af77c 100644 --- a/tests/hlsl/coverage.shader_test +++ b/tests/hlsl/coverage.shader_test @@ -5,7 +5,7 @@ shader model >= 4.1 format r32g32b32a32 float size (2dms, 4, 640, 480) -[pixel shader todo] +[pixel shader] float4 main(out uint sample_mask : SV_Coverage) : SV_Target { sample_mask = 0x5; @@ -13,11 +13,12 @@ float4 main(out uint sample_mask : SV_Coverage) : SV_Target } [test] -todo(sm<6) draw quad +clear rtv 0 0.0 0.0 0.0 0.0 +todo(glsl) draw quad probe (0, 0) rgba (0.5, 0.5, 0.5, 0.5) sample mask 0x0b clear rtv 0 0.0 0.0 0.0 0.0 -todo(sm<6) draw quad +todo(glsl) draw quad probe (0, 0) rgba (0.25, 0.25, 0.25, 0.25) diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 1595df86..43b1f0e9 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -2059,12 +2059,14 @@ static void test_signature_reflection(void) "void main(\n" " in float2 a : apple,\n" " out float4 b : sv_target2,\n" - " out float c : sv_depth,\n" + " out uint c : sv_coverage,\n" " in float4 d : position,\n" - " in float4 e : sv_position)\n" + " in float4 e : sv_position,\n" + " out float f : sv_depth)\n" "{\n" " b = d;\n" " c = 0;\n" + " f = 1;\n" "}"; static const D3D12_SIGNATURE_PARAMETER_DESC ps1_inputs[] = @@ -2076,8 +2078,9 @@ static void test_signature_reflection(void) static const D3D12_SIGNATURE_PARAMETER_DESC ps1_outputs[] = { - {"sv_target", 2, 2, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, - {"sv_depth", 0, ~0u, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe}, + {"sv_target", 2, 2, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + {"sv_coverage", 0, ~0u, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe}, + {"sv_depth", 0, ~0u, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe}, }; static const char ps2_source[] = @@ -2123,7 +2126,7 @@ static void test_signature_reflection(void) {vs1_source, "vs_4_0", true, vs1_inputs, ARRAY_SIZE(vs1_inputs), vs1_outputs, ARRAY_SIZE(vs1_outputs)}, {vs2_source, "vs_4_0", false, vs2_inputs, ARRAY_SIZE(vs2_inputs), vs2_outputs, ARRAY_SIZE(vs2_outputs)}, {vs2_source, "vs_4_0", true, vs2_inputs, ARRAY_SIZE(vs2_inputs), vs2_legacy_outputs, ARRAY_SIZE(vs2_legacy_outputs)}, - {ps1_source, "ps_4_0", false, ps1_inputs, ARRAY_SIZE(ps1_inputs), ps1_outputs, ARRAY_SIZE(ps1_outputs)}, + {ps1_source, "ps_4_1", false, ps1_inputs, ARRAY_SIZE(ps1_inputs), ps1_outputs, ARRAY_SIZE(ps1_outputs)}, {ps2_source, "ps_4_0", true, ps2_inputs, ARRAY_SIZE(ps2_inputs), ps2_outputs, ARRAY_SIZE(ps2_outputs)}, {cs1_source, "cs_5_0", false, NULL, 0, NULL, 0}, };