From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/glsl_shader.c | 11 ++++------- dlls/wined3d/stateblock.c | 27 +++++++++++++++++---------- dlls/wined3d/wined3d_private.h | 10 +++++++++- 3 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index efe4c3016c2..49b641d0635 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1566,15 +1566,12 @@ static void shader_glsl_ffp_vertex_normalmatrix_uniform(const struct wined3d_con const struct wined3d_ffp_vs_constants *constants, struct glsl_shader_prog_link *prog) { const struct wined3d_gl_info *gl_info = context_gl->gl_info; - float mat[3 * 3];
if (prog->vs.normal_matrix_location == -1) return;
- compute_normal_matrix(mat, context_gl->c.d3d_info->wined3d_creation_flags & WINED3D_LEGACY_FFP_LIGHTING, - &constants->modelview_matrices[0]); - - GL_EXTCALL(glUniformMatrix3fv(prog->vs.normal_matrix_location, 1, FALSE, mat)); + GL_EXTCALL(glUniformMatrix3fv(prog->vs.normal_matrix_location, + 1, FALSE, constants->modelview.not_blended.normal_matrix)); checkGLcall("glUniformMatrix3fv"); }
@@ -1792,7 +1789,7 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, constants = wined3d_buffer_load_sysmem(context->device->push_constants[WINED3D_PUSH_CONSTANTS_VS_FFP], context);
GL_EXTCALL(glUniformMatrix4fv(prog->vs.modelview_matrix_location[0], 1, - FALSE, &constants->modelview_matrices[0]._11)); + FALSE, &constants->modelview.modelview_matrices[0]._11)); checkGLcall("glUniformMatrix4fv");
shader_glsl_ffp_vertex_normalmatrix_uniform(context_gl, constants, prog); @@ -1810,7 +1807,7 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, break;
GL_EXTCALL(glUniformMatrix4fv(prog->vs.modelview_matrix_location[i], - 1, FALSE, &constants->modelview_matrices[i]._11)); + 1, FALSE, &constants->modelview.modelview_matrices[i]._11)); checkGLcall("glUniformMatrix4fv"); } } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index d32e95e98fa..3a5ac83883b 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -3530,21 +3530,28 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
if (changed->modelview_matrices) { - struct wined3d_matrix matrices[MAX_VERTEX_BLENDS]; + union wined3d_ffp_vs_modelview_matrices matrices;
- get_modelview_matrix(state, 0, &matrices[0]); - wined3d_device_context_push_constants(context, - WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_FFP_MODELVIEW, - offsetof(struct wined3d_ffp_vs_constants, modelview_matrices[0]), sizeof(matrices[0]), &matrices[0]); + get_modelview_matrix(state, 0, &matrices.modelview_matrices[0]);
if (state->rs[WINED3D_RS_VERTEXBLEND]) { for (i = 1; i < MAX_VERTEX_BLENDS; ++i) - get_modelview_matrix(state, i, &matrices[i]); - wined3d_device_context_push_constants(context, - WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_FFP_VERTEXBLEND, - offsetof(struct wined3d_ffp_vs_constants, modelview_matrices[1]), - sizeof(matrices) - sizeof(matrices[0]), &matrices[1]); + get_modelview_matrix(state, i, &matrices.modelview_matrices[i]); + + wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_VS_FFP, + WINED3D_SHADER_CONST_FFP_MODELVIEW | WINED3D_SHADER_CONST_FFP_VERTEXBLEND, + offsetof(struct wined3d_ffp_vs_constants, modelview), sizeof(matrices), &matrices); + } + else + { + compute_normal_matrix(matrices.not_blended.normal_matrix, + device->adapter->d3d_info.wined3d_creation_flags & WINED3D_LEGACY_FFP_LIGHTING, + &matrices.not_blended.modelview_matrix); + + wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_VS_FFP, + WINED3D_SHADER_CONST_FFP_MODELVIEW, + offsetof(struct wined3d_ffp_vs_constants, modelview), sizeof(matrices.not_blended), &matrices); } }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6cc1daa7164..84cf8f51f26 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2768,7 +2768,15 @@ BOOL wined3d_get_app_name(char *app_name, unsigned int app_name_size);
struct wined3d_ffp_vs_constants { - struct wined3d_matrix modelview_matrices[MAX_VERTEX_BLENDS]; + union wined3d_ffp_vs_modelview_matrices + { + struct wined3d_matrix modelview_matrices[MAX_VERTEX_BLENDS]; + struct + { + struct wined3d_matrix modelview_matrix; + float normal_matrix[9]; + } not_blended; + } modelview; struct wined3d_matrix projection_matrix; struct wined3d_matrix texture_matrices[WINED3D_MAX_FFP_TEXTURES]; struct wined3d_material material;