diff --git a/src/mesa/pipe/draw/draw_post_vs_sse.c b/src/mesa/pipe/draw/draw_post_vs_sse.c
new file mode 100644
index 0000000..331affa
--- /dev/null
+++ b/src/mesa/pipe/draw/draw_post_vs_sse.c
@@ -0,0 +1,144 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "pipe/p_util.h"
+
+#include "draw_private.h"
+
+#include "x86/rtasm/x86sse.h"
+
+#if defined(__i386__) || defined(__386__)
+
+static struct x86_reg
+make_xmm(
+   unsigned xmm)
+{
+   return x86_make_reg(
+      file_XMM,
+      (enum x86_reg_name) xmm);
+}
+
+static struct x86_reg
+get_argument(unsigned index)
+{
+   return x86_make_disp(
+      x86_make_reg(file_REG32, reg_SP),
+      (index + 1) * 4);
+}
+
+
+static struct x86_reg
+get_clip_base(void)
+{
+   return x86_make_reg(
+      file_REG32,
+      reg_AX);
+}
+
+static struct x86_reg
+get_clip(
+   unsigned vec,
+   unsigned chan)
+{
+   return x86_make_disp(
+      get_clip_base(),
+      (vec * 4 + chan) * 16);
+}
+
+
+static void
+emit_clipf(
+   struct x86_function *func,
+   unsigned xmm,
+   unsigned vec,
+   unsigned chan)
+{
+   sse_movups(
+      func,
+      make_xmm(xmm),
+      get_clip(vec, chan));
+}
+
+static struct x86_reg
+get_scale_base(void)
+{
+   return x86_make_reg(
+      file_REG32,
+      reg_DX);
+}
+
+static struct x86_reg
+get_trans_base(void)
+{
+   return x86_make_reg(
+      file_REG32,
+      reg_BX);
+}
+
+
+static void
+emit_inputf(
+   struct x86_function *func,
+   unsigned xmm,
+   unsigned vec,
+   unsigned chan )
+{
+   sse_movups(
+      func,
+      make_xmm(xmm),
+      get_clip(vec, chan));
+}
+
+void draw_post_generate_sse_emit(struct x86_function *func)
+{
+   func->csr = func->store;
+   x86_mov(func,
+           get_clip_base(),
+           get_argument(0));
+   x86_mov(func,
+           get_scale_base(),
+           get_argument(1));
+   x86_mov(func,
+           get_trans_base(),
+           get_argument(2));
+
+
+   {/*plane 0
+      tmp      = MOV    clip0
+      tmp      = CMP.LT tmp, clip3
+      tmp      = AND    tmp, signmask
+      signmask = SHL    signmask, { 1 }
+      clipmask = OR     clipmask, tmp
+    */
+   }
+   /*for all planes*/
+
+   /*for all userplanes dot4*/
+   
+}
+
+#endif /* i386 */
diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h
index 21de400..a49149e 100644
--- a/src/mesa/pipe/draw/draw_private.h
+++ b/src/mesa/pipe/draw/draw_private.h
@@ -129,11 +129,11 @@ struct draw_stage
  */
 struct draw_vertex_shader {
    const struct pipe_shader_state   *state;
-#if defined(__i386__) || defined(__386__)
-   struct x86_function              sse2_program;
-#endif
 #ifdef MESA_LLVM
    struct gallivm_prog *llvm_prog;
+#elif defined(__i386__) || defined(__386__)
+   struct x86_function              sse2_program;
+   struct x86_function              clip_program;
 #endif
 };
 
diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c
index 0806e23..6fd939b 100644
--- a/src/mesa/pipe/draw/draw_vertex_shader.c
+++ b/src/mesa/pipe/draw/draw_vertex_shader.c
@@ -78,6 +78,10 @@ typedef void (XSTDCALL *codegen_function) (
    float (*constant)[4],
    struct tgsi_exec_vector *temporary );
 
+typedef void (XSTDCALL *clip_function)(
+   const struct tgsi_exec_vector *input,
+   const float *scale,
+   const float *trans);
 
 /**
  * Transform vertices with the current vertex program/shader
@@ -137,6 +141,17 @@ run_vertex_program(struct draw_context *draw,
    /* store machine results */
    for (j = 0; j < count; j++) {
       unsigned slot;
+#if defined(__i386__) || defined(__386__)
+      if (draw->use_sse) {
+         /* run the generated sse */
+         struct draw_vertex_shader *shader
+            = (struct draw_vertex_shader *)draw->vertex_shader;
+         clip_function func
+            = (clip_function) x86_get_func(&shader->clip_program);
+         func(machine->Outputs, scale, trans);
+      } else
+#endif /* i386 */
+      {
       float x, y, z, w;
 
       /* Handle attr[0] (position) specially:
@@ -164,7 +179,7 @@ run_vertex_program(struct draw_context *draw,
       vOut[j]->data[0][1] = y * scale[1] + trans[1];
       vOut[j]->data[0][2] = z * scale[2] + trans[2];
       vOut[j]->data[0][3] = w;
-
+      }
 #if DBG_VS
       printf("output[%d]win: %f %f %f %f\n", j,
              vOut[j]->data[0][0],
@@ -270,6 +285,9 @@ draw_create_vertex_shader(struct draw_context *draw,
 
       x86_init_func( &vs->sse2_program );
       tgsi_emit_sse2( (struct tgsi_token *) sh->tokens, &vs->sse2_program );
+
+      x86_init_func(&vs->clip_program);
+      draw_post_generate_sse_emit(&vs->clip_program);
    }
 #endif
 
diff --git a/src/mesa/sources b/src/mesa/sources
index e31d8cc..69ca247 100644
--- a/src/mesa/sources
+++ b/src/mesa/sources
@@ -178,7 +178,8 @@ DRAW_SOURCES = \
 	pipe/draw/draw_vf.c \
 	pipe/draw/draw_vf_generic.c \
 	pipe/draw/draw_vf_sse.c \
-	pipe/draw/draw_wide_prims.c
+	pipe/draw/draw_wide_prims.c \
+        pipe/draw/draw_post_vs_sse.c
 
 TGSIEXEC_SOURCES = \
 	pipe/tgsi/exec/tgsi_exec.c \
