Module: wine Branch: master Commit: 05757794a0d2f456fd581d5eeae6bff04e61561f URL: http://source.winehq.org/git/wine.git/?a=commit;h=05757794a0d2f456fd581d5eea...
Author: Matteo Bruni mbruni@codeweavers.com Date: Thu Mar 26 20:12:20 2015 +0100
wined3d: Don't use the builtin FFP uniform for the projection matrix.
---
dlls/wined3d/glsl_shader.c | 30 ++++++++++++++++++------------ dlls/wined3d/state.c | 4 ++-- dlls/wined3d/wined3d_private.h | 5 ++--- 3 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 2dd4760..e4ddbe6 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -118,6 +118,7 @@ struct glsl_vs_program GLint pos_fixup_location;
GLint modelview_matrix_location; + GLint projection_matrix_location; GLint normal_matrix_location; };
@@ -876,6 +877,15 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context shader_glsl_ffp_vertex_normalmatrix_uniform(context, state, prog); }
+ if (update_mask & WINED3D_SHADER_CONST_FFP_PROJ) + { + struct wined3d_matrix projection; + + get_projection_matrix(context, state, &projection); + GL_EXTCALL(glUniformMatrix4fv(prog->vs.projection_matrix_location, 1, FALSE, &projection._11)); + checkGLcall("glUniformMatrix4fv"); + } + if (update_mask & WINED3D_SHADER_CONST_PS_F) shader_glsl_load_constantsF(pshader, gl_info, state->ps_consts_f, prog->ps.uniform_f_locations, &priv->pconst_heap, priv->stack, constant_version); @@ -5092,6 +5102,7 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_buffe shader_addline(buffer, "\n");
shader_addline(buffer, "uniform mat4 ffp_modelview_matrix;\n"); + shader_addline(buffer, "uniform mat4 ffp_projection_matrix;\n"); shader_addline(buffer, "uniform mat3 ffp_normal_matrix;\n");
shader_addline(buffer, "\nvoid main()\n{\n"); @@ -5101,13 +5112,13 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_buffe if (settings->transformed) { shader_addline(buffer, "vec4 ec_pos = vec4(gl_Vertex.xyz, 1.0);\n"); - shader_addline(buffer, "gl_Position = gl_ProjectionMatrix * ec_pos;\n"); + shader_addline(buffer, "gl_Position = ffp_projection_matrix * ec_pos;\n"); shader_addline(buffer, "if (gl_Vertex.w != 0.0) gl_Position /= gl_Vertex.w;\n"); } else { shader_addline(buffer, "vec4 ec_pos = ffp_modelview_matrix * gl_Vertex;\n"); - shader_addline(buffer, "gl_Position = gl_ProjectionMatrix * ec_pos;\n"); + shader_addline(buffer, "gl_Position = ffp_projection_matrix * ec_pos;\n"); if (settings->clipping) shader_addline(buffer, "gl_ClipVertex = ec_pos;\n"); shader_addline(buffer, "ec_pos /= ec_pos.w;\n"); @@ -5875,6 +5886,7 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info * vs->pos_fixup_location = GL_EXTCALL(glGetUniformLocation(program_id, "posFixup"));
vs->modelview_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_modelview_matrix")); + vs->projection_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_projection_matrix")); vs->normal_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_normal_matrix")); }
@@ -6178,7 +6190,8 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const } else { - entry->constant_update_mask |= WINED3D_SHADER_CONST_FFP_MODELVIEW; + entry->constant_update_mask |= WINED3D_SHADER_CONST_FFP_MODELVIEW + | WINED3D_SHADER_CONST_FFP_PROJ; }
if (gshader) @@ -7095,11 +7108,7 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, }
if (transformed != wasrhw) - { - if (!isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)) - && !isStateDirty(context, STATE_VIEWPORT)) - transform_projection(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); - } + context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_PROJ;
for (i = 0; i < MAX_TEXTURES; ++i) { @@ -7133,9 +7142,6 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, } }
- if (transformed != wasrhw && !isStateDirty(context, STATE_RENDER(WINED3D_RS_ZENABLE))) - context_apply_state(context, state, STATE_RENDER(WINED3D_RS_ZENABLE)); - context->last_was_vshader = use_vs(state); }
@@ -7194,7 +7200,7 @@ static void glsl_vertex_pipe_projection(struct wined3d_context *context, if (state->render_states[WINED3D_RS_FOGENABLE] && state->render_states[WINED3D_RS_FOGTABLEMODE] != WINED3D_FOG_NONE) context->shader_update_mask |= 1 << WINED3D_SHADER_TYPE_VERTEX; - transform_projection(context, state, state_id); + context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_PROJ; }
static void glsl_vertex_pipe_viewport(struct wined3d_context *context, diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index a949077..69623af 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -132,7 +132,7 @@ static void state_zenable(struct wined3d_context *context, const struct wined3d_ }
if (context->last_was_rhw && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION))) - transform_projection(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); + context_apply_state(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); }
static void state_cullmode(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) @@ -4029,7 +4029,7 @@ static void transform_view(struct wined3d_context *context, const struct wined3d } }
-void transform_projection(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +static void transform_projection(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = context->gl_info; struct wined3d_matrix projection; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c88f9b1..96b8244 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -307,7 +307,8 @@ enum wined3d_shader_resource_type #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00000100 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00000200 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00000400 -#define WINED3D_SHADER_CONST_FFP_PS 0x00000800 +#define WINED3D_SHADER_CONST_FFP_PROJ 0x00000800 +#define WINED3D_SHADER_CONST_FFP_PS 0x00001000
enum wined3d_shader_register_type { @@ -2812,8 +2813,6 @@ void sampler_texmatrix(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN; void state_specularenable(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN; -void transform_projection(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN; void transform_texture(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN; void state_ambient(struct wined3d_context *context,