mesa: remove gl_renderbuffer::DataType
[mesa.git] / src / mesa / swrast / s_triangle.c
index c4d504b06bf2e19b816c83e3d237150f2a457b6c..124aa5f8edd2f2005a3938c9c185a1bf1c25dde4 100644 (file)
@@ -132,7 +132,7 @@ _swrast_culltriangle( struct gl_context *ctx,
    const GLfloat twidth = (GLfloat) texImg->Width;                     \
    const GLfloat theight = (GLfloat) texImg->Height;                   \
    const GLint twidth_log2 = texImg->WidthLog2;                                \
-   const GLubyte *texture = (const GLubyte *) swImg->Data;             \
+   const GLubyte *texture = (const GLubyte *) swImg->Map;              \
    const GLint smask = texImg->Width - 1;                              \
    const GLint tmask = texImg->Height - 1;                             \
    ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888);                    \
@@ -157,7 +157,8 @@ _swrast_culltriangle( struct gl_context *ctx,
       span.intTex[0] += span.intTexStep[0];                            \
       span.intTex[1] += span.intTexStep[1];                            \
    }                                                                   \
-   rb->PutRow(ctx, rb, span.end, span.x, span.y, rgba, NULL);
+   _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, span.end,                 \
+                   span.x, span.y, rgba, NULL);
 
 #include "s_tritemp.h"
 
@@ -189,7 +190,7 @@ _swrast_culltriangle( struct gl_context *ctx,
    const GLfloat twidth = (GLfloat) texImg->Width;                     \
    const GLfloat theight = (GLfloat) texImg->Height;                   \
    const GLint twidth_log2 = texImg->WidthLog2;                                \
-   const GLubyte *texture = (const GLubyte *) swImg->Data;             \
+   const GLubyte *texture = (const GLubyte *) swImg->Map;              \
    const GLint smask = texImg->Width - 1;                              \
    const GLint tmask = texImg->Height - 1;                             \
    ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888);                    \
@@ -223,7 +224,8 @@ _swrast_culltriangle( struct gl_context *ctx,
       span.intTex[1] += span.intTexStep[1];                            \
       span.z += span.zStep;                                            \
    }                                                                   \
-   rb->PutRow(ctx, rb, span.end, span.x, span.y, rgba, span.array->mask);
+   _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE,                           \
+                   span.end, span.x, span.y, rgba, span.array->mask);
 
 #include "s_tritemp.h"
 
@@ -543,7 +545,7 @@ affine_span(struct gl_context *ctx, SWspan *span,
       swrast_texture_image_const(texImg);                              \
    const GLfloat twidth = (GLfloat) texImg->Width;                     \
    const GLfloat theight = (GLfloat) texImg->Height;                   \
-   info.texture = (const GLchan *) swImg->Data;                                \
+   info.texture = (const GLchan *) swImg->Map;                         \
    info.twidth_log2 = texImg->WidthLog2;                               \
    info.smask = texImg->Width - 1;                                     \
    info.tmask = texImg->Height - 1;                                    \
@@ -810,7 +812,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
       obj->Image[0][obj->BaseLevel];                                   \
    const struct swrast_texture_image *swImg =                          \
       swrast_texture_image_const(texImg);                              \
-   info.texture = (const GLchan *) swImg->Data;                                \
+   info.texture = (const GLchan *) swImg->Map;                         \
    info.twidth_log2 = texImg->WidthLog2;                               \
    info.smask = texImg->Width - 1;                                     \
    info.tmask = texImg->Height - 1;                                    \
@@ -874,19 +876,21 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
 /*
  * Special tri function for occlusion testing
  */
-#define NAME occlusion_zless_triangle
+#define NAME occlusion_zless_16_triangle
 #define INTERP_Z 1
 #define SETUP_CODE                                                     \
-   struct gl_renderbuffer *rb = ctx->DrawBuffer->_DepthBuffer;         \
+   struct gl_renderbuffer *rb =                                         \
+      ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;           \
    struct gl_query_object *q = ctx->Query.CurrentOcclusionObject;      \
    ASSERT(ctx->Depth.Test);                                            \
    ASSERT(!ctx->Depth.Mask);                                           \
    ASSERT(ctx->Depth.Func == GL_LESS);                                 \
+   assert(rb->Format == MESA_FORMAT_Z16);                               \
    if (!q) {                                                           \
       return;                                                          \
    }
 #define RENDER_SPAN( span )                                            \
-   if (rb->Format == MESA_FORMAT_Z16) {                                        \
+   {                                                                    \
       GLuint i;                                                                \
       const GLushort *zRow = (const GLushort *)                                \
          _swrast_pixel_address(rb, span.x, span.y);                     \
@@ -897,17 +901,6 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
          }                                                             \
          span.z += span.zStep;                                         \
       }                                                                        \
-   }                                                                   \
-   else {                                                              \
-      GLuint i;                                                                \
-      const GLuint *zRow = (const GLuint *)                            \
-         _swrast_pixel_address(rb, span.x, span.y);                    \
-      for (i = 0; i < span.end; i++) {                                 \
-         if ((GLuint)span.z < zRow[i]) {                               \
-            q->Result++;                                               \
-         }                                                             \
-         span.z += span.zStep;                                         \
-      }                                                                        \
    }
 #include "s_tritemp.h"
 
@@ -1014,6 +1007,8 @@ _swrast_choose_triangle( struct gl_context *ctx )
    }
 
    if (ctx->RenderMode==GL_RENDER) {
+      struct gl_renderbuffer *depthRb =
+         ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
 
       if (ctx->Polygon.SmoothFlag) {
          _swrast_set_aa_triangle_function(ctx);
@@ -1026,12 +1021,14 @@ _swrast_choose_triangle( struct gl_context *ctx )
           ctx->Depth.Test &&
           ctx->Depth.Mask == GL_FALSE &&
           ctx->Depth.Func == GL_LESS &&
-          !ctx->Stencil._Enabled) {
+          !ctx->Stencil._Enabled &&
+          depthRb &&
+          depthRb->Format == MESA_FORMAT_Z16) {
          if (ctx->Color.ColorMask[0][0] == 0 &&
             ctx->Color.ColorMask[0][1] == 0 &&
             ctx->Color.ColorMask[0][2] == 0 &&
             ctx->Color.ColorMask[0][3] == 0) {
-            USE(occlusion_zless_triangle);
+            USE(occlusion_zless_16_triangle);
             return;
          }
       }