[PATCH 2/4] wined3d: Move light state to wined3d_state.
Henri Verbeet
hverbeet at codeweavers.com
Tue Sep 21 14:20:54 CDT 2010
---
dlls/wined3d/device.c | 18 +++++++++---------
dlls/wined3d/state.c | 4 ++--
dlls/wined3d/stateblock.c | 24 +++++++++++++-----------
dlls/wined3d/wined3d_private.h | 12 ++++++------
4 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index c7dbe04..289c2a4 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2546,7 +2546,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I
return WINED3DERR_INVALIDCALL;
}
- LIST_FOR_EACH(e, &This->updateStateBlock->lightMap[Hi])
+ LIST_FOR_EACH(e, &This->updateStateBlock->state.light_map[Hi])
{
object = LIST_ENTRY(e, struct wined3d_light_info, entry);
if(object->OriginalIndex == Index) break;
@@ -2560,7 +2560,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I
ERR("Out of memory error when allocating a light\n");
return E_OUTOFMEMORY;
}
- list_add_head(&This->updateStateBlock->lightMap[Hi], &object->entry);
+ list_add_head(&This->updateStateBlock->state.light_map[Hi], &object->entry);
object->glIndex = -1;
object->OriginalIndex = Index;
}
@@ -2659,7 +2659,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetLight(IWineD3DDevice *iface, DWORD I
struct list *e;
TRACE("(%p) : Idx(%d), pLight(%p)\n", This, Index, pLight);
- LIST_FOR_EACH(e, &This->stateBlock->lightMap[Hi])
+ LIST_FOR_EACH(e, &This->stateBlock->state.light_map[Hi])
{
lightInfo = LIST_ENTRY(e, struct wined3d_light_info, entry);
if(lightInfo->OriginalIndex == Index) break;
@@ -2688,7 +2688,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, D
struct list *e;
TRACE("(%p) : Idx(%d), enable? %d\n", This, Index, Enable);
- LIST_FOR_EACH(e, &This->updateStateBlock->lightMap[Hi])
+ LIST_FOR_EACH(e, &This->updateStateBlock->state.light_map[Hi])
{
lightInfo = LIST_ENTRY(e, struct wined3d_light_info, entry);
if(lightInfo->OriginalIndex == Index) break;
@@ -2703,7 +2703,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, D
IWineD3DDeviceImpl_SetLight(iface, Index, &WINED3D_default_light);
/* Search for it again! Should be fairly quick as near head of list */
- LIST_FOR_EACH(e, &This->updateStateBlock->lightMap[Hi])
+ LIST_FOR_EACH(e, &This->updateStateBlock->state.light_map[Hi])
{
lightInfo = LIST_ENTRY(e, struct wined3d_light_info, entry);
if(lightInfo->OriginalIndex == Index) break;
@@ -2722,7 +2722,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, D
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(lightInfo->glIndex));
}
- This->updateStateBlock->activeLights[lightInfo->glIndex] = NULL;
+ This->updateStateBlock->state.lights[lightInfo->glIndex] = NULL;
lightInfo->glIndex = -1;
} else {
TRACE("Light already disabled, nothing to do\n");
@@ -2738,9 +2738,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, D
/* Find a free gl light */
for (i = 0; i < This->maxConcurrentLights; ++i)
{
- if (!This->updateStateBlock->activeLights[i])
+ if (!This->updateStateBlock->state.lights[i])
{
- This->updateStateBlock->activeLights[i] = lightInfo;
+ This->updateStateBlock->state.lights[i] = lightInfo;
lightInfo->glIndex = i;
break;
}
@@ -2775,7 +2775,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetLightEnable(IWineD3DDevice *iface, D
UINT Hi = LIGHTMAP_HASHFUNC(Index);
TRACE("(%p) : for idx(%d)\n", This, Index);
- LIST_FOR_EACH(e, &This->stateBlock->lightMap[Hi])
+ LIST_FOR_EACH(e, &This->stateBlock->state.light_map[Hi])
{
lightInfo = LIST_ENTRY(e, struct wined3d_light_info, entry);
if(lightInfo->OriginalIndex == Index) break;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 5f732f9..f7072f5 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3938,7 +3938,7 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
/* Reset lights. TODO: Call light apply func */
for (k = 0; k < stateblock->device->maxConcurrentLights; ++k)
{
- light = stateblock->activeLights[k];
+ light = stateblock->state.lights[k];
if(!light) continue;
glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn);
checkGLcall("glLightfv posn");
@@ -4812,7 +4812,7 @@ static void viewport_vertexpart(DWORD state, IWineD3DStateBlockImpl *stateblock,
static void light(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
UINT Index = state - STATE_ACTIVELIGHT(0);
- const struct wined3d_light_info *lightInfo = stateblock->activeLights[Index];
+ const struct wined3d_light_info *lightInfo = stateblock->state.lights[Index];
if(!lightInfo) {
glDisable(GL_LIGHT0 + Index);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 82e6081..c8152c8 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -452,7 +452,7 @@ static void stateblock_init_lights(IWineD3DStateBlockImpl *stateblock, struct li
struct wined3d_light_info *dst_light = HeapAlloc(GetProcessHeap(), 0, sizeof(*dst_light));
*dst_light = *src_light;
- list_add_tail(&stateblock->lightMap[i], &dst_light->entry);
+ list_add_tail(&stateblock->state.light_map[i], &dst_light->entry);
}
}
}
@@ -518,7 +518,7 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
for(counter = 0; counter < LIGHTMAP_SIZE; counter++) {
struct list *e1, *e2;
- LIST_FOR_EACH_SAFE(e1, e2, &This->lightMap[counter])
+ LIST_FOR_EACH_SAFE(e1, e2, &This->state.light_map[counter])
{
struct wined3d_light_info *light = LIST_ENTRY(e1, struct wined3d_light_info, entry);
list_remove(&light->entry);
@@ -549,12 +549,14 @@ static void record_lights(IWineD3DStateBlockImpl *This, const IWineD3DStateBlock
*/
for(i = 0; i < LIGHTMAP_SIZE; i++) {
struct list *e, *f;
- LIST_FOR_EACH(e, &This->lightMap[i]) {
+ LIST_FOR_EACH(e, &This->state.light_map[i])
+ {
BOOL updated = FALSE;
struct wined3d_light_info *src = LIST_ENTRY(e, struct wined3d_light_info, entry), *realLight;
/* Look up the light in the destination */
- LIST_FOR_EACH(f, &targetStateBlock->lightMap[i]) {
+ LIST_FOR_EACH(f, &targetStateBlock->state.light_map[i])
+ {
realLight = LIST_ENTRY(f, struct wined3d_light_info, entry);
if (realLight->OriginalIndex == src->OriginalIndex)
{
@@ -563,12 +565,12 @@ static void record_lights(IWineD3DStateBlockImpl *This, const IWineD3DStateBlock
if (realLight->glIndex == -1 && src->glIndex != -1)
{
/* Light disabled */
- This->activeLights[src->glIndex] = NULL;
+ This->state.lights[src->glIndex] = NULL;
}
else if (realLight->glIndex != -1 && src->glIndex == -1)
{
/* Light enabled */
- This->activeLights[realLight->glIndex] = src;
+ This->state.lights[realLight->glIndex] = src;
}
src->glIndex = realLight->glIndex;
updated = TRUE;
@@ -586,7 +588,7 @@ static void record_lights(IWineD3DStateBlockImpl *This, const IWineD3DStateBlock
src->OriginalParms = WINED3D_default_light;
if (src->glIndex != -1)
{
- This->activeLights[src->glIndex] = NULL;
+ This->state.lights[src->glIndex] = NULL;
src->glIndex = -1;
}
}
@@ -896,7 +898,7 @@ static void apply_lights(IWineD3DDevice *device, const IWineD3DStateBlockImpl *T
for(i = 0; i < LIGHTMAP_SIZE; i++) {
struct list *e;
- LIST_FOR_EACH(e, &This->lightMap[i])
+ LIST_FOR_EACH(e, &This->state.light_map[i])
{
const struct wined3d_light_info *light = LIST_ENTRY(e, struct wined3d_light_info, entry);
@@ -1371,7 +1373,7 @@ HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *
for (i = 0; i < LIGHTMAP_SIZE; i++)
{
- list_init(&stateblock->lightMap[i]);
+ list_init(&stateblock->state.light_map[i]);
}
hr = stateblock_allocate_shader_constants(stateblock);
@@ -1387,7 +1389,7 @@ HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *
switch (type)
{
case WINED3DSBT_ALL:
- stateblock_init_lights(stateblock, device->stateBlock->lightMap);
+ stateblock_init_lights(stateblock, device->stateBlock->state.light_map);
stateblock_savedstates_set_all(&stateblock->changed, device->d3d_vshader_constantF,
device->d3d_pshader_constantF);
break;
@@ -1397,7 +1399,7 @@ HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *
break;
case WINED3DSBT_VERTEXSTATE:
- stateblock_init_lights(stateblock, device->stateBlock->lightMap);
+ stateblock_init_lights(stateblock, device->stateBlock->state.light_map);
stateblock_savedstates_set_vertex(&stateblock->changed, device->d3d_vshader_constantF);
break;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index bc6a1a9..01c8469 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2378,6 +2378,12 @@ struct wined3d_state
WINED3DVIEWPORT viewport;
RECT scissor_rect;
+ /* Light hashmap . Collisions are handled using standard wine double linked lists */
+#define LIGHTMAP_SIZE 43 /* Use of a prime number recommended. Set to 1 for a linked list! */
+#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE) /* Primitive and simple function */
+ struct list light_map[LIGHTMAP_SIZE]; /* Hash map containing the lights */
+ const struct wined3d_light_info *lights[MAX_ACTIVE_LIGHTS]; /* Map of opengl lights to d3d lights */
+
DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
};
@@ -2395,12 +2401,6 @@ struct IWineD3DStateBlockImpl
SAVEDSTATES changed;
struct wined3d_state state;
- /* Light hashmap . Collisions are handled using standard wine double linked lists */
-#define LIGHTMAP_SIZE 43 /* Use of a prime number recommended. Set to 1 for a linked list! */
-#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE) /* Primitive and simple function */
- struct list lightMap[LIGHTMAP_SIZE]; /* Hash map containing the lights */
- const struct wined3d_light_info *activeLights[MAX_ACTIVE_LIGHTS]; /* Map of opengl lights to d3d lights */
-
/* Clipping */
double clipplane[MAX_CLIPPLANES][4];
WINED3DCLIPSTATUS clip_status;
--
1.7.2.2
More information about the wine-patches
mailing list