[PATCH 3/5] wined3d: Only write gl_ClipVertex if clipping is enabled in shader_glsl_generate_ffp_vertex_shader().
Henri Verbeet
hverbeet at codeweavers.com
Wed May 29 02:45:37 CDT 2013
---
dlls/wined3d/glsl_shader.c | 3 ++-
dlls/wined3d/state.c | 40 ++++++++++++++++++----------------------
dlls/wined3d/utils.c | 4 ++++
dlls/wined3d/wined3d_private.h | 3 ++-
4 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 9e3afe7..b46df8a 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -4937,7 +4937,8 @@ static GLhandleARB shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_
shader_addline(buffer, "vec4 ec_pos = gl_ModelViewMatrix * gl_Vertex;\n");
shader_addline(buffer, "gl_Position = gl_ProjectionMatrix * ec_pos;\n");
- shader_addline(buffer, "gl_ClipVertex = ec_pos;\n");
+ if (settings->clipping)
+ shader_addline(buffer, "gl_ClipVertex = ec_pos;\n");
shader_addline(buffer, "ec_pos /= ec_pos.w;\n");
if (!settings->normal)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 666983a..c01f516 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -593,32 +593,28 @@ void state_clipping(struct wined3d_context *context, const struct wined3d_state
DWORD enable = 0xffffffff;
DWORD disable = 0x00000000;
- if (use_vs(state))
+ if (use_vs(state) && !context->d3d_info->vs_clipping)
{
- if (!context->d3d_info->vs_clipping)
- {
- /* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't,
- * so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some
- * conditions I got sick of tracking down. The shader state handler disables all clip planes because
- * of that - don't do anything here and keep them disabled
- */
- if (state->render_states[WINED3D_RS_CLIPPLANEENABLE])
- {
- static BOOL warned = FALSE;
- if(!warned) {
- FIXME("Clipping not supported with vertex shaders\n");
- warned = TRUE;
- }
- }
- return;
- }
+ static BOOL warned;
- /* glEnable(GL_CLIP_PLANEx) doesn't apply to vertex shaders. The enabled / disabled planes are
- * hardcoded into the shader. Update the shader to update the enabled clipplanes */
- context->select_shader = 1;
- context->load_constants = 1;
+ /* The OpenGL spec says that clipping planes are disabled when using
+ * shaders. Direct3D planes aren't, so that is an issue. The MacOS ATI
+ * driver keeps clipping planes activated with shaders in some
+ * conditions I got sick of tracking down. The shader state handler
+ * disables all clip planes because of that - don't do anything here
+ * and keep them disabled. */
+ if (state->render_states[WINED3D_RS_CLIPPLANEENABLE] && !warned++)
+ FIXME("Clipping not supported with vertex shaders\n");
+ return;
}
+ /* glEnable(GL_CLIP_PLANEx) doesn't apply to (ARB backend) vertex shaders.
+ * The enabled / disabled planes are hardcoded into the shader. Update the
+ * shader to update the enabled clipplanes. In case of fixed function, we
+ * need to update the clipping field from ffp_vertex_settings. */
+ context->select_shader = 1;
+ context->load_constants = 1;
+
/* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
* of already set values
*/
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 16e8b2d..4f3ab2f 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3532,6 +3532,8 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct
{
memset(settings, 0, sizeof(*settings));
+ settings->clipping = state->render_states[WINED3D_RS_CLIPPING]
+ && state->render_states[WINED3D_RS_CLIPPLANEENABLE];
settings->point_size = state->gl_primitive_type == GL_POINTS;
if (!state->render_states[WINED3D_RS_FOGENABLE])
settings->fog_mode = WINED3D_FFP_VS_FOG_OFF;
@@ -3551,6 +3553,8 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct
return;
}
+ settings->clipping = state->render_states[WINED3D_RS_CLIPPING]
+ && state->render_states[WINED3D_RS_CLIPPLANEENABLE];
settings->normal = !!(si->use_map & (1 << WINED3D_FFP_NORMAL));
settings->normalize = settings->normal && state->render_states[WINED3D_RS_NORMALIZENORMALS];
settings->lighting = !!state->render_states[WINED3D_RS_LIGHTING];
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index e3b55ca..55cfa94 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1716,6 +1716,7 @@ struct wined3d_ffp_vs_settings
DWORD ambient_source : 2;
DWORD specular_source : 2;
+ DWORD clipping : 1;
DWORD normal : 1;
DWORD normalize : 1;
DWORD lighting : 1;
@@ -1723,7 +1724,7 @@ struct wined3d_ffp_vs_settings
DWORD point_size : 1;
DWORD fog_mode : 2;
DWORD texcoords : 8; /* MAX_TEXTURES */
- DWORD padding : 17;
+ DWORD padding : 16;
BYTE texgen[MAX_TEXTURES];
};
--
1.8.1.5
More information about the wine-patches
mailing list