Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/texture.c | 66 ++++++++++++++++------------------------------------- 1 file changed, 20 insertions(+), 46 deletions(-)
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index d3662f8498b..ec00776e8d3 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -78,6 +78,23 @@ static struct wined3d_shader_resource_view *d3d9_texture_acquire_shader_resource return texture->wined3d_srv; }
+static void d3d9_texture_cleanup(struct d3d9_texture *texture) +{ + IDirect3DDevice9Ex *parent_device = texture->parent_device; + struct d3d9_surface *surface; + + wined3d_mutex_lock(); + if (texture->wined3d_srv) + wined3d_shader_resource_view_decref(texture->wined3d_srv); + LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface, rtv_entry) + wined3d_rendertarget_view_decref(surface->wined3d_rtv); + wined3d_texture_decref(texture->wined3d_texture); + wined3d_mutex_unlock(); + + /* Release the device last, as it may cause the device to be destroyed. */ + IDirect3DDevice9Ex_Release(parent_device); +} + /* wined3d critical section must be taken by the caller. */ void d3d9_texture_gen_auto_mipmap(struct d3d9_texture *texture) { @@ -146,23 +163,7 @@ static ULONG WINAPI d3d9_texture_2d_Release(IDirect3DTexture9 *iface) TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (!ref) - { - IDirect3DDevice9Ex *parent_device = texture->parent_device; - struct d3d9_surface *surface; - - wined3d_mutex_lock(); - if (texture->wined3d_srv) - wined3d_shader_resource_view_decref(texture->wined3d_srv); - LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface, rtv_entry) - { - wined3d_rendertarget_view_decref(surface->wined3d_rtv); - } - wined3d_texture_decref(texture->wined3d_texture); - wined3d_mutex_unlock(); - - /* Release the device last, as it may cause the device to be destroyed. */ - IDirect3DDevice9Ex_Release(parent_device); - } + d3d9_texture_cleanup(texture); return ref; }
@@ -560,25 +561,7 @@ static ULONG WINAPI d3d9_texture_cube_Release(IDirect3DCubeTexture9 *iface) TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (!ref) - { - IDirect3DDevice9Ex *parent_device = texture->parent_device; - struct d3d9_surface *surface; - - TRACE("Releasing child %p.\n", texture->wined3d_texture); - - wined3d_mutex_lock(); - if (texture->wined3d_srv) - wined3d_shader_resource_view_decref(texture->wined3d_srv); - LIST_FOR_EACH_ENTRY(surface, &texture->rtv_list, struct d3d9_surface, rtv_entry) - { - wined3d_rendertarget_view_decref(surface->wined3d_rtv); - } - wined3d_texture_decref(texture->wined3d_texture); - wined3d_mutex_unlock(); - - /* Release the device last, as it may cause the device to be destroyed. */ - IDirect3DDevice9Ex_Release(parent_device); - } + d3d9_texture_cleanup(texture); return ref; }
@@ -996,16 +979,7 @@ static ULONG WINAPI d3d9_texture_3d_Release(IDirect3DVolumeTexture9 *iface) TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (!ref) - { - IDirect3DDevice9Ex *parent_device = texture->parent_device; - - wined3d_mutex_lock(); - wined3d_texture_decref(texture->wined3d_texture); - wined3d_mutex_unlock(); - - /* Release the device last, as it may cause the device to be destroyed. */ - IDirect3DDevice9Ex_Release(parent_device); - } + d3d9_texture_cleanup(texture); return ref; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Also rename it as test_mipmap_autogen().
dlls/d3d9/tests/visual.c | 168 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 160 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 4a257c3e034..c745c1b9240 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -5864,16 +5864,17 @@ done: DestroyWindow(window); }
-static void autogen_mipmap_test(void) +static void test_mipmap_autogen(void) { - IDirect3DTexture9 *texture = NULL; - IDirect3DSurface9 *surface; + IDirect3DSurface9 *surface, *surface2, *surface3, *backbuffer; + IDirect3DTexture9 *texture, *texture2, *texture3; IDirect3DDevice9 *device; unsigned int x, y; D3DLOCKED_RECT lr; IDirect3D9 *d3d; D3DCOLOR color; ULONG refcount; + D3DCAPS9 caps; HWND window; HRESULT hr;
@@ -5899,18 +5900,20 @@ static void autogen_mipmap_test(void) }
if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, - D3DFMT_X8R8G8B8, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8) != D3D_OK) + D3DFMT_X8R8G8B8, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8) != D3D_OK) { skip("No autogenmipmap support.\n"); IDirect3DDevice9_Release(device); goto done; }
+ hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer); + ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr); + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0); ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
- /* Make the mipmap big, so that a smaller mipmap is used - */ + /* Make the texture big enough that a mipmap level > 0 is used. */ hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture, 0); ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned %08x\n", hr); @@ -5976,10 +5979,159 @@ static void autogen_mipmap_test(void) color = getPixelColor(device, 360, 270); ok(color == 0x0000ff00, "pixel 360/270 has color %08x, expected 0x0000ff00\n", color); color = getPixelColor(device, 440, 270); - ok(color == 0x00ffffff, "pixel 440/200 has color %08x, expected 0x00ffffff\n", color); + ok(color == 0x00ffffff, "pixel 440/270 has color %08x, expected 0x00ffffff\n", color); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr);
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); + ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr); + if (!(caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES)) + { + skip("Blitting from textures is not supported.\n"); + IDirect3DSurface9_Release(backbuffer); + IDirect3DDevice9_Release(device); + goto done; + } + hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 1, 0, + D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, 0); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_AUTOGENMIPMAP, + D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture2, 0); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_RENDERTARGET, + D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture3, 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); + memset(&lr, 0, sizeof(lr)); + 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); + POINT pt; + + pt.x = x; + pt.y = y; + if (PtInRect(&r1, pt)) + *dst = 0xffff0000; + else if (PtInRect(&r2, pt)) + *dst = 0xff00ff00; + else if (PtInRect(&r3, pt)) + *dst = 0xff0000ff; + else if (PtInRect(&r4, pt)) + *dst = 0xff000000; + else + *dst = 0xffffffff; + } + } + hr = IDirect3DSurface9_UnlockRect(surface); + ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#x.\n", hr); + IDirect3DSurface9_Release(surface); + + hr = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture, + (IDirect3DBaseTexture9 *)texture2); + ok(SUCCEEDED(hr), "Failed to update texture, hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture2); + ok(SUCCEEDED(hr), "Failed to set texture, hr %x.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(SUCCEEDED(hr), "Failed to begin scene, 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); + + color = getPixelColor(device, 200, 200); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 280, 200); + ok(color == 0x000000ff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 360, 200); + ok(color == 0x00000000, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 440, 200); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 200, 270); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 280, 270); + ok(color == 0x00ff0000, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 360, 270); + ok(color == 0x0000ff00, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 440, 270); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + + hr = IDirect3DTexture9_GetSurfaceLevel(texture2, 0, &surface2); + ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr); + hr = IDirect3DTexture9_GetSurfaceLevel(texture3, 0, &surface3); + ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr); + hr = IDirect3DDevice9_StretchRect(device, surface2, NULL, surface3, NULL, D3DTEXF_POINT); + ok(SUCCEEDED(hr), "Failed to blit texture, hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture3); + ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(SUCCEEDED(hr), "Failed to begin scene, 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); + + color = getPixelColor(device, 200, 200); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 280, 200); + ok(color == 0x000000ff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 360, 200); + ok(color == 0x00000000, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 440, 200); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 200, 270); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 280, 270); + ok(color == 0x00ff0000, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 360, 270); + ok(color == 0x0000ff00, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 440, 270); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + + hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface3); + ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ffff, 1.0f, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetRenderTarget(device, 0, backbuffer); + ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(SUCCEEDED(hr), "Failed to begin scene, 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); + + color = getPixelColor(device, 200, 200); + ok(color == 0x0000ffff, "Unexpected color 0x%08x.\n", color); + + IDirect3DSurface9_Release(surface3); + IDirect3DSurface9_Release(surface2); + IDirect3DTexture9_Release(texture3); + IDirect3DTexture9_Release(texture2); + IDirect3DTexture9_Release(texture); + IDirect3DSurface9_Release(backbuffer); + refcount = IDirect3DDevice9_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); done: @@ -23309,7 +23461,7 @@ START_TEST(visual) g16r16_texture_test(); pixelshader_blending_test(); texture_transform_flags_test(); - autogen_mipmap_test(); + test_mipmap_autogen(); fixed_function_decl_test(); conditional_np2_repeat_test(); fixed_function_bumpmap_test();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/tests/visual.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index c745c1b9240..0439ebd52ee 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -5868,8 +5868,9 @@ static void test_mipmap_autogen(void) { IDirect3DSurface9 *surface, *surface2, *surface3, *backbuffer; IDirect3DTexture9 *texture, *texture2, *texture3; + IDirect3DCubeTexture9 *cube_texture; IDirect3DDevice9 *device; - unsigned int x, y; + unsigned int i, x, y; D3DLOCKED_RECT lr; IDirect3D9 *d3d; D3DCOLOR color; @@ -6130,6 +6131,77 @@ static void test_mipmap_autogen(void) IDirect3DTexture9_Release(texture3); IDirect3DTexture9_Release(texture2); IDirect3DTexture9_Release(texture); + + if (!(caps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP)) + { + skip("No cube textures support.\n"); + IDirect3DSurface9_Release(backbuffer); + IDirect3DDevice9_Release(device); + goto done; + } + hr = IDirect3DDevice9_CreateCubeTexture(device, 1024, 0, D3DUSAGE_AUTOGENMIPMAP, + D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &cube_texture, 0); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + for (i = 0; i < 6; ++i) + { + hr = IDirect3DCubeTexture9_LockRect(cube_texture, i, 0, &lr, NULL, 0); + ok(SUCCEEDED(hr), "Failed to map texture, 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); + POINT pt; + + pt.x = x; + pt.y = y; + if (PtInRect(&r1, pt)) + *dst = 0xffff0000; + else if (PtInRect(&r2, pt)) + *dst = 0xff00ff00; + else if (PtInRect(&r3, pt)) + *dst = 0xff0000ff; + else if (PtInRect(&r4, pt)) + *dst = 0xff000000; + else + *dst = 0xffffffff; + } + } + hr = IDirect3DCubeTexture9_UnlockRect(cube_texture, i, 0); + ok(SUCCEEDED(hr), "Failed to unmap texture, hr %#x.\n", hr); + } + + hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)cube_texture); + ok(SUCCEEDED(hr), "Failed to set texture, 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); + IDirect3DCubeTexture9_Release(cube_texture); + + color = getPixelColor(device, 200, 200); + ok(color == 0x00000000, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 280, 200); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 360, 200); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 440, 200); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 200, 270); + ok(color == 0x00000000, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 280, 270); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 360, 270); + ok(color == 0x00ffffff, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 440, 270); + ok(color == 0x0000ff00, "Unexpected color 0x%08x.\n", color); + IDirect3DSurface9_Release(backbuffer);
refcount = IDirect3DDevice9_Release(device);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@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);
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=35970
Your paranoid android.
=== w1064 (64 bit visual) === visual.c:8255: Test failed: Input test: Quad 3(2crd-wrongidx) returned color 0x00ff00ff, expected 0x00ff0080 visual.c:8303: Test failed: Got unexpected color 0x00007580 for quad 2 (different colors).
On 16 February 2018 at 03:17, Matteo Bruni mbruni@codeweavers.com wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
dlls/d3d9/tests/visual.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)
This fails here on Intel SKL:
visual.c:6509: Test failed: Unexpected color 0x007f7f7f. visual.c:6511: Test failed: Unexpected color 0x007f7f7f. visual.c:6513: Test failed: Unexpected color 0x007f7f7f. visual.c:6515: Test failed: Unexpected color 0x007f7f7f. visual.c:6517: Test failed: Unexpected color 0x007f7f7f. visual.c:6519: Test failed: Unexpected color 0x007f7f7f. visual.c:6521: Test failed: Unexpected color 0x007f7f7f. visual.c:6523: Test failed: Unexpected color 0x007f7f7f.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- It turns out it does nothing on non-D3DUSAGE_AUTOGENMIPMAP textures.
dlls/d3d9/tests/visual.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 47961af7889..8ff5c058faa 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -5864,6 +5864,136 @@ done: DestroyWindow(window); }
+static void test_generate_mipmap(void) +{ + static const RECT r1 = {256, 256, 512, 512}; + static const RECT r2 = {512, 256, 768, 512}; + static const RECT r3 = {256, 512, 512, 768}; + static const RECT r4 = {512, 512, 768, 768}; + static const float quad[] = + { + -0.5f, -0.5f, 0.1f, 0.0f, 0.0f, + -0.5f, 0.5f, 0.1f, 0.0f, 1.0f, + 0.5f, -0.5f, 0.1f, 1.0f, 0.0f, + 0.5f, 0.5f, 0.1f, 1.0f, 1.0f, + }; + IDirect3DTexture9 *texture, *texture2; + IDirect3DSurface9 *surface, *surface2; + IDirect3DDevice9 *device; + unsigned int x, y; + D3DLOCKED_RECT lr; + IDirect3D9 *d3d; + D3DCOLOR color; + ULONG refcount; + HWND window; + HRESULT hr; + + window = create_window(); + d3d = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d, window, window, TRUE))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + goto done; + } + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffff00, 1.0f, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* Make the texture big enough that a mipmap level > 0 is used. */ + hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, D3DUSAGE_RENDERTARGET, + D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, 0); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + + hr = IDirect3DDevice9_CreateTexture(device, 1024, 1024, 0, 0, + D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &texture2, 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 = IDirect3DTexture9_GetSurfaceLevel(texture2, 0, &surface2); + ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr); + hr = IDirect3DSurface9_LockRect(surface2, &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); + POINT pt; + + pt.x = x; + pt.y = y; + if (PtInRect(&r1, pt)) + *dst = 0xffff0000; + else if (PtInRect(&r2, pt)) + *dst = 0xff00ff00; + else if (PtInRect(&r3, pt)) + *dst = 0xff0000ff; + else if (PtInRect(&r4, pt)) + *dst = 0xff000000; + else + *dst = 0xffffffff; + } + } + hr = IDirect3DSurface9_UnlockRect(surface2); + ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#x.\n", hr); + + hr = IDirect3DDevice9_UpdateSurface(device, surface2, NULL, surface, NULL); + ok(SUCCEEDED(hr), "Failed to update surface, hr %#x.\n", hr); + + IDirect3DSurface9_Release(surface2); + IDirect3DSurface9_Release(surface); + IDirect3DTexture9_Release(texture2); + + hr = IDirect3DTexture9_SetAutoGenFilterType(texture, D3DTEXF_LINEAR); + ok(SUCCEEDED(hr), "Failed to set mipmap autogen filter type, hr %#x.\n", hr); + + IDirect3DTexture9_GenerateMipSubLevels(texture); + + hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture); + ok(SUCCEEDED(hr), "Failed to set texture, hr %x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT); + ok(SUCCEEDED(hr), "Failed to set mipmap filtering, hr %#x.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(SUCCEEDED(hr), "Failed to disable lighting, 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, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 280, 200); + ok(!color, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 360, 200); + ok(!color, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 440, 200); + ok(!color, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 200, 270); + ok(!color, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 280, 270); + ok(!color, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 360, 270); + ok(!color, "Unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 440, 270); + ok(!color, "Unexpected color 0x%08x.\n", color); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr); + + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +done: + IDirect3D9_Release(d3d); + DestroyWindow(window); +} + static void test_mipmap_autogen(void) { IDirect3DSurface9 *surface, *surface2, *surface3, *backbuffer; @@ -23596,6 +23726,7 @@ START_TEST(visual) g16r16_texture_test(); pixelshader_blending_test(); texture_transform_flags_test(); + test_generate_mipmap(); test_mipmap_autogen(); fixed_function_decl_test(); conditional_np2_repeat_test();
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=35971
Your paranoid android.
=== w864 (64 bit visual) === visual.c:8433: Test failed: Got unexpected color 0x0000ff00 for quad 2 (different colors).
=== w1064 (64 bit visual) === visual.c:8433: Test failed: Got unexpected color 0x00008080 for quad 2 (different colors).
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Fixes c6dfce272309c1ad869886a0fce186c795f3e5b7.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Over the last few days I had two wineserver crashes while updating prefixes (which I've been doing a lot so not that common - maybe 1 in 5 or so?). I think this fixes the root cause, although I can't really doublecheck... AFAIU the issue is old, c6dfce272309c1ad869886a0fce186c795f3e5b7 only made it a bit worse.
server/ptrace.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/server/ptrace.c b/server/ptrace.c index 704b17d5f29..4eda8ebec35 100644 --- a/server/ptrace.c +++ b/server/ptrace.c @@ -289,7 +289,7 @@ static int suspend_for_ptrace( struct thread *thread ) }
/* read a long from a thread address space */ -static long read_thread_long( struct thread *thread, long *addr, long *data ) +static int read_thread_long( struct thread *thread, void *addr, unsigned long *data ) { errno = 0; *data = ptrace( PTRACE_PEEKDATA, get_ptrace_pid(thread), (caddr_t)addr, 0 ); @@ -301,14 +301,26 @@ static long read_thread_long( struct thread *thread, long *addr, long *data ) return 0; }
+static int read_thread_int( struct thread *thread, void *addr, unsigned int *data ) +{ + unsigned long long_data; + int ret; + + ret = read_thread_long( thread, addr, &long_data ); + *data = long_data; + return ret; +} + /* write a long to a thread address space */ -static long write_thread_long( struct thread *thread, long *addr, long data, unsigned long mask ) +static long write_thread_long( struct thread *thread, void *addr, unsigned long data, unsigned long mask ) { - long res; + unsigned long old_data; + int res; + if (mask != ~0ul) { - if (read_thread_long( thread, addr, &res ) == -1) return -1; - data = (data & mask) | (res & ~mask); + if (read_thread_long( thread, addr, &old_data ) == -1) return -1; + data = (data & mask) | (old_data & ~mask); } if ((res = ptrace( PTRACE_POKEDATA, get_ptrace_pid(thread), (caddr_t)addr, data )) == -1) file_set_error(); @@ -333,7 +345,7 @@ int read_process_memory( struct process *process, client_ptr_t ptr, data_size_t { struct thread *thread = get_ptrace_thread( process ); unsigned int first_offset, last_offset, len; - long data, *addr; + unsigned long data, *addr;
if (!thread) return 0;
@@ -347,7 +359,7 @@ int read_process_memory( struct process *process, client_ptr_t ptr, data_size_t last_offset = (size + first_offset) % sizeof(long); if (!last_offset) last_offset = sizeof(long);
- addr = (long *)(unsigned long)(ptr - first_offset); + addr = (unsigned long *)(unsigned long)(ptr - first_offset); len = (size + first_offset + sizeof(long) - 1) / sizeof(long);
if (suspend_for_ptrace( thread )) @@ -517,13 +529,14 @@ void get_selector_entry( struct thread *thread, int entry, unsigned int *base, } if (suspend_for_ptrace( thread )) { - unsigned char flags_buf[4]; + unsigned int flags_buf; unsigned long addr = (unsigned long)thread->process->ldt_copy + (entry * 4); - if (read_thread_long( thread, (long *)addr, (long *)base ) == -1) goto done; - if (read_thread_long( thread, (long *)(addr + (8192 * 4)), (long *)limit ) == -1) goto done; + + if (read_thread_int( thread, (void *)addr, base ) == -1) goto done; + if (read_thread_int( thread, (void *)(addr + (8192 * 4)), limit ) == -1) goto done; addr = (unsigned long)thread->process->ldt_copy + (2 * 8192 * 4) + (entry & ~3); - if (read_thread_long( thread, (long *)addr, (long *)flags_buf ) == -1) goto done; - *flags = flags_buf[entry % 4]; + if (read_thread_int( thread, (void *)addr, &flags_buf ) == -1) goto done; + *flags = flags_buf >> (entry & 3) * 8; done: resume_after_ptrace( thread ); }