[PATCH 6/6] d3d10core/tests: Port stream output tests from d3d11.

Józef Kucia jkucia at codeweavers.com
Tue Apr 4 05:35:58 CDT 2017


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/d3d10core/tests/device.c | 367 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 367 insertions(+)

diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index a353388..b0bc8f9 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -11757,6 +11757,372 @@ float4 main(struct ps_data ps_input) : SV_Target
     release_test_context(&test_context);
 }
 
+#define check_so_desc(a, b, c, d, e, f, g) check_so_desc_(__LINE__, a, b, c, d, e, f, g)
+static void check_so_desc_(unsigned int line, ID3D10Device *device,
+        const DWORD *code, size_t code_size, const D3D10_SO_DECLARATION_ENTRY *entry,
+        unsigned int entry_count, unsigned int stride, BOOL valid)
+{
+    ID3D10GeometryShader *gs = (ID3D10GeometryShader *)0xdeadbeef;
+    HRESULT hr;
+
+    hr = ID3D10Device_CreateGeometryShaderWithStreamOutput(device, code, code_size,
+            entry, entry_count, stride, &gs);
+    ok_(__FILE__, line)(hr == (valid ? S_OK : E_INVALIDARG), "Got unexpected hr %#x.\n", hr);
+    if (!valid)
+        ok_(__FILE__, line)(!gs, "Got unexpected geometry shader %p.\n", gs);
+    if (SUCCEEDED(hr))
+        ID3D10GeometryShader_Release(gs);
+}
+
+static void test_stream_output(void)
+{
+    struct d3d10core_test_context test_context;
+    unsigned int i, count;
+    ID3D10Device *device;
+
+    static const DWORD vs_code[] =
+    {
+#if 0
+        struct data
+        {
+            float4 position : SV_Position;
+            float4 attrib1 : ATTRIB1;
+            float3 attrib2 : attrib2;
+            float2 attrib3 : ATTriB3;
+            float  attrib4 : ATTRIB4;
+        };
+
+        void main(in data i, out data o)
+        {
+            o = i;
+        }
+#endif
+        0x43425844, 0x3f5b621f, 0x8f390786, 0x7235c8d6, 0xc1181ad3, 0x00000001, 0x00000278, 0x00000003,
+        0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
+        0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
+        0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
+        0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
+        0x00000004, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69,
+        0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
+        0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+        0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
+        0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
+        0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
+        0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
+        0xababab00, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x0300005f, 0x001010f2, 0x00000000,
+        0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x00101072, 0x00000002, 0x0300005f, 0x00101032,
+        0x00000003, 0x0300005f, 0x00101012, 0x00000004, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
+        0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
+        0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
+        0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036, 0x00102072,
+        0x00000002, 0x00101246, 0x00000002, 0x05000036, 0x00102032, 0x00000003, 0x00101046, 0x00000003,
+        0x05000036, 0x00102042, 0x00000003, 0x0010100a, 0x00000004, 0x0100003e,
+    };
+    static const DWORD gs_code[] =
+    {
+#if 0
+        struct data
+        {
+            float4 position : SV_Position;
+            float4 attrib1 : ATTRIB1;
+            float3 attrib2 : attrib2;
+            float2 attrib3 : ATTriB3;
+            float  attrib4 : ATTRIB4;
+        };
+
+        [maxvertexcount(1)]
+        void main(point data i[1], inout PointStream<data> o)
+        {
+            o.Append(i[0]);
+        }
+#endif
+        0x43425844, 0x59c61884, 0x3eef167b, 0x82618c33, 0x243cb630, 0x00000001, 0x000002a0, 0x00000003,
+        0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
+        0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
+        0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
+        0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
+        0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69,
+        0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
+        0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+        0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
+        0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
+        0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
+        0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
+        0xababab00, 0x52444853, 0x00000114, 0x00020040, 0x00000045, 0x05000061, 0x002010f2, 0x00000001,
+        0x00000000, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x0400005f, 0x00201072,
+        0x00000001, 0x00000002, 0x0400005f, 0x00201032, 0x00000001, 0x00000003, 0x0400005f, 0x00201042,
+        0x00000001, 0x00000003, 0x0100085d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
+        0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
+        0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2,
+        0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
+        0x00000000, 0x00000001, 0x06000036, 0x00102072, 0x00000002, 0x00201246, 0x00000000, 0x00000002,
+        0x06000036, 0x00102072, 0x00000003, 0x00201246, 0x00000000, 0x00000003, 0x01000013, 0x0100003e,
+    };
+    static const D3D10_SO_DECLARATION_ENTRY so_declaration[] =
+    {
+        {"SV_Position", 0, 0, 4, 0},
+    };
+    static const D3D10_SO_DECLARATION_ENTRY invalid_gap_declaration[] =
+    {
+        {"SV_Position", 0, 0, 4, 0},
+        {NULL,          0, 0, 0, 0},
+    };
+    static const D3D10_SO_DECLARATION_ENTRY valid_so_declarations[][12] =
+    {
+        /* SemanticName and SemanticIndex */
+        {
+            {"sv_position", 0, 0, 4, 0},
+            {"attrib",      1, 0, 4, 0},
+        },
+        {
+            {"sv_position", 0, 0, 4, 0},
+            {"ATTRIB",      1, 0, 4, 0},
+        },
+        /* Gaps */
+        {
+            {"SV_POSITION", 0, 0, 4, 0},
+            {NULL,          0, 0, 8, 0},
+            {"ATTRIB",      1, 0, 4, 0},
+        },
+        {
+            {"SV_POSITION", 0, 0, 4, 0},
+            {NULL,          0, 0, 4, 0},
+            {NULL,          0, 0, 4, 0},
+            {"ATTRIB",      1, 0, 4, 0},
+        },
+        /* ComponentCount */
+        {
+            {"ATTRIB",      1, 0, 4, 0},
+        },
+        {
+            {"ATTRIB",      2, 0, 3, 0},
+        },
+        {
+            {"ATTRIB",      3, 0, 2, 0},
+        },
+        {
+            {"ATTRIB",      4, 0, 1, 0},
+        },
+        /* ComponentIndex */
+        {
+            {"ATTRIB",      1, 1, 3, 0},
+        },
+        {
+            {"ATTRIB",      1, 2, 2, 0},
+        },
+        {
+            {"ATTRIB",      1, 3, 1, 0},
+        },
+        {
+            {"ATTRIB",      3, 1, 1, 0},
+        },
+        /* OutputSlot */
+        {
+            {"attrib",      1, 0, 4, 0},
+        },
+        {
+            {"attrib",      1, 0, 4, 1},
+        },
+        {
+            {"attrib",      1, 0, 4, 2},
+        },
+        {
+            {"attrib",      1, 0, 4, 3},
+        },
+        {
+            {"attrib",      1, 0, 4, 0},
+            {"attrib",      2, 0, 3, 0},
+            {"attrib",      3, 0, 2, 0},
+            {"attrib",      4, 0, 1, 0},
+        },
+        {
+            {"attrib",      1, 0, 4, 0},
+            {"attrib",      2, 0, 3, 1},
+            {"attrib",      3, 0, 2, 2},
+            {"attrib",      4, 0, 1, 3},
+        },
+        {
+            {"attrib",      1, 0, 4, 0},
+            {"attrib",      2, 0, 3, 3},
+        },
+        {
+            {"attrib",      1, 0, 4, 0},
+            {"attrib",      2, 0, 3, 0},
+            {"attrib",      3, 0, 2, 0},
+            {NULL,          0, 0, 1, 0},
+            {"attrib",      4, 0, 1, 0},
+        },
+        /* Multiple occurrences of the same output */
+        {
+            {"ATTRIB",      1, 0, 2, 0},
+            {"ATTRIB",      1, 2, 2, 1},
+        },
+        {
+            {"ATTRIB",      1, 0, 1, 0},
+            {"ATTRIB",      1, 1, 3, 0},
+        },
+    };
+    static const D3D10_SO_DECLARATION_ENTRY invalid_so_declarations[][12] =
+    {
+        /* SemanticName and SemanticIndex */
+        {
+            {"SV_Position", 0, 0, 4, 0},
+            {"ATTRIB",      0, 0, 4, 0},
+        },
+        {
+            {"sv_position", 0, 0, 4, 0},
+            {"ATTRIB_",     1, 0, 4, 0},
+        },
+        /* Gaps */
+        {
+            {"SV_POSITION", 0, 0, 4, 0},
+            {NULL,          0, 1, 8, 0},
+            {"ATTRIB",      1, 0, 4, 0},
+        },
+        {
+            {"SV_POSITION", 0, 0, 4, 0},
+            {NULL,          1, 0, 8, 0},
+            {"ATTRIB",      1, 0, 4, 0},
+        },
+        /* Buffer stride */
+        {
+            {"SV_POSITION", 0, 0, 4, 0},
+            {NULL,          0, 0, 8, 0},
+            {NULL,          0, 0, 8, 0},
+            {"ATTRIB",      1, 0, 4, 0},
+        },
+        /* ComponentCount */
+        {
+            {"ATTRIB",      2, 0, 5, 0},
+        },
+        {
+            {"ATTRIB",      2, 0, 4, 0},
+        },
+        {
+            {"ATTRIB",      3, 0, 3, 0},
+        },
+        {
+            {"ATTRIB",      4, 0, 2, 0},
+        },
+        /* ComponentIndex */
+        {
+            {"ATTRIB",      1, 1, 4, 0},
+        },
+        {
+            {"ATTRIB",      1, 2, 3, 0},
+        },
+        {
+            {"ATTRIB",      1, 3, 2, 0},
+        },
+        {
+            {"ATTRIB",      1, 4, 0, 0},
+        },
+        {
+            {"ATTRIB",      1, 4, 1, 0},
+        },
+        {
+            {"ATTRIB",      3, 2, 1, 0},
+        },
+        {
+            {"ATTRIB",      3, 2, 0, 0},
+        },
+        /* OutputSlot */
+        {
+            {"attrib",      1, 0, 4, 0},
+            {NULL,          0, 0, 4, 0},
+            {"attrib",      4, 0, 1, 3},
+        },
+        {
+            {"attrib",      1, 0, 4, 0},
+            {NULL,          0, 0, 4, 0},
+            {NULL,          0, 0, 4, 0},
+            {"attrib",      4, 0, 1, 3},
+        },
+        {
+            {"attrib",      1, 0, 4, 0},
+            {"attrib",      2, 0, 3, 0},
+            {"attrib",      3, 0, 2, 0},
+            {"attrib",      4, 0, 1, 1},
+        },
+        {
+            {"attrib",      1, 0, 4, 0},
+            {"attrib",      2, 0, 3, 0},
+            {"attrib",      3, 0, 2, 3},
+            {NULL,          0, 0, 1, 3},
+            {"attrib",      4, 0, 1, 3},
+        },
+        {
+            {"attrib",      1, 0, 4, 0},
+            {"attrib",      1, 0, 3, 1},
+            {"attrib",      1, 0, 2, 2},
+            {"attrib",      1, 0, 1, 3},
+            {NULL,          0, 0, 3, 3},
+        },
+        /* Multiple occurrences of the same output */
+        {
+            {"ATTRIB",      1, 0, 4, 0},
+            {"ATTRIB",      1, 0, 4, 1},
+        },
+    };
+
+    if (!init_test_context(&test_context))
+        return;
+
+    device = test_context.device;
+
+    check_so_desc(device, gs_code, sizeof(gs_code), NULL, 0, 0, TRUE);
+    check_so_desc(device, gs_code, sizeof(gs_code), NULL, 0, 64, FALSE);
+    check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration), 64, TRUE);
+    check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration), 0, FALSE);
+
+    todo_wine
+    check_so_desc(device, vs_code, sizeof(vs_code), so_declaration, ARRAY_SIZE(so_declaration), 64, TRUE);
+
+    check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, 0, 64, FALSE);
+    check_so_desc(device, gs_code, sizeof(gs_code),
+            invalid_gap_declaration, ARRAY_SIZE(invalid_gap_declaration), 64, FALSE);
+    check_so_desc(device, gs_code, sizeof(gs_code),
+            invalid_gap_declaration, ARRAY_SIZE(invalid_gap_declaration), 64, FALSE);
+
+    check_so_desc(device, vs_code, sizeof(vs_code), so_declaration, 0, 64, FALSE);
+    check_so_desc(device, vs_code, sizeof(vs_code), NULL, 0, 64, FALSE);
+
+    for (i = 0; i < ARRAY_SIZE(valid_so_declarations); ++i)
+    {
+        unsigned int max_output_slot = 0;
+        for (count = 0; count < ARRAY_SIZE(valid_so_declarations[i]); ++count)
+        {
+            const D3D10_SO_DECLARATION_ENTRY *e = &valid_so_declarations[i][count];
+            max_output_slot = max(max_output_slot, e->OutputSlot);
+            if (!e->SemanticName && !e->SemanticIndex && !e->ComponentCount)
+                break;
+        }
+
+        check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count, 0, !!max_output_slot);
+        check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count, 64, !max_output_slot);
+    }
+
+    for (i = 0; i < ARRAY_SIZE(invalid_so_declarations); ++i)
+    {
+        for (count = 0; count < ARRAY_SIZE(invalid_so_declarations[i]); ++count)
+        {
+            const D3D10_SO_DECLARATION_ENTRY *e = &invalid_so_declarations[i][count];
+            if (!e->SemanticName && !e->SemanticIndex && !e->ComponentCount)
+                break;
+        }
+
+        check_so_desc(device, gs_code, sizeof(gs_code), invalid_so_declarations[i], count, 0, FALSE);
+        check_so_desc(device, gs_code, sizeof(gs_code), invalid_so_declarations[i], count, 64, FALSE);
+    }
+
+    /* Buffer stride */
+    check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration), 63, FALSE);
+    check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration), 1, FALSE);
+    check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration), 0, FALSE);
+
+    release_test_context(&test_context);
+}
+
 static void test_stream_output_resume(void)
 {
     struct d3d10core_test_context test_context;
@@ -11963,5 +12329,6 @@ START_TEST(device)
     test_render_target_device_mismatch();
     test_buffer_srv();
     test_geometry_shader();
+    test_stream_output();
     test_stream_output_resume();
 }
-- 
2.10.2




More information about the wine-patches mailing list