mesa: Introduce a globally-available minify() macro.
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_span.c
index 569aca92ce4b9d7da59ed5ed1d129c9fcbf47d5a..0617adc5bc5c1395a3ec541135a77c6c42d082ae 100644 (file)
@@ -43,126 +43,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/glheader.h"
 #include "main/texformat.h"
 #include "main/renderbuffer.h"
+#include "main/samplerobj.h"
 #include "swrast/swrast.h"
 #include "swrast/s_renderbuffer.h"
 
 #include "radeon_common.h"
 #include "radeon_span.h"
 
-#define DBG 0
-
-#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
-#if defined(__linux__)
-#include <byteswap.h>
-#define CPU_TO_LE16( x )       bswap_16( x )
-#define LE16_TO_CPU( x )       bswap_16( x )
-#endif /* __linux__ */
-#else
-#define CPU_TO_LE16( x )       ( x )
-#define LE16_TO_CPU( x )       ( x )
-#endif
-
-static void radeonSetSpanFunctions(struct radeon_renderbuffer *rrb);
-
-/*
- * Note that all information needed to access pixels in a renderbuffer
- * should be obtained through the gl_renderbuffer parameter, not per-context
- * information.
- */
-#define LOCAL_VARS                                             \
-   struct radeon_renderbuffer *rrb = (void *) rb;              \
-   int minx = 0, miny = 0;                                             \
-   int maxx = rb->Width;                                               \
-   int maxy = rb->Height;                                              \
-   void *buf = rb->Map;                                                \
-   int pitch = rb->RowStrideBytes;                             \
-   GLuint p;                                           \
-   (void)p;
-
-#define Y_FLIP(_y) (_y)
-
-#define HW_LOCK()
-#define HW_UNLOCK()
-#define HW_CLIPLOOP()
-#define HW_ENDCLIPLOOP()
-
-/* ================================================================
- * Color buffer
- */
-
-/* 16 bit, RGB565 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_RGB
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
-#define TAG(x)    radeon##x##_RGB565
-#define TAG2(x,y) radeon##x##_RGB565##y
-#include "spantmp2.h"
-
-#define SPANTMP_PIXEL_FMT GL_RGB
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5_REV
-#define TAG(x)    radeon##x##_RGB565_REV
-#define TAG2(x,y) radeon##x##_RGB565_REV##y
-#include "spantmp2.h"
-
-/* 16 bit, ARGB1555 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_1_5_5_5_REV
-#define TAG(x)    radeon##x##_ARGB1555
-#define TAG2(x,y) radeon##x##_ARGB1555##y
-#include "spantmp2.h"
-
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_1_5_5_5
-#define TAG(x)    radeon##x##_ARGB1555_REV
-#define TAG2(x,y) radeon##x##_ARGB1555_REV##y
-#include "spantmp2.h"
-
-/* 16 bit, RGBA4 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_4_4_4_4_REV
-#define TAG(x)    radeon##x##_ARGB4444
-#define TAG2(x,y) radeon##x##_ARGB4444##y
-#include "spantmp2.h"
-
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_4_4_4_4
-#define TAG(x)    radeon##x##_ARGB4444_REV
-#define TAG2(x,y) radeon##x##_ARGB4444_REV##y
-#include "spantmp2.h"
-
-/* 32 bit, xRGB8888 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
-#define TAG(x)    radeon##x##_xRGB8888
-#define TAG2(x,y) radeon##x##_xRGB8888##y
-#include "spantmp2.h"
-
-/* 32 bit, ARGB8888 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
-#define TAG(x)    radeon##x##_ARGB8888
-#define TAG2(x,y) radeon##x##_ARGB8888##y
-#include "spantmp2.h"
-
-/* 32 bit, BGRx8888 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8
-#define TAG(x)    radeon##x##_BGRx8888
-#define TAG2(x,y) radeon##x##_BGRx8888##y
-#include "spantmp2.h"
-
-/* 32 bit, BGRA8888 color spanline and pixel functions
- */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8
-#define TAG(x)    radeon##x##_BGRA8888
-#define TAG2(x,y) radeon##x##_BGRA8888##y
-#include "spantmp2.h"
 
 static void
 radeon_renderbuffer_map(struct gl_context *ctx, struct gl_renderbuffer *rb)
