From: Elizabeth Figura zfigura@codeweavers.com
We still need CS-side light state for the light type... --- dlls/wined3d/cs.c | 6 ------ dlls/wined3d/glsl_shader.c | 26 ++++++-------------------- dlls/wined3d/stateblock.c | 5 +++++ dlls/wined3d/utils.c | 2 -- dlls/wined3d/wined3d_private.h | 5 ++--- 5 files changed, 13 insertions(+), 31 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index c5e9d3edcb5..f7f8021e8ba 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2061,7 +2061,6 @@ static void wined3d_cs_exec_set_light(struct wined3d_cs *cs, const void *data) { if (light_info->OriginalParms.type != op->light.OriginalParms.type) device_invalidate_state(cs->c.device, STATE_LIGHT_TYPE); - device_invalidate_state(cs->c.device, STATE_ACTIVELIGHT(light_info->glIndex)); }
light_info->OriginalParms = op->light.OriginalParms; @@ -2085,7 +2084,6 @@ static void wined3d_cs_exec_set_light_enable(struct wined3d_cs *cs, const void * const struct wined3d_cs_set_light_enable *op = data; struct wined3d_device *device = cs->c.device; struct wined3d_light_info *light_info; - int prev_idx;
if (!(light_info = wined3d_light_state_get_light(&cs->state.light_state, op->idx))) { @@ -2093,12 +2091,8 @@ static void wined3d_cs_exec_set_light_enable(struct wined3d_cs *cs, const void * return; }
- prev_idx = light_info->glIndex; if (wined3d_light_state_enable_light(&cs->state.light_state, &device->adapter->d3d_info, light_info, op->enable)) - { device_invalidate_state(device, STATE_LIGHT_TYPE); - device_invalidate_state(device, STATE_ACTIVELIGHT(op->enable ? light_info->glIndex : prev_idx)); - } }
void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context *context, unsigned int idx, BOOL enable) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index c7a2f9cd393..cad4bb0f9e6 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1536,10 +1536,9 @@ static void shader_glsl_ffp_vertex_material_uniform(const struct wined3d_context }
static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl *context_gl, - const struct wined3d_state *state, unsigned int light, const struct wined3d_light_info *light_info, - struct glsl_shader_prog_link *prog) + const struct wined3d_state *state, unsigned int light, enum wined3d_light_type type, + const struct wined3d_light_constants *constants, struct glsl_shader_prog_link *prog) { - const struct wined3d_light_constants *constants = &light_info->constants; const struct wined3d_matrix *view = &state->transforms[WINED3D_TS_VIEW]; const struct wined3d_gl_info *gl_info = context_gl->gl_info; struct wined3d_vec4 vec4; @@ -1548,7 +1547,7 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].specular, 1, &constants->specular.r)); GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].ambient, 1, &constants->ambient.r));
- switch (light_info->OriginalParms.type) + switch (type) { case WINED3D_LIGHT_POINT: wined3d_vec4_transform(&vec4, &constants->position, view); @@ -1586,7 +1585,7 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl break;
default: - FIXME("Unrecognized light type %#x.\n", light_info->OriginalParms.type); + FIXME("Unrecognized light type %#x.\n", type); } checkGLcall("setting FFP lights uniforms"); } @@ -1834,7 +1833,8 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, FIXME("Unhandled light type %#x.\n", light_info->OriginalParms.type); continue; } - shader_glsl_ffp_vertex_light_uniform(context_gl, state, idx, light_info, prog); + shader_glsl_ffp_vertex_light_uniform(context_gl, state, idx, + light_info->OriginalParms.type, &constants->light.lights[i], prog); } }
@@ -11937,12 +11937,6 @@ static void glsl_vertex_pipe_material(struct wined3d_context *context, context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_MATERIAL; }
-static void glsl_vertex_pipe_light(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) -{ - context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_LIGHTS; -} - static void glsl_vertex_pipe_pointsize(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { @@ -12012,14 +12006,6 @@ static const struct wined3d_state_entry_template glsl_vertex_pipe_vp_states[] = {STATE_CLIPPLANE(7), {STATE_CLIPPLANE(7), clipplane }, WINED3D_GL_EXT_NONE }, /* Lights */ {STATE_LIGHT_TYPE, {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, - {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 }, /* Viewport */ {STATE_VIEWPORT, {STATE_VIEWPORT, glsl_vertex_pipe_viewport}, WINED3D_GL_EXT_NONE }, /* Transform states */ diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index fbe9d94e813..05ce6067d16 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -3358,6 +3358,11 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, }
wined3d_color_from_d3dcolor(&constants.ambient, state->rs[WINED3D_RS_AMBIENT]); + for (unsigned int i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i) + { + if (state->light_state->lights[i]) + constants.lights[i] = state->light_state->lights[i]->constants; + } wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_FFP_LIGHTS, offsetof(struct wined3d_ffp_vs_constants, light), sizeof(constants), &constants); } diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index c43995b06ea..71b629da50e 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5365,8 +5365,6 @@ const char *debug_d3dstate(uint32_t state) return "STATE_VIEWPORT"; 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)) return "STATE_SCISSORRECT"; if (STATE_IS_CLIPPLANE(state)) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 256dbc75f22..c8b437aa524 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1750,10 +1750,8 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state
#define STATE_LIGHT_TYPE (STATE_VIEWPORT + 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(WINED3D_MAX_ACTIVE_LIGHTS))
-#define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1) +#define STATE_SCISSORRECT (STATE_LIGHT_TYPE + 1) #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
#define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a)) @@ -2776,6 +2774,7 @@ struct wined3d_ffp_vs_constants struct wined3d_ffp_light_constants { struct wined3d_color ambient; + struct wined3d_light_constants lights[8]; } light; };