Commit 10e7f7ca authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d9/tests: Add basic test for StretchRect() with multisample resources.

parent 0c165890
......@@ -4072,6 +4072,135 @@ done:
DestroyWindow(window);
}
static void test_multisample_stretch_rect(void)
{
static const D3DTEXTUREFILTERTYPE filters[] =
{
D3DTEXF_NONE,
D3DTEXF_POINT,
D3DTEXF_LINEAR,
};
IDirect3DSurface9 *rt, *ms_rt, *rt_r5g6b5;
struct surface_readback rb;
IDirect3DDevice9 *device;
DWORD quality_levels;
IDirect3D9 *d3d;
unsigned int i;
ULONG refcount;
HWND window;
DWORD color;
HRESULT hr;
RECT rect;
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES, &quality_levels) == D3DERR_NOTAVAILABLE)
{
skip("Multisampling not supported for D3DFMT_A8R8G8B8.\n");
IDirect3D9_Release(d3d);
DestroyWindow(window);
return;
}
if (!(device = create_device(d3d, window, window, TRUE)))
{
skip("Failed to create a 3D device.\n");
IDirect3D9_Release(d3d);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
ok(hr == S_OK, "Failed to create render target, hr %#x.\n", hr);
hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, quality_levels - 1, FALSE, &ms_rt, NULL);
ok(hr == S_OK, "Failed to create render target, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, ms_rt);
ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff00ff, 0.0f, 0);
ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr);
for (i = 0; i < sizeof(filters) / sizeof(*filters); ++i)
{
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr);
hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, filters[i]);
ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr);
color = getPixelColor(device, 64, 64);
ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color);
}
/* Scaling */
SetRect(&rect, 0, 0, 64, 64);
for (i = 0; i < sizeof(filters) / sizeof(*filters); ++i)
{
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr);
hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, &rect, filters[i]);
ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr);
get_rt_readback(rt, &rb);
color = get_readback_color(&rb, 32, 32);
ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color);
color = get_readback_color(&rb, 64, 64);
ok(color == 0xffffffff, "Test %u: Got color 0x%08x.\n", i, color);
color = get_readback_color(&rb, 96, 96);
ok(color == 0xffffffff, "Test %u: Got color 0x%08x.\n", i, color);
release_surface_readback(&rb);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr);
hr = IDirect3DDevice9_StretchRect(device, ms_rt, &rect, rt, NULL, filters[i]);
ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr);
get_rt_readback(rt, &rb);
color = get_readback_color(&rb, 32, 32);
ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color);
color = get_readback_color(&rb, 64, 64);
ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color);
color = get_readback_color(&rb, 96, 96);
ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color);
release_surface_readback(&rb);
}
/* Format conversion */
hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
D3DFMT_R5G6B5, D3DMULTISAMPLE_NONE, 0, FALSE, &rt_r5g6b5, NULL);
if (FAILED(hr))
{
skip("Failed to create D3DFMT_R5G6B5 render target.\n");
goto done;
}
for (i = 0; i < sizeof(filters) / sizeof(*filters); ++i)
{
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr);
hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt_r5g6b5, NULL, filters[i]);
ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr);
hr = IDirect3DDevice9_StretchRect(device, rt_r5g6b5, NULL, rt, NULL, filters[i]);
ok(hr == S_OK, "Test %u: Failed to stretch rect, hr %#x.\n", i, hr);
color = getPixelColor(device, 64, 64);
ok(color == 0x00ff00ff, "Test %u: Got color 0x%08x.\n", i, color);
}
IDirect3DSurface9_Release(rt_r5g6b5);
done:
IDirect3DSurface9_Release(ms_rt);
IDirect3DSurface9_Release(rt);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
static void maxmip_test(void)
{
IDirect3DTexture9 *texture;
......@@ -23645,6 +23774,7 @@ START_TEST(visual)
test_sanity();
depth_clamp_test();
stretchrect_test();
test_multisample_stretch_rect();
lighting_test();
test_specular_lighting();
clear_test();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment