From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d8/tests/visual.c | 153 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index 2f9462f2d44..05a1fc38844 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -19,6 +19,7 @@
/* See comment in dlls/d3d9/tests/visual.c for general guidelines */
+#include <stdbool.h> #include <limits.h> #include <math.h>
@@ -41,6 +42,14 @@ struct vec4 float x, y, z, w; };
+struct d3d8_test_context +{ + HWND window; + IDirect3D8 *d3d; + IDirect3DDevice8 *device; + IDirect3DSurface8 *backbuffer; +}; + static HWND create_window(void) { RECT rect; @@ -239,8 +248,9 @@ static void check_rect(struct surface_readback *rb, RECT r, const char *message) } }
-#define check_rt_color(a, b) check_rt_color_(__LINE__, a, b) -static void check_rt_color_(unsigned int line, IDirect3DSurface8 *rt, D3DCOLOR expected_color) +#define check_rt_color(a, b) check_rt_color_(__LINE__, a, b, false) +#define check_rt_color_todo(a, b) check_rt_color_(__LINE__, a, b, true) +static void check_rt_color_(unsigned int line, IDirect3DSurface8 *rt, D3DCOLOR expected_color, bool todo) { unsigned int color = 0xdeadbeef; struct surface_readback rb; @@ -264,7 +274,8 @@ static void check_rt_color_(unsigned int line, IDirect3DSurface8 *rt, D3DCOLOR e break; } release_surface_readback(&rb); - ok_(__FILE__, line)(color == expected_color, "Got unexpected color 0x%08x.\n", color); + todo_wine_if (todo) + ok_(__FILE__, line)(color == expected_color, "Got unexpected color 0x%08x.\n", color); }
static IDirect3DDevice8 *create_device(IDirect3D8 *d3d, HWND device_window, HWND focus_window, BOOL windowed) @@ -288,6 +299,101 @@ static IDirect3DDevice8 *create_device(IDirect3D8 *d3d, HWND device_window, HWND return NULL; }
+static bool init_test_context(struct d3d8_test_context *context) +{ + HRESULT hr; + + memset(context, 0, sizeof(*context)); + + context->window = create_window(); + context->d3d = Direct3DCreate8(D3D_SDK_VERSION); + ok(!!context->d3d, "Failed to create a D3D object.\n"); + if (!(context->device = create_device(context->d3d, context->window, context->window, TRUE))) + { + skip("Failed to create a D3D device.\n"); + IDirect3D8_Release(context->d3d); + DestroyWindow(context->window); + return false; + } + + hr = IDirect3DDevice8_GetRenderTarget(context->device, &context->backbuffer); + ok(hr == S_OK, "Failed to get backbuffer, hr %#lx.\n", hr); + + return true; +} + +#define release_test_context(a) release_test_context_(__LINE__, a) +static void release_test_context_(unsigned int line, struct d3d8_test_context *context) +{ + ULONG refcount; + + IDirect3DSurface8_Release(context->backbuffer); + refcount = IDirect3DDevice8_Release(context->device); + ok(!refcount, "Device has %lu references left.\n", refcount); + refcount = IDirect3D8_Release(context->d3d); + ok(!refcount, "D3D object has %lu references left.\n", refcount); + DestroyWindow(context->window); +} + +static void draw_textured_quad(struct d3d8_test_context *context, IDirect3DTexture8 *texture) +{ + IDirect3DDevice8 *device = context->device; + HRESULT hr; + + static const struct + { + struct vec3 position; + struct vec2 texcoord; + } + quad[] = + { + {{-1.0f, -1.0f, 0.0f}, {0.0f, 0.0f}}, + {{-1.0f, 1.0f, 0.0f}, {0.0f, 1.0f}}, + {{ 1.0f, -1.0f, 0.0f}, {1.0f, 0.0f}}, + {{ 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f}}, + }; + + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_TEX1); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_BeginScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad, sizeof(*quad)); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_EndScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); +} + +static HRESULT reset_device(struct d3d8_test_context *context) +{ + D3DPRESENT_PARAMETERS present_parameters = {0}; + HRESULT hr; + + IDirect3DSurface8_Release(context->backbuffer); + + present_parameters.BackBufferWidth = 640; + present_parameters.BackBufferHeight = 480; + present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8; + present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; + present_parameters.hDeviceWindow = context->window; + present_parameters.Windowed = TRUE; + present_parameters.EnableAutoDepthStencil = TRUE; + present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8; + hr = IDirect3DDevice8_Reset(context->device, &present_parameters); + + if (SUCCEEDED(hr)) + IDirect3DDevice8_GetRenderTarget(context->device, &context->backbuffer); + + return hr; +} + static void test_sanity(void) { IDirect3DDevice8 *device; @@ -5398,6 +5504,15 @@ static void fill_surface(IDirect3DSurface8 *surface, DWORD color, DWORD flags) ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr); }
+static void fill_texture(IDirect3DTexture8 *texture, DWORD color, DWORD flags) +{ + IDirect3DSurface8 *surface; + + IDirect3DTexture8_GetSurfaceLevel(texture, 0, &surface); + fill_surface(surface, color, flags); + IDirect3DSurface8_Release(surface); +} + static void add_dirty_rect_test_draw(IDirect3DDevice8 *device) { HRESULT hr; @@ -11979,6 +12094,37 @@ static void test_filling_convention(void) DestroyWindow(window); }
+static void test_managed_reset(void) +{ + struct d3d8_test_context context; + IDirect3DTexture8 *texture; + IDirect3DDevice8 *device; + HRESULT hr; + + if (!init_test_context(&context)) + return; + device = context.device; + + hr = IDirect3DDevice8_CreateTexture(device, 256, 256, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + fill_texture(texture, 0x0000ff00, 0); + + draw_textured_quad(&context, texture); + check_rt_color(context.backbuffer, 0x0000ff00); + + hr = reset_device(&context); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + draw_textured_quad(&context, texture); + check_rt_color_todo(context.backbuffer, 0x0000ff00); + + IDirect3DTexture8_Release(texture); + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER8 identifier; @@ -12060,4 +12206,5 @@ START_TEST(visual) test_sample_mask(); test_dynamic_map_synchronization(); test_filling_convention(); + test_managed_reset(); }
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 153 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index d8fa298d6c7..fc30090562f 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -28,6 +28,7 @@ * causes visible results in games can be tested in a way that does not depend on pixel exactness */
+#include <stdbool.h> #include <limits.h> #include <math.h>
@@ -51,6 +52,14 @@ struct vec4 float x, y, z, w; };
+struct d3d9_test_context +{ + HWND window; + IDirect3D9 *d3d; + IDirect3DDevice9 *device; + IDirect3DSurface9 *backbuffer; +}; + static HWND create_window(void) { HWND hwnd; @@ -249,8 +258,9 @@ static DWORD getPixelColor(IDirect3DDevice9 *device, UINT x, UINT y) return ret; }
-#define check_rt_color(a, b) check_rt_color_(__LINE__, a, b) -static void check_rt_color_(unsigned int line, IDirect3DSurface9 *rt, D3DCOLOR expected_color) +#define check_rt_color(a, b) check_rt_color_(__LINE__, a, b, false) +#define check_rt_color_todo(a, b) check_rt_color_(__LINE__, a, b, true) +static void check_rt_color_(unsigned int line, IDirect3DSurface9 *rt, D3DCOLOR expected_color, bool todo) { unsigned int color = 0xdeadbeef; struct surface_readback rb; @@ -274,7 +284,8 @@ static void check_rt_color_(unsigned int line, IDirect3DSurface9 *rt, D3DCOLOR e break; } release_surface_readback(&rb); - ok_(__FILE__, line)(color == expected_color, "Got unexpected color 0x%08x.\n", color); + todo_wine_if (todo) + ok_(__FILE__, line)(color == expected_color, "Got unexpected color 0x%08x.\n", color); }
static IDirect3DDevice9 *create_device(IDirect3D9 *d3d, HWND device_window, HWND focus_window, BOOL windowed) @@ -315,6 +326,101 @@ static void cleanup_device(IDirect3DDevice9 *device) } }
+static bool init_test_context(struct d3d9_test_context *context) +{ + HRESULT hr; + + memset(context, 0, sizeof(*context)); + + context->window = create_window(); + context->d3d = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!context->d3d, "Failed to create a D3D object.\n"); + if (!(context->device = create_device(context->d3d, context->window, context->window, TRUE))) + { + skip("Failed to create a D3D device.\n"); + IDirect3D9_Release(context->d3d); + DestroyWindow(context->window); + return false; + } + + hr = IDirect3DDevice9_GetRenderTarget(context->device, 0, &context->backbuffer); + ok(hr == S_OK, "Failed to get backbuffer, hr %#lx.\n", hr); + + return true; +} + +#define release_test_context(a) release_test_context_(__LINE__, a) +static void release_test_context_(unsigned int line, struct d3d9_test_context *context) +{ + ULONG refcount; + + IDirect3DSurface9_Release(context->backbuffer); + refcount = IDirect3DDevice9_Release(context->device); + ok(!refcount, "Device has %lu references left.\n", refcount); + refcount = IDirect3D9_Release(context->d3d); + ok(!refcount, "D3D object has %lu references left.\n", refcount); + DestroyWindow(context->window); +} + +static void draw_textured_quad(struct d3d9_test_context *context, IDirect3DTexture9 *texture) +{ + IDirect3DDevice9 *device = context->device; + HRESULT hr; + + static const struct + { + struct vec3 position; + struct vec2 texcoord; + } + quad[] = + { + {{-1.0f, -1.0f, 0.0f}, {0.0f, 0.0f}}, + {{-1.0f, 1.0f, 0.0f}, {0.0f, 1.0f}}, + {{ 1.0f, -1.0f, 0.0f}, {1.0f, 0.0f}}, + {{ 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f}}, + }; + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, &quad, sizeof(*quad)); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); +} + +static HRESULT reset_device(struct d3d9_test_context *context) +{ + D3DPRESENT_PARAMETERS present_parameters = {0}; + HRESULT hr; + + IDirect3DSurface9_Release(context->backbuffer); + + present_parameters.BackBufferWidth = 640; + present_parameters.BackBufferHeight = 480; + present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8; + present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; + present_parameters.hDeviceWindow = context->window; + present_parameters.Windowed = TRUE; + present_parameters.EnableAutoDepthStencil = TRUE; + present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8; + hr = IDirect3DDevice9_Reset(context->device, &present_parameters); + + if (SUCCEEDED(hr)) + IDirect3DDevice9_GetRenderTarget(context->device, 0, &context->backbuffer); + + return hr; +} + static void test_sanity(void) { IDirect3DDevice9 *device; @@ -3901,6 +4007,15 @@ static void fill_surface(IDirect3DSurface9 *surface, DWORD color, DWORD flags) ok(hr == S_OK, "Got hr %#lx.\n", hr); }
+static void fill_texture(IDirect3DTexture9 *texture, DWORD color, DWORD flags) +{ + IDirect3DSurface9 *surface; + + IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface); + fill_surface(surface, color, flags); + IDirect3DSurface9_Release(surface); +} + static void stretchrect_test(void) { enum surface_type @@ -27723,6 +27838,37 @@ static void test_filling_convention(void) DestroyWindow(window); }
+static void test_managed_reset(void) +{ + struct d3d9_test_context context; + IDirect3DTexture9 *texture; + IDirect3DDevice9 *device; + HRESULT hr; + + if (!init_test_context(&context)) + return; + device = context.device; + + hr = IDirect3DDevice9_CreateTexture(device, 256, 256, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + fill_texture(texture, 0x0000ff00, 0); + + draw_textured_quad(&context, texture); + check_rt_color(context.backbuffer, 0x0000ff00); + + hr = reset_device(&context); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + draw_textured_quad(&context, texture); + check_rt_color_todo(context.backbuffer, 0x0000ff00); + + IDirect3DTexture9_Release(texture); + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER9 identifier; @@ -27874,4 +28020,5 @@ START_TEST(visual) test_sample_mask(); test_dynamic_map_synchronization(); test_filling_convention(); + test_managed_reset(); }
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/device.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index c314292031d..6cf7d8a35a3 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5509,6 +5509,21 @@ BOOL CDECL wined3d_device_show_cursor(struct wined3d_device *device, BOOL show) return oldVisible; }
+static void mark_managed_resource_dirty(struct wined3d_resource *resource) +{ + if (resource->type != WINED3D_RTYPE_BUFFER) + { + struct wined3d_texture *texture = texture_from_resource(resource); + unsigned int i; + + if (texture->dirty_regions) + { + for (i = 0; i < texture->layer_count; ++i) + wined3d_texture_add_dirty_region(texture, i, NULL); + } + } +} + void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device) { struct wined3d_resource *resource, *cursor; @@ -5527,17 +5542,7 @@ void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device) wined3d_cs_emit_unload_resource(device->cs, resource); }
- if (resource->type != WINED3D_RTYPE_BUFFER) - { - struct wined3d_texture *texture = texture_from_resource(resource); - unsigned int i; - - if (texture->dirty_regions) - { - for (i = 0; i < texture->layer_count; ++i) - wined3d_texture_add_dirty_region(texture, i, NULL); - } - } + mark_managed_resource_dirty(resource); } } }
From: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53798 --- dlls/d3d8/tests/visual.c | 2 +- dlls/d3d9/tests/visual.c | 2 +- dlls/wined3d/device.c | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index 05a1fc38844..434474b292d 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -12119,7 +12119,7 @@ static void test_managed_reset(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
draw_textured_quad(&context, texture); - check_rt_color_todo(context.backbuffer, 0x0000ff00); + check_rt_color(context.backbuffer, 0x0000ff00);
IDirect3DTexture8_Release(texture); release_test_context(&context); diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index fc30090562f..f8375d238e4 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -27863,7 +27863,7 @@ static void test_managed_reset(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
draw_textured_quad(&context, texture); - check_rt_color_todo(context.backbuffer, 0x0000ff00); + check_rt_color(context.backbuffer, 0x0000ff00);
IDirect3DTexture9_Release(texture); release_test_context(&context); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 6cf7d8a35a3..913376ee3ee 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5829,6 +5829,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, { TRACE("Unloading resource %p.\n", resource); wined3d_cs_emit_unload_resource(device->cs, resource); + + if (resource->usage & WINED3DUSAGE_MANAGED) + mark_managed_resource_dirty(resource); }
device->adapter->adapter_ops->adapter_uninit_3d(device);
From: Zebediah Figura zfigura@codeweavers.com
Regardless of whether WINED3D_MAP_NO_DIRTY_UPDATE is specified. Dirty rects are independent of resource location management. --- dlls/wined3d/texture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index f385394497b..c9d5193e291 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -3748,8 +3748,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour && !(flags & WINED3D_MAP_NO_DIRTY_UPDATE) && !texture_level) wined3d_texture_dirty_region_add(texture, sub_resource_idx / texture->level_count, box);
- if (flags & WINED3D_MAP_WRITE - && (!(flags & WINED3D_MAP_NO_DIRTY_UPDATE) || (resource->usage & WINED3DUSAGE_DYNAMIC))) + if (flags & WINED3D_MAP_WRITE) wined3d_texture_invalidate_location(texture, sub_resource_idx, ~resource->map_binding);
wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, resource->map_binding);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125222
Your paranoid android.
=== debian11 (32 bit report) ===
d3d9: device.c:5893: Test failed: Failed to create a D3D object.
=== debian11 (build log) ===
Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24816. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24816. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24816.
This merge request was approved by Jan Sikorski.