Commit 1db76b03 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3dx9/tests: Use compare_float() in test_D3DXSHEvalSphericalLight().

parent d1ac3b8e
...@@ -3073,78 +3073,86 @@ static void test_D3DXSHEvalHemisphereLight(void) ...@@ -3073,78 +3073,86 @@ static void test_D3DXSHEvalHemisphereLight(void)
static void test_D3DXSHEvalSphericalLight(void) static void test_D3DXSHEvalSphericalLight(void)
{ {
float bout[49], expected, gout[49], rout[49];
unsigned int j, l, order;
D3DXVECTOR3 dir; D3DXVECTOR3 dir;
FLOAT bout[49], expected, gout[49], rout[49]; HRESULT hr;
const FLOAT table[] = { BOOL equal;
/* Red colour */
3.01317239f, -0.97724032f, 2.24765277f, -0.89580363f, 0.0f, 0.0f, static const float table[] =
0.0f, 0.0f, 0.0f, 0.06292814f, -0.42737406f, 0.61921263f, {
-0.30450898f, 0.56761158f, 0.03723336f, -0.08191673f, 0.0f, 0.0f, /* Red colour. */
0.0f, 0.0f, 0.0f, -0.0f, 0.0f, 0.0f, 3.01317239e+00f, -9.77240324e-01f, 2.24765277e+00f, -8.95803630e-01f, -1.22213947e-07f, 3.06645916e-07f,
0.0f, 0.01249927f, -0.01374878f, -0.14810932f, 0.43434596f, -0.24598616f, -3.36369283e-07f, 2.81092071e-07f, 1.06474305e-08f, 6.29281402e-02f, -4.27374065e-01f, 6.19212627e-01f,
-0.15175794f, -0.22548729f, -0.03784076f, 0.19280137f, -0.07830712f, 0.00797894f, -3.04508984e-01f, 5.67611575e-01f, 3.72333601e-02f, -8.19167346e-02f, -4.70457762e-09f, -7.94764006e-08f,
3.32868979e-07f, -3.08902315e-07f, 5.30925970e-10f, -2.83160460e-07f, -2.89999580e-08f, 1.03458447e-07f,
0.40251964f, -0.24365333f, 0.56040263f, -0.22334887f, 0.16204689f, -0.40659040f, -2.67952434e-08f, 1.24992710e-02f, -1.37487827e-02f, -1.48109317e-01f, 4.34345961e-01f, -2.45986164e-01f,
0.44600141f, -0.37270784f, -0.01411773f, -0.04319951f, 0.29338786f, -0.42508304f, -1.51757941e-01f, -2.25487292e-01f, -3.78407575e-02f, 1.92801371e-01f, -7.83071220e-02f, 7.97894225e-03f,
0.20904225f, -0.38965943f, -0.02556031f, 0.05623499f, -0.00468823f, -0.07920021f,
0.33171222f, -0.30782884f, 0.00052908f, -0.28217643f, -0.02889918f, 0.10309891f, 4.02519643e-01f, -2.43653327e-01f, 5.60402632e-01f, -2.23348871e-01f, 1.62046894e-01f, -4.06590402e-01f,
-0.02670213f, 0.00724340f, -0.00796750f, -0.08583023f, 0.25170606f, -0.14255044f, 4.46001410e-01f, -3.72707844e-01f, -1.41177261e-02f, -4.31995131e-02f, 2.93387860e-01f, -4.25083041e-01f,
-0.08794463f, -0.13067122f, -0.02192894f, 0.11172954f, -0.04537944f, 0.00462384f, 2.09042251e-01f, -3.89659435e-01f, -2.55603138e-02f, 5.62349856e-02f, -4.68822848e-03f, -7.92002082e-02f,
3.31712216e-01f, -3.07828844e-01f, 5.29080920e-04f, -2.82176435e-01f, -2.88991798e-02f, 1.03098914e-01f,
1.95445275f, -0.85659367f, 1.97016549f, -0.78521085f, 0.23103346f, -0.57968396f, -2.67021265e-02f, 7.24340184e-03f, -7.96750095e-03f, -8.58302265e-02f, 2.51706064e-01f, -1.42550439e-01f,
0.63587302f, -0.53137696f, -0.02012792f, 0.02111043f, -0.14337072f, 0.20772660f, -8.79446268e-02f, -1.30671218e-01f, -2.19289437e-02f, 1.11729540e-01f, -4.53794412e-02f, 4.62384429e-03f,
-0.10215330f, 0.19041604f, 0.01249063f, -0.02748052f, 0.00633162f, 0.10696279f,
-0.44798949f, 0.41573414f, -0.00071454f, 0.38108963f, 0.03902940f, -0.13923886f, 1.95445275e+00f, -8.56593668e-01f, 1.97016549e+00f, -7.85210848e-01f, 2.31033459e-01f, -5.79683959e-01f,
0.03606220f, -0.00447360f, 0.00492081f, 0.05300967f, -0.15545636f, 0.08804068f, 6.35873020e-01f, -5.31376958e-01f, -2.01279204e-02f, 2.11104341e-02f, -1.43370718e-01f, 2.07726598e-01f,
0.05431554f, 0.08070395f, 0.01354355f, -0.06900536f, 0.02802683f, -0.00285574f, -1.02153301e-01f, 1.90416038e-01f, 1.24906348e-02f, -2.74805184e-02f, 6.33162493e-03f, 1.06962793e-01f,
/* Green colour */ -4.47989494e-01f, 4.15734142e-01f, -7.14543217e-04f, 3.81089628e-01f, 3.90294008e-02f, -1.39238864e-01f,
4.60838127f, -1.49460280f, 3.43758631f, -1.37005258f, 0.0f, 0.0f, 3.60621996e-02f, -4.47360286e-03f, 4.92081419e-03f, 5.30096702e-02f, -1.55456364e-01f, 8.80406797e-02f,
0.0f, 0.0f, 0.0f, 0.09624302f, -0.65363091f, 0.94703102f, 5.43155447e-02f, 8.07039514e-02f, 1.35435509e-02f, -6.90053627e-02f, 2.80268304e-02f, -2.85573583e-03f,
-0.46571958f, 0.86811179f, 0.05694513f, -0.12528442f, -0.0f, 0.0f, /* Green colour. */
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 4.60838127e+00f, -1.49460280e+00f, 3.43758631e+00f, -1.37005258e+00f, -1.86915443e-07f, 4.68987878e-07f,
0.0f, 0.01911653f, -0.02102755f, -0.22652012f, 0.66429377f, -0.37621412f, -5.14447095e-07f, 4.29905526e-07f, 1.62843055e-08f, 9.62430239e-02f, -6.53630912e-01f, 9.47031021e-01f,
-0.23210037f, -0.34486291f, -0.05787410f, 0.29487267f, -0.11976383f, 0.01220309f, -4.65719581e-01f, 8.68111789e-01f, 5.69451340e-02f, -1.25284418e-01f, -7.19523641e-09f, -1.21552148e-07f,
5.09093695e-07f, -4.72438842e-07f, 8.12004408e-10f, -4.33068919e-07f, -4.43528769e-08f, 1.58230563e-07f,
0.61561823f, -0.37264627f, 0.85708636f, -0.34159240f, 0.24783641f, -0.62184411f, -4.09809608e-08f, 1.91165321e-02f, -2.10275482e-02f, -2.26520121e-01f, 6.64293766e-01f, -3.76214117e-01f,
0.68211979f, -0.57002378f, -0.02159182f, -0.06606984f, 0.44871080f, -0.65012693f, -2.32100368e-01f, -3.44862908e-01f, -5.78740984e-02f, 2.94872671e-01f, -1.19763829e-01f, 1.22030871e-02f,
0.31971166f, -0.59594971f, -0.03909224f, 0.08600645f, -0.00717023f, -0.12112973f,
0.50732452f, -0.47079703f, 0.00080918f, -0.43156394f, -0.04419874f, 0.15768069f, 6.15618229e-01f, -3.72646272e-01f, 8.57086360e-01f, -3.41592401e-01f, 2.47836411e-01f, -6.21844113e-01f,
-0.04083854f, 0.01107814f, -0.01218559f, -0.13126975f, 0.38496217f, -0.21801829f, 6.82119787e-01f, -5.70023775e-01f, -2.15918161e-02f, -6.60698414e-02f, 4.48710799e-01f, -6.50126934e-01f,
-0.13450353f, -0.19985008f, -0.03353838f, 0.17088045f, -0.06940385f, 0.00707176f, 3.19711655e-01f, -5.95949709e-01f, -3.90922427e-02f, 8.60064477e-02f, -7.17023155e-03f, -1.21129729e-01f,
5.07324517e-01f, -4.70797032e-01f, 8.09182529e-04f, -4.31563944e-01f, -4.41987440e-02f, 1.57680690e-01f,
2.98916292f, -1.31008446f, 3.01319408f, -1.20091069f, 0.35334525f, -0.88657540f, -4.08385433e-02f, 1.10781426e-02f, -1.21855885e-02f, -1.31269753e-01f, 3.84962171e-01f, -2.18018293e-01f,
0.97251165f, -0.81269407f, -0.03078388f, 0.03228654f, -0.21927285f, 0.31769949f, -1.34503528e-01f, -1.99850082e-01f, -3.35383788e-02f, 1.70880452e-01f, -6.94038495e-02f, 7.07176095e-03f,
-0.15623444f, 0.29122451f, 0.01910332f, -0.04202903f, 0.00968366f, 0.16359015f,
-0.68516040f, 0.63582867f, -0.00109283f, 0.58284295f, 0.05969203f, -0.21295355f, 2.98916292e+00f, -1.31008446e+00f, 3.01319408e+00f, -1.20091069e+00f, 3.53345245e-01f, -8.86575401e-01f,
0.05515395f, -0.00684198f, 0.00752595f, 0.08107361f, -0.23775679f, 0.13465045f, 9.72511649e-01f, -8.12694073e-01f, -3.07838768e-02f, 3.22865434e-02f, -2.19272852e-01f, 3.17699492e-01f,
0.08307083f, 0.12342957f, 0.02071366f, -0.10553761f, 0.04286456f, -0.00436760f, -1.56234443e-01f, 2.91224509e-01f, 1.91033222e-02f, -4.20290269e-02f, 9.68366116e-03f, 1.63590148e-01f,
/* Blue colour */ -6.85160398e-01f, 6.35828674e-01f, -1.09283067e-03f, 5.82842946e-01f, 5.96920252e-02f, -2.12953553e-01f,
6.20359039f, -2.01196527f, 4.62752008f, -1.84430146f, 0.0f, 0.0f, 5.51539510e-02f, -6.84198039e-03f, 7.52595067e-03f, 8.10736120e-02f, -2.37756789e-01f, 1.34650454e-01f,
0.0f, 0.0f, 0.0f, 0.12955792f, -0.87988776f, 1.27484941f, 8.30708295e-02f, 1.23429567e-01f, 2.07136646e-02f, -1.05537608e-01f, 4.28645648e-02f, -4.36759600e-03f,
-0.62693024f, 1.16861200f, 0.07665691f, -0.16865209f, 0.0f, 0.0f, /* Blue colour. */
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.20359039e+00f, -2.01196527e+00f, 4.62752008e+00f, -1.84430146e+00f, -2.51616967e-07f, 6.31329840e-07f,
0.0f, 0.02573379f, -0.02830632f, -0.30493096f, 0.89424169f, -0.50644207f, -6.92524964e-07f, 5.78718982e-07f, 2.19211813e-08f, 1.29557922e-01f, -8.79887760e-01f, 1.27484941e+00f,
-0.31244281f, -0.46423855f, -0.07790744f, 0.39694402f, -0.16122055f, 0.01642723f, -6.26930237e-01f, 1.16861200e+00f, 7.66569078e-02f, -1.68652087e-01f, -9.68589564e-09f, -1.63627888e-07f,
6.85318469e-07f, -6.35975368e-07f, 1.09308285e-09f, -5.82977407e-07f, -5.97057976e-08f, 2.13002679e-07f,
0.82871687f, -0.50163919f, 1.15377009f, -0.45983589f, 0.33362597f, -0.83709794f, -5.51666766e-08f, 2.57337932e-02f, -2.83063166e-02f, -3.04930955e-01f, 8.94241691e-01f, -5.06442070e-01f,
0.91823828f, -0.76733971f, -0.02906591f, -0.08894017f, 0.60403383f, -0.87517095f, -3.12442809e-01f, -4.64238554e-01f, -7.79074430e-02f, 3.96944016e-01f, -1.61220551e-01f, 1.64272338e-02f,
0.43038112f, -0.80224001f, -0.05262417f, 0.11577792f, -0.00965224f, -0.16305926f,
0.68293691f, -0.63376528f, 0.00108928f, -0.58095151f, -0.05949831f, 0.21226248f, 8.28716874e-01f, -5.01639187e-01f, 1.15377009e+00f, -4.59835887e-01f, 3.33625972e-01f, -8.37097943e-01f,
-0.05497497f, 0.01491288f, -0.01640368f, -0.17670928f, 0.51821834f, -0.29348618f, 9.18238282e-01f, -7.67339706e-01f, -2.90659070e-02f, -8.89401734e-02f, 6.04033828e-01f, -8.75170946e-01f,
-0.18106246f, -0.26902896f, -0.04514782f, 0.23003140f, -0.09342826f, 0.00951968f, 4.30381119e-01f, -8.02240014e-01f, -5.26241735e-02f, 1.15777917e-01f, -9.65223555e-03f, -1.63059264e-01f,
6.82936907e-01f, -6.33765280e-01f, 1.08928420e-03f, -5.80951512e-01f, -5.94983101e-02f, 2.12262481e-01f,
4.02387333f, -1.76357520f, 4.05622292f, -1.61661065f, 0.47565711f, -1.19346702f, -5.49749658e-02f, 1.49128847e-02f, -1.64036769e-02f, -1.76709279e-01f, 5.18218338e-01f, -2.93486178e-01f,
1.30915034f, -1.09401131f, -0.04143983f, 0.04346266f, -0.29517499f, 0.42767239f, -1.81062460e-01f, -2.69028962e-01f, -4.51478213e-02f, 2.30031401e-01f, -9.34282616e-02f, 9.51967947e-03f,
-0.21031560f, 0.39203301f, 0.02571601f, -0.05657754f, 0.01303570f, 0.22021750f,
-0.92233127f, 0.85592318f, -0.00147112f, 0.78459626f, 0.08035465f, -0.28666824f, 4.02387333e+00f, -1.76357520e+00f, 4.05622292e+00f, -1.61661065e+00f, 4.75657105e-01f, -1.19346702e+00f,
0.07424571f, -0.00921036f, 0.01013109f, 0.10913756f, -0.32005721f, 0.18126021f, 1.30915034e+00f, -1.09401131e+00f, -4.14398350e-02f, 4.34626564e-02f, -2.95174986e-01f, 4.27672386e-01f,
0.11182612f, 0.16615519f, 0.02788378f, -0.14206986f, 0.05770230f, -0.00587946f, }; -2.10315600e-01f, 3.92033011e-01f, 2.57160105e-02f, -5.65775372e-02f, 1.30356979e-02f, 2.20217496e-01f,
struct -9.22331274e-01f, 8.55923176e-01f, -1.47111830e-03f, 7.84596264e-01f, 8.03546458e-02f, -2.86668241e-01f,
7.42457062e-02f, -9.21035837e-03f, 1.01310881e-02f, 1.09137557e-01f, -3.20057213e-01f, 1.81260213e-01f,
1.11826122e-01f, 1.66155189e-01f, 2.78837811e-02f, -1.42069861e-01f, 5.77022992e-02f, -5.87945618e-03f,
};
const struct
{
float *red_received, *green_received, *blue_received;
const float *red_expected, *green_expected, *blue_expected;
float radius, roffset, goffset, boffset;
}
test[] =
{ {
FLOAT *red_received, *green_received, *blue_received;
const FLOAT *red_expected, *green_expected, *blue_expected;
FLOAT radius, roffset, goffset, boffset;
} test[] = {
{ rout, gout, bout, table, &table[108], &table[216], 17.4f, 1.01f, 1.02f, 1.03f, }, { rout, gout, bout, table, &table[108], &table[216], 17.4f, 1.01f, 1.02f, 1.03f, },
{ rout, gout, bout, &table[36], &table[144], &table[252], 1.6f, 1.01f, 1.02f, 1.03f, }, { rout, gout, bout, &table[36], &table[144], &table[252], 1.6f, 1.01f, 1.02f, 1.03f, },
{ rout, gout, bout, &table[72], &table[180], &table[288], -3.0f, 1.01f, 1.02f, 1.03f, }, { rout, gout, bout, &table[72], &table[180], &table[288], -3.0f, 1.01f, 1.02f, 1.03f, },
...@@ -3155,9 +3163,8 @@ static void test_D3DXSHEvalSphericalLight(void) ...@@ -3155,9 +3163,8 @@ static void test_D3DXSHEvalSphericalLight(void)
/* D3DXSHEvalSphericalLight accepts NULL green or blue colour. */ /* D3DXSHEvalSphericalLight accepts NULL green or blue colour. */
{ rout, NULL, bout, table, NULL, &table[216], 17.4f, 1.01f, 0.0f, 1.03f, }, { rout, NULL, bout, table, NULL, &table[216], 17.4f, 1.01f, 0.0f, 1.03f, },
{ rout, gout, NULL, table, &table[108], NULL, 17.4f, 1.01f, 1.02f, 0.0f, }, { rout, gout, NULL, table, &table[108], NULL, 17.4f, 1.01f, 1.02f, 0.0f, },
{ rout, NULL, NULL, table, NULL, NULL, 17.4f, 1.01f, 0.0f, 0.0f, }, }; { rout, NULL, NULL, table, NULL, NULL, 17.4f, 1.01f, 0.0f, 0.0f, },
HRESULT hr; };
unsigned int j, l, order;
dir.x = 1.1f; dir.y = 1.2f; dir.z = 2.76f; dir.x = 1.1f; dir.y = 1.2f; dir.z = 2.76f;
...@@ -3183,8 +3190,10 @@ static void test_D3DXSHEvalSphericalLight(void) ...@@ -3183,8 +3190,10 @@ static void test_D3DXSHEvalSphericalLight(void)
expected = j + test[l].roffset; expected = j + test[l].roffset;
else else
expected = test[l].red_expected[j]; expected = test[l].red_expected[j];
ok(relative_error(expected, test[l].red_received[j]) < 0.0005f, equal = compare_float(expected, test[l].red_received[j], 2048);
"Red: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, test[l].red_received[j]); ok(equal || (fabs(expected) < 1.0e-6f && fabs(test[l].red_received[j]) < 1.0e-6f),
"Red: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
l, order, j, expected, test[l].red_received[j]);
if (test[l].green_received) if (test[l].green_received)
{ {
...@@ -3192,8 +3201,10 @@ static void test_D3DXSHEvalSphericalLight(void) ...@@ -3192,8 +3201,10 @@ static void test_D3DXSHEvalSphericalLight(void)
expected = j + test[l].goffset; expected = j + test[l].goffset;
else else
expected = test[l].green_expected[j]; expected = test[l].green_expected[j];
ok(relative_error(expected, test[l].green_received[j]) < 0.0005f, equal = compare_float(expected, test[l].green_received[j], 2048);
"Green: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, test[l].green_received[j]); ok(equal || (fabs(expected) < 1.0e-6f && fabs(test[l].green_received[j]) < 1.0e-6f),
"Green: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
l, order, j, expected, test[l].green_received[j]);
} }
if (test[l].blue_received) if (test[l].blue_received)
...@@ -3202,8 +3213,10 @@ static void test_D3DXSHEvalSphericalLight(void) ...@@ -3202,8 +3213,10 @@ static void test_D3DXSHEvalSphericalLight(void)
expected = j + test[l].boffset; expected = j + test[l].boffset;
else else
expected = test[l].blue_expected[j]; expected = test[l].blue_expected[j];
ok(relative_error(expected, test[l].blue_received[j]) < 0.0005f, equal = compare_float(expected, test[l].blue_received[j], 2048);
"Blue: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, test[l].blue_received[j]); ok(equal || (fabs(expected) < 1.0e-6f && fabs(test[l].blue_received[j]) < 1.0e-6f),
"Blue: case %u, order %u: expected[%u] = %.8e, received %.8e.\n",
l, order, j, expected, test[l].blue_received[j]);
} }
} }
} }
......
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