From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/ddraw/surface.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 203f02bbd2d..179262a629e 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -4706,12 +4706,20 @@ static HRESULT WINAPI ddraw_surface1_SetClipper(IDirectDrawSurface *iface, IDire static HRESULT ddraw_surface_set_wined3d_textures_colour_key(struct ddraw_surface *surface, DWORD flags, struct wined3d_color_key *color_key) { + struct d3d_device *device; HRESULT hr;
hr = wined3d_texture_set_color_key(surface->wined3d_texture, flags, color_key); if (surface->draw_texture && SUCCEEDED(hr)) hr = wined3d_texture_set_color_key(surface->draw_texture, flags, color_key);
+ LIST_FOR_EACH_ENTRY(device, &surface->ddraw->d3ddevice_list, struct d3d_device, ddraw_entry) + { + wined3d_stateblock_texture_changed(device->state, surface->wined3d_texture); + if (surface->draw_texture) + wined3d_stateblock_texture_changed(device->state, surface->draw_texture); + } + return hr; }
From: Elizabeth Figura zfigura@codeweavers.com
Preparation for storing just this structure in the push constant buffer. --- dlls/wined3d/cs.c | 3 +- dlls/wined3d/device.c | 10 +++---- dlls/wined3d/glsl_shader.c | 39 ++++++++++++------------ dlls/wined3d/stateblock.c | 55 +++++++++++++++++++++------------- dlls/wined3d/wined3d_private.h | 13 ++++++-- 5 files changed, 71 insertions(+), 49 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 275941dd183..c5e9d3edcb5 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2065,8 +2065,7 @@ static void wined3d_cs_exec_set_light(struct wined3d_cs *cs, const void *data) }
light_info->OriginalParms = op->light.OriginalParms; - light_info->position = op->light.position; - light_info->direction = op->light.direction; + light_info->constants = op->light.constants; }
void wined3d_device_context_emit_set_light(struct wined3d_device_context *context, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e445679ec2f..a2ca7ddc848 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2999,7 +2999,7 @@ static void init_transformed_lights(struct lights_settings *ls, continue;
light = &ls->lights[index]; - wined3d_vec4_transform(&vec4, &light_info->direction, &state->transforms[WINED3D_TS_VIEW]); + wined3d_vec4_transform(&vec4, &light_info->constants.direction, &state->transforms[WINED3D_TS_VIEW]); light->direction = *(struct wined3d_vec3 *)&vec4; wined3d_vec3_normalise(&light->direction);
@@ -3017,7 +3017,7 @@ static void init_transformed_lights(struct lights_settings *ls,
light = &ls->lights[index];
- wined3d_vec4_transform(&light->position, &light_info->position, &state->transforms[WINED3D_TS_VIEW]); + wined3d_vec4_transform(&light->position, &light_info->constants.position, &state->transforms[WINED3D_TS_VIEW]); light->range = light_info->OriginalParms.range; light->c_att = light_info->OriginalParms.attenuation0; light->l_att = light_info->OriginalParms.attenuation1; @@ -3037,8 +3037,8 @@ static void init_transformed_lights(struct lights_settings *ls,
light = &ls->lights[index];
- wined3d_vec4_transform(&light->position, &light_info->position, &state->transforms[WINED3D_TS_VIEW]); - wined3d_vec4_transform(&vec4, &light_info->direction, &state->transforms[WINED3D_TS_VIEW]); + wined3d_vec4_transform(&light->position, &light_info->constants.position, &state->transforms[WINED3D_TS_VIEW]); + wined3d_vec4_transform(&vec4, &light_info->constants.direction, &state->transforms[WINED3D_TS_VIEW]); light->direction = *(struct wined3d_vec3 *)&vec4; wined3d_vec3_normalise(&light->direction); light->range = light_info->OriginalParms.range; @@ -3063,7 +3063,7 @@ static void init_transformed_lights(struct lights_settings *ls,
light = &ls->lights[index];
- wined3d_vec4_transform(&vec4, &light_info->position, &state->transforms[WINED3D_TS_VIEW]); + wined3d_vec4_transform(&vec4, &light_info->constants.position, &state->transforms[WINED3D_TS_VIEW]); *(struct wined3d_vec3 *)&light->position = *(struct wined3d_vec3 *)&vec4; wined3d_vec3_normalise((struct wined3d_vec3 *)&light->position); light->diffuse = light_info->OriginalParms.diffuse; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index c0d75897857..67fb41d862a 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1539,48 +1539,49 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_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_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;
- GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].diffuse, 1, &light_info->OriginalParms.diffuse.r)); - GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].specular, 1, &light_info->OriginalParms.specular.r)); - GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].ambient, 1, &light_info->OriginalParms.ambient.r)); + GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].diffuse, 1, &constants->diffuse.r)); + 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) { case WINED3D_LIGHT_POINT: - wined3d_vec4_transform(&vec4, &light_info->position, view); + wined3d_vec4_transform(&vec4, &constants->position, view); GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &vec4.x)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].range, light_info->OriginalParms.range)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].c_att, light_info->OriginalParms.attenuation0)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].l_att, light_info->OriginalParms.attenuation1)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].q_att, light_info->OriginalParms.attenuation2)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].range, constants->range)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].c_att, constants->const_att)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].l_att, constants->linear_att)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].q_att, constants->quad_att)); break;
case WINED3D_LIGHT_SPOT: - wined3d_vec4_transform(&vec4, &light_info->position, view); + wined3d_vec4_transform(&vec4, &constants->position, view); GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &vec4.x));
- wined3d_vec4_transform(&vec4, &light_info->direction, view); + wined3d_vec4_transform(&vec4, &constants->direction, view); GL_EXTCALL(glUniform3fv(prog->vs.light_location[light].direction, 1, &vec4.x));
- GL_EXTCALL(glUniform1f(prog->vs.light_location[light].range, light_info->OriginalParms.range)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].falloff, light_info->OriginalParms.falloff)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].c_att, light_info->OriginalParms.attenuation0)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].l_att, light_info->OriginalParms.attenuation1)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].q_att, light_info->OriginalParms.attenuation2)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].cos_htheta, cosf(light_info->OriginalParms.theta / 2.0f))); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].cos_hphi, cosf(light_info->OriginalParms.phi / 2.0f))); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].range, constants->range)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].falloff, constants->falloff)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].c_att, constants->const_att)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].l_att, constants->linear_att)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].q_att, constants->quad_att)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].cos_htheta, cosf(constants->theta / 2.0f))); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].cos_hphi, cosf(constants->phi / 2.0f))); break;
case WINED3D_LIGHT_DIRECTIONAL: - wined3d_vec4_transform(&vec4, &light_info->direction, view); + wined3d_vec4_transform(&vec4, &constants->direction, view); GL_EXTCALL(glUniform3fv(prog->vs.light_location[light].direction, 1, &vec4.x)); break;
case WINED3D_LIGHT_PARALLELPOINT: - wined3d_vec4_transform(&vec4, &light_info->position, view); + wined3d_vec4_transform(&vec4, &constants->position, view); GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &vec4.x)); break;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 548bf9aa477..f92ab4b4961 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -661,6 +661,7 @@ static void set_light_changed(struct wined3d_stateblock *stateblock, struct wine static HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, unsigned int light_idx, const struct wined3d_light *params, struct wined3d_light_info **light_info) { + struct wined3d_light_constants *constants; struct wined3d_light_info *object;
if (!(object = wined3d_light_state_get_light(state, light_idx))) @@ -677,6 +678,8 @@ static HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, rb_put(&state->lights_tree, (void *)(ULONG_PTR)light_idx, &object->entry); }
+ constants = &object->constants; + object->OriginalParms = *params;
/* Initialize the object. */ @@ -689,46 +692,58 @@ static HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, params->direction.x, params->direction.y, params->direction.z, params->range, params->falloff, params->theta, params->phi);
+ constants->diffuse = params->diffuse; + constants->specular = params->specular; + constants->ambient = params->ambient; + + constants->range = params->range; + constants->falloff = params->falloff; + constants->const_att = params->attenuation0; + constants->linear_att = params->attenuation1; + constants->quad_att = params->attenuation2; + constants->theta = params->theta; + constants->phi = params->phi; + switch (params->type) { case WINED3D_LIGHT_POINT: /* Position */ - object->position.x = params->position.x; - object->position.y = params->position.y; - object->position.z = params->position.z; - object->position.w = 1.0f; + constants->position.x = params->position.x; + constants->position.y = params->position.y; + constants->position.z = params->position.z; + constants->position.w = 1.0f; /* FIXME: Range */ break;
case WINED3D_LIGHT_DIRECTIONAL: /* Direction */ - object->direction.x = -params->direction.x; - object->direction.y = -params->direction.y; - object->direction.z = -params->direction.z; - object->direction.w = 0.0f; + constants->direction.x = -params->direction.x; + constants->direction.y = -params->direction.y; + constants->direction.z = -params->direction.z; + constants->direction.w = 0.0f; break;
case WINED3D_LIGHT_SPOT: /* Position */ - object->position.x = params->position.x; - object->position.y = params->position.y; - object->position.z = params->position.z; - object->position.w = 1.0f; + constants->position.x = params->position.x; + constants->position.y = params->position.y; + constants->position.z = params->position.z; + constants->position.w = 1.0f;
/* Direction */ - object->direction.x = params->direction.x; - object->direction.y = params->direction.y; - object->direction.z = params->direction.z; - object->direction.w = 0.0f; + constants->direction.x = params->direction.x; + constants->direction.y = params->direction.y; + constants->direction.z = params->direction.z; + constants->direction.w = 0.0f;
/* FIXME: Range */ break;
case WINED3D_LIGHT_PARALLELPOINT: - object->position.x = params->position.x; - object->position.y = params->position.y; - object->position.z = params->position.z; - object->position.w = 1.0f; + constants->position.x = params->position.x; + constants->position.y = params->position.y; + constants->position.z = params->position.z; + constants->position.w = 1.0f; break;
default: diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9ad1d0f8ba5..9580406ce3a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2064,6 +2064,14 @@ void context_state_drawbuf(struct wined3d_context *context, void context_state_fb(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id);
+struct wined3d_light_constants +{ + struct wined3d_color diffuse, specular, ambient; + struct wined3d_vec4 position, direction; + float range, falloff, theta, phi; + float const_att, linear_att, quad_att; +}; + /***************************************************************************** * Internal representation of a light */ @@ -2074,9 +2082,8 @@ struct wined3d_light_info LONG glIndex; BOOL enabled;
- /* Converted parms to speed up swapping lights */ - struct wined3d_vec4 position; - struct wined3d_vec4 direction; + /* Computed constants used by the vertex pipe. */ + struct wined3d_light_constants constants;
struct rb_entry entry; struct list changed_entry;
From: Elizabeth Figura zfigura@codeweavers.com
Since the goal is to use the constant buffer uninterpreted, this means we need to perform any transformations not performed by the shader *before* uploading the constants. --- dlls/wined3d/glsl_shader.c | 4 ++-- dlls/wined3d/stateblock.c | 4 ++-- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 67fb41d862a..c7a2f9cd393 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1571,8 +1571,8 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl GL_EXTCALL(glUniform1f(prog->vs.light_location[light].c_att, constants->const_att)); GL_EXTCALL(glUniform1f(prog->vs.light_location[light].l_att, constants->linear_att)); GL_EXTCALL(glUniform1f(prog->vs.light_location[light].q_att, constants->quad_att)); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].cos_htheta, cosf(constants->theta / 2.0f))); - GL_EXTCALL(glUniform1f(prog->vs.light_location[light].cos_hphi, cosf(constants->phi / 2.0f))); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].cos_htheta, constants->cos_half_theta)); + GL_EXTCALL(glUniform1f(prog->vs.light_location[light].cos_hphi, constants->cos_half_phi)); break;
case WINED3D_LIGHT_DIRECTIONAL: diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index f92ab4b4961..fbe9d94e813 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -701,8 +701,8 @@ static HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, constants->const_att = params->attenuation0; constants->linear_att = params->attenuation1; constants->quad_att = params->attenuation2; - constants->theta = params->theta; - constants->phi = params->phi; + constants->cos_half_theta = cosf(params->theta / 2.0f); + constants->cos_half_phi = cosf(params->phi / 2.0f);
switch (params->type) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9580406ce3a..256dbc75f22 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2068,7 +2068,7 @@ struct wined3d_light_constants { struct wined3d_color diffuse, specular, ambient; struct wined3d_vec4 position, direction; - float range, falloff, theta, phi; + float range, falloff, cos_half_theta, cos_half_phi; float const_att, linear_att, quad_att; };
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; };
From: Elizabeth Figura zfigura@codeweavers.com
As is done in the GLSL backend.
Eventually we will stop manually calculating light counts in each individual place, and instead retrieve that from a stored struct wined3d_ffp_vs_settings. --- dlls/wined3d/glsl_shader.c | 48 +++++++++---------------------- dlls/wined3d/stateblock.c | 59 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 36 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index cad4bb0f9e6..ecc9dcd2ef5 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1768,11 +1768,11 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv,
if (update_mask & WINED3D_SHADER_CONST_FFP_LIGHTS) { - unsigned int point_idx, spot_idx, directional_idx, parallel_point_idx; const struct wined3d_ffp_vs_constants *constants; DWORD point_count = 0; DWORD spot_count = 0; DWORD directional_count = 0; + DWORD parallel_point_count = 0;
constants = wined3d_buffer_load_sysmem(context->device->push_constants[WINED3D_PUSH_CONSTANTS_VS_FFP], context);
@@ -1793,49 +1793,29 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, ++directional_count; break; case WINED3D_LIGHT_PARALLELPOINT: + ++parallel_point_count; break; default: FIXME("Unhandled light type %#x.\n", state->light_state.lights[i]->OriginalParms.type); break; } } - point_idx = 0; - spot_idx = point_idx + point_count; - directional_idx = spot_idx + spot_count; - parallel_point_idx = directional_idx + directional_count;
GL_EXTCALL(glUniform3fv(prog->vs.light_ambient_location, 1, &constants->light.ambient.r)); checkGLcall("glUniform3fv");
- for (i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i) - { - const struct wined3d_light_info *light_info = state->light_state.lights[i]; - unsigned int idx; - - if (!light_info) - continue; - - switch (light_info->OriginalParms.type) - { - case WINED3D_LIGHT_POINT: - idx = point_idx++; - break; - case WINED3D_LIGHT_SPOT: - idx = spot_idx++; - break; - case WINED3D_LIGHT_DIRECTIONAL: - idx = directional_idx++; - break; - case WINED3D_LIGHT_PARALLELPOINT: - idx = parallel_point_idx++; - break; - default: - FIXME("Unhandled light type %#x.\n", light_info->OriginalParms.type); - continue; - } - shader_glsl_ffp_vertex_light_uniform(context_gl, state, idx, - light_info->OriginalParms.type, &constants->light.lights[i], prog); - } + for (i = 0; i < point_count; ++i) + shader_glsl_ffp_vertex_light_uniform(context_gl, state, i, + WINED3D_LIGHT_POINT, &constants->light.lights[i], prog); + for (; i < point_count + spot_count; ++i) + shader_glsl_ffp_vertex_light_uniform(context_gl, state, i, + WINED3D_LIGHT_SPOT, &constants->light.lights[i], prog); + for (; i < point_count + spot_count + directional_count; ++i) + shader_glsl_ffp_vertex_light_uniform(context_gl, state, i, + WINED3D_LIGHT_DIRECTIONAL, &constants->light.lights[i], prog); + for (; i < point_count + spot_count + directional_count + parallel_point_count; ++i) + shader_glsl_ffp_vertex_light_uniform(context_gl, state, i, + WINED3D_LIGHT_PARALLELPOINT, &constants->light.lights[i], prog); }
if (update_mask & WINED3D_SHADER_CONST_PS_F) diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 05ce6067d16..244d31e5d81 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -3346,6 +3346,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
if (changed->lights) { + unsigned int point_idx, spot_idx, directional_idx, parallel_point_idx; + unsigned int point_count = 0, spot_count = 0, directional_count = 0; struct wined3d_ffp_light_constants constants; struct wined3d_light_info *light, *cursor;
@@ -3358,11 +3360,64 @@ 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]) + continue; + + switch (state->light_state->lights[i]->OriginalParms.type) + { + case WINED3D_LIGHT_POINT: + ++point_count; + break; + case WINED3D_LIGHT_SPOT: + ++spot_count; + break; + case WINED3D_LIGHT_DIRECTIONAL: + ++directional_count; + break; + case WINED3D_LIGHT_PARALLELPOINT: + break; + default: + FIXME("Unhandled light type %#x.\n", state->light_state->lights[i]->OriginalParms.type); + break; + } + } + point_idx = 0; + spot_idx = point_idx + point_count; + directional_idx = spot_idx + spot_count; + parallel_point_idx = directional_idx + directional_count; + 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; + const struct wined3d_light_info *light_info = state->light_state->lights[i]; + unsigned int idx; + + if (!light_info) + continue; + + switch (light_info->OriginalParms.type) + { + case WINED3D_LIGHT_POINT: + idx = point_idx++; + break; + case WINED3D_LIGHT_SPOT: + idx = spot_idx++; + break; + case WINED3D_LIGHT_DIRECTIONAL: + idx = directional_idx++; + break; + case WINED3D_LIGHT_PARALLELPOINT: + idx = parallel_point_idx++; + break; + default: + FIXME("Unhandled light type %#x.\n", light_info->OriginalParms.type); + continue; + } + constants.lights[idx] = 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); }
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/glsl_shader.c | 18 +++++------------- dlls/wined3d/stateblock.c | 21 ++++++++++++++++++--- 2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ecc9dcd2ef5..6eb83ec3f2c 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1539,9 +1539,7 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl 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_matrix *view = &state->transforms[WINED3D_TS_VIEW]; const struct wined3d_gl_info *gl_info = context_gl->gl_info; - struct wined3d_vec4 vec4;
GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].diffuse, 1, &constants->diffuse.r)); GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].specular, 1, &constants->specular.r)); @@ -1550,8 +1548,7 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl switch (type) { case WINED3D_LIGHT_POINT: - wined3d_vec4_transform(&vec4, &constants->position, view); - GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &vec4.x)); + GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &constants->position.x)); GL_EXTCALL(glUniform1f(prog->vs.light_location[light].range, constants->range)); GL_EXTCALL(glUniform1f(prog->vs.light_location[light].c_att, constants->const_att)); GL_EXTCALL(glUniform1f(prog->vs.light_location[light].l_att, constants->linear_att)); @@ -1559,11 +1556,9 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl break;
case WINED3D_LIGHT_SPOT: - wined3d_vec4_transform(&vec4, &constants->position, view); - GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &vec4.x)); + GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &constants->position.x));
- wined3d_vec4_transform(&vec4, &constants->direction, view); - GL_EXTCALL(glUniform3fv(prog->vs.light_location[light].direction, 1, &vec4.x)); + GL_EXTCALL(glUniform3fv(prog->vs.light_location[light].direction, 1, &constants->direction.x));
GL_EXTCALL(glUniform1f(prog->vs.light_location[light].range, constants->range)); GL_EXTCALL(glUniform1f(prog->vs.light_location[light].falloff, constants->falloff)); @@ -1575,13 +1570,11 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl break;
case WINED3D_LIGHT_DIRECTIONAL: - wined3d_vec4_transform(&vec4, &constants->direction, view); - GL_EXTCALL(glUniform3fv(prog->vs.light_location[light].direction, 1, &vec4.x)); + GL_EXTCALL(glUniform3fv(prog->vs.light_location[light].direction, 1, &constants->direction.x)); break;
case WINED3D_LIGHT_PARALLELPOINT: - wined3d_vec4_transform(&vec4, &constants->position, view); - GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &vec4.x)); + GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &constants->position.x)); break;
default: @@ -11867,7 +11860,6 @@ static void glsl_vertex_pipe_view(struct wined3d_context *context, const struct unsigned int k;
context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_MODELVIEW - | WINED3D_SHADER_CONST_FFP_LIGHTS | WINED3D_SHADER_CONST_FFP_VERTEXBLEND;
if (needs_legacy_glsl_syntax(gl_info)) diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 244d31e5d81..5d275be1ae1 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -3294,6 +3294,10 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, { j = wined3d_bit_scan(&map); idx = i * word_bit_count + j; + + if (idx == WINED3D_TS_VIEW) + changed->lights = 1; + wined3d_device_set_transform(device, idx, &state->transforms[idx]); } } @@ -3392,12 +3396,16 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, for (unsigned int i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i) { const struct wined3d_light_info *light_info = state->light_state->lights[i]; + const struct wined3d_light_constants *light_constants; + enum wined3d_light_type type; unsigned int idx;
if (!light_info) continue; + type = light_info->OriginalParms.type; + light_constants = &state->light_state->lights[i]->constants;
- switch (light_info->OriginalParms.type) + switch (type) { case WINED3D_LIGHT_POINT: idx = point_idx++; @@ -3412,10 +3420,17 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, idx = parallel_point_idx++; break; default: - FIXME("Unhandled light type %#x.\n", light_info->OriginalParms.type); + FIXME("Unhandled light type %#x.\n", type); continue; } - constants.lights[idx] = state->light_state->lights[i]->constants; + constants.lights[idx] = *light_constants; + + if (type != WINED3D_LIGHT_DIRECTIONAL) + wined3d_vec4_transform(&constants.lights[idx].position, + &light_constants->position, &state->transforms[WINED3D_TS_VIEW]); + if (type == WINED3D_LIGHT_SPOT || type == WINED3D_LIGHT_DIRECTIONAL) + wined3d_vec4_transform(&constants.lights[idx].direction, + &light_constants->direction, &state->transforms[WINED3D_TS_VIEW]); }
wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_FFP_LIGHTS,
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147107
Your paranoid android.
=== debian11b (64 bit WoW report) ===
ddraw: ddraw4.c:3969: Test failed: Expected message 0x5, but didn't receive it.
This merge request was approved by Jan Sikorski.