i915: Enable point sprite coordinate generation
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 30 Nov 2009 01:40:02 +0000 (17:40 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 30 Nov 2009 01:40:02 +0000 (17:40 -0800)
Support still isn't completely correct, but it's better.  piglit
point-sprite now passes.  However, glean's pointSprite test fails.  In
that test the texture on the sprite is somehow inverted as though
GL_POINT_SPRITE_COORD_ORIGIN were set to GL_LOWER_LEFT.  i915 hardware
shouldn't be able to do that!

I believe there are also problems when not all texture units have
GL_COORD_REPLACE set.  The hardware enable seems to be all or nothing.

Fixes bug #25313.

src/mesa/drivers/dri/i915/i915_state.c

index b60efea75bdc32c3b749c23fbdae2e7b7a848611..1ec84ef1167b1a443ebd687c97212390c04f07cb 100644 (file)
@@ -599,6 +599,24 @@ i915PointSize(GLcontext * ctx, GLfloat size)
 }
 
 
+static void
+i915PointParameterfv(GLcontext * ctx, GLenum pname, const GLfloat *params)
+{
+   struct i915_context *i915 = I915_CONTEXT(ctx);
+
+   switch (pname) {
+   case GL_POINT_SPRITE_COORD_ORIGIN:
+      /* This could be supported, but it would require modifying the fragment
+       * program to invert the y component of the texture coordinate by
+       * inserting a 'SUB tc.y, {1.0}.xxxx, tc' instruction.
+       */
+      FALLBACK(&i915->intel, I915_FALLBACK_POINT_SPRITE_COORD_ORIGIN,
+              (params[0] != GL_UPPER_LEFT));
+      break;
+   }
+}
+
+
 /* =============================================================
  * Color masks
  */
@@ -939,6 +957,17 @@ i915Enable(GLcontext * ctx, GLenum cap, GLboolean state)
    case GL_POLYGON_SMOOTH:
       break;
 
+   case GL_POINT_SPRITE:
+      /* This state change is handled in i915_reduced_primitive_state because
+       * the hardware bit should only be set when rendering points.
+       */
+      I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+      if (state)
+        i915->state.Ctx[I915_CTXREG_LIS4] |= S4_SPRITE_POINT_ENABLE;
+      else
+        i915->state.Ctx[I915_CTXREG_LIS4] &= ~S4_SPRITE_POINT_ENABLE;
+      break;
+
    case GL_POINT_SMOOTH:
       break;