From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/ffp_gl.c | 50 ++++++++++++++++++++----------------- dlls/wined3d/glsl_shader.c | 51 +++++++++++--------------------------- dlls/wined3d/wined3d_gl.h | 2 ++ 3 files changed, 43 insertions(+), 60 deletions(-)
diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index d0d82181c1e..a50f7c7a4b0 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1035,35 +1035,39 @@ static void shader_bumpenv(struct wined3d_context *context, const struct wined3d
void clipplane(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - UINT index = state_id - STATE_CLIPPLANE(0); - GLdouble plane[4]; + context->constant_update_mask |= WINED3D_SHADER_CONST_VS_CLIP_PLANES; +}
- if (index >= gl_info->limits.user_clip_distances) - return; +void ffp_vertex_update_clip_plane_constants(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state) +{ + for (unsigned int i = 0; i < gl_info->limits.user_clip_distances; ++i) + { + GLdouble plane[4];
- gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW); - gl_info->gl_ops.gl.p_glPushMatrix(); + gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW); + gl_info->gl_ops.gl.p_glPushMatrix();
- /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */ - if (!use_vs(state)) - gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW]._11); - else - /* With vertex shaders, clip planes are not transformed in Direct3D, - * while in OpenGL they are still transformed by the model view matrix. */ - gl_info->gl_ops.gl.p_glLoadIdentity(); + /* Clip plane settings are affected by the model view in OpenGL, + * and the view transform in Direct3D. + * + * With vertex shaders, Direct3D clip planes are not transformed, + * whereas in OpenGL they are still transformed by the model view + * matrix. */ + if (!use_vs(state)) + gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW]._11); + else + gl_info->gl_ops.gl.p_glLoadIdentity();
- plane[0] = state->clip_planes[index].x; - plane[1] = state->clip_planes[index].y; - plane[2] = state->clip_planes[index].z; - plane[3] = state->clip_planes[index].w; + plane[0] = state->clip_planes[i].x; + plane[1] = state->clip_planes[i].y; + plane[2] = state->clip_planes[i].z; + plane[3] = state->clip_planes[i].w;
- TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n", - plane[0], plane[1], plane[2], plane[3]); - gl_info->gl_ops.gl.p_glClipPlane(GL_CLIP_PLANE0 + index, plane); - checkGLcall("glClipPlane"); + gl_info->gl_ops.gl.p_glClipPlane(GL_CLIP_PLANE0 + i, plane); + checkGLcall("glClipPlane");
- gl_info->gl_ops.gl.p_glPopMatrix(); + gl_info->gl_ops.gl.p_glPopMatrix(); + } }
static void streamsrc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 6eb83ec3f2c..295867c32b1 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1688,8 +1688,15 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv,
if (update_mask & WINED3D_SHADER_CONST_VS_CLIP_PLANES) { - for (i = 0; i < gl_info->limits.user_clip_distances; ++i) - shader_glsl_clip_plane_uniform(context_gl, state, i, prog); + if (gl_info->supported[WINED3D_GLSL_130]) + { + for (i = 0; i < gl_info->limits.user_clip_distances; ++i) + shader_glsl_clip_plane_uniform(context_gl, state, i, prog); + } + else + { + ffp_vertex_update_clip_plane_constants(gl_info, state); + } }
if (update_mask & WINED3D_SHADER_CONST_VS_POINTSIZE) @@ -11720,14 +11727,12 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, const struct wined3d_vertex_declaration *vdecl = state->vertex_declaration; struct wined3d_context_gl *context_gl = wined3d_context_gl(context); const struct wined3d_gl_info *gl_info = context_gl->gl_info; - const BOOL legacy_clip_planes = needs_legacy_glsl_syntax(gl_info); BOOL transformed = context->stream_info.position_transformed; BOOL wasrhw = context->last_was_rhw; bool point_size = vdecl && vdecl->point_size; bool specular = vdecl && vdecl->specular; bool diffuse = vdecl && vdecl->diffuse; bool normal = vdecl && vdecl->normal; - unsigned int i;
context->last_was_rhw = transformed;
@@ -11743,13 +11748,7 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, if (!use_vs(state)) { if (context->last_was_vshader) - { - if (legacy_clip_planes) - for (i = 0; i < gl_info->limits.user_clip_distances; ++i) - clipplane(context, state, STATE_CLIPPLANE(i)); - else - context->constant_update_mask |= WINED3D_SHADER_CONST_VS_CLIP_PLANES; - } + context->constant_update_mask |= WINED3D_SHADER_CONST_VS_CLIP_PLANES;
context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_TEXMATRIX;
@@ -11772,15 +11771,9 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, } else { + /* Vertex shader clipping ignores the view matrix. Update all clip planes. */ if (!context->last_was_vshader) - { - /* Vertex shader clipping ignores the view matrix. Update all clip planes. */ - if (legacy_clip_planes) - for (i = 0; i < gl_info->limits.user_clip_distances; ++i) - clipplane(context, state, STATE_CLIPPLANE(i)); - else - context->constant_update_mask |= WINED3D_SHADER_CONST_VS_CLIP_PLANES; - } + context->constant_update_mask |= WINED3D_SHADER_CONST_VS_CLIP_PLANES; }
context->last_was_vshader = use_vs(state); @@ -11855,25 +11848,9 @@ static void glsl_vertex_pipe_vertexblend(struct wined3d_context *context,
static void glsl_vertex_pipe_view(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - struct wined3d_context_gl *context_gl = wined3d_context_gl(context); - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - unsigned int k; - context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_MODELVIEW - | WINED3D_SHADER_CONST_FFP_VERTEXBLEND; - - if (needs_legacy_glsl_syntax(gl_info)) - { - for (k = 0; k < gl_info->limits.user_clip_distances; ++k) - { - if (!isStateDirty(context, STATE_CLIPPLANE(k))) - clipplane(context, state, STATE_CLIPPLANE(k)); - } - } - else - { - context->constant_update_mask |= WINED3D_SHADER_CONST_VS_CLIP_PLANES; - } + | WINED3D_SHADER_CONST_FFP_VERTEXBLEND + | WINED3D_SHADER_CONST_VS_CLIP_PLANES; }
static void glsl_vertex_pipe_projection(struct wined3d_context *context, diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index ac875ce1fe7..039f652adb9 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -773,6 +773,8 @@ void wined3d_ffp_blitter_create(struct wined3d_blitter **next, const struct wine struct wined3d_blitter *wined3d_glsl_blitter_create(struct wined3d_blitter **next, const struct wined3d_device *device); void wined3d_raw_blitter_create(struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info);
+void ffp_vertex_update_clip_plane_constants(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state); + struct wined3d_caps_gl_ctx { HDC dc;