[PATCH 4/6] d3d10core/tests: Introduce draw_quad().

Józef Kucia jkucia at codeweavers.com
Thu Mar 10 00:41:49 CST 2016


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

diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 2b5deb2..eaaec20 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -266,6 +266,10 @@ struct d3d10core_test_context
     IDXGISwapChain *swapchain;
     ID3D10Texture2D *backbuffer;
     ID3D10RenderTargetView *backbuffer_rtv;
+
+    ID3D10InputLayout *input_layout;
+    ID3D10VertexShader *vs;
+    ID3D10Buffer *vb;
 };
 
 #define init_test_context(c) init_test_context_(__LINE__, c)
@@ -309,6 +313,13 @@ static void release_test_context_(unsigned int line, struct d3d10core_test_conte
 {
     ULONG ref;
 
+    if (context->input_layout)
+        ID3D10InputLayout_Release(context->input_layout);
+    if (context->vs)
+        ID3D10VertexShader_Release(context->vs);
+    if (context->vb)
+        ID3D10Buffer_Release(context->vb);
+
     ID3D10RenderTargetView_Release(context->backbuffer_rtv);
     ID3D10Texture2D_Release(context->backbuffer);
     IDXGISwapChain_Release(context->swapchain);
@@ -318,6 +329,81 @@ static void release_test_context_(unsigned int line, struct d3d10core_test_conte
     ok_(__FILE__, line)(!ref, "Device has %u references left.\n", ref);
 }
 
+#define draw_quad(c) draw_quad_(__LINE__, c)
+static void draw_quad_(unsigned int line, struct d3d10core_test_context *context)
+{
+    static const D3D10_INPUT_ELEMENT_DESC default_layout_desc[] =
+    {
+        {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
+    };
+    static const DWORD default_vs_code[] =
+    {
+#if 0
+        float4 main(float4 position : POSITION) : SV_POSITION
+        {
+            return position;
+        }
+#endif
+        0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
+        0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+        0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
+        0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
+        0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
+        0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
+        0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
+    };
+    static const struct
+    {
+        struct vec2 position;
+    }
+    quad[] =
+    {
+        {{-1.0f, -1.0f}},
+        {{-1.0f,  1.0f}},
+        {{ 1.0f, -1.0f}},
+        {{ 1.0f,  1.0f}},
+    };
+
+    ID3D10Device *device = context->device;
+    D3D10_SUBRESOURCE_DATA resource_data;
+    D3D10_BUFFER_DESC buffer_desc;
+    unsigned int stride, offset;
+    HRESULT hr;
+
+    if (!context->input_layout)
+    {
+        hr = ID3D10Device_CreateInputLayout(device, default_layout_desc,
+                sizeof(default_layout_desc) / sizeof(*default_layout_desc),
+                default_vs_code, sizeof(default_vs_code), &context->input_layout);
+        ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
+
+        buffer_desc.ByteWidth = sizeof(quad);
+        buffer_desc.Usage = D3D10_USAGE_DEFAULT;
+        buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
+        buffer_desc.CPUAccessFlags = 0;
+        buffer_desc.MiscFlags = 0;
+
+        resource_data.pSysMem = quad;
+        resource_data.SysMemPitch = 0;
+        resource_data.SysMemSlicePitch = 0;
+
+        hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &resource_data, &context->vb);
+        ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+
+        hr = ID3D10Device_CreateVertexShader(device, default_vs_code, sizeof(default_vs_code), &context->vs);
+        ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+    }
+
+    ID3D10Device_IASetInputLayout(context->device, context->input_layout);
+    ID3D10Device_IASetPrimitiveTopology(context->device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+    stride = sizeof(*quad);
+    offset = 0;
+    ID3D10Device_IASetVertexBuffers(context->device, 0, 1, &context->vb, &stride, &offset);
+    ID3D10Device_VSSetShader(context->device, context->vs);
+
+    ID3D10Device_Draw(context->device, 4, 0);
+}
+
 static void test_feature_level(void)
 {
     D3D_FEATURE_LEVEL feature_level;
@@ -2088,46 +2174,15 @@ static void test_device_removed_reason(void)
 static void test_scissor(void)
 {
     struct d3d10core_test_context test_context;
-    D3D10_SUBRESOURCE_DATA buffer_data;
-    ID3D10InputLayout *input_layout;
     D3D10_RASTERIZER_DESC rs_desc;
-    D3D10_BUFFER_DESC buffer_desc;
-    unsigned int stride, offset;
     ID3D10RasterizerState *rs;
     D3D10_RECT scissor_rect;
-    ID3D10VertexShader *vs;
     ID3D10PixelShader *ps;
     ID3D10Device *device;
-    ID3D10Buffer *vb;
     DWORD color;
     HRESULT hr;
 
     static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f};
-    static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
-    {
-        {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
-    };
-    static const DWORD vs_code[] =
-    {
-        /* float4 main(float4 position : POSITION) : SV_POSITION
-         * {
-         *     return position;
-         * } */
-        0x43425844, 0x1fa8c27f, 0x52d2f21d, 0xc196fdb7, 0x376f283a, 0x00000001, 0x000001b4, 0x00000005,
-        0x00000034, 0x0000008c, 0x000000c0, 0x000000f4, 0x00000138, 0x46454452, 0x00000050, 0x00000000,
-        0x00000000, 0x00000000, 0x0000001c, 0xfffe0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
-        0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e30332e,
-        0x30303239, 0x3336312e, 0xab003438, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
-        0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
-        0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
-        0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
-        0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
-        0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453, 0x00000074,
-        0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
-        0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-        0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-        0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
-    };
     static const DWORD ps_code[] =
     {
         /* float4 main(float4 position : SV_POSITION) : SV_Target
@@ -2149,41 +2204,12 @@ static void test_scissor(void)
         0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
         0x00000000, 0x00000000, 0x00000000, 0x00000000,
     };
-    static const struct
-    {
-        float x, y;
-    }
-    quad[] =
-    {
-        {-1.0f, -1.0f},
-        {-1.0f,  1.0f},
-        { 1.0f, -1.0f},
-        { 1.0f,  1.0f},
-    };
 
     if (!init_test_context(&test_context))
         return;
 
     device = test_context.device;
 
-    hr = ID3D10Device_CreateInputLayout(device, layout_desc, sizeof(layout_desc) / sizeof(*layout_desc),
-            vs_code, sizeof(vs_code), &input_layout);
-    ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
-
-    buffer_desc.ByteWidth = sizeof(quad);
-    buffer_desc.Usage = D3D10_USAGE_DEFAULT;
-    buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
-    buffer_desc.CPUAccessFlags = 0;
-    buffer_desc.MiscFlags = 0;
-
-    buffer_data.pSysMem = quad;
-    buffer_data.SysMemPitch = 0;
-    buffer_data.SysMemSlicePitch = 0;
-
-    hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &buffer_data, &vb);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
-    hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
     hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps);
     ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
 
@@ -2200,12 +2226,6 @@ static void test_scissor(void)
     hr = ID3D10Device_CreateRasterizerState(device, &rs_desc, &rs);
     ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
 
-    ID3D10Device_IASetInputLayout(device, input_layout);
-    ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-    stride = sizeof(*quad);
-    offset = 0;
-    ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
-    ID3D10Device_VSSetShader(device, vs);
     ID3D10Device_PSSetShader(device, ps);
 
     scissor_rect.left = 160;
@@ -2217,7 +2237,7 @@ static void test_scissor(void)
     ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, red);
     check_texture_color(test_context.backbuffer, 0xff0000ff, 1);
 
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
     color = get_texture_color(test_context.backbuffer, 320, 60);
     ok(compare_color(color, 0xff00ff00, 1), "Got unexpected color 0x%08x.\n", color);
     color = get_texture_color(test_context.backbuffer, 80, 240);
@@ -2231,7 +2251,7 @@ static void test_scissor(void)
 
     ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, red);
     ID3D10Device_RSSetState(device, rs);
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
     color = get_texture_color(test_context.backbuffer, 320, 60);
     ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
     color = get_texture_color(test_context.backbuffer, 80, 240);
@@ -2245,9 +2265,6 @@ static void test_scissor(void)
 
     ID3D10RasterizerState_Release(rs);
     ID3D10PixelShader_Release(ps);
-    ID3D10VertexShader_Release(vs);
-    ID3D10Buffer_Release(vb);
-    ID3D10InputLayout_Release(input_layout);
     release_test_context(&test_context);
 }
 
@@ -3365,46 +3382,22 @@ static void test_texture(void)
 
     struct d3d10core_test_context test_context;
     const struct texture *current_texture;
-    D3D10_SUBRESOURCE_DATA resource_data;
     D3D10_TEXTURE2D_DESC texture_desc;
     D3D10_SAMPLER_DESC sampler_desc;
-    ID3D10InputLayout *input_layout;
     const struct shader *current_ps;
     ID3D10ShaderResourceView *srv;
     D3D10_BUFFER_DESC buffer_desc;
     ID3D10SamplerState *sampler;
-    unsigned int stride, offset;
     struct texture_readback rb;
     ID3D10Texture2D *texture;
-    ID3D10VertexShader *vs;
     ID3D10PixelShader *ps;
-    ID3D10Buffer *vb, *cb;
     ID3D10Device *device;
     unsigned int i, x, y;
     struct vec4 miplevel;
+    ID3D10Buffer *cb;
     DWORD color;
     HRESULT hr;
 
-    static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
-    {
-        {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
-    };
-    static const DWORD vs_code[] =
-    {
-#if 0
-        float4 main(float4 position : POSITION) : SV_POSITION
-        {
-            return position;
-        }
-#endif
-        0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
-        0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
-        0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
-        0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
-        0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
-        0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
-        0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
-    };
     static const DWORD ps_ld_code[] =
     {
 #if 0
@@ -3595,17 +3588,6 @@ static void test_texture(void)
     static const struct shader ps_sample = {ps_sample_code, sizeof(ps_sample_code)};
     static const struct shader ps_sample_b = {ps_sample_b_code, sizeof(ps_sample_b_code)};
     static const struct shader ps_sample_l = {ps_sample_l_code, sizeof(ps_sample_l_code)};
-    static const struct
-    {
-        struct vec2 position;
-    }
-    quad[] =
-    {
-        {{-1.0f, -1.0f}},
-        {{-1.0f,  1.0f}},
-        {{ 1.0f, -1.0f}},
-        {{ 1.0f,  1.0f}},
-    };
     static const DWORD rgba_level_0[] =
     {
         0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00,
@@ -3830,38 +3812,15 @@ static void test_texture(void)
 
     device = test_context.device;
 
-    hr = ID3D10Device_CreateInputLayout(device, layout_desc, sizeof(layout_desc) / sizeof(*layout_desc),
-            vs_code, sizeof(vs_code), &input_layout);
-    ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
-
-    buffer_desc.ByteWidth = sizeof(quad);
+    buffer_desc.ByteWidth = sizeof(miplevel);
     buffer_desc.Usage = D3D10_USAGE_DEFAULT;
-    buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
+    buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
     buffer_desc.CPUAccessFlags = 0;
     buffer_desc.MiscFlags = 0;
 
-    resource_data.pSysMem = quad;
-    resource_data.SysMemPitch = 0;
-    resource_data.SysMemSlicePitch = 0;
-
-    hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &resource_data, &vb);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
-
-    buffer_desc.ByteWidth = sizeof(miplevel);
-    buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
-
     hr = ID3D10Device_CreateBuffer(device, &buffer_desc, NULL, &cb);
     ok(SUCCEEDED(hr), "Failed to create constant buffer, hr %#x.\n", hr);
 
-    hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
-
-    ID3D10Device_IASetInputLayout(device, input_layout);
-    ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-    stride = sizeof(*quad);
-    offset = 0;
-    ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
-    ID3D10Device_VSSetShader(device, vs);
     ID3D10Device_PSSetConstantBuffers(device, 0, 1, &cb);
 
     texture_desc.Width = 4;
@@ -3959,7 +3918,8 @@ static void test_texture(void)
         ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &miplevel, 0, 0);
 
         ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, red);
-        ID3D10Device_Draw(device, 4, 0);
+
+        draw_quad(&test_context);
 
         get_texture_readback(test_context.backbuffer, &rb);
         for (x = 0; x < 4; ++x)
@@ -3979,9 +3939,6 @@ static void test_texture(void)
     ID3D10PixelShader_Release(ps);
 
     ID3D10Buffer_Release(cb);
-    ID3D10VertexShader_Release(vs);
-    ID3D10Buffer_Release(vb);
-    ID3D10InputLayout_Release(input_layout);
     release_test_context(&test_context);
 }
 
@@ -4573,36 +4530,13 @@ static void test_fragment_coords(void)
 {
     struct d3d10core_test_context test_context;
     D3D10_SUBRESOURCE_DATA resource_data;
-    ID3D10InputLayout *input_layout;
     ID3D10PixelShader *ps, *ps_frac;
     D3D10_BUFFER_DESC buffer_desc;
-    unsigned int stride, offset;
-    ID3D10Buffer *vb, *ps_cb;
-    ID3D10VertexShader *vs;
     ID3D10Device *device;
+    ID3D10Buffer *ps_cb;
     DWORD color;
     HRESULT hr;
 
-    static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
-    {
-        {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0,  0, D3D10_INPUT_PER_VERTEX_DATA, 0},
-    };
-    static const DWORD vs_code[] =
-    {
-#if 0
-        float4 main(float4 position : POSITION) : SV_POSITION
-        {
-            return position;
-        }
-#endif
-        0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
-        0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
-        0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
-        0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
-        0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
-        0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
-        0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
-    };
     static const DWORD ps_code[] =
     {
 #if 0
@@ -4649,17 +4583,6 @@ static void test_fragment_coords(void)
         0x0500001a, 0x00102032, 0x00000000, 0x00101046, 0x00000000, 0x08000036, 0x001020c2, 0x00000000,
         0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
     };
-    static const struct
-    {
-        struct vec2 position;
-    }
-    quad[] =
-    {
-        {{-1.0f, -1.0f}},
-        {{-1.0f,  1.0f}},
-        {{ 1.0f, -1.0f}},
-        {{ 1.0f,  1.0f}},
-    };
     static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f};
     struct vec4 cutoff = {320.0f, 240.0f, 0.0f, 0.0f};
 
@@ -4668,50 +4591,30 @@ static void test_fragment_coords(void)
 
     device = test_context.device;
 
-    hr = ID3D10Device_CreateInputLayout(device, layout_desc, sizeof(layout_desc) / sizeof(*layout_desc),
-            vs_code, sizeof(vs_code), &input_layout);
-    ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
-
-    buffer_desc.ByteWidth = sizeof(quad);
+    buffer_desc.ByteWidth = sizeof(cutoff);
     buffer_desc.Usage = D3D10_USAGE_DEFAULT;
-    buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
+    buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
     buffer_desc.CPUAccessFlags = 0;
     buffer_desc.MiscFlags = 0;
 
-    resource_data.pSysMem = quad;
+    resource_data.pSysMem = &cutoff;
     resource_data.SysMemPitch = 0;
     resource_data.SysMemSlicePitch = 0;
 
-    hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &resource_data, &vb);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
-
-    buffer_desc.ByteWidth = sizeof(cutoff);
-    buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
-
-    resource_data.pSysMem = &cutoff;
-
     hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &resource_data, &ps_cb);
     ok(SUCCEEDED(hr), "Failed to create constant buffer, hr %#x.\n", hr);
 
-    hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
     hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps);
     ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
     hr = ID3D10Device_CreatePixelShader(device, ps_frac_code, sizeof(ps_frac_code), &ps_frac);
     ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
 
-    ID3D10Device_IASetInputLayout(device, input_layout);
-    ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-    stride = sizeof(*quad);
-    offset = 0;
-    ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
-    ID3D10Device_VSSetShader(device, vs);
     ID3D10Device_PSSetConstantBuffers(device, 0, 1, &ps_cb);
     ID3D10Device_PSSetShader(device, ps);
 
     ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, red);
 
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
 
     color = get_texture_color(test_context.backbuffer, 319, 239);
     ok(compare_color(color, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color);
@@ -4729,7 +4632,7 @@ static void test_fragment_coords(void)
     ok(SUCCEEDED(hr), "Failed to create constant buffer, hr %#x.\n", hr);
     ID3D10Device_PSSetConstantBuffers(device, 0, 1, &ps_cb);
 
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
 
     color = get_texture_color(test_context.backbuffer, 14, 14);
     ok(compare_color(color, 0xff000000, 1), "Got unexpected color 0x%08x.\n", color);
@@ -4743,7 +4646,7 @@ static void test_fragment_coords(void)
     ID3D10Device_PSSetShader(device, ps_frac);
     ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, red);
 
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
 
     color = get_texture_color(test_context.backbuffer, 14, 14);
     ok(compare_color(color, 0xff008080, 1), "Got unexpected color 0x%08x.\n", color);
@@ -4751,54 +4654,25 @@ static void test_fragment_coords(void)
     ID3D10Buffer_Release(ps_cb);
     ID3D10PixelShader_Release(ps_frac);
     ID3D10PixelShader_Release(ps);
-    ID3D10VertexShader_Release(vs);
-    ID3D10Buffer_Release(vb);
-    ID3D10InputLayout_Release(input_layout);
     release_test_context(&test_context);
 }
 
 static void test_update_subresource(void)
 {
     struct d3d10core_test_context test_context;
-    D3D10_SUBRESOURCE_DATA resource_data;
     D3D10_TEXTURE2D_DESC texture_desc;
     ID3D10SamplerState *sampler_state;
     ID3D10ShaderResourceView *ps_srv;
     D3D10_SAMPLER_DESC sampler_desc;
-    ID3D10InputLayout *input_layout;
-    D3D10_BUFFER_DESC buffer_desc;
-    unsigned int stride, offset;
     struct texture_readback rb;
     ID3D10Texture2D *texture;
-    ID3D10VertexShader *vs;
     ID3D10PixelShader *ps;
     ID3D10Device *device;
     unsigned int i, j;
-    ID3D10Buffer *vb;
     D3D10_BOX box;
     DWORD color;
     HRESULT hr;
 
-    static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
-    {
-        {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0,  0, D3D10_INPUT_PER_VERTEX_DATA, 0},
-    };
-    static const DWORD vs_code[] =
-    {
-#if 0
-        float4 main(float4 position : POSITION) : SV_POSITION
-        {
-            return position;
-        }
-#endif
-        0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
-        0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
-        0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
-        0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
-        0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
-        0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
-        0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
-    };
     static const DWORD ps_code[] =
     {
 #if 0
@@ -4825,17 +4699,6 @@ static void test_update_subresource(void)
         0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
         0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
     };
-    static const struct
-    {
-        float x, y;
-    }
-    quad[] =
-    {
-        {-1.0f, -1.0f},
-        {-1.0f,  1.0f},
-        { 1.0f, -1.0f},
-        { 1.0f,  1.0f},
-    };
     static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f};
     static const DWORD bitmap_data[] =
     {
@@ -4857,23 +4720,6 @@ static void test_update_subresource(void)
 
     device = test_context.device;
 
-    hr = ID3D10Device_CreateInputLayout(device, layout_desc, sizeof(layout_desc) / sizeof(*layout_desc),
-            vs_code, sizeof(vs_code), &input_layout);
-    ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
-
-    buffer_desc.ByteWidth = sizeof(quad);
-    buffer_desc.Usage = D3D10_USAGE_DEFAULT;
-    buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
-    buffer_desc.CPUAccessFlags = 0;
-    buffer_desc.MiscFlags = 0;
-
-    resource_data.pSysMem = quad;
-    resource_data.SysMemPitch = 0;
-    resource_data.SysMemSlicePitch = 0;
-
-    hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &resource_data, &vb);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
-
     texture_desc.Width = 4;
     texture_desc.Height = 4;
     texture_desc.MipLevels = 1;
@@ -4909,17 +4755,9 @@ static void test_update_subresource(void)
     hr = ID3D10Device_CreateSamplerState(device, &sampler_desc, &sampler_state);
     ok(SUCCEEDED(hr), "Failed to create sampler state, hr %#x.\n", hr);
 
-    hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
     hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps);
     ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
 
-    ID3D10Device_IASetInputLayout(device, input_layout);
-    ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-    stride = sizeof(*quad);
-    offset = 0;
-    ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
-    ID3D10Device_VSSetShader(device, vs);
     ID3D10Device_PSSetShaderResources(device, 0, 1, &ps_srv);
     ID3D10Device_PSSetSamplers(device, 0, 1, &sampler_state);
     ID3D10Device_PSSetShader(device, ps);
@@ -4927,7 +4765,7 @@ static void test_update_subresource(void)
     ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, red);
     check_texture_color(test_context.backbuffer, 0x7f0000ff, 1);
 
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
     check_texture_color(test_context.backbuffer, 0x00000000, 0);
 
     set_box(&box, 1, 1, 0, 3, 3, 1);
@@ -4948,7 +4786,7 @@ static void test_update_subresource(void)
     set_box(&box, 0, 0, 0, 4, 4, 0);
     ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture, 0, &box,
             bitmap_data, 4 * sizeof(*bitmap_data), 0);
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
     get_texture_readback(test_context.backbuffer, &rb);
     for (i = 0; i < 4; ++i)
     {
@@ -4964,7 +4802,7 @@ static void test_update_subresource(void)
 
     ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture, 0, NULL,
             bitmap_data, 4 * sizeof(*bitmap_data), 0);
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
     get_texture_readback(test_context.backbuffer, &rb);
     for (i = 0; i < 4; ++i)
     {
@@ -4979,12 +4817,9 @@ static void test_update_subresource(void)
     release_texture_readback(&rb);
 
     ID3D10PixelShader_Release(ps);
-    ID3D10VertexShader_Release(vs);
     ID3D10SamplerState_Release(sampler_state);
     ID3D10ShaderResourceView_Release(ps_srv);
     ID3D10Texture2D_Release(texture);
-    ID3D10Buffer_Release(vb);
-    ID3D10InputLayout_Release(input_layout);
     release_test_context(&test_context);
 }
 
@@ -4997,39 +4832,14 @@ static void test_copy_subresource_region(void)
     ID3D10SamplerState *sampler_state;
     ID3D10ShaderResourceView *ps_srv;
     D3D10_SAMPLER_DESC sampler_desc;
-    ID3D10InputLayout *input_layout;
-    D3D10_BUFFER_DESC buffer_desc;
-    unsigned int stride, offset;
     struct texture_readback rb;
-    ID3D10VertexShader *vs;
     ID3D10PixelShader *ps;
     ID3D10Device *device;
     unsigned int i, j;
-    ID3D10Buffer *vb;
     D3D10_BOX box;
     DWORD color;
     HRESULT hr;
 
-    static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
-    {
-        {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0,  0, D3D10_INPUT_PER_VERTEX_DATA, 0},
-    };
-    static const DWORD vs_code[] =
-    {
-#if 0
-        float4 main(float4 position : POSITION) : SV_POSITION
-        {
-            return position;
-        }
-#endif
-        0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
-        0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
-        0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
-        0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
-        0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
-        0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
-        0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
-    };
     static const DWORD ps_code[] =
     {
 #if 0
@@ -5056,17 +4866,6 @@ static void test_copy_subresource_region(void)
         0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000,
         0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e,
     };
-    static const struct
-    {
-        float x, y;
-    }
-    quad[] =
-    {
-        {-1.0f, -1.0f},
-        {-1.0f,  1.0f},
-        { 1.0f, -1.0f},
-        { 1.0f,  1.0f},
-    };
     static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f};
     static const DWORD bitmap_data[] =
     {
@@ -5088,23 +4887,6 @@ static void test_copy_subresource_region(void)
 
     device = test_context.device;
 
-    hr = ID3D10Device_CreateInputLayout(device, layout_desc, sizeof(layout_desc) / sizeof(*layout_desc),
-            vs_code, sizeof(vs_code), &input_layout);
-    ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
-
-    buffer_desc.ByteWidth = sizeof(quad);
-    buffer_desc.Usage = D3D10_USAGE_DEFAULT;
-    buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
-    buffer_desc.CPUAccessFlags = 0;
-    buffer_desc.MiscFlags = 0;
-
-    resource_data.pSysMem = quad;
-    resource_data.SysMemPitch = 0;
-    resource_data.SysMemSlicePitch = 0;
-
-    hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &resource_data, &vb);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
-
     texture_desc.Width = 4;
     texture_desc.Height = 4;
     texture_desc.MipLevels = 1;
@@ -5124,6 +4906,7 @@ static void test_copy_subresource_region(void)
 
     resource_data.pSysMem = bitmap_data;
     resource_data.SysMemPitch = 4 * sizeof(*bitmap_data);
+    resource_data.SysMemSlicePitch = 0;
 
     hr = ID3D10Device_CreateTexture2D(device, &texture_desc, &resource_data, &src_texture);
     ok(SUCCEEDED(hr), "Failed to create 2d texture, hr %#x.\n", hr);
@@ -5148,17 +4931,9 @@ static void test_copy_subresource_region(void)
     hr = ID3D10Device_CreateSamplerState(device, &sampler_desc, &sampler_state);
     ok(SUCCEEDED(hr), "Failed to create sampler state, hr %#x.\n", hr);
 
-    hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs);
-    ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
     hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps);
     ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
 
-    ID3D10Device_IASetInputLayout(device, input_layout);
-    ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-    stride = sizeof(*quad);
-    offset = 0;
-    ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
-    ID3D10Device_VSSetShader(device, vs);
     ID3D10Device_PSSetShaderResources(device, 0, 1, &ps_srv);
     ID3D10Device_PSSetSamplers(device, 0, 1, &sampler_state);
     ID3D10Device_PSSetShader(device, ps);
@@ -5183,7 +4958,7 @@ static void test_copy_subresource_region(void)
     set_box(&box, 0, 0, 0, 4, 4, 0);
     ID3D10Device_CopySubresourceRegion(device, (ID3D10Resource *)dst_texture, 0,
             0, 0, 0, (ID3D10Resource *)src_texture, 0, &box);
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
     get_texture_readback(test_context.backbuffer, &rb);
     for (i = 0; i < 4; ++i)
     {
@@ -5199,7 +4974,7 @@ static void test_copy_subresource_region(void)
 
     ID3D10Device_CopySubresourceRegion(device, (ID3D10Resource *)dst_texture, 0,
             0, 0, 0, (ID3D10Resource *)src_texture, 0, NULL);
-    ID3D10Device_Draw(device, 4, 0);
+    draw_quad(&test_context);
     get_texture_readback(test_context.backbuffer, &rb);
     for (i = 0; i < 4; ++i)
     {
@@ -5214,13 +4989,10 @@ static void test_copy_subresource_region(void)
     release_texture_readback(&rb);
 
     ID3D10PixelShader_Release(ps);
-    ID3D10VertexShader_Release(vs);
     ID3D10SamplerState_Release(sampler_state);
     ID3D10ShaderResourceView_Release(ps_srv);
     ID3D10Texture2D_Release(dst_texture);
     ID3D10Texture2D_Release(src_texture);
-    ID3D10Buffer_Release(vb);
-    ID3D10InputLayout_Release(input_layout);
     release_test_context(&test_context);
 }
 
-- 
2.4.10




More information about the wine-patches mailing list