@@ -178,11 +65,10 @@ radeon_renderbuffer_map(struct gl_context *ctx, struct gl_renderbuffer *rb)
                                    GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
                                    &map, &stride);
 
-       rb->Map = map;
-       rb->RowStride = stride / _mesa_get_format_bytes(rb->Format);
-       rb->RowStrideBytes = stride;
-
-       radeonSetSpanFunctions(rrb);
+       rrb->base.Map = map;
+       rrb->base.RowStride = stride;
+       /* No floating point color buffers, use GLubytes */
+       rrb->base.ColorType = GL_UNSIGNED_BYTE;
 }
 
 static void
@@ -194,11 +80,8 @@ radeon_renderbuffer_unmap(struct gl_context *ctx, struct gl_renderbuffer *rb)
 
        ctx->Driver.UnmapRenderbuffer(ctx, rb);
 
-       rb->GetRow = NULL;
-       rb->PutRow = NULL;
-       rb->Map = NULL;
-       rb->RowStride = 0;
-       rb->RowStrideBytes = 0;
+       rrb->base.Map = NULL;
+       rrb->base.RowStride = 0;
 }
 
 static void
@@ -242,7 +125,8 @@ static void radeonSpanRenderStart(struct gl_context * ctx)
 
        for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
                if (ctx->Texture.Unit[i]._ReallyEnabled) {
-                       radeon_validate_texture_miptree(ctx, ctx->Texture.Unit[i]._Current);
+                       radeon_validate_texture_miptree(ctx, _mesa_get_samplerobj(ctx, i),
+                                                       ctx->Texture.Unit[i]._Current);
                        radeon_swrast_map_texture_images(ctx, ctx->Texture.Unit[i]._Current);
                }
        }
@@ -275,40 +159,3 @@ void radeonInitSpanFuncs(struct gl_context * ctx)
        swdd->SpanRenderFinish = radeonSpanRenderFinish;
 }
 
-/**
- * Plug in the Get/Put routines for the given driRenderbuffer.
- */
-static void radeonSetSpanFunctions(struct radeon_renderbuffer *rrb)
-{
-       if (rrb->base.Format == MESA_FORMAT_RGB565) {
-               radeonInitPointers_RGB565(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_RGB565_REV) {
-               radeonInitPointers_RGB565_REV(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_XRGB8888) {
-               radeonInitPointers_xRGB8888(&rrb->base);
-        } else if (rrb->base.Format == MESA_FORMAT_XRGB8888_REV) {
-               radeonInitPointers_BGRx8888(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_ARGB8888) {
-               radeonInitPointers_ARGB8888(&rrb->base);
-        } else if (rrb->base.Format == MESA_FORMAT_ARGB8888_REV) {
-               radeonInitPointers_BGRA8888(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_ARGB4444) {
-               radeonInitPointers_ARGB4444(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_ARGB4444_REV) {
-               radeonInitPointers_ARGB4444_REV(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_ARGB1555) {
-               radeonInitPointers_ARGB1555(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_ARGB1555_REV) {
-               radeonInitPointers_ARGB1555_REV(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_Z16) {
-               _swrast_set_renderbuffer_accessors(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_X8_Z24) {
-               _swrast_set_renderbuffer_accessors(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_S8_Z24) {
-               _swrast_set_renderbuffer_accessors(&rrb->base);
-       } else if (rrb->base.Format == MESA_FORMAT_S8) {
-               _swrast_set_renderbuffer_accessors(&rrb->base);
-       } else {
-               fprintf(stderr, "radeonSetSpanFunctions: bad format: 0x%04X\n", rrb->base.Format);
-       }
-}