Commit 3d78a77f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9/tests: Use a separate device for fixed_function_bumpmap_test().

parent f3a898a8
...@@ -8929,15 +8929,21 @@ done: ...@@ -8929,15 +8929,21 @@ done:
DestroyWindow(window); DestroyWindow(window);
} }
static void fixed_function_bumpmap_test(IDirect3DDevice9 *device) static void fixed_function_bumpmap_test(void)
{ {
HRESULT hr; IDirect3DVertexDeclaration9 *vertex_declaration;
DWORD color; IDirect3DTexture9 *texture, *tex1, *tex2;
int i;
D3DCAPS9 caps;
BOOL L6V5U5_supported = FALSE;
IDirect3DTexture9 *tex1, *tex2;
D3DLOCKED_RECT locked_rect; D3DLOCKED_RECT locked_rect;
IDirect3DDevice9 *device;
BOOL L6V5U5_supported;
float scale, offset;
IDirect3D9 *d3d;
unsigned int i;
D3DCOLOR color;
ULONG refcount;
D3DCAPS9 caps;
HWND window;
HRESULT hr;
static const float quad[][7] = static const float quad[][7] =
{ {
...@@ -8946,46 +8952,49 @@ static void fixed_function_bumpmap_test(IDirect3DDevice9 *device) ...@@ -8946,46 +8952,49 @@ static void fixed_function_bumpmap_test(IDirect3DDevice9 *device)
{ 1.0f, -1.0f, 0.1f, 1.0f, 0.0f, 1.0f, 0.0f}, { 1.0f, -1.0f, 0.1f, 1.0f, 0.0f, 1.0f, 0.0f},
{ 1.0f, 1.0f, 0.1f, 1.0f, 1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, 0.1f, 1.0f, 1.0f, 1.0f, 1.0f},
}; };
static const D3DVERTEXELEMENT9 decl_elements[] =
static const D3DVERTEXELEMENT9 decl_elements[] = { {
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
{0, 20, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, {0, 20, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1},
D3DDECL_END() D3DDECL_END()
}; };
/* use asymmetric matrix to test loading */ /* use asymmetric matrix to test loading */
float bumpenvmat[4] = {0.0,0.5,-0.5,0.0}; static const float bumpenvmat[4] = {0.0f, 0.5f, -0.5f, 0.0f};
float scale, offset;
IDirect3DVertexDeclaration9 *vertex_declaration = NULL; window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
IDirect3DTexture9 *texture = NULL; 0, 0, 640, 480, NULL, NULL, NULL, NULL);
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;
}
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed hr=%08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps failed hr=%08x\n", hr);
if(!(caps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP)) { if (!(caps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP))
{
skip("D3DTEXOPCAPS_BUMPENVMAP not set, skipping bumpmap tests\n"); skip("D3DTEXOPCAPS_BUMPENVMAP not set, skipping bumpmap tests\n");
return; IDirect3DDevice9_Release(device);
} else { goto done;
/* This check is disabled, some Windows drivers do not handle D3DUSAGE_QUERY_LEGACYBUMPMAP properly. }
* They report that it is not supported, but after that bump mapping works properly. So just test
* if the format is generally supported, and check the BUMPENVMAP flag
*/
IDirect3D9 *d3d9;
IDirect3DDevice9_GetDirect3D(device, &d3d9); /* This check is disabled, some Windows drivers do not handle
hr = IDirect3D9_CheckDeviceFormat(d3d9, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, * D3DUSAGE_QUERY_LEGACYBUMPMAP properly. They report that it is not
D3DRTYPE_TEXTURE, D3DFMT_L6V5U5); * supported, but after that bump mapping works properly. So just test if
L6V5U5_supported = SUCCEEDED(hr); * the format is generally supported, and check the BUMPENVMAP flag. */
hr = IDirect3D9_CheckDeviceFormat(d3d9, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, L6V5U5_supported = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL,
D3DRTYPE_TEXTURE, D3DFMT_V8U8); D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_L6V5U5));
IDirect3D9_Release(d3d9); if (FAILED(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL,
if(FAILED(hr)) { D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_V8U8)))
{
skip("D3DFMT_V8U8 not supported for legacy bump mapping\n"); skip("D3DFMT_V8U8 not supported for legacy bump mapping\n");
IDirect3DDevice9_Release(device);
return; return;
} }
}
/* Generate the textures */ /* Generate the textures */
generate_bumpmap_textures(device); generate_bumpmap_textures(device);
...@@ -9019,10 +9028,9 @@ static void fixed_function_bumpmap_test(IDirect3DDevice9 *device) ...@@ -9019,10 +9028,9 @@ static void fixed_function_bumpmap_test(IDirect3DDevice9 *device)
hr = IDirect3DDevice9_SetVertexShader(device, NULL); hr = IDirect3DDevice9_SetVertexShader(device, NULL);
ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr); ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0); hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff00ff, 1.0f, 0);
ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed (%08x)\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed (%08x)\n", hr);
hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration); hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr); ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr);
hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration); hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
...@@ -9065,16 +9073,15 @@ static void fixed_function_bumpmap_test(IDirect3DDevice9 *device) ...@@ -9065,16 +9073,15 @@ static void fixed_function_bumpmap_test(IDirect3DDevice9 *device)
IDirect3DTexture9_Release(texture); /* To destroy it */ IDirect3DTexture9_Release(texture); /* To destroy it */
} }
if(!(caps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAPLUMINANCE)) { if (!L6V5U5_supported || !(caps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAPLUMINANCE))
skip("D3DTOP_BUMPENVMAPLUMINANCE not supported, skipping\n"); {
goto cleanup; skip("L6V5U5 / D3DTOP_BUMPENVMAPLUMINANCE not supported, skipping tests.\n");
} IDirect3DVertexDeclaration9_Release(vertex_declaration);
if(L6V5U5_supported == FALSE) { IDirect3DDevice9_Release(device);
skip("L6V5U5_supported not supported, skipping D3DTOP_BUMPENVMAPLUMINANCE test\n"); goto done;
goto cleanup;
} }
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00000000, 0.0, 0x8); hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr); ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr);
/* This test only tests the luminance part. The bumpmapping part was already tested above and /* This test only tests the luminance part. The bumpmapping part was already tested above and
* would only make this test more complicated * would only make this test more complicated
...@@ -9172,23 +9179,14 @@ static void fixed_function_bumpmap_test(IDirect3DDevice9 *device) ...@@ -9172,23 +9179,14 @@ static void fixed_function_bumpmap_test(IDirect3DDevice9 *device)
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr); ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (%08x)\n", hr);
hr = IDirect3DDevice9_SetTexture(device, 1, NULL);
ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (%08x)\n", hr);
IDirect3DTexture9_Release(tex1); IDirect3DTexture9_Release(tex1);
IDirect3DTexture9_Release(tex2); IDirect3DTexture9_Release(tex2);
cleanup:
hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);
hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
ok(SUCCEEDED(hr), "SetVertexDeclaration failed (%08x)\n", hr);
IDirect3DVertexDeclaration9_Release(vertex_declaration); IDirect3DVertexDeclaration9_Release(vertex_declaration);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
} }
static void stencil_cull_test(void) static void stencil_cull_test(void)
...@@ -16522,11 +16520,11 @@ START_TEST(visual) ...@@ -16522,11 +16520,11 @@ START_TEST(visual)
autogen_mipmap_test(device_ptr); autogen_mipmap_test(device_ptr);
fixed_function_decl_test(device_ptr); fixed_function_decl_test(device_ptr);
conditional_np2_repeat_test(device_ptr); conditional_np2_repeat_test(device_ptr);
fixed_function_bumpmap_test(device_ptr);
cleanup_device(device_ptr); cleanup_device(device_ptr);
device_ptr = NULL; device_ptr = NULL;
fixed_function_bumpmap_test();
pointsize_test(); pointsize_test();
tssargtemp_test(); tssargtemp_test();
np2_stretch_rect_test(); np2_stretch_rect_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