[PATCH 1/2] d3d8/tests: Make getPixelColor() checks into actual ok() calls.

Zebediah Figura wine at gitlab.winehq.org
Wed Jul 6 22:46:04 CDT 2022


From: Zebediah Figura <zfigura at codeweavers.com>

These should never fail.
---
 dlls/d3d8/tests/visual.c | 48 +++++++---------------------------------
 1 file changed, 8 insertions(+), 40 deletions(-)

diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index fa0030b2187..afcda103844 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -114,56 +114,28 @@ static void get_rt_readback(IDirect3DSurface8 *surface, struct surface_readback
     hr = IDirect3DSurface8_GetDesc(surface, &desc);
     ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
     hr = IDirect3DDevice8_CreateTexture(device, desc.Width, desc.Height, 1, 0, desc.Format, D3DPOOL_SYSTEMMEM, &tex);
-    if (FAILED(hr) || !tex)
-    {
-        trace("Can't create an offscreen plain surface to read the render target data, hr %#x.\n", hr);
-        goto error;
-    }
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
     hr = IDirect3DTexture8_GetSurfaceLevel(tex, 0, &rb->surface);
-    if (FAILED(hr))
-    {
-        trace("Can't get surface from texture, hr %#x.\n", hr);
-        goto error;
-    }
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
     hr = IDirect3DDevice8_CopyRects(device, surface, NULL, 0, rb->surface, NULL);
-    if (FAILED(hr))
-    {
-        trace("Can't read the render target, hr %#x.\n", hr);
-        goto error;
-    }
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
     hr = IDirect3DSurface8_LockRect(rb->surface, &rb->locked_rect, NULL, D3DLOCK_READONLY);
-    if (FAILED(hr))
-    {
-        trace("Can't lock the offscreen surface, hr %#x.\n", hr);
-        goto error;
-    }
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
     IDirect3DTexture8_Release(tex);
     IDirect3DDevice8_Release(device);
-    return;
-
-error:
-    if (rb->surface)
-        IDirect3DSurface8_Release(rb->surface);
-    rb->surface = NULL;
-    if (tex)
-        IDirect3DTexture8_Release(tex);
-    IDirect3DDevice8_Release(device);
 }
 
 static DWORD get_readback_color(struct surface_readback *rb, unsigned int x, unsigned int y)
 {
-    return rb->locked_rect.pBits
-            ? ((DWORD *)rb->locked_rect.pBits)[y * rb->locked_rect.Pitch / sizeof(DWORD) + x] : 0xdeadbeef;
+    return ((DWORD *)rb->locked_rect.pBits)[y * rb->locked_rect.Pitch / sizeof(DWORD) + x];
 }
 
 static void release_surface_readback(struct surface_readback *rb)
 {
     HRESULT hr;
 
-    if (!rb->surface)
-        return;
-    if (rb->locked_rect.pBits && FAILED(hr = IDirect3DSurface8_UnlockRect(rb->surface)))
-        trace("Can't unlock the offscreen surface, hr %#x.\n", hr);
+    hr = IDirect3DSurface8_UnlockRect(rb->surface);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
     IDirect3DSurface8_Release(rb->surface);
 }
 
@@ -175,11 +147,7 @@ static DWORD getPixelColor(IDirect3DDevice8 *device, UINT x, UINT y)
     HRESULT hr;
 
     hr = IDirect3DDevice8_GetRenderTarget(device, &rt);
-    if (FAILED(hr))
-    {
-        trace("Can't get the render target, hr %#x.\n", hr);
-        return 0xdeadbeef;
-    }
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
 
     get_rt_readback(rt, &rb);
     /* Remove the X channel for now. DirectX and OpenGL have different ideas how to treat it apparently, and it isn't
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/394



More information about the wine-devel mailing list