radeon: FBO fixes for big endian.
authorMichel Dänzer <daenzer@vmware.com>
Tue, 17 Nov 2009 07:05:22 +0000 (08:05 +0100)
committerMichel Dänzer <daenzer@vmware.com>
Tue, 17 Nov 2009 07:05:22 +0000 (08:05 +0100)
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/radeon/radeon_fbo.c
src/mesa/drivers/dri/radeon/radeon_screen.c

index 1e2a54f63426f73ecded94bac0f5f758a048ccea..c7996eb76a213c8bc68f95800ba6aa49475c1756 100644 (file)
@@ -281,12 +281,27 @@ static void emit_cb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
                cbpitch |= R300_COLOR_FORMAT_ARGB8888;
        else switch (rrb->base.Format) {
         case MESA_FORMAT_RGB565:
+               assert(_mesa_little_endian());
+               cbpitch |= R300_COLOR_FORMAT_RGB565;
+               break;
+        case MESA_FORMAT_RGB565_REV:
+               assert(!_mesa_little_endian());
                cbpitch |= R300_COLOR_FORMAT_RGB565;
                break;
         case MESA_FORMAT_ARGB4444:
+               assert(_mesa_little_endian());
+               cbpitch |= R300_COLOR_FORMAT_ARGB4444;
+               break;
+        case MESA_FORMAT_ARGB4444_REV:
+               assert(!_mesa_little_endian());
                cbpitch |= R300_COLOR_FORMAT_ARGB4444;
                break;
        case MESA_FORMAT_ARGB1555:
+               assert(_mesa_little_endian());
+               cbpitch |= R300_COLOR_FORMAT_ARGB1555;
+               break;
+       case MESA_FORMAT_ARGB1555_REV:
+               assert(!_mesa_little_endian());
                cbpitch |= R300_COLOR_FORMAT_ARGB1555;
                break;
        default:
index bf69cd933709a162a6509f1a4da922d47d7161df..7ec641ff18a05fa2e87ed1db35d342e1f5a5adbb 100644 (file)
@@ -90,7 +90,7 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_R3_G3_B2:
    case GL_RGB4:
    case GL_RGB5:
-      rb->Format = MESA_FORMAT_RGB565;
+      rb->Format = _dri_texformat_rgb565;
       rb->DataType = GL_UNSIGNED_BYTE;
       cpp = 2;
       break;
@@ -99,7 +99,7 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      rb->Format = MESA_FORMAT_ARGB8888;
+      rb->Format = _dri_texformat_argb8888;
       rb->DataType = GL_UNSIGNED_BYTE;
       cpp = 4;
       break;
@@ -111,7 +111,7 @@ radeon_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    case GL_RGB10_A2:
    case GL_RGBA12:
    case GL_RGBA16:
-      rb->Format = MESA_FORMAT_ARGB8888;
+      rb->Format = _dri_texformat_argb8888;
       rb->DataType = GL_UNSIGNED_BYTE;
       cpp = 4;
       break;
@@ -261,14 +261,32 @@ radeon_create_renderbuffer(gl_format format, __DRIdrawablePrivate *driDrawPriv)
 
     switch (format) {
         case MESA_FORMAT_RGB565:
+           assert(_mesa_little_endian());
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGB;
+           break;
+        case MESA_FORMAT_RGB565_REV:
+           assert(!_mesa_little_endian());
            rrb->base.DataType = GL_UNSIGNED_BYTE;
             rrb->base._BaseFormat = GL_RGB;
            break;
         case MESA_FORMAT_XRGB8888:
+           assert(_mesa_little_endian());
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGB;
+           break;
+        case MESA_FORMAT_XRGB8888_REV:
+           assert(!_mesa_little_endian());
            rrb->base.DataType = GL_UNSIGNED_BYTE;
             rrb->base._BaseFormat = GL_RGB;
            break;
        case MESA_FORMAT_ARGB8888:
+           assert(_mesa_little_endian());
+           rrb->base.DataType = GL_UNSIGNED_BYTE;
+            rrb->base._BaseFormat = GL_RGBA;
+           break;
+       case MESA_FORMAT_ARGB8888_REV:
+           assert(!_mesa_little_endian());
            rrb->base.DataType = GL_UNSIGNED_BYTE;
             rrb->base._BaseFormat = GL_RGBA;
            break;
@@ -359,21 +377,21 @@ radeon_update_wrapper(GLcontext *ctx, struct radeon_renderbuffer *rrb,
        gl_format texFormat;
 
 restart:
-       if (texImage->TexFormat == MESA_FORMAT_ARGB8888) {
+       if (texImage->TexFormat == _dri_texformat_argb8888) {
                rrb->base.DataType = GL_UNSIGNED_BYTE;
                DBG("Render to RGBA8 texture OK\n");
        }
-       else if (texImage->TexFormat == MESA_FORMAT_RGB565) {
+       else if (texImage->TexFormat == _dri_texformat_rgb565) {
                rrb->base.DataType = GL_UNSIGNED_BYTE;
                DBG("Render to RGB5 texture OK\n");
        }
-       else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
+       else if (texImage->TexFormat == _dri_texformat_argb1555) {
                rrb->base.DataType = GL_UNSIGNED_BYTE;
                DBG("Render to ARGB1555 texture OK\n");
        }
-       else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
+       else if (texImage->TexFormat == _dri_texformat_argb4444) {
                rrb->base.DataType = GL_UNSIGNED_BYTE;
-               DBG("Render to ARGB1555 texture OK\n");
+               DBG("Render to ARGB4444 texture OK\n");
        }
        else if (texImage->TexFormat == MESA_FORMAT_Z16) {
                rrb->base.DataType = GL_UNSIGNED_SHORT;
index 2bcceb16d606f5120bc65507d01721427c142f46..be2d8365ef56a599a5e0d9b290068a1be0c3427f 100644 (file)
@@ -1484,11 +1484,11 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
     _mesa_initialize_framebuffer(&rfb->base, mesaVis);
 
     if (mesaVis->redBits == 5)
-        rgbFormat = MESA_FORMAT_RGB565;
+        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_RGB565 : MESA_FORMAT_RGB565_REV;
     else if (mesaVis->alphaBits == 0)
-        rgbFormat = MESA_FORMAT_XRGB8888;
+        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_XRGB8888 : MESA_FORMAT_XRGB8888_REV;
     else
-        rgbFormat = MESA_FORMAT_ARGB8888;
+        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB8888_REV;
 
     /* front color renderbuffer */
     rfb->color_rb[0] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);