Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/tests/device.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index ad1d2899a14..e9ad3c70baa 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -1836,6 +1836,7 @@ static void test_reset(void) IDirect3DIndexBuffer9 *ib; DEVMODEW devmode; IDirect3D9 *d3d; + ULONG refcount; D3DCAPS9 caps; DWORD value; HWND hwnd; @@ -2187,6 +2188,38 @@ static void test_reset(void) skip("Volume textures not supported.\n"); }
+ /* Test with DEFAULT pool resources bound but otherwise not referenced. */ + hr = IDirect3DDevice9_CreateVertexBuffer(device1, 16, 0, + D3DFVF_XYZ, D3DPOOL_DEFAULT, &vb, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetStreamSource(device1, 0, vb, 0, 16); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + refcount = IDirect3DVertexBuffer9_Release(vb); + ok(!refcount, "Unexpected refcount %u.\n", refcount); + hr = IDirect3DDevice9_CreateIndexBuffer(device1, 16, 0, + D3DFMT_INDEX16, D3DPOOL_DEFAULT, &ib, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetIndices(device1, ib); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + refcount = IDirect3DIndexBuffer9_Release(ib); + ok(!refcount, "Unexpected refcount %u.\n", refcount); + hr = IDirect3DDevice9_CreateTexture(device1, 16, 16, 0, 0, + D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetTexture(device1, i, (IDirect3DBaseTexture9 *)texture); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_Reset(device1, &d3dpp); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_GetIndices(device1, &ib); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + refcount = IDirect3DTexture9_Release(texture); + ok(!refcount, "Unexpected refcount %u.\n", refcount); + + hr = IDirect3DDevice9_Reset(device1, &d3dpp); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + /* Scratch, sysmem and managed pools are fine */ hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device1, 16, 16, D3DFMT_R5G6B5, D3DPOOL_SCRATCH, &surface, NULL); ok(hr == D3D_OK, "IDirect3DDevice9_CreateOffscreenPlainSurface returned %08x\n", hr); @@ -2368,12 +2401,12 @@ cleanup: HeapFree(GetProcessHeap(), 0, modes); if (device2) { - UINT refcount = IDirect3DDevice9_Release(device2); + refcount = IDirect3DDevice9_Release(device2); ok(!refcount, "Device has %u references left.\n", refcount); } if (device1) { - UINT refcount = IDirect3DDevice9_Release(device1); + refcount = IDirect3DDevice9_Release(device1); ok(!refcount, "Device has %u references left.\n", refcount); } IDirect3D9_Release(d3d);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: It turns out this also fixes the existing test_fractional_viewports() (but only when ARB_clip_control is supported...)
Avoids two failures in (upcoming) d3d11:test_viewport().
My understanding of what's happening is: the affected quad extends to the left of the viewport bounds and moving the viewport even a tiny bit to the left makes GL take an extra column of pixels in consideration. Those pixels are covered by the quad since the pixel center is inside the quad, so they are drawn.
My reading of the spec doesn't entirely clarify if this is correct / expected behavior, of course the pixel center of those "extra" pixels isn't inside the viewport, but part of the pixel is. It looks to me as the first few lines at https://docs.microsoft.com/en-us/windows/desktop/direct3d11/d3d10-graphics-p... might be interpreted as implying this is actually correct behavior as far as d3d is concerned and I suspect the hardware to be quite tied to it.
FWIW decreasing the offset fixes the issue only when the offset is effectively set to 0.
Of course the offset was added in the first place for a reason, specifically to force the expected (d3d) top-left rule for triangle rasterization, since OpenGL leaves that unspecified except for requiring that only one of two adjacent triangles get to cover any pixel. I suspect that all the GPUs supporting ARB_clip_control also in practice make use of the same rule in OpenGL. Also the test should check that case too and it passes for me on AMD and Nvidia.
If this all seems too much of a hassle I can drop this patch and update the test accordingly, no worries. I really only wanted to get to the bottom of the test failure, this patch created itself while debugging :P
dlls/d3d11/tests/d3d11.c | 1 - dlls/wined3d/state.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 3c870c27e77..c8df7b8c7c4 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -25853,7 +25853,6 @@ static void test_fractional_viewports(void) ok(compare_float(v->x, expected.x, 0) && compare_float(v->y, expected.y, 0), "Got fragcoord {%.8e, %.8e}, expected {%.8e, %.8e} at (%u, %u), offset %.8e.\n", v->x, v->y, expected.x, expected.y, x, y, viewport_offsets[i]); - todo_wine ok(compare_float(v->z, expected.z, 2) && compare_float(v->w, expected.w, 2), "Got texcoord {%.8e, %.8e}, expected {%.8e, %.8e} at (%u, %u), offset %.8e.\n", v->z, v->w, expected.z, expected.w, x, y, viewport_offsets[i]); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 1b5eacdf216..43fef746f11 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4089,7 +4089,7 @@ static void viewport_miscpart_cc(struct wined3d_context *context, { /* See get_projection_matrix() in utils.c for a discussion about those values. */ float pixel_center_offset = context->d3d_info->wined3d_creation_flags - & WINED3D_PIXEL_CENTER_INTEGER ? 63.0f / 128.0f : -1.0f / 128.0f; + & WINED3D_PIXEL_CENTER_INTEGER ? 63.0f / 128.0f : 0.0f; const struct wined3d_gl_info *gl_info = context->gl_info; struct wined3d_viewport vp[WINED3D_MAX_VIEWPORTS]; GLdouble depth_ranges[2 * WINED3D_MAX_VIEWPORTS];
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=47541
Your paranoid android.
=== debian9 (32 bit report) ===
d3d11: Unhandled exception: page fault on execute access to 0x00000000 in 32-bit code (0x00000000).
=== debian9 (32 bit French report) ===
d3d11: Unhandled exception: page fault on execute access to 0x00000000 in 32-bit code (0x00000000).
=== debian9 (32 bit Japanese:Japan report) ===
d3d11: Unhandled exception: page fault on read access to 0x3f800000 in 32-bit code (0x7ec11f4d).
=== debian9 (32 bit Chinese:China report) ===
d3d11: d3d11.c:5346: Test failed: Got unexpected hr 0x8876086a for query type 4. d3d11.c:5593: Test failed: Got unexpected hr 0x8876086a.
=== debian9 (64 bit WoW report) ===
d3d11: d3d11.c:16715: Test failed: Got {-1.00787401e+00, 0.00000000e+00, 1.00000000e+00, 5.03937006e-01}, expected {-1.00000000e+00, 0.00000000e+00, 1.00000000e+00, 5.03937006e-01} at (0, 0), sub-resource 0.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d11/tests/d3d11.c | 201 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 197 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 670435d122f..da6db2268b4 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -1282,6 +1282,67 @@ static void check_texture_uvec4_(unsigned int line, ID3D11Texture2D *texture, check_texture_sub_resource_uvec4_(line, texture, sub_resource_idx, NULL, expected_value); }
+static void check_rect(struct resource_readback *rb, RECT r, const char *message) +{ + LONG x_coords[2][2] = + { + {r.left - 1, r.left + 1}, + {r.right + 1, r.right - 1}, + }; + LONG y_coords[2][2] = + { + {r.top - 1, r.top + 1}, + {r.bottom + 1, r.bottom - 1} + }; + unsigned int i, j, x_side, y_side; + DWORD color = 0; + LONG x = 0, y; + + if (r.left < 0 && r.top < 0 && r.right < 0 && r.bottom < 0) + { + BOOL all_match = TRUE; + + for (y = 0; y < rb->height; ++y) + { + for (x = 0; x < rb->width; ++x) + { + color = get_readback_color(rb, x, y, 0); + if (color != 0xff000000) + { + all_match = FALSE; + break; + } + } + if (!all_match) + break; + } + ok(all_match, "%s: pixel (%d, %d) has color %08x.\n", message, x, y, color); + return; + } + + for (i = 0; i < 2; ++i) + { + for (j = 0; j < 2; ++j) + { + for (x_side = 0; x_side < 2; ++x_side) + { + for (y_side = 0; y_side < 2; ++y_side) + { + DWORD expected = (x_side == 1 && y_side == 1) ? 0xffffffff : 0xff000000; + + x = x_coords[i][x_side]; + y = y_coords[j][y_side]; + if (x < 0 || x >= rb->width || y < 0 || y >= rb->height) + continue; + color = get_readback_color(rb, x, y, 0); + ok(color == expected, "%s: pixel (%d, %d) has color %08x, expected %08x.\n", + message, x, y, color, expected); + } + } + } + } +} + static IDXGIAdapter *create_adapter(void) { IDXGIFactory4 *factory4; @@ -1540,10 +1601,11 @@ struct d3d11_test_context ID3D11DeviceContext *immediate_context;
ID3D11InputLayout *input_layout; + ID3D11Buffer *vb; + unsigned int vb_stride; ID3D11VertexShader *vs; const DWORD *vs_code; ID3D11Buffer *vs_cb; - ID3D11Buffer *vb;
ID3D11PixelShader *ps; ID3D11Buffer *ps_cb; @@ -1662,7 +1724,7 @@ static void draw_quad_vs_(unsigned int line, struct d3d11_test_context *context, };
ID3D11Device *device = context->device; - unsigned int stride, offset; + unsigned int offset; HRESULT hr;
if (!vs_code) @@ -1690,13 +1752,15 @@ static void draw_quad_vs_(unsigned int line, struct d3d11_test_context *context, }
if (!context->vb) + { context->vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(quad), quad); + context->vb_stride = sizeof(*quad); + }
ID3D11DeviceContext_IASetInputLayout(context->immediate_context, context->input_layout); ID3D11DeviceContext_IASetPrimitiveTopology(context->immediate_context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - stride = sizeof(*quad); offset = 0; - ID3D11DeviceContext_IASetVertexBuffers(context->immediate_context, 0, 1, &context->vb, &stride, &offset); + ID3D11DeviceContext_IASetVertexBuffers(context->immediate_context, 0, 1, &context->vb, &context->vb_stride, &offset); ID3D11DeviceContext_VSSetShader(context->immediate_context, context->vs, NULL, 0);
ID3D11DeviceContext_Draw(context->immediate_context, 4, 0); @@ -1792,6 +1856,77 @@ static void draw_color_quad_(unsigned int line, struct d3d11_test_context *conte draw_quad_vs_(line, context, vs_code, vs_code_size); }
+#define draw_custom_quad(context, color, vs_code, vs_code_size, quad) \ + draw_custom_quad_(__LINE__, context, color, vs_code, vs_code_size, quad) +static void draw_custom_quad_(unsigned int line, struct d3d11_test_context *context, + const struct vec4 *color, const DWORD *vs_code, unsigned int vs_code_size, + const struct vec4 *quad) +{ + static const D3D11_INPUT_ELEMENT_DESC default_layout_desc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + static const DWORD default_vs_code[] = + { +#if 0 + float4 main(float4 position : POSITION) : SV_POSITION + { + return position; + } +#endif + 0x43425844, 0x4fb19b86, 0x955fa240, 0x1a630688, 0x24eb9db4, 0x00000001, 0x000001e0, 0x00000006, + 0x00000038, 0x00000084, 0x000000d0, 0x00000134, 0x00000178, 0x000001ac, 0x53414e58, 0x00000044, + 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, + 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x02000001, 0xc00f0000, 0x80e40000, + 0x0000ffff, 0x50414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, + 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, + 0x02000001, 0xc00f0000, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x0000005c, 0x0000005c, 0xfffe0200, + 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240001, 0x00000000, + 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000, 0x90ff0000, 0xa0e40000, + 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853, 0x0000003c, 0x00010040, + 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, + 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 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, + }; + ID3D11Device *device = context->device; + HRESULT hr; + + if (!vs_code) + { + vs_code = default_vs_code; + vs_code_size = sizeof(default_vs_code); + } + + if (!context->input_layout) + { + hr = ID3D11Device_CreateInputLayout(device, default_layout_desc, + sizeof(default_layout_desc) / sizeof(*default_layout_desc), + vs_code, vs_code_size, &context->input_layout); + ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr); + } + + if (!context->vb) + { + context->vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(*quad) * 4, quad); + context->vb_stride = sizeof(*quad); + } + + if (context->vs_code != vs_code) + { + if (context->vs) + ID3D11VertexShader_Release(context->vs); + + hr = ID3D11Device_CreateVertexShader(device, vs_code, vs_code_size, NULL, &context->vs); + ok_(__FILE__, line)(hr == S_OK, "Failed to create vertex shader, hr %#x.\n", hr); + + context->vs_code = vs_code; + } + + draw_color_quad_(line, context, color, vs_code, vs_code_size); +} + static void test_create_device(void) { static const D3D_FEATURE_LEVEL default_feature_levels[] = @@ -29141,6 +29276,63 @@ static void test_standard_pattern(void) release_test_context(&test_context); }
+static void test_viewport(void) +{ + static const struct + { + D3D11_VIEWPORT vp; + RECT expected_rect; + const char *message; + } + tests[] = + { + {{ 0.0f, 0.0f, 640.0f, 480.0f}, { 0, 120, 479, 359}, "(0, 0) - (640, 480) viewport"}, + {{ 0.0f, 0.0f, 320.0f, 240.0f}, { 0, 60, 239, 179}, "(0, 0) - (320, 240) viewport"}, + {{ 0.0f, 0.0f, 1280.0f, 960.0f}, { 0, 240, 639, 479}, "(0, 0) - (1280, 960) viewport"}, + {{ 0.0f, 0.0f, 2000.0f, 1600.0f}, { 0, 400, 639, 479}, "(0, 0) - (2000, 1600) viewport"}, + {{ 100.0f, 100.0f, 640.0f, 480.0f}, {100, 220, 579, 459}, "(100, 100) - (640, 480) viewport"}, + {{ 100.4f, 100.4f, 640.0f, 480.0f}, {100, 220, 579, 459}, "(100.4, 100.4) - (640, 480) viewport"}, + {{ 100.5f, 100.5f, 640.0f, 480.0f}, {100, 220, 579, 459}, "(100.5, 100.5) - (640, 480) viewport"}, + {{ 100.6f, 100.6f, 640.0f, 480.0f}, {100, 220, 580, 460}, "(100.6, 100.6) - (640, 480) viewport"}, + {{ 100.9f, 100.9f, 640.0f, 480.0f}, {100, 220, 580, 460}, "(100.9, 100.9) - (640, 480) viewport"}, + {{-100.0f, -100.0f, 640.0f, 480.0f}, { 0, 20, 379, 259}, "(-100, -100) - (640, 480) viewport"}, + {{ 0.0f, 0.0f, 8192.0f, 8192.0f}, {-10, -10, -1, -1}, "(0, 0) - (8192, 8192) viewport"}, + {{ 0.0f, 0.0f, 8192.0f, 480.0f}, { 0, 120, 639, 359}, "(0, 0) - (8192, 480) viewport"}, + }; + static const struct vec4 quad[] = + { + {-1.5f, -0.5f, 0.1f, 1.0f}, + {-1.5f, 0.5f, 0.1f, 1.0f}, + { 0.5f, -0.5f, 0.1f, 1.0f}, + { 0.5f, 0.5f, 0.1f, 1.0f}, + }; + static const struct vec4 black = {0.0f, 0.0f, 0.0f, 1.0f}; + static const struct vec4 white = {1.0f, 1.0f, 1.0f, 1.0f}; + struct d3d11_test_context test_context; + ID3D11DeviceContext *context; + struct resource_readback rb; + unsigned int i; + + if (!init_test_context(&test_context, NULL)) + return; + + context = test_context.immediate_context; + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, &black.x); + + ID3D11DeviceContext_RSSetViewports(context, 1, &tests[i].vp); + draw_custom_quad(&test_context, &white, NULL, 0, quad); + + get_texture_readback(test_context.backbuffer, 0, &rb); + check_rect(&rb, tests[i].expected_rect, tests[i].message); + release_resource_readback(&rb); + } + + release_test_context(&test_context); +} + START_TEST(d3d11) { unsigned int argc, i; @@ -29296,6 +29488,7 @@ START_TEST(d3d11) queue_test(test_staging_buffers); queue_test(test_render_a8); queue_test(test_standard_pattern); + queue_test(test_viewport);
run_queued_tests(); }
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=47542
Your paranoid android.
=== w2008s64 (32 bit report) ===
d3d11: d3d11.c:5752: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5753: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5754: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5757: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5758: Test failed: Got unexpected CPrimitives count: 0.
=== debian9 (32 bit report) ===
d3d11: Unhandled exception: page fault on read access to 0x69766560 in 32-bit code (0x7ecfa092).
=== debian9 (32 bit French report) ===
d3d11: d3d11.c:5728: Test failed: Got unexpected hr 0x8876086a. Unhandled exception: page fault on read access to 0x3f800000 in 32-bit code (0x7ed1108d).
=== debian9 (32 bit Japanese:Japan report) ===
d3d11: Unhandled exception: page fault on read access to 0x3f800000 in 32-bit code (0x7ec1208d).
=== debian9 (32 bit Chinese:China report) ===
d3d11: d3d11.c:5481: Test failed: Got unexpected hr 0x8876086a for query type 4. d3d11.c:5728: Test failed: Got unexpected hr 0x8876086a.
=== debian9 (32 bit WoW report) ===
d3d11: Unhandled exception: page fault on execute access to 0x00000000 in 32-bit code (0x00000000).
=== debian9 (64 bit WoW report) ===
d3d11: d3d11.c:16850: Test failed: Got {-1.00787401e+00, 0.00000000e+00, 1.00000000e+00, 5.03937006e-01}, expected {-1.00000000e+00, 0.00000000e+00, 1.00000000e+00, 5.03937006e-01} at (0, 0), sub-resource 0.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d10core/tests/d3d10core.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c index 5b8e7e1c7ba..9ce385db6c8 100644 --- a/dlls/d3d10core/tests/d3d10core.c +++ b/dlls/d3d10core/tests/d3d10core.c @@ -1389,6 +1389,9 @@ static void draw_quad_vs_(unsigned int line, struct d3d10core_test_context *cont ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr); }
+ if (!context->vb) + context->vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(quad), quad); + if (context->vs_code != vs_code) { if (context->vs) @@ -1400,9 +1403,6 @@ static void draw_quad_vs_(unsigned int line, struct d3d10core_test_context *cont context->vs_code = vs_code; }
- if (!context->vb) - context->vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(quad), quad); - ID3D10Device_IASetInputLayout(context->device, context->input_layout); ID3D10Device_IASetPrimitiveTopology(context->device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); stride = sizeof(*quad); @@ -10338,10 +10338,6 @@ static void test_cb_relative_addressing(void) 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 @@ -10451,10 +10447,6 @@ float4 main(const ps_in v) : SV_TARGET
device = test_context.device;
- hr = ID3D10Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc), - vs_code, sizeof(vs_code), &test_context.input_layout); - ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr); - colors_cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(colors), &colors); index_cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(index), NULL);
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=47543
Your paranoid android.
=== debian9 (32 bit report) ===
d3d10core: Unhandled exception: page fault on read access to 0x6976656c in 32-bit code (0x7ed24918).
=== debian9 (32 bit Japanese:Japan report) ===
d3d10core: d3d10core.c:4626: Test failed: Got unexpected hr 0x8876086a. Unhandled exception: page fault on read access to 0x6976656c in 32-bit code (0x7ec24918).
=== debian9 (32 bit Chinese:China report) ===
d3d10core: d3d10core.c:4423: Test failed: Got unexpected hr 0x8876086a for query type 4. Unhandled exception: page fault on read access to 0x6976656c in 32-bit code (0x7eb86918).
=== debian9 (32 bit WoW report) ===
d3d10core: Unhandled exception: page fault on read access to 0x6976656c in 32-bit code (0x7ed24918).
=== debian9 (64 bit WoW report) ===
d3d10core: d3d10core.c:12479: Test failed: Got {-1.00787401e+00, 0.00000000e+00, 1.00000000e+00, 5.03937006e-01}, expected {-1.00000000e+00, 0.00000000e+00, 1.00000000e+00, 5.03937006e-01} at (0, 0), sub-resource 0.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d10core/tests/d3d10core.c | 189 ++++++++++++++++++++++++++++++- 1 file changed, 185 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c index 9ce385db6c8..5fcb82aebae 100644 --- a/dlls/d3d10core/tests/d3d10core.c +++ b/dlls/d3d10core/tests/d3d10core.c @@ -1092,6 +1092,67 @@ static IDXGIAdapter *create_adapter(void) return adapter; }
+static void check_rect(struct resource_readback *rb, RECT r, const char *message) +{ + LONG x_coords[2][2] = + { + {r.left - 1, r.left + 1}, + {r.right + 1, r.right - 1}, + }; + LONG y_coords[2][2] = + { + {r.top - 1, r.top + 1}, + {r.bottom + 1, r.bottom - 1} + }; + unsigned int i, j, x_side, y_side; + DWORD color = 0; + LONG x = 0, y; + + if (r.left < 0 && r.top < 0 && r.right < 0 && r.bottom < 0) + { + BOOL all_match = TRUE; + + for (y = 0; y < rb->height; ++y) + { + for (x = 0; x < rb->width; ++x) + { + color = get_readback_color(rb, x, y); + if (color != 0xff000000) + { + all_match = FALSE; + break; + } + } + if (!all_match) + break; + } + ok(all_match, "%s: pixel (%d, %d) has color %08x.\n", message, x, y, color); + return; + } + + for (i = 0; i < 2; ++i) + { + for (j = 0; j < 2; ++j) + { + for (x_side = 0; x_side < 2; ++x_side) + { + for (y_side = 0; y_side < 2; ++y_side) + { + DWORD expected = (x_side == 1 && y_side == 1) ? 0xffffffff : 0xff000000; + + x = x_coords[i][x_side]; + y = y_coords[j][y_side]; + if (x < 0 || x >= rb->width || y < 0 || y >= rb->height) + continue; + color = get_readback_color(rb, x, y); + ok(color == expected, "%s: pixel (%d, %d) has color %08x, expected %08x.\n", + message, x, y, color, expected); + } + } + } + } +} + static ID3D10Device *create_device(void) { unsigned int flags = 0; @@ -1265,10 +1326,11 @@ struct d3d10core_test_context ID3D10RenderTargetView *backbuffer_rtv;
ID3D10InputLayout *input_layout; + ID3D10Buffer *vb; + unsigned int vb_stride; ID3D10VertexShader *vs; const DWORD *vs_code; ID3D10Buffer *vs_cb; - ID3D10Buffer *vb;
ID3D10PixelShader *ps; ID3D10Buffer *ps_cb; @@ -1373,7 +1435,7 @@ static void draw_quad_vs_(unsigned int line, struct d3d10core_test_context *cont };
ID3D10Device *device = context->device; - unsigned int stride, offset; + unsigned int offset; HRESULT hr;
if (!vs_code) @@ -1390,7 +1452,10 @@ static void draw_quad_vs_(unsigned int line, struct d3d10core_test_context *cont }
if (!context->vb) + { context->vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(quad), quad); + context->vb_stride = sizeof(*quad); + }
if (context->vs_code != vs_code) { @@ -1405,9 +1470,8 @@ static void draw_quad_vs_(unsigned int line, struct d3d10core_test_context *cont
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_IASetVertexBuffers(context->device, 0, 1, &context->vb, &context->vb_stride, &offset); ID3D10Device_VSSetShader(context->device, context->vs);
ID3D10Device_Draw(context->device, 4, 0); @@ -1491,6 +1555,69 @@ static void draw_color_quad_(unsigned int line, struct d3d10core_test_context *c draw_quad_vs_(line, context, vs_code, vs_code_size); }
+#define draw_custom_quad(context, color, vs_code, vs_code_size, quad) \ + draw_custom_quad_(__LINE__, context, color, vs_code, vs_code_size, quad) +static void draw_custom_quad_(unsigned int line, struct d3d10core_test_context *context, + const struct vec4 *color, const DWORD *vs_code, unsigned int vs_code_size, + const struct vec4 *quad) +{ + static const D3D10_INPUT_ELEMENT_DESC default_layout_desc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_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, + }; + ID3D10Device *device = context->device; + HRESULT hr; + + if (!vs_code) + { + vs_code = default_vs_code; + vs_code_size = sizeof(default_vs_code); + } + + if (!context->input_layout) + { + hr = ID3D10Device_CreateInputLayout(device, default_layout_desc, + sizeof(default_layout_desc) / sizeof(*default_layout_desc), + vs_code, vs_code_size, &context->input_layout); + ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr); + } + + if (!context->vb) + { + context->vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(*quad) * 4, quad); + context->vb_stride = sizeof(*quad); + } + + if (context->vs_code != vs_code) + { + if (context->vs) + ID3D10VertexShader_Release(context->vs); + + hr = ID3D10Device_CreateVertexShader(device, vs_code, vs_code_size, &context->vs); + ok_(__FILE__, line)(hr == S_OK, "Failed to create vertex shader, hr %#x.\n", hr); + + context->vs_code = vs_code; + } + + draw_color_quad_(line, context, color, vs_code, vs_code_size); +} + static void test_feature_level(void) { D3D_FEATURE_LEVEL feature_level; @@ -17879,6 +18006,59 @@ static void test_render_a8(void) release_test_context(&test_context); }
+static void test_viewport(void) +{ + static const struct + { + D3D10_VIEWPORT vp; + RECT expected_rect; + const char *message; + } + tests[] = + { + {{ 0, 0, 640, 480}, { 0, 120, 479, 359}, "(0, 0) - (640, 480) viewport"}, + {{ 0, 0, 320, 240}, { 0, 60, 239, 179}, "(0, 0) - (320, 240) viewport"}, + {{ 0, 0, 1280, 960}, { 0, 240, 639, 479}, "(0, 0) - (1280, 960) viewport"}, + {{ 0, 0, 2000, 1600}, { 0, 400, 639, 479}, "(0, 0) - (2000, 1600) viewport"}, + {{ 100, 100, 640, 480}, {100, 220, 579, 459}, "(100, 100) - (640, 480) viewport"}, + {{-100, -100, 640, 480}, { 0, 20, 379, 259}, "(-100, -100) - (640, 480) viewport"}, + {{ 0, 0, 8192, 8192}, {-10, -10, -1, -1}, "(0, 0) - (8192, 8192) viewport"}, + {{ 0, 0, 8192, 480}, { 0, 120, 639, 359}, "(0, 0) - (8192, 480) viewport"}, + }; + static const struct vec4 quad[] = + { + {-1.5f, -0.5f, 0.1f, 1.0f}, + {-1.5f, 0.5f, 0.1f, 1.0f}, + { 0.5f, -0.5f, 0.1f, 1.0f}, + { 0.5f, 0.5f, 0.1f, 1.0f}, + }; + static const struct vec4 black = {0.0f, 0.0f, 0.0f, 1.0f}; + static const struct vec4 white = {1.0f, 1.0f, 1.0f, 1.0f}; + struct d3d10core_test_context test_context; + struct resource_readback rb; + ID3D10Device *device; + unsigned int i; + + if (!init_test_context(&test_context)) + return; + + device = test_context.device; + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, &black.x); + + ID3D10Device_RSSetViewports(device, 1, &tests[i].vp); + draw_custom_quad(&test_context, &white, NULL, 0, quad); + + get_texture_readback(test_context.backbuffer, 0, &rb); + check_rect(&rb, tests[i].expected_rect, tests[i].message); + release_resource_readback(&rb); + } + + release_test_context(&test_context); +} + START_TEST(d3d10core) { unsigned int argc, i; @@ -17994,6 +18174,7 @@ START_TEST(d3d10core) queue_test(test_depth_clip); queue_test(test_staging_buffers); queue_test(test_render_a8); + queue_test(test_viewport);
run_queued_tests();
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=47544
Your paranoid android.
=== debian9 (32 bit report) ===
d3d10core: Unhandled exception: page fault on read access to 0x00000001 in 32-bit code (0x7ed23a03).
=== debian9 (32 bit French report) ===
d3d10core: Unhandled exception: page fault on read access to 0x00000001 in 32-bit code (0x7ed2da03).
=== debian9 (32 bit Japanese:Japan report) ===
d3d10core: d3d10core.c:4753: Test failed: Got unexpected hr 0x8876086a. Unhandled exception: page fault on read access to 0x2e2f2e56 in 32-bit code (0x7ec45a08).
=== debian9 (32 bit Chinese:China report) ===
d3d10core: Unhandled exception: page fault on read access to 0x00000001 in 32-bit code (0x7eb77a03).
=== debian9 (32 bit WoW report) ===
d3d10core: d3d10core.c:4550: Test failed: Got unexpected hr 0x8876086a for query type 4. Unhandled exception: page fault on read access to 0x00000001 in 32-bit code (0x7ed3aa03).
=== debian9 (64 bit WoW report) ===
d3d10core: d3d10core.c:4753: Test failed: Got unexpected hr 0x8876086a. Unhandled exception: page fault on execute access to 0x00000000 in 64-bit code (0x0000000000000000).
Report errors: d3d10core:d3d10core crashed (c0000005)
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=47540
Your paranoid android.
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
On Tue, 12 Feb 2019 at 20:56, Matteo Bruni mbruni@codeweavers.com wrote:
dlls/d3d9/tests/device.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
This appears to cause failures in the occlusion query test on Windows:
device.c:6038: Expects 0x0000000104000000 samples. device.c:6065: Test failed: Got unexpected query result 0xdddddddd00000000. device.c:6093: Test failed: Got unexpected query result 0xdddddddd00000000.