i965/gs: Fixup gl_PointSize on entry to geometry shaders.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vec4_gs_visitor.cpp
index 2d3a058ee80c5272c221ec1554e64e1e3d9f4d25..96636e8838bfeae39216e3121b236e41a812e265 100644 (file)
@@ -156,6 +156,23 @@ vec4_gs_visitor::emit_prolog()
       }
    }
 
+   /* If the geometry shader uses the gl_PointSize input, we need to fix it up
+    * to account for the fact that the vertex shader stored it in the w
+    * component of VARYING_SLOT_PSIZ.
+    */
+   if (c->gp->program.Base.InputsRead & VARYING_BIT_PSIZ) {
+      this->current_annotation = "swizzle gl_PointSize input";
+      for (int vertex = 0; vertex < c->gp->program.VerticesIn; vertex++) {
+         dst_reg dst(ATTR,
+                     BRW_VARYING_SLOT_COUNT * vertex + VARYING_SLOT_PSIZ);
+         dst.type = BRW_REGISTER_TYPE_F;
+         src_reg src(dst);
+         dst.writemask = WRITEMASK_X;
+         src.swizzle = BRW_SWIZZLE_WWWW;
+         emit(MOV(dst, src));
+      }
+   }
+
    this->current_annotation = NULL;
 }