mesa/formats: add more MESA_FORMAT_LAYOUTs
[mesa.git] / src / mesa / swrast / s_triangle.c
index 00383fb84f8996415898d9b02164c8a1ae1a4f89..876a74b086304e4d3e8040ffbd43340d1e56b199 100644 (file)
 
 #include "main/glheader.h"
 #include "main/context.h"
-#include "main/colormac.h"
 #include "main/imports.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/state.h"
 #include "main/samplerobj.h"
+#include "main/teximage.h"
 #include "program/prog_instruction.h"
 
 #include "s_aatriangle.h"
@@ -77,8 +77,8 @@ _swrast_culltriangle( struct gl_context *ctx,
 #define NAME flat_rgba_triangle
 #define INTERP_Z 1
 #define SETUP_CODE                             \
-   ASSERT(ctx->Texture._EnabledCoordUnits == 0);\
-   ASSERT(ctx->Light.ShadeModel==GL_FLAT);     \
+   assert(ctx->Texture._EnabledCoordUnits == 0);\
+   assert(ctx->Light.ShadeModel==GL_FLAT);     \
    span.interpMask |= SPAN_RGBA;               \
    span.red = ChanToFixed(v2->color[0]);       \
    span.green = ChanToFixed(v2->color[1]);     \
@@ -103,8 +103,8 @@ _swrast_culltriangle( struct gl_context *ctx,
 #define SETUP_CODE                             \
    {                                           \
       /* texturing must be off */              \
-      ASSERT(ctx->Texture._EnabledCoordUnits == 0);    \
-      ASSERT(ctx->Light.ShadeModel==GL_SMOOTH);        \
+      assert(ctx->Texture._EnabledCoordUnits == 0);    \
+      assert(ctx->Light.ShadeModel==GL_SMOOTH);        \
    }
 #define RENDER_SPAN( span )  _swrast_write_rgba_span(ctx, &span);
 #include "s_tritemp.h"
@@ -127,7 +127,7 @@ _swrast_culltriangle( struct gl_context *ctx,
    const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
    const struct gl_texture_image *texImg =                             \
-      obj->Image[0][obj->BaseLevel];                                   \
+      _mesa_base_tex_image(obj);                                       \
    const struct swrast_texture_image *swImg =                          \
       swrast_texture_image_const(texImg);                              \
    const GLfloat twidth = (GLfloat) texImg->Width;                     \
@@ -136,7 +136,7 @@ _swrast_culltriangle( struct gl_context *ctx,
    const GLubyte *texture = (const GLubyte *) swImg->ImageSlices[0];   \
    const GLint smask = texImg->Width - 1;                              \
    const GLint tmask = texImg->Height - 1;                             \
-   ASSERT(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8);                        \
+   assert(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8);                        \
    if (!rb || !texture) {                                              \
       return;                                                          \
    }
@@ -185,7 +185,7 @@ _swrast_culltriangle( struct gl_context *ctx,
    const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
    const struct gl_texture_image *texImg =                             \
-       obj->Image[0][obj->BaseLevel];                                  \
+      _mesa_base_tex_image(obj);                                       \
    const struct swrast_texture_image *swImg =                          \
       swrast_texture_image_const(texImg);                              \
    const GLfloat twidth = (GLfloat) texImg->Width;                     \
@@ -194,7 +194,7 @@ _swrast_culltriangle( struct gl_context *ctx,
    const GLubyte *texture = (const GLubyte *) swImg->ImageSlices[0];   \
    const GLint smask = texImg->Width - 1;                              \
    const GLint tmask = texImg->Height - 1;                             \
-   ASSERT(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8);                        \
+   assert(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8);                        \
    if (!rb || !texture) {                                              \
       return;                                                          \
    }
@@ -512,7 +512,7 @@ affine_span(struct gl_context *ctx, SWspan *span,
       break;
    }
    span->interpMask &= ~SPAN_RGBA;
-   ASSERT(span->arrayMask & SPAN_RGBA);
+   assert(span->arrayMask & SPAN_RGBA);
 
    _swrast_write_rgba_span(ctx, span);
 
@@ -542,7 +542,7 @@ affine_span(struct gl_context *ctx, SWspan *span,
    const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
    const struct gl_texture_image *texImg =                             \
-      obj->Image[0][obj->BaseLevel];                                   \
+      _mesa_base_tex_image(obj);                                       \
    const struct swrast_texture_image *swImg =                          \
       swrast_texture_image_const(texImg);                              \
    const GLfloat twidth = (GLfloat) texImg->Width;                     \
@@ -782,7 +782,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
       break;
    }
    
-   ASSERT(span->arrayMask & SPAN_RGBA);
+   assert(span->arrayMask & SPAN_RGBA);
    _swrast_write_rgba_span(ctx, span);
 
 #undef SPAN_NEAREST
@@ -811,7 +811,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
    const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
    const struct gl_texture_image *texImg =                             \
-      obj->Image[0][obj->BaseLevel];                                   \
+      _mesa_base_tex_image(obj);                                       \
    const struct swrast_texture_image *swImg =                          \
       swrast_texture_image_const(texImg);                              \
    info.texture = (const GLchan *) swImg->ImageSlices[0];              \
@@ -884,9 +884,9 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
    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(ctx->Depth.Test);                                            \
+   assert(!ctx->Depth.Mask);                                           \
+   assert(ctx->Depth.Func == GL_LESS);                                 \
    assert(rb->Format == MESA_FORMAT_Z_UNORM16);                               \
    if (!q) {                                                           \
       return;                                                          \
@@ -1014,7 +1014,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
 
       if (ctx->Polygon.SmoothFlag) {
          _swrast_set_aa_triangle_function(ctx);
-         ASSERT(swrast->Triangle);
+         assert(swrast->Triangle);
          return;
       }
 
@@ -1059,7 +1059,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
          else
             samp = NULL;
 
-         texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL;
+         texImg = texObj2D ? _mesa_base_tex_image(texObj2D) : NULL;
          swImg = swrast_texture_image_const(texImg);
 
          format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
@@ -1071,8 +1071,8 @@ _swrast_choose_triangle( struct gl_context *ctx )
          if (ctx->Texture._EnabledCoordUnits == 0x1
              && !_swrast_use_fragment_program(ctx)
              && !ctx->ATIFragmentShader._Enabled
-             && ctx->Texture._EnabledUnits == 0x1
-             && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
+             && ctx->Texture._MaxEnabledTexImageUnit == 0
+             && ctx->Texture.Unit[0]._Current->Target == GL_TEXTURE_2D
              && samp->WrapS == GL_REPEAT
              && samp->WrapT == GL_REPEAT
              && texObj2D->_Swizzle == SWIZZLE_NOOP
@@ -1133,8 +1133,8 @@ _swrast_choose_triangle( struct gl_context *ctx )
          }
       }
       else {
-         ASSERT(!swrast->_FogEnabled);
-         ASSERT(!_mesa_need_secondary_color(ctx));
+         assert(!swrast->_FogEnabled);
+         assert(!_mesa_need_secondary_color(ctx));
         if (ctx->Light.ShadeModel==GL_SMOOTH) {
            /* smooth shaded, no texturing, stippled or some raster ops */
 #if CHAN_BITS != 8