d3dx9: Implementation of D3DXSHMultiply2.

oldstable
Nozomi Kodama 2012-07-13 02:53:18 +02:00 committed by Alexandre Julliard
parent 1ceec8c789
commit f757f3fb7d
4 changed files with 42 additions and 1 deletions

View File

@ -279,7 +279,7 @@
@ stub D3DXSHEvalDirectionalLight(long ptr long long long long ptr ptr ptr)
@ stub D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr)
@ stub D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr)
@ stub D3DXSHMultiply2(ptr ptr ptr)
@ stdcall D3DXSHMultiply2(ptr ptr ptr)
@ stdcall D3DXSHMultiply3(ptr ptr ptr)
@ stub D3DXSHMultiply4(ptr ptr ptr)
@ stub D3DXSHMultiply5(ptr ptr ptr)

View File

@ -1995,6 +1995,23 @@ FLOAT WINAPI D3DXSHDot(UINT order, CONST FLOAT *a, CONST FLOAT *b)
return s;
}
FLOAT* WINAPI D3DXSHMultiply2(FLOAT *out, CONST FLOAT *a, CONST FLOAT *b)
{
FLOAT ta, tb;
TRACE("(%p, %p, %p)\n", out, a, b);
ta = 0.28209479f * a[0];
tb = 0.28209479f * b[0];
out[0]= 0.28209479f * D3DXSHDot(2, a, b);
out[1] = ta * b[1] + tb * a[1];
out[2] = ta * b[2] + tb * a[2];
out[3] = ta * b[3] + tb * a[3];
return out;
}
FLOAT* WINAPI D3DXSHMultiply3(FLOAT *out, CONST FLOAT *a, CONST FLOAT *b)
{
FLOAT t, ta, tb;

View File

@ -2422,6 +2422,28 @@ static void test_D3DXSHDot(void)
return;
}
static void test_D3DXSHMultiply2(void)
{
unsigned int i;
FLOAT a[20], b[20], c[20];
/* D3DXSHMultiply2 only modifies the first 4 elements of the array */
const FLOAT expected[20] =
{ 3.418594f, 1.698211f, 1.703853f, 1.709494f, 4.0f, 5.0f,
6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f,
14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f };
for (i = 0; i < 20; i++)
{
a[i] = 1.0f + i / 100.0f;
b[i] = 3.0f - i / 100.0f;
c[i] = i;
}
D3DXSHMultiply2(c, a, b);
for (i = 0; i < 20; i++)
ok(relative_error(c[i], expected[i]) < admitted_error, "Expected[%d] = %f, received = %f\n", i, expected[i], c[i]);
}
static void test_D3DXSHMultiply3(void)
{
unsigned int i;
@ -2490,6 +2512,7 @@ START_TEST(math)
test_D3DXFloat_Array();
test_D3DXSHAdd();
test_D3DXSHDot();
test_D3DXSHMultiply2();
test_D3DXSHMultiply3();
test_D3DXSHScale();
}

View File

@ -379,6 +379,7 @@ FLOAT *WINAPI D3DXFloat16To32Array(FLOAT *pout, CONST D3DXFLOAT16 *pin, UINT n);
FLOAT* WINAPI D3DXSHAdd(FLOAT *out, UINT order, CONST FLOAT *a, CONST FLOAT *b);
FLOAT WINAPI D3DXSHDot(UINT order, CONST FLOAT *a, CONST FLOAT *b);
FLOAT* WINAPI D3DXSHMultiply2(FLOAT *out, CONST FLOAT *a, CONST FLOAT *b);
FLOAT* WINAPI D3DXSHMultiply3(FLOAT *out, CONST FLOAT *a, CONST FLOAT *b);
FLOAT* WINAPI D3DXSHScale(FLOAT *out, UINT order, CONST FLOAT *a, CONST FLOAT scale);