summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/nine/device9.c
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2016-10-19 23:29:58 +0200
committerAxel Davy <[email protected]>2016-12-20 23:44:22 +0100
commitcbe370020e4e2b6293230bf0908f3f199c2468eb (patch)
tree46b983e4c2dbc0da25b9ee31a6f66f342fe1c9cf /src/gallium/state_trackers/nine/device9.c
parentc5af96aebd2be165e29124c1e5d5bb3b7021bb30 (diff)
st/nine: Refactor SetLight
Call a helper function to set the light. Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine/device9.c')
-rw-r--r--src/gallium/state_trackers/nine/device9.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 2587ad1d7ae..74c1bea7857 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2073,6 +2073,7 @@ NineDevice9_SetLight( struct NineDevice9 *This,
const D3DLIGHT9 *pLight )
{
struct nine_state *state = This->update;
+ HRESULT hr;
DBG("This=%p Index=%u pLight=%p\n", This, Index, pLight);
if (pLight)
@@ -2083,27 +2084,10 @@ NineDevice9_SetLight( struct NineDevice9 *This,
user_assert(Index < NINE_MAX_LIGHTS, D3DERR_INVALIDCALL); /* sanity */
- if (Index >= state->ff.num_lights) {
- unsigned n = state->ff.num_lights;
- unsigned N = Index + 1;
-
- state->ff.light = REALLOC(state->ff.light, n * sizeof(D3DLIGHT9),
- N * sizeof(D3DLIGHT9));
- if (!state->ff.light)
- return E_OUTOFMEMORY;
- state->ff.num_lights = N;
-
- for (; n < Index; ++n) {
- memset(&state->ff.light[n], 0, sizeof(D3DLIGHT9));
- state->ff.light[n].Type = (D3DLIGHTTYPE)NINED3DLIGHT_INVALID;
- }
- }
- state->ff.light[Index] = *pLight;
+ hr = nine_state_set_light(&state->ff, Index, pLight);
+ if (hr != D3D_OK)
+ return hr;
- if (pLight->Type == D3DLIGHT_SPOT && pLight->Theta >= pLight->Phi) {
- DBG("Warning: clamping D3DLIGHT9.Theta\n");
- state->ff.light[Index].Theta = state->ff.light[Index].Phi;
- }
if (pLight->Type != D3DLIGHT_DIRECTIONAL &&
pLight->Attenuation0 == 0.0f &&
pLight->Attenuation1 == 0.0f &&