Commit 0b630e14 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9/tests: Add a test for clearing render targets in an MRT.

parent d374d850
...@@ -9043,7 +9043,7 @@ static void multiple_rendertargets_test(IDirect3DDevice9 *device) ...@@ -9043,7 +9043,7 @@ static void multiple_rendertargets_test(IDirect3DDevice9 *device)
IDirect3DVertexShader9 *vs; IDirect3DVertexShader9 *vs;
IDirect3DPixelShader9 *ps; IDirect3DPixelShader9 *ps;
IDirect3DTexture9 *tex1, *tex2; IDirect3DTexture9 *tex1, *tex2;
IDirect3DSurface9 *surf1, *surf2, *backbuf; IDirect3DSurface9 *surf1, *surf2, *backbuf, *readback;
D3DCAPS9 caps; D3DCAPS9 caps;
DWORD color; DWORD color;
float quad[] = { float quad[] = {
...@@ -9075,9 +9075,15 @@ static void multiple_rendertargets_test(IDirect3DDevice9 *device) ...@@ -9075,9 +9075,15 @@ static void multiple_rendertargets_test(IDirect3DDevice9 *device)
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.0, 0); hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.0, 0);
ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr=%08x\n", hr);
hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &tex1, NULL); hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 16, 16,
D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &readback, NULL);
ok(SUCCEEDED(hr), "CreateOffscreenPlainSurface failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex1, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr=%08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr=%08x\n", hr);
hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &tex2, NULL); hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tex2, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr=%08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed, hr=%08x\n", hr);
hr = IDirect3DDevice9_CreateVertexShader(device, vshader_code, &vs); hr = IDirect3DDevice9_CreateVertexShader(device, vshader_code, &vs);
ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "CreateVertexShader failed, hr %#x.\n", hr);
...@@ -9102,6 +9108,32 @@ static void multiple_rendertargets_test(IDirect3DDevice9 *device) ...@@ -9102,6 +9108,32 @@ static void multiple_rendertargets_test(IDirect3DDevice9 *device)
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed, hr=%08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed, hr=%08x\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
ok(SUCCEEDED(hr), "Clear failed, hr %#x,\n", hr);
hr = IDirect3DDevice9_GetRenderTargetData(device, surf1, readback);
ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
color = getPixelColorFromSurface(readback, 8, 8);
ok(color_match(color, D3DCOLOR_ARGB(0xff, 0x00, 0x00, 0xff), 0),
"Expected color 0x000000ff, got 0x%08x.\n", color);
hr = IDirect3DDevice9_GetRenderTargetData(device, surf2, readback);
ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
color = getPixelColorFromSurface(readback, 8, 8);
ok(color_match(color, D3DCOLOR_ARGB(0xff, 0x00, 0x00, 0xff), 0),
"Expected color 0x000000ff, got 0x%08x.\n", color);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
ok(SUCCEEDED(hr), "Clear failed, hr %#x,\n", hr);
hr = IDirect3DDevice9_GetRenderTargetData(device, surf1, readback);
ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
color = getPixelColorFromSurface(readback, 8, 8);
ok(color_match(color, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0x00), 0),
"Expected color 0x0000ff00, got 0x%08x.\n", color);
hr = IDirect3DDevice9_GetRenderTargetData(device, surf2, readback);
ok(SUCCEEDED(hr), "GetRenderTargetData failed, hr %#x.\n", hr);
color = getPixelColorFromSurface(readback, 8, 8);
ok(color_match(color, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0x00), 0),
"Expected color 0x0000ff00, got 0x%08x.\n", color);
hr = IDirect3DDevice9_BeginScene(device); hr = IDirect3DDevice9_BeginScene(device);
ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed, hr=%08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed, hr=%08x\n", hr);
if(SUCCEEDED(hr)) { if(SUCCEEDED(hr)) {
...@@ -9149,6 +9181,7 @@ static void multiple_rendertargets_test(IDirect3DDevice9 *device) ...@@ -9149,6 +9181,7 @@ static void multiple_rendertargets_test(IDirect3DDevice9 *device)
IDirect3DSurface9_Release(surf1); IDirect3DSurface9_Release(surf1);
IDirect3DSurface9_Release(surf2); IDirect3DSurface9_Release(surf2);
IDirect3DSurface9_Release(backbuf); IDirect3DSurface9_Release(backbuf);
IDirect3DSurface9_Release(readback);
} }
struct formats { struct formats {
......
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