glx/dri: add initial dri interface for GLX_EXT_framebuffer_sRGB.
[mesa.git] / src / mesa / drivers / dri / common / stenciltmp.h
index e279b5b5c031bdb541e7d09d46d42115f6e12ae1..fef09720895c0ee6f329450e8007b334866fff60 100644 (file)
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.3 2001/03/21 16:14:20 dawes Exp $ */
 
 #include "spantmp_common.h"
 
@@ -6,7 +5,15 @@
 #define DBG 0
 #endif
 
-static void TAG(WriteStencilSpan)( GLcontext *ctx,
+#ifndef HAVE_HW_STENCIL_SPANS
+#define HAVE_HW_STENCIL_SPANS 0
+#endif
+
+#ifndef HAVE_HW_STENCIL_PIXELS
+#define HAVE_HW_STENCIL_PIXELS 0
+#endif
+
+static void TAG(WriteStencilSpan)( struct gl_context *ctx,
                                    struct gl_renderbuffer *rb,
                                   GLuint n, GLint x, GLint y,
                                   const void *values, const GLubyte mask[] )
@@ -20,6 +27,14 @@ static void TAG(WriteStencilSpan)( GLcontext *ctx,
 
         y = Y_FLIP(y);
 
+#if HAVE_HW_STENCIL_SPANS
+        (void) x1; (void) n1;
+
+        if (DBG) fprintf(stderr, "WriteStencilSpan 0..%d (x1 %d)\n",
+                         (int)n1, (int)x1);
+
+        WRITE_STENCIL_SPAN();
+#else /* HAVE_HW_STENCIL_SPANS */
         HW_CLIPLOOP() 
            {
               GLint i = 0;
@@ -41,12 +56,27 @@ static void TAG(WriteStencilSpan)( GLcontext *ctx,
               }
            }
         HW_ENDCLIPLOOP();
+#endif /* !HAVE_HW_STENCIL_SPANS */
       }
    HW_WRITE_UNLOCK();
 }
 
-
-static void TAG(WriteMonoStencilSpan)( GLcontext *ctx,
+#if HAVE_HW_STENCIL_SPANS
+/* implement MonoWriteDepthSpan() in terms of WriteDepthSpan() */
+static void
+TAG(WriteMonoStencilSpan)( struct gl_context *ctx, struct gl_renderbuffer *rb,
+                           GLuint n, GLint x, GLint y,
+                           const void *value, const GLubyte mask[] )
+{
+   const GLuint stenVal = *((GLuint *) value);
+   GLuint stens[MAX_WIDTH];
+   GLuint i;
+   for (i = 0; i < n; i++)
+      stens[i] = stenVal;
+   TAG(WriteStencilSpan)(ctx, rb, n, x, y, stens, mask);
+}
+#else /* HAVE_HW_STENCIL_SPANS */
+static void TAG(WriteMonoStencilSpan)( struct gl_context *ctx,
                                        struct gl_renderbuffer *rb,
                                        GLuint n, GLint x, GLint y,
                                        const void *value,
@@ -85,10 +115,10 @@ static void TAG(WriteMonoStencilSpan)( GLcontext *ctx,
       }
    HW_WRITE_UNLOCK();
 }
+#endif /* !HAVE_HW_STENCIL_SPANS */
 
 
-
-static void TAG(WriteStencilPixels)( GLcontext *ctx,
+static void TAG(WriteStencilPixels)( struct gl_context *ctx,
                                      struct gl_renderbuffer *rb,
                                     GLuint n,
                                     const GLint x[], const GLint y[],
@@ -102,6 +132,11 @@ static void TAG(WriteStencilPixels)( GLcontext *ctx,
 
         if (DBG) fprintf(stderr, "WriteStencilPixels\n");
 
+#if HAVE_HW_STENCIL_PIXELS
+        (void) i;
+
+        WRITE_STENCIL_PIXELS();
+#else /* HAVE_HW_STENCIL_PIXELS */
         HW_CLIPLOOP()
            {
               for (i=0;i<n;i++)
@@ -114,6 +149,7 @@ static void TAG(WriteStencilPixels)( GLcontext *ctx,
               }
            }
         HW_ENDCLIPLOOP();
+#endif /* !HAVE_HW_STENCIL_PIXELS */
       }
    HW_WRITE_UNLOCK();
 }
@@ -121,7 +157,7 @@ static void TAG(WriteStencilPixels)( GLcontext *ctx,
 
 /* Read stencil spans and pixels
  */
-static void TAG(ReadStencilSpan)( GLcontext *ctx,
+static void TAG(ReadStencilSpan)( struct gl_context *ctx,
                                   struct gl_renderbuffer *rb,
                                  GLuint n, GLint x, GLint y,
                                  void *values)
@@ -136,6 +172,11 @@ static void TAG(ReadStencilSpan)( GLcontext *ctx,
 
         if (DBG) fprintf(stderr, "ReadStencilSpan\n");
 
+#if HAVE_HW_STENCIL_SPANS
+        (void) x1; (void) n1;
+
+        READ_STENCIL_SPAN();
+#else /* HAVE_HW_STENCIL_SPANS */
         HW_CLIPLOOP() 
            {
               GLint i = 0;
@@ -144,11 +185,12 @@ static void TAG(ReadStencilSpan)( GLcontext *ctx,
                  READ_STENCIL( stencil[i], (x+i), y );
            }
         HW_ENDCLIPLOOP();
+#endif /* !HAVE_HW_STENCIL_SPANS */
       }
    HW_READ_UNLOCK();
 }
 
-static void TAG(ReadStencilPixels)( GLcontext *ctx,
+static void TAG(ReadStencilPixels)( struct gl_context *ctx,
                                     struct gl_renderbuffer *rb,
                                     GLuint n, const GLint x[], const GLint y[],
                                    void *values )
@@ -161,6 +203,11 @@ static void TAG(ReadStencilPixels)( GLcontext *ctx,
 
         if (DBG) fprintf(stderr, "ReadStencilPixels\n");
  
+#if HAVE_HW_STENCIL_PIXELS
+        (void) i;
+
+        READ_STENCIL_PIXELS();
+#else /* HAVE_HW_STENCIL_PIXELS */
         HW_CLIPLOOP()
            {
               for (i=0;i<n;i++) {
@@ -170,6 +217,7 @@ static void TAG(ReadStencilPixels)( GLcontext *ctx,
               }
            }
         HW_ENDCLIPLOOP();
+#endif /* !HAVE_HW_STENCIL_PIXELS */
       }
    HW_READ_UNLOCK();
 }