ddraw/tests: Cleanup and extend d3d7 ComputeSphereVisibility() tests.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5f5e83977b
commit
52512b3d01
|
@ -2526,194 +2526,6 @@ static void SetMaterialTest(void)
|
||||||
ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ComputeSphereVisibility(void)
|
|
||||||
{
|
|
||||||
D3DMATRIX proj =
|
|
||||||
{
|
|
||||||
1.810660f, 0.000000f, 0.000000f, 0.000000f,
|
|
||||||
0.000000f, 2.414213f, 0.000000f, 0.000000f,
|
|
||||||
0.000000f, 0.000000f, 1.020408f, 1.000000f,
|
|
||||||
0.000000f, 0.000000f, -0.102041f, 0.000000f,
|
|
||||||
};
|
|
||||||
D3DMATRIX view =
|
|
||||||
{
|
|
||||||
1.000000f, 0.000000f, 0.000000f, 0.000000f,
|
|
||||||
0.000000f, 0.768221f, -0.640185f, 0.000000f,
|
|
||||||
-0.000000f, 0.640185f, 0.768221f, 0.000000f,
|
|
||||||
-14.852037f, 9.857489f, 11.600972f, 1.000000f,
|
|
||||||
};
|
|
||||||
D3DMATRIX world =
|
|
||||||
{
|
|
||||||
1.0f, 0.0f, 0.0f, 0.0f,
|
|
||||||
0.0f, 1.0f, 0.0f, 0.0f,
|
|
||||||
0.0f, 0.0f, 1.0f, 0.0f,
|
|
||||||
0.0f, 0.0f, 0.0f, 1.0f,
|
|
||||||
};
|
|
||||||
D3DVALUE radius[3];
|
|
||||||
D3DVECTOR center[3];
|
|
||||||
DWORD result[3];
|
|
||||||
HRESULT rc;
|
|
||||||
|
|
||||||
IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_WORLD, &world);
|
|
||||||
IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_VIEW , &view);
|
|
||||||
IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_PROJECTION, &proj);
|
|
||||||
|
|
||||||
U1(center[0]).x=11.461533;
|
|
||||||
U2(center[0]).y=-4.761727;
|
|
||||||
U3(center[0]).z=-1.171646;
|
|
||||||
|
|
||||||
radius[0]=38.252632;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x3f, "Expected 0x3f, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=-3.515620; U2(center[0]).y=-1.560661; U3(center[0]).z=-12.464638;
|
|
||||||
radius[0]=4.354097;
|
|
||||||
U1(center[1]).x=14.290396; U2(center[1]).y=-2.981143; U3(center[1]).z=-24.311312;
|
|
||||||
radius[1]=12.500704;
|
|
||||||
U1(center[2]).x=1.461626; U2(center[2]).y=-6.093709; U3(center[2]).z=-13.901010;
|
|
||||||
radius[2]=17.251318;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 3, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x103d, "Expected 0x103d, got %x\n", result[0]);
|
|
||||||
ok(result[1] == 0x3f, "Expected 0x3f, got %x\n", result[1]);
|
|
||||||
ok(result[2] == 0x3f, "Expected 0x3f, got %x\n", result[2]);
|
|
||||||
|
|
||||||
view._11=1.0; view._12=0.0; view._13=0.0; view._14=0.0;
|
|
||||||
view._21=0.0; view._22=1.0; view._23=0.0; view._24=0.0;
|
|
||||||
view._31=0.0; view._32=0.0; view._33=1.0; view._34=0.0;
|
|
||||||
view._41=0.0; view._42=0.0; view._43=0.0; view._44=1.0;
|
|
||||||
|
|
||||||
proj._11=10.0; proj._12=0.0; proj._13=0.0; proj._14=0.0;
|
|
||||||
proj._21=0.0; proj._22=10.0; proj._23=0.0, proj._24=0.0;
|
|
||||||
proj._31=0.0; proj._32=0.0; proj._33=10.0, proj._34=0.0;
|
|
||||||
proj._41=0.0; proj._42=0.0; proj._43=0.0; proj._44=1.0;
|
|
||||||
|
|
||||||
U1(center[0]).x=0.0;
|
|
||||||
U2(center[0]).y=0.0;
|
|
||||||
U3(center[0]).z=0.05;
|
|
||||||
|
|
||||||
radius[0]=0.04;
|
|
||||||
|
|
||||||
IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_VIEW , &view);
|
|
||||||
IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_PROJECTION, &proj);
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x0, "Expected 0x0, got %x\n", result[0]);
|
|
||||||
|
|
||||||
proj._11=1.0; proj._12=0.0; proj._13=0.0; proj._14=0.0;
|
|
||||||
proj._21=0.0; proj._22=1.0; proj._23=0.0, proj._24=0.0;
|
|
||||||
proj._31=0.0; proj._32=0.0; proj._33=1.0, proj._34=0.0;
|
|
||||||
proj._41=0.0; proj._42=0.0; proj._43=0.0; proj._44=1.0;
|
|
||||||
|
|
||||||
IDirect3DDevice7_SetTransform(lpD3DDevice, D3DTRANSFORMSTATE_PROJECTION, &proj);
|
|
||||||
|
|
||||||
U1(center[0]).x=0.0;
|
|
||||||
U2(center[0]).y=0.0;
|
|
||||||
U3(center[0]).z=0.5;
|
|
||||||
|
|
||||||
radius[0]=0.5;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x0, "Expected 0x0, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=0.0;
|
|
||||||
U2(center[0]).y=0.0;
|
|
||||||
U3(center[0]).z=0.0;
|
|
||||||
|
|
||||||
radius[0]=0.0;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x0, "Expected 0x0, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=-1.0;
|
|
||||||
U2(center[0]).y=-1.0;
|
|
||||||
U3(center[0]).z=0.50;
|
|
||||||
|
|
||||||
radius[0]=0.25;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x9, "Expected 0x9, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=-20.0;
|
|
||||||
U2(center[0]).y=0.0;
|
|
||||||
U3(center[0]).z=0.50;
|
|
||||||
|
|
||||||
radius[0]=3.0;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x103d, "Expected 0x103d, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=20.0;
|
|
||||||
U2(center[0]).y=0.0;
|
|
||||||
U3(center[0]).z=0.50;
|
|
||||||
|
|
||||||
radius[0]=3.0f;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x203e, "Expected 0x203e, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=0.0;
|
|
||||||
U2(center[0]).y=-20.0;
|
|
||||||
U3(center[0]).z=0.50;
|
|
||||||
|
|
||||||
radius[0]=3.0;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x803b, "Expected 0x803b, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=0.0;
|
|
||||||
U2(center[0]).y=20.0;
|
|
||||||
U3(center[0]).z=0.5;
|
|
||||||
|
|
||||||
radius[0]=3.0;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x4037, "Expected 0x4037, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=0.0;
|
|
||||||
U2(center[0]).y=0.0;
|
|
||||||
U3(center[0]).z=-20;
|
|
||||||
|
|
||||||
radius[0]=3.0;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x1001f, "Expected 0x1001f, got %x\n", result[0]);
|
|
||||||
|
|
||||||
U1(center[0]).x=0.0;
|
|
||||||
U2(center[0]).y=0.0;
|
|
||||||
U3(center[0]).z=20.0;
|
|
||||||
|
|
||||||
radius[0]=3.0;
|
|
||||||
|
|
||||||
rc = IDirect3DDevice7_ComputeSphereVisibility(lpD3DDevice, center, radius, 1, 0, result);
|
|
||||||
|
|
||||||
ok(rc == D3D_OK, "Expected D3D_OK, received %x\n", rc);
|
|
||||||
ok(result[0] == 0x2002f, "Expected 0x2002f, got %x\n", result[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetRenderTargetTest(void)
|
static void SetRenderTargetTest(void)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -3667,7 +3479,6 @@ START_TEST(d3d)
|
||||||
D3D7EnumTest();
|
D3D7EnumTest();
|
||||||
D3D7EnumLifetimeTest();
|
D3D7EnumLifetimeTest();
|
||||||
SetMaterialTest();
|
SetMaterialTest();
|
||||||
ComputeSphereVisibility();
|
|
||||||
CapsTest();
|
CapsTest();
|
||||||
VertexBufferDescTest();
|
VertexBufferDescTest();
|
||||||
D3D7_OldRenderStateTest();
|
D3D7_OldRenderStateTest();
|
||||||
|
|
|
@ -13127,6 +13127,112 @@ static void test_vb_refcount(void)
|
||||||
DestroyWindow(window);
|
DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_compute_sphere_visibility(void)
|
||||||
|
{
|
||||||
|
static D3DVALUE clip_plane[4] = {1.0f, 0.0f, 0.0f, 0.5f};
|
||||||
|
static D3DMATRIX proj_1 =
|
||||||
|
{
|
||||||
|
1.810660f, 0.000000f, 0.000000f, 0.000000f,
|
||||||
|
0.000000f, 2.414213f, 0.000000f, 0.000000f,
|
||||||
|
0.000000f, 0.000000f, 1.020408f, 1.000000f,
|
||||||
|
0.000000f, 0.000000f, -0.102041f, 0.000000f,
|
||||||
|
};
|
||||||
|
static D3DMATRIX proj_2 =
|
||||||
|
{
|
||||||
|
10.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 10.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 10.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
};
|
||||||
|
static D3DMATRIX view_1 =
|
||||||
|
{
|
||||||
|
1.000000f, 0.000000f, 0.000000f, 0.000000f,
|
||||||
|
0.000000f, 0.768221f, -0.640185f, 0.000000f,
|
||||||
|
-0.000000f, 0.640185f, 0.768221f, 0.000000f,
|
||||||
|
-14.852037f, 9.857489f, 11.600972f, 1.000000f,
|
||||||
|
};
|
||||||
|
static D3DMATRIX identity =
|
||||||
|
{
|
||||||
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
};
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
D3DMATRIX *view, *proj;
|
||||||
|
unsigned int sphere_count;
|
||||||
|
D3DVECTOR center[3];
|
||||||
|
D3DVALUE radius[3];
|
||||||
|
DWORD enable_planes;
|
||||||
|
const DWORD expected[3];
|
||||||
|
}
|
||||||
|
tests[] =
|
||||||
|
{
|
||||||
|
{&view_1, &proj_1, 1, {{{11.461533f}, {-4.761727f}, {-1.171646f}}}, {38.252632f}, 0, {0x3f}},
|
||||||
|
{&view_1, &proj_1, 3, {{{-3.515620f}, {-1.560661f}, {-12.464638f}},
|
||||||
|
{{14.290396f}, {-2.981143f}, {-24.311312f}},
|
||||||
|
{{1.461626f}, {-6.093709f}, {-13.901010f}}},
|
||||||
|
{4.354097f, 12.500704f, 17.251318f}, 0, {0x103d, 0x3f, 0x3f}},
|
||||||
|
{&identity, &proj_2, 1, {{{0.0f}, {0.0f}, {0.05f}}}, {0.04f}, 0, {0}},
|
||||||
|
{&identity, &identity, 1, {{{0.0f}, {0.0f}, {0.5f}}}, {0.5f}, 0, {0}},
|
||||||
|
{&identity, &identity, 1, {{{0.0f}, {0.0f}, {0.0f}}}, {0.0f}, 0, {0}},
|
||||||
|
{&identity, &identity, 1, {{{-1.0f}, {-1.0f}, {0.5f}}}, {0.25f}, 0, {0x9}}, /* 5 */
|
||||||
|
{&identity, &identity, 1, {{{-20.0f}, {0.0f}, {0.5f}}}, {3.0f}, 0, {0x103d}},
|
||||||
|
{&identity, &identity, 1, {{{20.0f}, {0.0f}, {0.5f}}}, {3.0f}, 0, {0x203e}},
|
||||||
|
{&identity, &identity, 1, {{{0.0f}, {-20.0f}, {0.5f}}}, {3.0f}, 0, {0x803b}},
|
||||||
|
{&identity, &identity, 1, {{{0.0f}, {20.0f}, {0.5f}}}, {3.0f}, 0, {0x4037}},
|
||||||
|
{&identity, &identity, 1, {{{0.0f}, {0.0f}, {-20.0f}}}, {3.0f}, 0, {0x1001f}}, /* 10 */
|
||||||
|
{&identity, &identity, 1, {{{0.0f}, {0.0f}, {20.0f}}}, {3.0f}, 0, {0x2002f}},
|
||||||
|
{&identity, &identity, 1, {{{0.0f}, {0.0f}, {0.0f}}}, {5.0f}, 1, {0x7f}},
|
||||||
|
{&identity, &identity, 1, {{{-0.5f}, {0.0f}, {0.0f}}}, {5.0f}, 1, {0x7f}},
|
||||||
|
{&identity, &identity, 1, {{{-0.5f}, {0.0f}, {0.0f}}}, {1.0f}, 1, {0x51}},
|
||||||
|
{&identity, &identity, 1, {{{-2.5f}, {0.0f}, {0.0f}}}, {1.0f}, 1, {0x41051}}, /* 15 */
|
||||||
|
};
|
||||||
|
IDirect3DDevice7 *device;
|
||||||
|
unsigned int i, j;
|
||||||
|
DWORD result[3];
|
||||||
|
ULONG refcount;
|
||||||
|
HWND window;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
window = CreateWindowA("static", "d3d_test", WS_OVERLAPPEDWINDOW,
|
||||||
|
0, 0, 640, 480, 0, 0, 0, 0);
|
||||||
|
if (!(device = create_device(window, DDSCL_NORMAL)))
|
||||||
|
{
|
||||||
|
skip("Failed to create a 3D device, skipping test.\n");
|
||||||
|
DestroyWindow(window);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_SetClipPlane(device, 0, clip_plane);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set user clip plane, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &identity);
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
|
||||||
|
{
|
||||||
|
IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, tests[i].view);
|
||||||
|
IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, tests[i].proj);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE,
|
||||||
|
tests[i].enable_planes);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to enable / disable user clip planes, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_ComputeSphereVisibility(device, tests[i].center, tests[i].radius,
|
||||||
|
tests[i].sphere_count, 0, result);
|
||||||
|
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
|
for (j = 0; j < tests[i].sphere_count; ++j)
|
||||||
|
ok(result[j] == tests[i].expected[j], "Test %u sphere %u: expected %#x, got %#x.\n",
|
||||||
|
i, j, tests[i].expected[j], result[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice7_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
DestroyWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(ddraw7)
|
START_TEST(ddraw7)
|
||||||
{
|
{
|
||||||
HMODULE module = GetModuleHandleA("ddraw.dll");
|
HMODULE module = GetModuleHandleA("ddraw.dll");
|
||||||
|
@ -13242,4 +13348,5 @@ START_TEST(ddraw7)
|
||||||
test_get_surface_from_dc();
|
test_get_surface_from_dc();
|
||||||
test_ck_operation();
|
test_ck_operation();
|
||||||
test_vb_refcount();
|
test_vb_refcount();
|
||||||
|
test_compute_sphere_visibility();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue