[PATCH 3/5] d3dcompiler: Unconditionally report special (pixel shader output) sysvals based on the semantic name.

Zebediah Figura z.figura12 at gmail.com
Wed Aug 12 19:33:38 CDT 2020


That is, do not check that the shader is a pixel shader and that the signature
is an output signature. These semantic names can only be generated in such
conditions; using the name for any other stage is invalid.

The motivation for this patch is that the correct sysval should be reported
even if the RDEF chunk is missing. Accordingly I have replaced each test
shader with a stripped version.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/d3dcompiler_43/reflection.c       |  39 +++----
 dlls/d3dcompiler_43/tests/reflection.c | 152 ++++++++-----------------
 2 files changed, 59 insertions(+), 132 deletions(-)

diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c
index 729501dbddc..a081b20d68f 100644
--- a/dlls/d3dcompiler_43/reflection.c
+++ b/dlls/d3dcompiler_43/reflection.c
@@ -1608,7 +1608,7 @@ err_out:
     return hr;
 }
 
-static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *s, struct dxbc_section *section, DWORD target)
+static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *s, struct dxbc_section *section)
 {
     D3D11_SIGNATURE_PARAMETER_DESC *d;
     unsigned int string_data_offset;
@@ -1690,27 +1690,16 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
         d[i].ReadWriteMask = (mask >> 8) & 0xff;
         d[i].Mask = mask & 0xff;
 
-        /* pixel shaders have a special handling for SystemValueType in the output signature */
-        if (((target & D3DCOMPILER_SHADER_TARGET_SHADERTYPE_MASK) == 0xffff0000) && (section->tag == TAG_OSG5 || section->tag == TAG_OSGN))
-        {
-            TRACE("Pixelshader output signature fixup.\n");
-
-            if (d[i].Register == 0xffffffff)
-            {
-                if (!stricmp(d[i].SemanticName, "sv_depth"))
-                    d[i].SystemValueType = D3D_NAME_DEPTH;
-                else if (!stricmp(d[i].SemanticName, "sv_coverage"))
-                    d[i].SystemValueType = D3D_NAME_COVERAGE;
-                else if (!stricmp(d[i].SemanticName, "sv_depthgreaterequal"))
-                    d[i].SystemValueType = D3D_NAME_DEPTH_GREATER_EQUAL;
-                else if (!stricmp(d[i].SemanticName, "sv_depthlessequal"))
-                    d[i].SystemValueType = D3D_NAME_DEPTH_LESS_EQUAL;
-            }
-            else
-            {
-                d[i].SystemValueType = D3D_NAME_TARGET;
-            }
-        }
+        if (!stricmp(d[i].SemanticName, "sv_depth"))
+            d[i].SystemValueType = D3D_NAME_DEPTH;
+        else if (!stricmp(d[i].SemanticName, "sv_coverage"))
+            d[i].SystemValueType = D3D_NAME_COVERAGE;
+        else if (!stricmp(d[i].SemanticName, "sv_depthgreaterequal"))
+            d[i].SystemValueType = D3D_NAME_DEPTH_GREATER_EQUAL;
+        else if (!stricmp(d[i].SemanticName, "sv_depthlessequal"))
+            d[i].SystemValueType = D3D_NAME_DEPTH_LESS_EQUAL;
+        else if (!stricmp(d[i].SemanticName, "sv_target"))
+            d[i].SystemValueType = D3D_NAME_TARGET;
 
         TRACE("semantic: %s, semantic idx: %u, sysval_semantic %#x, "
                 "type %u, register idx: %u, use_mask %#x, input_mask %#x, stream %u\n",
@@ -1777,7 +1766,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl
                     goto err_out;
                 }
 
-                hr = d3dcompiler_parse_signature(reflection->isgn, section, reflection->target);
+                hr = d3dcompiler_parse_signature(reflection->isgn, section);
                 if (FAILED(hr))
                 {
                     WARN("Failed to parse section ISGN.\n");
@@ -1795,7 +1784,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl
                     goto err_out;
                 }
 
-                hr = d3dcompiler_parse_signature(reflection->osgn, section, reflection->target);
+                hr = d3dcompiler_parse_signature(reflection->osgn, section);
                 if (FAILED(hr))
                 {
                     WARN("Failed to parse section OSGN.\n");
@@ -1812,7 +1801,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl
                     goto err_out;
                 }
 
-                hr = d3dcompiler_parse_signature(reflection->pcsg, section, reflection->target);
+                hr = d3dcompiler_parse_signature(reflection->pcsg, section);
                 if (FAILED(hr))
                 {
                     WARN("Failed to parse section PCSG.\n");
diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c
index 617003a97b7..b51a0a20f4d 100644
--- a/dlls/d3dcompiler_43/tests/reflection.c
+++ b/dlls/d3dcompiler_43/tests/reflection.c
@@ -794,9 +794,6 @@ static void test_reflection_desc_ps(void)
     ok(count == 0, "Release failed %u\n", count);
 }
 
-/*
- * fxc.exe /E PS /Tps_5_0 /Fx
- */
 #if 0
 float4 PS() : SV_Target3
 {
@@ -804,25 +801,16 @@ float4 PS() : SV_Target3
     return a;
 }
 #endif
-static const DWORD test_reflection_desc_ps_output_blob_0[] = {
-0x43425844, 0x3e7b77e6, 0xe4e920b7, 0x9cad0533, 0x240117cc, 0x00000001, 0x0000018c, 0x00000005,
-0x00000034, 0x0000008c, 0x0000009c, 0x000000d0, 0x00000110, 0x46454452, 0x00000050, 0x00000000,
-0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
-0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
-0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
-0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000003, 0x00000000, 0x00000003, 0x00000003,
-0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
-0x03000065, 0x001020f2, 0x00000003, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x3f99999a,
-0x3f800000, 0x3e4ccccd, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000,
-0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000
+static const DWORD test_reflection_desc_ps_output_blob_0[] =
+{
+    0x43425844, 0xc3773602, 0x04f86bdc, 0x715f33b2, 0x9c063cae, 0x00000001, 0x000000b4, 0x00000003,
+    0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000003, 0x00000000, 0x00000003, 0x00000003,
+    0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000003c, 0x00000050, 0x0000000f,
+    0x0100086a, 0x03000065, 0x001020f2, 0x00000003, 0x08000036, 0x001020f2, 0x00000003, 0x00004002,
+    0x3f99999a, 0x3f800000, 0x3e4ccccd, 0x00000000, 0x0100003e,
 };
 
-/*
- * fxc.exe /E PS /Tps_5_0 /Fx
- */
 #if 0
 float PS() : SV_DepthLessEqual
 {
@@ -830,27 +818,16 @@ float PS() : SV_DepthLessEqual
     return a;
 }
 #endif
-static const DWORD test_reflection_desc_ps_output_blob_1[] = {
-0x43425844, 0xd8ead3ec, 0x61276ada, 0x70cdaa9e, 0x2cfd7f4c, 0x00000001, 0x000001c4, 0x00000005,
-0x00000034, 0x000000ac, 0x000000bc, 0x000000f8, 0x00000128, 0x46454452, 0x00000070, 0x00000000,
-0x00000000, 0x00000000, 0x0000003c, 0xffff0500, 0x00000100, 0x0000003c, 0x31314452, 0x0000003c,
-0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x7263694d, 0x666f736f,
-0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
-0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
-0x00000034, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
-0x00000e01, 0x445f5653, 0x68747065, 0x7373654c, 0x61757145, 0xabab006c, 0x58454853, 0x00000028,
-0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00027001, 0x04000036, 0x00027001, 0x00004001,
-0x3f99999a, 0x0100003e, 0x54415453, 0x00000094, 0x00000002, 0x00000000, 0x00000000, 0x00000001,
-0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000,
+static const DWORD test_reflection_desc_ps_output_blob_1[] =
+{
+    0x43425844, 0xc45db587, 0xdb0601fb, 0x7370900b, 0x219464be, 0x00000001, 0x000000a8, 0x00000003,
+    0x0000002c, 0x0000003c, 0x00000078, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+    0x00000034, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
+    0x00000e01, 0x445f5653, 0x68747065, 0x7373654c, 0x61757145, 0xabab006c, 0x58454853, 0x00000028,
+    0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00027001, 0x04000036, 0x00027001, 0x00004001,
+    0x3f99999a, 0x0100003e,
 };
 
-/*
- * fxc.exe /E PS /Tps_5_0 /Fx
- */
 #if 0
 float PS() : SV_DepthGreaterEqual
 {
@@ -858,27 +835,16 @@ float PS() : SV_DepthGreaterEqual
     return a;
 }
 #endif
-static const DWORD test_reflection_desc_ps_output_blob_2[] = {
-0x43425844, 0x9f61c8df, 0x612cbb1f, 0x9e1d039e, 0xf925a074, 0x00000001, 0x000001c8, 0x00000005,
-0x00000034, 0x000000ac, 0x000000bc, 0x000000fc, 0x0000012c, 0x46454452, 0x00000070, 0x00000000,
-0x00000000, 0x00000000, 0x0000003c, 0xffff0500, 0x00000100, 0x0000003c, 0x31314452, 0x0000003c,
-0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x7263694d, 0x666f736f,
-0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
-0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
-0x00000038, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
-0x00000e01, 0x445f5653, 0x68747065, 0x61657247, 0x45726574, 0x6c617571, 0xababab00, 0x58454853,
-0x00000028, 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00026001, 0x04000036, 0x00026001,
-0x00004001, 0x3f99999a, 0x0100003e, 0x54415453, 0x00000094, 0x00000002, 0x00000000, 0x00000000,
-0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000,
+static const DWORD test_reflection_desc_ps_output_blob_2[] =
+{
+    0x43425844, 0x13cce144, 0x3628f322, 0xa8ea9b7d, 0xbbf9f8d7, 0x00000001, 0x000000ac, 0x00000003,
+    0x0000002c, 0x0000003c, 0x0000007c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+    0x00000038, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
+    0x00000e01, 0x445f5653, 0x68747065, 0x61657247, 0x45726574, 0x6c617571, 0xababab00, 0x58454853,
+    0x00000028, 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00026001, 0x04000036, 0x00026001,
+    0x00004001, 0x3f99999a, 0x0100003e,
 };
 
-/*
- * fxc.exe /E PS /Tps_5_0 /Fx
- */
 #if 0
 float PS() : sV_DePtH
 {
@@ -886,26 +852,15 @@ float PS() : sV_DePtH
     return a;
 }
 #endif
-static const DWORD test_reflection_desc_ps_output_blob_3[] = {
-0x43425844, 0x32cec0e6, 0x3873ed32, 0x2e86ffd0, 0x21bb00e8, 0x00000001, 0x000001bc, 0x00000005,
-0x00000034, 0x000000ac, 0x000000bc, 0x000000f0, 0x00000120, 0x46454452, 0x00000070, 0x00000000,
-0x00000000, 0x00000000, 0x0000003c, 0xffff0500, 0x00000100, 0x0000003c, 0x31314452, 0x0000003c,
-0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x7263694d, 0x666f736f,
-0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
-0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
-0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
-0x00000e01, 0x445f5673, 0x48745065, 0xababab00, 0x58454853, 0x00000028, 0x00000050, 0x0000000a,
-0x0100086a, 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e,
-0x54415453, 0x00000094, 0x00000002, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
-0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+static const DWORD test_reflection_desc_ps_output_blob_3[] =
+{
+    0x43425844, 0x31c891d1, 0xcbb9d935, 0xa199e1d5, 0x70205254, 0x00000001, 0x000000a0, 0x00000003,
+    0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
+    0x00000e01, 0x445f5673, 0x48745065, 0xababab00, 0x58454853, 0x00000028, 0x00000050, 0x0000000a,
+    0x0100086a, 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e,
 };
 
-/*
- * fxc.exe /E PS /Tps_4_0 /Fx
- */
 #if 0
 float PS() : SV_Depth
 {
@@ -913,24 +868,15 @@ float PS() : SV_Depth
     return a;
 }
 #endif
-static const DWORD test_reflection_desc_ps_output_blob_4[] = {
-0x43425844, 0x7af34874, 0x975f09ad, 0xf6e50764, 0xdfb1255f, 0x00000001, 0x00000178, 0x00000005,
-0x00000034, 0x0000008c, 0x0000009c, 0x000000d0, 0x000000fc, 0x46454452, 0x00000050, 0x00000000,
-0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
-0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
-0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
-0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
-0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000024, 0x00000040, 0x00000009,
-0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e, 0x54415453,
-0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
-0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+static const DWORD test_reflection_desc_ps_output_blob_4[] =
+{
+    0x43425844, 0x1d404736, 0x00e4a4aa, 0x5fcdad54, 0x5abd13f8, 0x00000001, 0x0000009c, 0x00000003,
+    0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
+    0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000024, 0x00000040, 0x00000009,
+    0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e,
 };
 
-/*
- * fxc.exe /E PS /Tps_4_0 /Fx
- */
 #if 0
 bool PS() : SV_COVERAGE
 {
@@ -938,21 +884,13 @@ bool PS() : SV_COVERAGE
     return a;
 }
 #endif
-static const DWORD test_reflection_desc_ps_output_blob_5[] = {
-0x43425844, 0x40ae32a7, 0xe944bb1c, 0x1a2b1923, 0xea25962d, 0x00000001, 0x000001bc, 0x00000005,
-0x00000034, 0x000000ac, 0x000000bc, 0x000000f0, 0x00000120, 0x46454452, 0x00000070, 0x00000000,
-0x00000000, 0x00000000, 0x0000003c, 0xffff0500, 0x00000100, 0x0000003c, 0x31314452, 0x0000003c,
-0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x7263694d, 0x666f736f,
-0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
-0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
-0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0xffffffff,
-0x00000e01, 0x435f5653, 0x5245564f, 0x00454741, 0x58454853, 0x00000028, 0x00000050, 0x0000000a,
-0x0100086a, 0x02000065, 0x0000f000, 0x04000036, 0x0000f001, 0x00004001, 0xffffffff, 0x0100003e,
-0x54415453, 0x00000094, 0x00000002, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
-0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+static const DWORD test_reflection_desc_ps_output_blob_5[] =
+{
+    0x43425844, 0x6127612d, 0x09e2bb9a, 0xbba3889a, 0x987dafc2, 0x00000001, 0x000000a0, 0x00000003,
+    0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0xffffffff,
+    0x00000e01, 0x435f5653, 0x5245564f, 0x00454741, 0x52444853, 0x00000028, 0x00000041, 0x0000000a,
+    0x0100086a, 0x02000065, 0x0000f000, 0x04000036, 0x0000f001, 0x00004001, 0xffffffff, 0x0100003e,
 };
 
 static void test_reflection_desc_ps_output(void)
-- 
2.27.0




More information about the wine-devel mailing list