Commit 965e2714 authored by Nozomi Kodama's avatar Nozomi Kodama Committed by Alexandre Julliard

d3dx9_36: Fix the case out = in for D3DXSHRotate.

parent 1ca9ed90
......@@ -2774,7 +2774,7 @@ static void rotate_X(FLOAT *out, UINT order, FLOAT a, FLOAT *in)
FLOAT* WINAPI D3DXSHRotate(FLOAT *out, UINT order, CONST D3DXMATRIX *matrix, CONST FLOAT *in)
{
FLOAT alpha, beta, gamma, sinb, temp[36];
FLOAT alpha, beta, gamma, sinb, temp[36], temp1[36];
TRACE("out %p, order %u, matrix %p, in %p\n", out, order, matrix, in);
......@@ -2848,11 +2848,11 @@ FLOAT* WINAPI D3DXSHRotate(FLOAT *out, UINT order, CONST D3DXMATRIX *matrix, CON
gamma = 0.0f;
}
D3DXSHRotateZ(out, order, gamma, in);
rotate_X(temp, order, 1.0f, out);
D3DXSHRotateZ(out, order, beta, temp);
rotate_X(temp, order, -1.0f, out);
D3DXSHRotateZ(out, order, alpha, temp);
D3DXSHRotateZ(temp, order, gamma, in);
rotate_X(temp1, order, 1.0f, temp);
D3DXSHRotateZ(temp, order, beta, temp1);
rotate_X(temp1, order, -1.0f, temp);
D3DXSHRotateZ(out, order, alpha, temp1);
return out;
}
......
......@@ -2751,7 +2751,7 @@ static void test_D3DXSHMultiply4(void)
static void test_D3DXSHRotate(void)
{
D3DXMATRIX m[4];
FLOAT expected, in[49], out[49], *received_ptr;
FLOAT expected, in[49], out[49], *out_temp, *received_ptr;
static const FLOAT table[]=
{ /* Rotation around X-axis Pi/2 */
1.01f, -3.01f, 2.01f, 4.01f, -8.01f, -6.01f,
......@@ -2760,6 +2760,8 @@ static void test_D3DXSHRotate(void)
30.241013f, 26.919991f, 39.236877f, -22.632446f, 6.707388f, -11.768282f,
3.443672f, -6.07445f, 11.61839f, 1.527561f, 37.89633f, -56.9012f,
47.42289f, 50.39153f, 10.61819f, 25.50101f, 0.049241f, 16.98330f,
1.01f, -3.01f, -3.01f, 4.01f, -8.01f, -6.01f, -11.307889f, -8.01f, 14.297919f,
/* Rotation around X-axis -Pi/2 */
1.01f, 3.01f, -2.01f, 4.01f, 8.01f, -6.01f,
-11.307890f, -5.01f, -1.565839f, -1.093598f, -11.01f, -19.833414f,
......@@ -2767,6 +2769,8 @@ static void test_D3DXSHRotate(void)
-30.241013f, 26.919991f, 39.236877f, 22.632446f, 6.707388f, 11.768282f,
3.443672f, 6.07445f, 11.61839f, -1.527561f, 37.89633f, 56.9012f,
-47.42289f, 50.39153f, -10.61819f, 25.50101f, -0.049248f, 16.98330f,
1.01f, 3.01f, -3.01f, 4.01f, 8.01f, -6.01f, -11.307890f, -8.01f, 14.297919f,
/* Yaw Pi/3, Pitch Pi/4, Roll Pi/5 */
1.01f, 4.944899f, 1.442301f, 1.627281f, 0.219220f, 10.540824f,
-9.136903f, 2.763750f, -7.30904f, -5.875721f, 5.303124f, -8.682154f,
......@@ -2774,41 +2778,62 @@ static void test_D3DXSHRotate(void)
14.629795f, -54.467102f, -12.231035f, -4.089857f, -9.444222f, 3.056035f,
0.179257f, -10.041875f, 23.090092f, -23.188709f, 11.727098f, -65.183090f,
48.671577f, -15.073209f, 38.793171f, -26.039536f, 6.192769f, -17.672247f,
1.01f, 4.944899f, -0.891142f, 4.607695f, 0.219218f, 10.773325f,
-8.204769f, 13.563829f, -12.007767f,
/* Rotation around Z-axis Pi/6 */
1.01f, 3.745711f, 3.01f, 2.467762f, 10.307889f, 9.209813f,
7.01f, 3.931864f, 0.166212f, 16.01f, 18.504042f, 17.405966f,
13.01f, 6.128016f, -2.029941f, -10.01f, 13.154292f, 24.01f,
29.432245f, 28.334167f, 21.01f, 9.056221f, -4.958143f, -18.01f,
-27.236094f, -4.520332f, 16.814543f, 34.01f, 43.092495f, 41.994423f,
31.01f, 12.716471f, -8.618400f, -28.01f, -40.896347f, -44.190571,};
unsigned int i, j, order;
31.01f, 12.716471f, -8.618400f, -28.01f, -40.896347f, -44.190571,
1.01f, 3.745711f, 3.01f, 1.599906f, 10.307889f, 9.209813f,
7.01f, 2.331957f, -4.421894f, };
unsigned int i, j, l, order;
D3DXMatrixRotationX(&m[0], -D3DX_PI / 2.0f);
D3DXMatrixRotationX(&m[1], D3DX_PI / 2.0f);
D3DXMatrixRotationYawPitchRoll(&m[2], D3DX_PI / 3.0f, D3DX_PI / 4.0f, D3DX_PI / 5.0f);
D3DXMatrixRotationZ(&m[3], D3DX_PI / 6.0f);
for (i = 0; i < 49; i++)
in[i] = i + 1.01f;
for (j = 0; j < 4; j++)
for (l = 0; l < 2; l++)
{
for (order = 0; order <= D3DXSH_MAXORDER; order++)
{
for (i = 0; i < 49; i++)
out[i] = ( i + 1.0f ) * ( i + 1.0f );
received_ptr = D3DXSHRotate(out, order, &m[j], in);
ok(received_ptr == out, "Order %u, expected %p, received %p\n", order, out, received_ptr);
if (l == 0)
out_temp = out;
else
out_temp = in;
for (i = 0; i < 49; i++)
for (j = 0; j < 4; j++)
{
for (order = 0; order <= D3DXSH_MAXORDER; order++)
{
if ( ( i > 0 ) && ( ( i >= order * order ) || ( order > D3DXSH_MAXORDER ) ) )
expected = ( i + 1.0f ) * ( i + 1.0f );
else
expected = table[36 * j + i];
for (i = 0; i < 49; i++)
{
out[i] = ( i + 1.0f ) * ( i + 1.0f );
in[i] = i + 1.01f;
}
received_ptr = D3DXSHRotate(out_temp, order, &m[j], in);
ok(received_ptr == out_temp, "Order %u, expected %p, received %p\n", order, out, received_ptr);
ok(relative_error(out[i], expected) < admitted_error, "Order %u index %u, expected %f, received %f\n", order, i, expected, out[i]);
for (i = 0; i < 49; i++)
{
if ((i > 0) && ((i >= order * order) || (order > D3DXSH_MAXORDER)))
{
if (l == 0)
expected = ( i + 1.0f ) * ( i + 1.0f );
else
expected = i + 1.01f;
}
else if ((l == 0) || (order > 3))
expected = table[45 * j + i];
else
expected = table[45 * j + 36 +i];
ok(relative_error(out_temp[i], expected) < admitted_error,
"Order %u index %u, expected %f, received %f\n", order, i, expected, out_temp[i]);
}
}
}
}
......
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