Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / mesa / drivers / dri / r128 / r128_span.c
index a24e63c9b675dcb82799a637cdb834ec6287f40e..307de56ee13d3f7d55907cd0de672dc7bc509447 100644 (file)
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.c,v 1.8 2002/10/30 12:51:39 alanh Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -36,9 +35,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "r128_context.h"
 #include "r128_ioctl.h"
-#include "r128_state.h"
 #include "r128_span.h"
-#include "r128_tex.h"
 
 #include "swrast/swrast.h"
 
@@ -51,8 +48,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define LOCAL_VARS                                                     \
    r128ContextPtr rmesa = R128_CONTEXT(ctx);                           \
-   __DRIscreenPrivate *sPriv = rmesa->driScreen;                       \
-   __DRIdrawablePrivate *dPriv = rmesa->driDrawable;                   \
+   __DRIscreen *sPriv = rmesa->driScreen;                      \
+   __DRIdrawable *dPriv = rmesa->driDrawable;                  \
    driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
    GLuint height = dPriv->h;                                           \
    GLuint p;                                                           \
@@ -61,8 +58,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define LOCAL_DEPTH_VARS                                               \
    r128ContextPtr rmesa = R128_CONTEXT(ctx);                           \
    r128ScreenPtr r128scrn = rmesa->r128Screen;                         \
-   __DRIscreenPrivate *sPriv = rmesa->driScreen;                       \
-   __DRIdrawablePrivate *dPriv = rmesa->driDrawable;                   \
+   __DRIscreen *sPriv = rmesa->driScreen;                      \
+   __DRIdrawable *dPriv = rmesa->driDrawable;                  \
    GLuint height = dPriv->h;                                           \
    (void) r128scrn; (void) sPriv; (void) height
 
@@ -123,8 +120,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * Depth buffer
  */
 
+/* These functions require locking */
+#undef HW_LOCK
+#undef HW_UNLOCK
+#define HW_LOCK()    LOCK_HARDWARE(R128_CONTEXT(ctx));
+#define HW_UNLOCK()  UNLOCK_HARDWARE(R128_CONTEXT(ctx));
+
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH_SPAN()                                             \
 do {                                                                   \
@@ -201,9 +205,11 @@ do {                                                                       \
 
 /* 24-bit depth, 8-bit stencil buffer functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH_SPAN()                                             \
 do {                                                                   \
-   GLint buf[n];                                                       \
+   GLuint buf[n];                                                      \
    GLint i;                                                            \
    GLuint *readbuf = (GLuint *)((GLubyte *)sPriv->pFB +                        \
                                r128scrn->spanOffset);                  \
@@ -222,7 +228,7 @@ do {                                                                        \
 
 #define WRITE_DEPTH_PIXELS()                                           \
 do {                                                                   \
-   GLint buf[n];                                                       \
+   GLuint buf[n];                                                      \
    GLint ox[MAX_WIDTH];                                                        \
    GLint oy[MAX_WIDTH];                                                        \
    GLuint *readbuf = (GLuint *)((GLubyte *)sPriv->pFB +                        \
@@ -303,7 +309,7 @@ do {                                                                        \
  */
 #define WRITE_STENCIL_SPAN()                                           \
 do {                                                                   \
-   GLint buf[n];                                                       \
+   GLuint buf[n];                                                      \
    GLint i;                                                            \
    GLuint *readbuf = (GLuint *)((GLubyte *)sPriv->pFB +                        \
                                r128scrn->spanOffset);                  \
@@ -322,7 +328,7 @@ do {                                                                        \
 
 #define WRITE_STENCIL_PIXELS()                                         \
 do {                                                                   \
-   GLint buf[n];                                                       \
+   GLuint buf[n];                                                      \
    GLint ox[MAX_WIDTH];                                                        \
    GLint oy[MAX_WIDTH];                                                        \
    GLuint *readbuf = (GLuint *)((GLubyte *)sPriv->pFB +                        \
@@ -394,7 +400,7 @@ do {                                                                        \
 #include "stenciltmp.h"
 
 static void
-r128SpanRenderStart( GLcontext *ctx )
+r128SpanRenderStart( struct gl_context *ctx )
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
    FLUSH_BATCH(rmesa);
@@ -403,7 +409,7 @@ r128SpanRenderStart( GLcontext *ctx )
 }
 
 static void
-r128SpanRenderFinish( GLcontext *ctx )
+r128SpanRenderFinish( struct gl_context *ctx )
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
    _swrast_flush( ctx );
@@ -411,7 +417,7 @@ r128SpanRenderFinish( GLcontext *ctx )
    UNLOCK_HARDWARE( rmesa );
 }
 
-void r128DDInitSpanFuncs( GLcontext *ctx )
+void r128DDInitSpanFuncs( struct gl_context *ctx )
 {
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
    swdd->SpanRenderStart       = r128SpanRenderStart;
@@ -423,23 +429,21 @@ void r128DDInitSpanFuncs( GLcontext *ctx )
  * Plug in the Get/Put routines for the given driRenderbuffer.
  */
 void
-r128SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+r128SetSpanFunctions(driRenderbuffer *drb, const struct gl_config *vis)
 {
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         r128InitPointers_RGB565(&drb->Base);
-      }
-      else {
-         r128InitPointers_ARGB8888(&drb->Base);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      r128InitPointers_RGB565(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      r128InitPointers_ARGB8888(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       r128InitDepthPointers_z16(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (drb->Base.Format == MESA_FORMAT_S8_Z24) {
       r128InitDepthPointers_z24_s8(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (drb->Base.Format == MESA_FORMAT_S8) {
       radeonInitStencilPointers_z24_s8(&drb->Base);
    }
 }