d3d9/tests: Test multisample mismatch.
This commit is contained in:
parent
4e53faf77b
commit
4d8bfe190c
|
@ -18555,6 +18555,223 @@ done:
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_multisample_mismatch(void)
|
||||
{
|
||||
IDirect3DDevice9 *device;
|
||||
IDirect3D9 *d3d;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
D3DCOLOR color;
|
||||
ULONG refcount;
|
||||
IDirect3DSurface9 *rt, *rt_multi, *ds;
|
||||
static const struct
|
||||
{
|
||||
struct vec3 position;
|
||||
DWORD color;
|
||||
}
|
||||
quad[] =
|
||||
{
|
||||
{{ -1.0f, -1.0f, 0.0f}, 0x000000ff},
|
||||
{{ -1.0f, 1.0f, 0.0f}, 0x000000ff},
|
||||
{{ 1.0f, -1.0f, 1.0f}, 0x000000ff},
|
||||
{{ 1.0f, 1.0f, 1.0f}, 0x000000ff},
|
||||
};
|
||||
|
||||
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
0, 0, 640, 480, NULL, NULL, NULL, NULL);
|
||||
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
ok(!!d3d, "Failed to create a D3D object.\n");
|
||||
if (FAILED(IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
|
||||
D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES, NULL)))
|
||||
{
|
||||
skip("Multisampling not supported for D3DFMT_A8R8G8B8, skipping multisample mismatch test.\n");
|
||||
IDirect3D9_Release(d3d);
|
||||
return;
|
||||
}
|
||||
if (FAILED(IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
|
||||
D3DFMT_D24X8, TRUE, D3DMULTISAMPLE_2_SAMPLES, NULL)))
|
||||
{
|
||||
skip("Multisampling not supported for D3DFMT_D24X8, skipping multisample mismatch test.\n");
|
||||
IDirect3D9_Release(d3d);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(device = create_device(d3d, window, window, TRUE)))
|
||||
{
|
||||
skip("Failed to create a D3D device, skipping tests.\n");
|
||||
IDirect3D9_Release(d3d);
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
|
||||
hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8,
|
||||
D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &rt_multi, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 0.1f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds);
|
||||
ok(SUCCEEDED(hr), "Failed to set depth stencil, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
|
||||
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt_multi);
|
||||
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||
ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZWRITEENABLE, FALSE);
|
||||
ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
|
||||
|
||||
/* Clear with incompatible buffers. Partial and combined clears. */
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 0.3f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0000ff00, 0.5f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
|
||||
/* The color buffer is reliably cleared on AMD and Nvidia GPUs. */
|
||||
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
|
||||
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_StretchRect(device, rt_multi, NULL, rt, NULL, D3DTEXF_POINT);
|
||||
ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
|
||||
color = getPixelColor(device, 320, 240);
|
||||
ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
|
||||
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
|
||||
|
||||
/* Check depth buffer values. AMD GPUs (r500 and evergreen tested) clear the depth buffer
|
||||
* like you'd expect in a correct framebuffer setup. Nvidia doesn't clear it, neither in
|
||||
* the Z only clear case nor in the combined clear case. */
|
||||
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
|
||||
ok(SUCCEEDED(hr), "Failed to set FVF, 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, sizeof(*quad));
|
||||
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, 62, 240);
|
||||
ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
|
||||
color = getPixelColor(device, 64, 240);
|
||||
ok(color_match(color, 0x0000ff00, 1) || broken(color_match(color, 0x000000ff, 1)),
|
||||
"Got unexpected color 0x%08x.\n", color);
|
||||
color = getPixelColor(device, 318, 240);
|
||||
ok(color_match(color, 0x0000ff00, 1) || broken(color_match(color, 0x000000ff, 1)),
|
||||
"Got unexpected color 0x%08x.\n", color);
|
||||
color = getPixelColor(device, 322, 240);
|
||||
ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
|
||||
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
|
||||
|
||||
/* Draw with incompatible buffers. AMD even performs Z testing, and the Z test
|
||||
* results appear to be correct for this simple draw. Nvidia doesn't draw unless
|
||||
* the depth test is disabled. Setting ZFUNC = ALWAYS doesn't make the geometry
|
||||
* show up either. Only test the ZENABLE = FALSE case for now. */
|
||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
|
||||
ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt_multi);
|
||||
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.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, sizeof(*quad));
|
||||
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);
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
|
||||
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_StretchRect(device, rt_multi, NULL, rt, NULL, D3DTEXF_POINT);
|
||||
ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
|
||||
color = getPixelColor(device, 320, 240);
|
||||
ok(color_match(color, 0x000000ff, 1), "Got 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(ds);
|
||||
|
||||
/* Test the reverse situation: Multisampled depth buffer, single sampled color buffer.
|
||||
* Color clears work as expected, AMD also clears the depth buffer, Nvidia does not. */
|
||||
hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24X8,
|
||||
D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &ds, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to create depth/stencil, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
|
||||
ok(SUCCEEDED(hr), "Failed to set depth stencil surface, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt_multi);
|
||||
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00ffff00, 0.1f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
|
||||
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 0.3f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0000ff00, 0.5f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
|
||||
color = getPixelColor(device, 320, 240);
|
||||
ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
|
||||
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt_multi);
|
||||
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
|
||||
ok(SUCCEEDED(hr), "Failed to set render state, 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, sizeof(*quad));
|
||||
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);
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
|
||||
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_StretchRect(device, rt_multi, NULL, rt, NULL, D3DTEXF_POINT);
|
||||
ok(SUCCEEDED(hr), "StretchRect failed, hr %#x.\n", hr);
|
||||
color = getPixelColor(device, 62, 240);
|
||||
ok(color_match(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
|
||||
color = getPixelColor(device, 318, 240);
|
||||
ok(color_match(color, 0x00ffff00, 1) || broken(color_match(color, 0x000000ff, 1)),
|
||||
"Got unexpected color 0x%08x.\n", color);
|
||||
color = getPixelColor(device, 322, 240);
|
||||
ok(color_match(color, 0x00ffff00, 1), "Got unexpected color 0x%08x.\n", color);
|
||||
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
|
||||
|
||||
/* Draw with a single sampled color buffer and a multisampled depth buffer. Again
|
||||
* AMD seems to perform correct Z testing, Nvidia doesn't draw unless the Z test
|
||||
* is disabled. Again only test the ZENABLE = FALSE case. */
|
||||
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
|
||||
ok(SUCCEEDED(hr), "Failed to set render state, 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, sizeof(*quad));
|
||||
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, 320, 240);
|
||||
ok(color_match(color, 0x000000ff, 1), "Got 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(rt);
|
||||
IDirect3DSurface9_Release(ds);
|
||||
IDirect3DSurface9_Release(rt_multi);
|
||||
|
||||
refcount = IDirect3DDevice9_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
IDirect3D9_Release(d3d);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(visual)
|
||||
{
|
||||
D3DADAPTER_IDENTIFIER9 identifier;
|
||||
|
@ -18668,4 +18885,5 @@ START_TEST(visual)
|
|||
test_position_index();
|
||||
test_table_fog_zw();
|
||||
test_signed_formats();
|
||||
test_multisample_mismatch();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue