[PATCH 4/6] d3d9/tests: Add a mipmap autogeneration test for sRGB textures.

Matteo Bruni mbruni at codeweavers.com
Thu Feb 15 17:47:53 CST 2018


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
 dlls/d3d9/tests/visual.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 0439ebd52ee..47961af7889 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -6202,6 +6202,69 @@ static void test_mipmap_autogen(void)
     color = getPixelColor(device, 440, 270);
     ok(color == 0x0000ff00, "Unexpected color 0x%08x.\n", color);
 
+    /* Test the effect of the sRGB sample toggle */
+    if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
+            D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_SRGBREAD, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8) != D3D_OK)
+    {
+        skip("sRGB read not supported.\n");
+        IDirect3DSurface9_Release(backbuffer);
+        IDirect3DDevice9_Release(device);
+        goto done;
+    }
+    hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_AUTOGENMIPMAP,
+            D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0);
+    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+    hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+    ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+    hr = IDirect3DSurface9_LockRect(surface, &lr, NULL, 0);
+    ok(SUCCEEDED(hr), "Failed to map surface, hr %#x.\n", hr);
+    for (y = 0; y < 1024; ++y)
+    {
+        for (x = 0; x < 1024; ++x)
+        {
+            DWORD *dst = (DWORD *)((BYTE *)lr.pBits + y * lr.Pitch + x * 4);
+
+            *dst = (x + y) % 2 * 0xffffffff;
+        }
+    }
+    hr = IDirect3DSurface9_UnlockRect(surface);
+    ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#x.\n", hr);
+    IDirect3DSurface9_Release(surface);
+
+    hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, TRUE);
+    ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice9_BeginScene(device);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
+    ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    hr = IDirect3DDevice9_EndScene(device);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    IDirect3DTexture9_Release(texture);
+
+    color = getPixelColor(device, 200, 200);
+    ok(color_match(color, 0x00363636, 1), "Unexpected color 0x%08x.\n", color);
+    color = getPixelColor(device, 280, 200);
+    ok(color_match(color, 0x00363636, 1), "Unexpected color 0x%08x.\n", color);
+    color = getPixelColor(device, 360, 200);
+    ok(color_match(color, 0x00363636, 1), "Unexpected color 0x%08x.\n", color);
+    color = getPixelColor(device, 440, 200);
+    ok(color_match(color, 0x00363636, 1), "Unexpected color 0x%08x.\n", color);
+    color = getPixelColor(device, 200, 270);
+    ok(color_match(color, 0x00363636, 1), "Unexpected color 0x%08x.\n", color);
+    color = getPixelColor(device, 280, 270);
+    ok(color_match(color, 0x00363636, 1), "Unexpected color 0x%08x.\n", color);
+    color = getPixelColor(device, 360, 270);
+    ok(color_match(color, 0x00363636, 1), "Unexpected color 0x%08x.\n", color);
+    color = getPixelColor(device, 440, 270);
+    ok(color_match(color, 0x00363636, 1), "Unexpected color 0x%08x.\n", color);
+    hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+    ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+
     IDirect3DSurface9_Release(backbuffer);
 
     refcount = IDirect3DDevice9_Release(device);
-- 
2.13.6




More information about the wine-devel mailing list