From: Nozomi Kodama Subject: d3dx9_36 [patch 1/3]: Implement D3DXSHEvalHemisphereLight Message-Id: <1352876877.45969.YahooMailNeo@web132304.mail.ird.yahoo.com> Date: Wed, 14 Nov 2012 07:07:57 +0000 (GMT)
From dbec178d86613568195bbf03a586bcf0a2e9eeb6 Mon Sep 17 00:00:00 2001 From: Nozomi Kodama Date: Tue, 13 Nov 2012 20:54:35 -1000 Subject: Implement D3DXSHEvalHemisphereLight --- dlls/d3dx9_24/d3dx9_24.spec | 2 +- dlls/d3dx9_25/d3dx9_25.spec | 2 +- dlls/d3dx9_26/d3dx9_26.spec | 2 +- dlls/d3dx9_27/d3dx9_27.spec | 2 +- dlls/d3dx9_28/d3dx9_28.spec | 2 +- dlls/d3dx9_29/d3dx9_29.spec | 2 +- dlls/d3dx9_30/d3dx9_30.spec | 2 +- dlls/d3dx9_31/d3dx9_31.spec | 2 +- dlls/d3dx9_32/d3dx9_32.spec | 2 +- dlls/d3dx9_33/d3dx9_33.spec | 2 +- dlls/d3dx9_34/d3dx9_34.spec | 2 +- dlls/d3dx9_35/d3dx9_35.spec | 2 +- dlls/d3dx9_36/d3dx9_36.spec | 2 +- dlls/d3dx9_36/math.c | 45 +++++++++++++++++++++ dlls/d3dx9_36/tests/math.c | 93 +++++++++++++++++++++++++++++++++++++++++++ dlls/d3dx9_37/d3dx9_37.spec | 2 +- dlls/d3dx9_38/d3dx9_38.spec | 2 +- dlls/d3dx9_39/d3dx9_39.spec | 2 +- dlls/d3dx9_40/d3dx9_40.spec | 2 +- dlls/d3dx9_41/d3dx9_41.spec | 2 +- dlls/d3dx9_42/d3dx9_42.spec | 2 +- dlls/d3dx9_43/d3dx9_43.spec | 2 +- include/d3dx9math.h | 1 + 23 files changed, 159 insertions(+), 20 deletions(-) diff --git a/dlls/d3dx9_24/d3dx9_24.spec b/dlls/d3dx9_24/d3dx9_24.spec index 54e94b3..2316d7b 100644 --- a/dlls/d3dx9_24/d3dx9_24.spec +++ b/dlls/d3dx9_24/d3dx9_24.spec @@ -269,7 +269,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHProjectCubeMap(long ptr ptr ptr ptr) d3dx9_36.D3DXSHProjectCubeMap @ stdcall D3DXSHPRTCompSplitMeshSC(ptr long long ptr long ptr long long ptr ptr long ptr ptr ptr ptr ptr) d3dx9_36.D3DXSHPRTCompSplitMeshSC diff --git a/dlls/d3dx9_25/d3dx9_25.spec b/dlls/d3dx9_25/d3dx9_25.spec index 0652ee5..292aaaf 100644 --- a/dlls/d3dx9_25/d3dx9_25.spec +++ b/dlls/d3dx9_25/d3dx9_25.spec @@ -269,7 +269,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHProjectCubeMap(long ptr ptr ptr ptr) d3dx9_36.D3DXSHProjectCubeMap @ stdcall D3DXSHPRTCompSplitMeshSC(ptr long long ptr long ptr long long ptr ptr long ptr ptr ptr ptr ptr) d3dx9_36.D3DXSHPRTCompSplitMeshSC diff --git a/dlls/d3dx9_26/d3dx9_26.spec b/dlls/d3dx9_26/d3dx9_26.spec index dcae11a..ef1208c 100644 --- a/dlls/d3dx9_26/d3dx9_26.spec +++ b/dlls/d3dx9_26/d3dx9_26.spec @@ -273,7 +273,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHProjectCubeMap(long ptr ptr ptr ptr) d3dx9_36.D3DXSHProjectCubeMap @ stdcall D3DXSHPRTCompSplitMeshSC(ptr long long ptr long ptr long long ptr ptr long ptr ptr ptr ptr ptr) d3dx9_36.D3DXSHPRTCompSplitMeshSC diff --git a/dlls/d3dx9_27/d3dx9_27.spec b/dlls/d3dx9_27/d3dx9_27.spec index dcae11a..ef1208c 100644 --- a/dlls/d3dx9_27/d3dx9_27.spec +++ b/dlls/d3dx9_27/d3dx9_27.spec @@ -273,7 +273,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHProjectCubeMap(long ptr ptr ptr ptr) d3dx9_36.D3DXSHProjectCubeMap @ stdcall D3DXSHPRTCompSplitMeshSC(ptr long long ptr long ptr long long ptr ptr long ptr ptr ptr ptr ptr) d3dx9_36.D3DXSHPRTCompSplitMeshSC diff --git a/dlls/d3dx9_28/d3dx9_28.spec b/dlls/d3dx9_28/d3dx9_28.spec index f093338..3bedc3d 100644 --- a/dlls/d3dx9_28/d3dx9_28.spec +++ b/dlls/d3dx9_28/d3dx9_28.spec @@ -278,7 +278,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHProjectCubeMap(long ptr ptr ptr ptr) d3dx9_36.D3DXSHProjectCubeMap @ stdcall D3DXSHPRTCompSplitMeshSC(ptr long long ptr long ptr long long ptr ptr long ptr ptr ptr ptr ptr) d3dx9_36.D3DXSHPRTCompSplitMeshSC diff --git a/dlls/d3dx9_29/d3dx9_29.spec b/dlls/d3dx9_29/d3dx9_29.spec index f093338..3bedc3d 100644 --- a/dlls/d3dx9_29/d3dx9_29.spec +++ b/dlls/d3dx9_29/d3dx9_29.spec @@ -278,7 +278,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHProjectCubeMap(long ptr ptr ptr ptr) d3dx9_36.D3DXSHProjectCubeMap @ stdcall D3DXSHPRTCompSplitMeshSC(ptr long long ptr long ptr long long ptr ptr long ptr ptr ptr ptr ptr) d3dx9_36.D3DXSHPRTCompSplitMeshSC diff --git a/dlls/d3dx9_30/d3dx9_30.spec b/dlls/d3dx9_30/d3dx9_30.spec index bfd9fba..b42b6ca 100644 --- a/dlls/d3dx9_30/d3dx9_30.spec +++ b/dlls/d3dx9_30/d3dx9_30.spec @@ -278,7 +278,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHProjectCubeMap(long ptr ptr ptr ptr) d3dx9_36.D3DXSHProjectCubeMap @ stdcall D3DXSHPRTCompSplitMeshSC(ptr long long ptr long ptr long long ptr ptr long ptr ptr ptr ptr ptr) d3dx9_36.D3DXSHPRTCompSplitMeshSC diff --git a/dlls/d3dx9_31/d3dx9_31.spec b/dlls/d3dx9_31/d3dx9_31.spec index 007ae71..7e2e0db 100644 --- a/dlls/d3dx9_31/d3dx9_31.spec +++ b/dlls/d3dx9_31/d3dx9_31.spec @@ -275,7 +275,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHProjectCubeMap(long ptr ptr ptr ptr) d3dx9_36.D3DXSHProjectCubeMap @ stdcall D3DXSHPRTCompSplitMeshSC(ptr long long ptr long ptr long long ptr ptr long ptr ptr ptr ptr ptr) d3dx9_36.D3DXSHPRTCompSplitMeshSC diff --git a/dlls/d3dx9_32/d3dx9_32.spec b/dlls/d3dx9_32/d3dx9_32.spec index 8f5b56a..6673b48 100644 --- a/dlls/d3dx9_32/d3dx9_32.spec +++ b/dlls/d3dx9_32/d3dx9_32.spec @@ -275,7 +275,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_33/d3dx9_33.spec b/dlls/d3dx9_33/d3dx9_33.spec index 8f5b56a..6673b48 100644 --- a/dlls/d3dx9_33/d3dx9_33.spec +++ b/dlls/d3dx9_33/d3dx9_33.spec @@ -275,7 +275,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_34/d3dx9_34.spec b/dlls/d3dx9_34/d3dx9_34.spec index 8f5b56a..6673b48 100644 --- a/dlls/d3dx9_34/d3dx9_34.spec +++ b/dlls/d3dx9_34/d3dx9_34.spec @@ -275,7 +275,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_35/d3dx9_35.spec b/dlls/d3dx9_35/d3dx9_35.spec index 8f5b56a..6673b48 100644 --- a/dlls/d3dx9_35/d3dx9_35.spec +++ b/dlls/d3dx9_35/d3dx9_35.spec @@ -275,7 +275,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec index ac1d208..a79b27a 100644 --- a/dlls/d3dx9_36/d3dx9_36.spec +++ b/dlls/d3dx9_36/d3dx9_36.spec @@ -277,7 +277,7 @@ @ stub D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) @ stdcall D3DXSHEvalDirection(ptr long ptr) @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) -@ stub D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) @ stub D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) @ stdcall D3DXSHMultiply2(ptr ptr ptr) @ stdcall D3DXSHMultiply3(ptr ptr ptr) diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c index 12073e3..6ce5df8 100644 --- a/dlls/d3dx9_36/math.c +++ b/dlls/d3dx9_36/math.c @@ -2319,6 +2319,51 @@ HRESULT WINAPI D3DXSHEvalDirectionalLight(UINT order, CONST D3DXVECTOR3 *dir, FL return D3D_OK; } +HRESULT WINAPI D3DXSHEvalHemisphereLight(UINT order, CONST D3DXVECTOR3 *dir, D3DXCOLOR top, D3DXCOLOR bottom, FLOAT *rout, FLOAT *gout, FLOAT *bout) +{ + FLOAT a[2], temp[4]; + UINT i, j; + + TRACE("order %u, dir %p, rout %p, gout %p, bout %p\n", order, dir, rout, gout, bout); + + D3DXSHEvalDirection(temp, 2, dir); + + a[0] = (top.r + bottom.r) * 3.0f * D3DX_PI; + a[1] = (top.r - bottom.r) * D3DX_PI; + for (i = 0; i < order; i++) + for (j = 0; j < 2 * i + 1; j++) + if (i < 2) + rout[i * i + j] = temp[i * i + j] * a[i]; + else + rout[i * i + j] = 0.0f; + + if (gout) + { + a[0] = (top.g + bottom.g) * 3.0f * D3DX_PI; + a[1] = (top.g - bottom.g) * D3DX_PI; + for (i = 0; i < order; i++) + for (j = 0; j < 2 * i + 1; j++) + if (i < 2) + gout[i * i + j] = temp[i * i + j] * a[i]; + else + gout[i * i + j] = 0.0f; + } + + if (bout) + { + a[0] = (top.b + bottom.b) * 3.0f * D3DX_PI; + a[1] = (top.b - bottom.b) * D3DX_PI; + for (i = 0; i < order; i++) + for (j = 0; j < 2 * i + 1; j++) + if (i < 2) + bout[i * i + j] = temp[i * i + j] * a[i]; + else + bout[i * i + j] = 0.0f; + } + + return D3D_OK; +} + FLOAT * WINAPI D3DXSHMultiply2(FLOAT *out, const FLOAT *a, const FLOAT *b) { FLOAT ta, tb; diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c index c727c5f..e577e6f 100644 --- a/dlls/d3dx9_36/tests/math.c +++ b/dlls/d3dx9_36/tests/math.c @@ -2655,6 +2655,98 @@ static void test_D3DXSHEvalDirectionalLight(void) ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr); } +static void test_D3DXSHEvalHemisphereLight(void) +{ + D3DXCOLOR bottom, top; + D3DXVECTOR3 dir; + FLOAT *blue_out, bout[49], expected, gout[49], *green_out, *red_out, rout[49]; + const FLOAT table[] = { + /* Red colour */ + 23.422981f, 15.859521f, -36.476898f, 14.537894f, + /* Green colour */ + 19.966694f, 6.096982f, -14.023058f, 5.588900f, + /* Blue colour */ + 24.566214f, 8.546826f, -19.657701f, 7.834591f, }; + struct + { + FLOAT *red_in, *green_in, *blue_in; + const FLOAT *red_out, *green_out, *blue_out; + } test[] = + { { rout, gout, bout, table, &table[4], &table[8], }, + { rout, rout, rout, &table[8], &table[8], &table[8], }, + { rout, rout, bout, &table[4], &table[4], &table[8], }, + { rout, gout, gout, table, &table[8], &table[8], }, + { rout, gout, rout, &table[8], &table[4], &table[8], }, + /* D3DXSHEvalHemisphereLight accepts NULL green or blue colour. */ + { rout, NULL, bout, table, NULL, &table[8], }, + { rout, gout, NULL, table, &table[4], NULL, }, + { rout, NULL, NULL, table, NULL, NULL, }, }; + HRESULT hr; + unsigned int j, l, order; + + dir.x = 1.1f; dir.y = 1.2f; dir.z = 2.76f; + top.r = 0.1f; top.g = 2.1f; top.b = 2.3f; top.a = 4.3f; + bottom.r = 8.71f; bottom.g = 5.41f; bottom.b = 6.94f; bottom.a = 8.43f; + + for (l = 0; l < sizeof(test) / sizeof(test[0]); l++) + { + for (order = D3DXSH_MINORDER; order <= D3DXSH_MAXORDER + 1; order++) + { + red_out = test[l].red_in; + green_out = test[l].green_in; + blue_out = test[l].blue_in; + + for (j = 0; j < 49; j++) + { + red_out[j] = 1.01f + j; + if (green_out) + green_out[j] = 1.02f + j; + if (blue_out) + blue_out[j] = 1.03f + j; + } + + hr = D3DXSHEvalHemisphereLight(order, &dir, top, bottom, red_out, green_out, blue_out); + ok(hr == D3D_OK, "Expected %#x, got %#x\n", D3D_OK, hr); + + for (j = 0; j < 49; j++) + { + if ((j >= 4) && (j < order * order)) + expected = 0.0f; + else if (j >= order * order) + expected = test[l].red_in[j]; + else + expected = test[l].red_out[j]; + ok(relative_error(expected, red_out[j]) < admitted_error, + "Red: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, red_out[j]); + + if (green_out) + { + if ((j >= 4) && (j < order * order)) + expected = 0.0f; + else if (j >= order * order) + expected = test[l].green_in[j]; + else + expected = test[l].green_out[j]; + ok(relative_error(expected, green_out[j]) < admitted_error, + "Green: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, green_out[j]); + } + + if (blue_out) + { + if ((j >= 4) && (j < order * order)) + expected = 0.0f; + else if (j >= order * order) + expected = test[l].blue_in[j]; + else + expected = test[l].blue_out[j]; + ok(relative_error(expected, blue_out[j]) < admitted_error, + "Blue: case %u, order %u: expected[%u] = %f, received %f\n", l, order, j, expected, blue_out[j]); + } + } + } + } +} + static void test_D3DXSHMultiply2(void) { unsigned int i; @@ -2999,6 +3091,7 @@ START_TEST(math) test_D3DXSHDot(); test_D3DXSHEvalDirection(); test_D3DXSHEvalDirectionalLight(); + test_D3DXSHEvalHemisphereLight(); test_D3DXSHMultiply2(); test_D3DXSHMultiply3(); test_D3DXSHMultiply4(); diff --git a/dlls/d3dx9_37/d3dx9_37.spec b/dlls/d3dx9_37/d3dx9_37.spec index fd149ac..c8ba069 100644 --- a/dlls/d3dx9_37/d3dx9_37.spec +++ b/dlls/d3dx9_37/d3dx9_37.spec @@ -277,7 +277,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_38/d3dx9_38.spec b/dlls/d3dx9_38/d3dx9_38.spec index fd149ac..c8ba069 100644 --- a/dlls/d3dx9_38/d3dx9_38.spec +++ b/dlls/d3dx9_38/d3dx9_38.spec @@ -277,7 +277,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_39/d3dx9_39.spec b/dlls/d3dx9_39/d3dx9_39.spec index fd149ac..c8ba069 100644 --- a/dlls/d3dx9_39/d3dx9_39.spec +++ b/dlls/d3dx9_39/d3dx9_39.spec @@ -277,7 +277,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_40/d3dx9_40.spec b/dlls/d3dx9_40/d3dx9_40.spec index fd149ac..c8ba069 100644 --- a/dlls/d3dx9_40/d3dx9_40.spec +++ b/dlls/d3dx9_40/d3dx9_40.spec @@ -277,7 +277,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_41/d3dx9_41.spec b/dlls/d3dx9_41/d3dx9_41.spec index fd149ac..c8ba069 100644 --- a/dlls/d3dx9_41/d3dx9_41.spec +++ b/dlls/d3dx9_41/d3dx9_41.spec @@ -277,7 +277,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_42/d3dx9_42.spec b/dlls/d3dx9_42/d3dx9_42.spec index fd149ac..c8ba069 100644 --- a/dlls/d3dx9_42/d3dx9_42.spec +++ b/dlls/d3dx9_42/d3dx9_42.spec @@ -277,7 +277,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/dlls/d3dx9_43/d3dx9_43.spec b/dlls/d3dx9_43/d3dx9_43.spec index a803216..6a70cf3 100644 --- a/dlls/d3dx9_43/d3dx9_43.spec +++ b/dlls/d3dx9_43/d3dx9_43.spec @@ -270,7 +270,7 @@ @ stdcall D3DXSHEvalConeLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalConeLight @ stdcall D3DXSHEvalDirection(ptr long ptr) d3dx9_36.D3DXSHEvalDirection @ stdcall D3DXSHEvalDirectionalLight(long ptr float float float ptr ptr ptr) d3dx9_36.D3DXSHEvalDirectionalLight -@ stdcall D3DXSHEvalHemisphereLight(long ptr long long ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight +@ stdcall D3DXSHEvalHemisphereLight(long ptr int128 int128 ptr ptr ptr) d3dx9_36.D3DXSHEvalHemisphereLight @ stdcall D3DXSHEvalSphericalLight(long ptr long long long long ptr ptr ptr) d3dx9_36.D3DXSHEvalSphericalLight @ stdcall D3DXSHMultiply2(ptr ptr ptr) d3dx9_36.D3DXSHMultiply2 @ stdcall D3DXSHMultiply3(ptr ptr ptr) d3dx9_36.D3DXSHMultiply3 diff --git a/include/d3dx9math.h b/include/d3dx9math.h index 0f5dc7c..dca7ea5 100644 --- a/include/d3dx9math.h +++ b/include/d3dx9math.h @@ -381,6 +381,7 @@ 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 D3DXSHEvalDirection(FLOAT *out, UINT order, CONST D3DXVECTOR3 *dir); HRESULT WINAPI D3DXSHEvalDirectionalLight(UINT order, CONST D3DXVECTOR3 *dir, FLOAT Rintensity, FLOAT Gintensity, FLOAT Bintensity, FLOAT *rout, FLOAT *gout, FLOAT *bout); +HRESULT WINAPI D3DXSHEvalHemisphereLight(UINT order, CONST D3DXVECTOR3 *dir, D3DXCOLOR top, D3DXCOLOR bottom, FLOAT *rout, FLOAT *gout, FLOAT *bout); FLOAT* WINAPI D3DXSHMultiply2(FLOAT *out, CONST FLOAT *a, CONST FLOAT *b); FLOAT* WINAPI D3DXSHMultiply3(FLOAT *out, CONST FLOAT *a, CONST FLOAT *b); FLOAT* WINAPI D3DXSHMultiply4(FLOAT *out, CONST FLOAT *a, CONST FLOAT *b); -- 1.7.10.4