Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Add a couple of comments.
dlls/d3d9/d3d9_private.h | 2 ++ dlls/d3d9/device.c | 26 ++++++++++++++++++++++++-- dlls/d3d9/tests/visual.c | 23 +++++++++++++++++++++++ dlls/d3d9/vertexdeclaration.c | 2 +- 4 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 3fe0376e5c1..50b18b1ed36 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -256,6 +256,8 @@ struct d3d9_vertex_declaration IDirect3DDevice9Ex *parent_device; };
+HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elements, + struct wined3d_vertex_element **wined3d_elements, UINT *element_count) DECLSPEC_HIDDEN; HRESULT d3d9_vertex_declaration_create(struct d3d9_device *device, const D3DVERTEXELEMENT9 *elements, struct d3d9_vertex_declaration **declaration) DECLSPEC_HIDDEN; struct d3d9_vertex_declaration *unsafe_impl_from_IDirect3DVertexDeclaration9( diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 6cc3f180b09..ef73adcc789 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2730,23 +2730,45 @@ static void d3d9_generate_auto_mipmaps(struct d3d9_device *device) static void d3d9_device_upload_sysmem_vertex_buffers(struct d3d9_device *device, int base_vertex, unsigned int start_vertex, unsigned int vertex_count) { + struct wined3d_vertex_declaration *wined3d_decl; struct wined3d_box box = {0, 0, 0, 1, 0, 1}; + unsigned int i, offset, stride, map, count; + struct wined3d_vertex_element *elements; struct d3d9_vertexbuffer *d3d9_buffer; struct wined3d_resource *dst_resource; - unsigned int i, offset, stride, map; + struct d3d9_vertex_declaration *decl; struct wined3d_buffer *dst_buffer; struct wined3d_resource_desc desc; HRESULT hr;
if (!device->sysmem_vb) return; + wined3d_decl = wined3d_device_get_vertex_declaration(device->wined3d_device); + if (!wined3d_decl) + return;
if (base_vertex >= 0 || start_vertex >= -base_vertex) start_vertex += base_vertex; else FIXME("System memory vertex data offset is negative.\n");
- map = device->sysmem_vb; + /* Make sure to only upload buffers that are used by the current draw: + * released buffers might still be bound as stream sources. */ + decl = wined3d_vertex_declaration_get_parent(wined3d_decl); + if (!decl->elements) + { + map = 1; + } + else + { + map = 0; + if (FAILED(convert_to_wined3d_declaration(decl->elements, &elements, &count))) + return; + for (i = 0; i < count; ++i) + map |= 1u << elements[i].input_slot; + heap_free(elements); + } + map &= device->sysmem_vb; while (map) { i = wined3d_bit_scan(&map); diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 52d67c81991..0e572984784 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -24713,6 +24713,29 @@ static void test_sysmem_draw(void) colour = getPixelColor(device, 320, 240); ok(color_match(colour, 0x00443322, 1), "Got unexpected colour 0x%08x.\n", colour);
+ /* Test that releasing but not unbinding a vertex buffer doesn't break. */ + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, sizeof(*quad)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetIndices(device, ib); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + IDirect3DVertexBuffer9_Release(vb_s1); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 0, 4, 0, 2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour); + hr = IDirect3DDevice9_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, NULL); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); memset(&lr, 0, sizeof(lr)); diff --git a/dlls/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c index b6445255238..5f07207a482 100644 --- a/dlls/d3d9/vertexdeclaration.c +++ b/dlls/d3d9/vertexdeclaration.c @@ -320,7 +320,7 @@ static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops d3d9_vertexdeclaration_wined3d_object_destroyed, };
-static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elements, +HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elements, struct wined3d_vertex_element **wined3d_elements, UINT *element_count) { const D3DVERTEXELEMENT9* element;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46371 Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Add a couple of comments.
dlls/d3d8/d3d8_private.h | 2 ++ dlls/d3d8/device.c | 29 +++++++++++++++++++++++++++-- dlls/d3d8/tests/visual.c | 24 +++++++++++++++++++++++- dlls/d3d8/vertexdeclaration.c | 2 +- 4 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 7c44f07c5ea..f3cab96f9d8 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -255,6 +255,8 @@ struct d3d8_vertex_declaration DWORD shader_handle; };
+UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, + struct wined3d_vertex_element **wined3d_elements) DECLSPEC_HIDDEN; void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration) DECLSPEC_HIDDEN; HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration, struct d3d8_device *device, const DWORD *elements, DWORD shader_handle) DECLSPEC_HIDDEN; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index d367f4200cc..2295b125506 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2269,15 +2269,40 @@ static HRESULT WINAPI d3d8_device_GetCurrentTexturePalette(IDirect3DDevice8 *ifa static void d3d8_device_upload_sysmem_vertex_buffers(struct d3d8_device *device, unsigned int start_vertex, unsigned int vertex_count) { + struct wined3d_vertex_declaration *wined3d_decl; struct wined3d_box box = {0, 0, 0, 1, 0, 1}; + unsigned int i, offset, stride, map, count; + struct wined3d_vertex_element *elements; struct d3d8_vertexbuffer *d3d8_buffer; struct wined3d_resource *dst_resource; - unsigned int i, offset, stride, map; + struct d3d8_vertex_declaration *decl; struct wined3d_buffer *dst_buffer; struct wined3d_resource_desc desc; HRESULT hr;
- map = device->sysmem_vb; + if (!device->sysmem_vb) + return; + wined3d_decl = wined3d_device_get_vertex_declaration(device->wined3d_device); + if (!wined3d_decl) + return; + /* Make sure to only upload buffers that are used by the current draw: + * released buffers might still be bound as stream sources. */ + decl = wined3d_vertex_declaration_get_parent(wined3d_decl); + if (!decl->elements) + { + map = 1; + } + else + { + map = 0; + count = convert_to_wined3d_declaration(decl->elements, &decl->elements_size, &elements); + if (!count) + return; + for (i = 0; i < count; ++i) + map |= 1u << elements[i].input_slot; + heap_free(elements); + } + map &= device->sysmem_vb; while (map) { i = wined3d_bit_scan(&map); diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index c405f8245ee..ac6a050f5fa 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -10698,6 +10698,29 @@ static void test_sysmem_draw(void) colour = getPixelColor(device, 320, 240); ok(color_match(colour, 0x00443322, 1), "Got unexpected colour 0x%08x.\n", colour);
+ /* Test that releasing but not unbinding a vertex buffer doesn't break. */ + hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice8_SetStreamSource(device, 0, vb, sizeof(*quad)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice8_SetIndices(device, ib, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + IDirect3DVertexBuffer8_Release(vb_s1); + + hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice8_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 4, 0, 2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice8_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour); + hr = IDirect3DDevice8_CreateTexture(device, 2, 2, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &texture); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); memset(&lr, 0, sizeof(lr)); @@ -10727,7 +10750,6 @@ static void test_sysmem_draw(void) ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
IDirect3DTexture8_Release(texture); - IDirect3DVertexBuffer8_Release(vb_s1); IDirect3DVertexBuffer8_Release(vb_s0); IDirect3DDevice8_DeleteVertexShader(device, vs); IDirect3DIndexBuffer8_Release(ib); diff --git a/dlls/d3d8/vertexdeclaration.c b/dlls/d3d8/vertexdeclaration.c index 709e04bace4..3c05101cb7f 100644 --- a/dlls/d3d8/vertexdeclaration.c +++ b/dlls/d3d8/vertexdeclaration.c @@ -249,7 +249,7 @@ wined3d_usage_lookup[] = };
/* TODO: find out where rhw (or positionT) is for declaration8 */ -static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, +UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, struct wined3d_vertex_element **wined3d_elements) { struct wined3d_vertex_element *element;
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=48236
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) 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) 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)
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d8/tests/device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 4dbe1687d89..a64736913da 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -3049,8 +3049,9 @@ static void test_wndproc(void) /* Remove the maximized state from the SYSCOMMAND test while we're not * interfering with a device. */ ShowWindow(focus_window, SW_SHOWNORMAL); - filter_messages = focus_window;
+ /* On Windows 10 style change messages are delivered on device + * creation. */ device_desc.device_window = focus_window; if (!(device = create_device(d3d8, focus_window, &device_desc))) { @@ -3065,7 +3066,6 @@ static void test_wndproc(void) SetForegroundWindow(GetDesktopWindow()); ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n", expect_messages->message, expect_messages->window); - ok(!windowposchanged_received, "Received WM_WINDOWPOSCHANGED but did not expect it.\n"); expect_messages = NULL;
/* The window is iconic even though no message was sent. */ @@ -3121,6 +3121,7 @@ static void test_wndproc(void) hr = IDirect3DDevice8_TestCooperativeLevel(device); ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+ filter_messages = NULL; hr = reset_device(device, &device_desc); ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
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=48237
Your paranoid android.
=== w8 (32 bit report) ===
d3d8: device.c:9451: Test failed: DrawPrimitive failed, hr 0x80004005. device.c:9460: Test failed: DrawPrimitiveUP failed, hr 0x80004005. device.c:9465: Test failed: Unexpected stride 16. device.c:9471: Test failed: DrawIndexedPrimitive failed, hr 0x80004005. device.c:9477: Test failed: DrawIndexedPrimitive failed, hr 0x80004005. device.c:9487: Test failed: DrawIndexedPrimitiveUP failed, hr 0x80004005. device.c:9506: Test failed: DrawIndexedPrimitiveUP failed, hr 0x80004005. device.c:9515: Test failed: Unexpected stride 16.
=== 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) 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) 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)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/tests/d3d9ex.c | 42 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index 81dd5912b23..047623df443 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -2058,20 +2058,21 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL); - ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED || hr == S_PRESENT_MODE_CHANGED || broken(hr == D3D_OK), + "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0); - ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED || hr == S_PRESENT_MODE_CHANGED, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK || hr == S_PRESENT_MODE_CHANGED, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window); ok(ret, "Failed to set foreground window.\n"); @@ -2084,7 +2085,7 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
desc.width = 1024; desc.height = 768; @@ -2099,7 +2100,7 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
desc.flags = 0; hr = reset_device(device, &desc); @@ -2166,24 +2167,24 @@ static void test_lost_device(void) hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL); - ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED || broken(hr == D3D_OK), "Got unexpected hr %#x.\n", hr); hr = reset_device(device, &desc); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK || broken(hr == S_FALSE), "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_PresentEx(device, NULL, NULL, NULL, NULL, 0); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK || broken(hr == S_FALSE), "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, window); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL); - ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr); + ok(hr == S_PRESENT_OCCLUDED || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
refcount = IDirect3DDevice9Ex_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); @@ -3214,7 +3215,7 @@ static void test_wndproc(void)
if (!(tests[i].create_flags & CREATE_DEVICE_NOWINDOWCHANGES)) { - ok(windowpos.hwnd == device_window && !windowpos.hwndInsertAfter + ok(windowpos.hwnd == device_window && !windowpos.x && !windowpos.y && !windowpos.cx && !windowpos.cy && windowpos.flags == (SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE), "Got unexpected WINDOWPOS hwnd=%p, insertAfter=%p, x=%d, y=%d, cx=%d, cy=%d, flags=%x\n", @@ -3518,10 +3519,12 @@ static void test_window_style(void) }
style = GetWindowLongA(device_window, GWL_STYLE); - todo_wine ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n", + todo_wine ok((style & ~WS_OVERLAPPEDWINDOW) == (device_style & ~WS_OVERLAPPEDWINDOW), + "Expected device window style %#x, got %#x, i=%u.\n", device_style, style, i); style = GetWindowLongA(device_window, GWL_EXSTYLE); - todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n", + todo_wine ok((style & ~WS_EX_OVERLAPPEDWINDOW) == (device_exstyle & ~WS_EX_OVERLAPPEDWINDOW), + "Expected device window extended style %#x, got %#x, i=%u.\n", device_exstyle, style, i);
style = GetWindowLongA(focus_window, GWL_STYLE); @@ -3539,7 +3542,8 @@ static void test_window_style(void) ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s, i=%u.\n", wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r), i); GetClientRect(device_window, &r2); - todo_wine ok(!EqualRect(&r, &r2), "Client rect and window rect are equal, i=%u.\n", i); + if (!(device_style & WS_OVERLAPPEDWINDOW)) + ok(!EqualRect(&r, &r2), "Client rect and window rect are equal, i=%u.\n", i); GetWindowRect(focus_window, &r); ok(EqualRect(&r, &focus_rect), "Expected %s, got %s, i=%u.\n", wine_dbgstr_rect(&focus_rect), wine_dbgstr_rect(&r), i); @@ -3588,11 +3592,13 @@ static void test_window_style(void) ok(!!device, "Failed to create a D3D device.\n"); style = GetWindowLongA(device_window, GWL_STYLE); expected_style = device_style | tests[i].create2_style; - todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n", + todo_wine ok((style & ~WS_OVERLAPPEDWINDOW) == (expected_style & ~WS_OVERLAPPEDWINDOW), + "Expected device window style %#x, got %#x, i=%u.\n", expected_style, style, i); expected_style = device_exstyle | tests[i].create2_exstyle; style = GetWindowLongA(device_window, GWL_EXSTYLE); - todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n", + todo_wine ok((style & ~WS_EX_OVERLAPPEDWINDOW) == (expected_style & ~WS_EX_OVERLAPPEDWINDOW), + "Expected device window extended style %#x, got %#x, i=%u.\n", expected_style, style, i);
style = GetWindowLongA(focus_window, GWL_STYLE); @@ -4139,7 +4145,7 @@ static void test_frame_latency(void)
hr = IDirect3DDevice9Ex_GetMaximumFrameLatency(device, &latency); ok(SUCCEEDED(hr), "Failed to get max frame latency, hr %#x.\n", hr); - ok(latency == 3, "Unexpected default max frame latency %u.\n", latency); + ok(latency == 3 || !latency, "Unexpected default max frame latency %u.\n", latency);
hr = IDirect3DDevice9Ex_SetMaximumFrameLatency(device, 30); ok(SUCCEEDED(hr), "Failed to set max frame latency, hr %#x.\n", hr);
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=48238
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) 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) 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)
On Mon, 25 Feb 2019 at 21:31, Matteo Bruni mbruni@codeweavers.com wrote:
dlls/d3d9/tests/d3d9ex.c | 42 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-)
As a general comment, this patch does several things at once.
@@ -3518,10 +3519,12 @@ static void test_window_style(void) }
style = GetWindowLongA(device_window, GWL_STYLE);
todo_wine ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
todo_wine ok((style & ~WS_OVERLAPPEDWINDOW) == (device_style & ~WS_OVERLAPPEDWINDOW),
"Expected device window style %#x, got %#x, i=%u.\n", device_style, style, i); style = GetWindowLongA(device_window, GWL_EXSTYLE);
todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
todo_wine ok((style & ~WS_EX_OVERLAPPEDWINDOW) == (device_exstyle & ~WS_EX_OVERLAPPEDWINDOW),
"Expected device window extended style %#x, got %#x, i=%u.\n", device_exstyle, style, i);
That seems to defeat the point of the test somewhat. Perhaps that's ok for d3d9ex though. Which styles does it touch specifically?
On Tue, Feb 26, 2019 at 5:31 PM Henri Verbeet hverbeet@gmail.com wrote:
On Mon, 25 Feb 2019 at 21:31, Matteo Bruni mbruni@codeweavers.com wrote:
dlls/d3d9/tests/d3d9ex.c | 42 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-)
As a general comment, this patch does several things at once.
@@ -3518,10 +3519,12 @@ static void test_window_style(void) }
style = GetWindowLongA(device_window, GWL_STYLE);
todo_wine ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
todo_wine ok((style & ~WS_OVERLAPPEDWINDOW) == (device_style & ~WS_OVERLAPPEDWINDOW),
"Expected device window style %#x, got %#x, i=%u.\n", device_style, style, i); style = GetWindowLongA(device_window, GWL_EXSTYLE);
todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
todo_wine ok((style & ~WS_EX_OVERLAPPEDWINDOW) == (device_exstyle & ~WS_EX_OVERLAPPEDWINDOW),
"Expected device window extended style %#x, got %#x, i=%u.\n", device_exstyle, style, i);
That seems to defeat the point of the test somewhat. Perhaps that's ok for d3d9ex though. Which styles does it touch specifically?
Most of WS_OVERLAPPEDWINDOW: only WS_CLIPSIBLINGS is left (and WS_OVERLAPPED, but that's 0). EX styles loses WS_EX_WINDOWEDGE, which is the only one present before that. It also preserves WS_VISIBLE and WS_EX_TOPMOST in the tests immediately after these.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- I'm resending this patch unchanged since I can't reproduce the test failure and I don't feel comfortable with blindly changing the code.
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 7d8b4fdfcd4..bf64ddf1633 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);
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=48239
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) 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) 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)
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=48235
Your paranoid android.
=== w8adm (32 bit report) ===
d3d9: visual.c:8750: Test failed: Got unexpected color 0x00007580 for quad 2 (different colors).
=== w1064 (32 bit report) ===
d3d9: visual.c:8750: Test failed: Got unexpected color 0x00008080 for quad 2 (different colors).
=== 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) 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 Mon, 25 Feb 2019 at 21:31, Matteo Bruni mbruni@codeweavers.com wrote:
- /* Make sure to only upload buffers that are used by the current draw:
* released buffers might still be bound as stream sources. */
Thinking about it some more, does this really solve the issue? In particular, what about the case where the buffer is released, but also referenced by the vertex declaration? Shouldn't we just delay releasing the wined3d system memory buffer until wined3d_object_destroyed()?
On Tue, Feb 26, 2019 at 4:54 PM Henri Verbeet hverbeet@gmail.com wrote:
On Mon, 25 Feb 2019 at 21:31, Matteo Bruni mbruni@codeweavers.com wrote:
- /* Make sure to only upload buffers that are used by the current draw:
* released buffers might still be bound as stream sources. */
Thinking about it some more, does this really solve the issue? In particular, what about the case where the buffer is released, but also referenced by the vertex declaration? Shouldn't we just delay releasing the wined3d system memory buffer until wined3d_object_destroyed()?
I'll write a test for that case. I think something like this patch will be useful anyway to avoid spurious buffer uploads (not strictly for performance reasons, those extra uploads did look somewhat confusing in the log.)
On Tue, Feb 26, 2019 at 6:07 PM Matteo Bruni matteo.mystral@gmail.com wrote:
On Tue, Feb 26, 2019 at 4:54 PM Henri Verbeet hverbeet@gmail.com wrote:
On Mon, 25 Feb 2019 at 21:31, Matteo Bruni mbruni@codeweavers.com wrote:
- /* Make sure to only upload buffers that are used by the current draw:
* released buffers might still be bound as stream sources. */
Thinking about it some more, does this really solve the issue? In particular, what about the case where the buffer is released, but also referenced by the vertex declaration? Shouldn't we just delay releasing the wined3d system memory buffer until wined3d_object_destroyed()?
I'll write a test for that case. I think something like this patch will be useful anyway to avoid spurious buffer uploads (not strictly for performance reasons, those extra uploads did look somewhat confusing in the log.)
Eh, the test isn't that convincing, somehow it doesn't crash for me on Wine (I'm sure it did crash previously and I can see we're using the destroyed buffer sysmem as expected). Anyway, I'll work on the proper fix.