glsl_to_tgsi: fix dst register for texturing fetches.
[mesa.git] / src / mesa / state_tracker / st_atom_clip.c
index 16f7aaae6f41bf0cd704d2c0fa8225d21a5a2b03..8558d768faa00a06c23ef72698739756df19ac6b 100644 (file)
@@ -34,7 +34,8 @@
 #include "st_context.h"
 #include "pipe/p_context.h"
 #include "st_atom.h"
-
+#include "st_program.h"
+#include "util/u_debug.h"
 #include "cso_cache/cso_context.h"
 
 
 static void update_clip( struct st_context *st )
 {
    struct pipe_clip_state clip;
-   GLuint i;
+   const struct gl_context *ctx = st->ctx;
+   bool use_eye = FALSE;
 
-   memset(&clip, 0, sizeof(clip));
+   STATIC_ASSERT(sizeof(clip.ucp) <= sizeof(ctx->Transform._ClipUserPlane));
 
-   for (i = 0; i < PIPE_MAX_CLIP_PLANES; i++) {
-      if (st->ctx->Transform.ClipPlanesEnabled & (1 << i)) {
-        memcpy(clip.ucp[clip.nr], 
-               st->ctx->Transform._ClipUserPlane[i], 
-               sizeof(clip.ucp[0]));
-        clip.nr++;
-      }
+   /* if we have a vertex shader that writes clip vertex we need to pass
+      the pre-projection transformed coordinates into the driver. */
+   if (st->vp) {
+      if (ctx->Shader.CurrentVertexProgram)
+         use_eye = TRUE;
    }
 
-   clip.depth_clamp = st->ctx->Transform.DepthClamp != GL_FALSE;
-      
-   if (memcmp(&clip, &st->state.clip, sizeof(clip)) != 0) {
-      st->state.clip = clip;
-      cso_set_clip(st->cso_context, &clip);
-   }
+   memcpy(clip.ucp,
+          use_eye ? ctx->Transform.EyeUserPlane
+                  : ctx->Transform._ClipUserPlane, sizeof(clip.ucp));
+   st->state.clip = clip;
+   cso_set_clip(st->cso_context, &clip);
 }
 
 
 const struct st_tracked_state st_update_clip = {
    "st_update_clip",                                   /* name */
    {                                                   /* dirty */
-      (_NEW_TRANSFORM),                                        /* mesa */
-      0,                                               /* st */
+      _NEW_TRANSFORM,                                   /* mesa */
+      ST_NEW_VERTEX_PROGRAM,                           /* st */
    },
    update_clip                                         /* update */
 };