diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 249a15da7f4..ac6a33429bd 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1783,6 +1783,14 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, TRACE("... Range(%f), Falloff(%f), Theta(%f), Phi(%f)\n", light->range, light->falloff, light->theta, light->phi); + /* Update the live definitions if the light is currently assigned a glIndex. */ + if (object->glIndex != -1 && !device->isRecordingState) + { + if (object->OriginalParms.type != light->type) + device_invalidate_state(device, STATE_LIGHT_TYPE); + device_invalidate_state(device, STATE_ACTIVELIGHT(object->glIndex)); + } + /* Save away the information. */ object->OriginalParms = *light; @@ -1855,10 +1863,6 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, FIXME("Unrecognized light type %#x.\n", light->type); } - /* Update the live definitions if the light is currently assigned a glIndex. */ - if (object->glIndex != -1 && !device->isRecordingState) - device_invalidate_state(device, STATE_ACTIVELIGHT(object->glIndex)); - return WINED3D_OK; } @@ -1932,7 +1936,10 @@ HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UIN if (light_info->glIndex != -1) { if (!device->isRecordingState) + { + device_invalidate_state(device, STATE_LIGHT_TYPE); device_invalidate_state(device, STATE_ACTIVELIGHT(light_info->glIndex)); + } device->updateStateBlock->state.lights[light_info->glIndex] = NULL; light_info->glIndex = -1; @@ -1978,7 +1985,10 @@ HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UIN /* i == light_info->glIndex */ if (!device->isRecordingState) + { + device_invalidate_state(device, STATE_LIGHT_TYPE); device_invalidate_state(device, STATE_ACTIVELIGHT(i)); + } } } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index b46df8a5379..e85b57e3b95 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -6729,13 +6729,6 @@ static void glsl_vertex_pipe_shader(struct wined3d_context *context, context->select_shader = 1; } -static void glsl_vertex_pipe_light(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) -{ - light(context, state, state_id); - context->select_shader = 1; -} - static const struct StateEntryTemplate glsl_vertex_pipe_vp_states[] = { {STATE_VDECL, {STATE_VDECL, vertexdeclaration }, WINED3D_GL_EXT_NONE }, @@ -6776,14 +6769,15 @@ static const struct StateEntryTemplate glsl_vertex_pipe_vp_states[] = {STATE_CLIPPLANE(30), {STATE_CLIPPLANE(30), clipplane }, WINED3D_GL_EXT_NONE }, {STATE_CLIPPLANE(31), {STATE_CLIPPLANE(31), clipplane }, WINED3D_GL_EXT_NONE }, /* Lights */ - {STATE_ACTIVELIGHT(0), {STATE_ACTIVELIGHT(0), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, - {STATE_ACTIVELIGHT(1), {STATE_ACTIVELIGHT(1), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, - {STATE_ACTIVELIGHT(2), {STATE_ACTIVELIGHT(2), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, - {STATE_ACTIVELIGHT(3), {STATE_ACTIVELIGHT(3), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, - {STATE_ACTIVELIGHT(4), {STATE_ACTIVELIGHT(4), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, - {STATE_ACTIVELIGHT(5), {STATE_ACTIVELIGHT(5), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, - {STATE_ACTIVELIGHT(6), {STATE_ACTIVELIGHT(6), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, - {STATE_ACTIVELIGHT(7), {STATE_ACTIVELIGHT(7), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, + {STATE_LIGHT_TYPE, {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, + {STATE_ACTIVELIGHT(0), {STATE_ACTIVELIGHT(0), light }, WINED3D_GL_EXT_NONE }, + {STATE_ACTIVELIGHT(1), {STATE_ACTIVELIGHT(1), light }, WINED3D_GL_EXT_NONE }, + {STATE_ACTIVELIGHT(2), {STATE_ACTIVELIGHT(2), light }, WINED3D_GL_EXT_NONE }, + {STATE_ACTIVELIGHT(3), {STATE_ACTIVELIGHT(3), light }, WINED3D_GL_EXT_NONE }, + {STATE_ACTIVELIGHT(4), {STATE_ACTIVELIGHT(4), light }, WINED3D_GL_EXT_NONE }, + {STATE_ACTIVELIGHT(5), {STATE_ACTIVELIGHT(5), light }, WINED3D_GL_EXT_NONE }, + {STATE_ACTIVELIGHT(6), {STATE_ACTIVELIGHT(6), light }, WINED3D_GL_EXT_NONE }, + {STATE_ACTIVELIGHT(7), {STATE_ACTIVELIGHT(7), light }, WINED3D_GL_EXT_NONE }, /* Viewport */ {STATE_VIEWPORT, {STATE_VIEWPORT, viewport_vertexpart }, WINED3D_GL_EXT_NONE }, /* Transform states */ diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index c01f516792b..1204744e9d6 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -5167,6 +5167,7 @@ const struct StateEntryTemplate vp_ffp_states[] = { STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane }, WINED3D_GL_EXT_NONE }, { STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane }, WINED3D_GL_EXT_NONE }, /* Lights */ + { STATE_LIGHT_TYPE, { STATE_LIGHT_TYPE, state_nop }, WINED3D_GL_EXT_NONE }, { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light }, WINED3D_GL_EXT_NONE }, { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light }, WINED3D_GL_EXT_NONE }, { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light }, WINED3D_GL_EXT_NONE }, @@ -5862,6 +5863,7 @@ static void validate_state_table(struct StateEntry *state_table) STATE_GEOMETRY_SHADER, STATE_PIXELSHADER, STATE_VIEWPORT, + STATE_LIGHT_TYPE, STATE_SCISSORRECT, STATE_FRONTFACE, STATE_POINTSPRITECOORDORIGIN, diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 4f3ab2faf14..0442957f89e 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -2572,6 +2572,8 @@ const char *debug_d3dstate(DWORD state) return "STATE_VERTEXSHADERCONSTANT"; if (STATE_IS_PIXELSHADERCONSTANT(state)) return "STATE_PIXELSHADERCONSTANT"; + if (STATE_IS_LIGHT_TYPE(state)) + return "STATE_LIGHT_TYPE"; if (STATE_IS_ACTIVELIGHT(state)) return wine_dbg_sprintf("STATE_ACTIVELIGHT(%#x)", state - STATE_ACTIVELIGHT(0)); if (STATE_IS_SCISSORRECT(state)) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 55cfa9421f2..9e63f2cd000 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -983,7 +983,9 @@ extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC #define STATE_IS_VERTEXSHADERCONSTANT(a) ((a) == STATE_VERTEXSHADERCONSTANT) #define STATE_IS_PIXELSHADERCONSTANT(a) ((a) == STATE_PIXELSHADERCONSTANT) -#define STATE_ACTIVELIGHT(a) (STATE_PIXELSHADERCONSTANT + (a) + 1) +#define STATE_LIGHT_TYPE (STATE_PIXELSHADERCONSTANT + 1) +#define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE) +#define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a)) #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS)) #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS - 1) + 1)