Fix 24bpp software rendering
authorMarc Pignat <marc@pignat.org>
Fri, 24 Jun 2011 13:19:32 +0000 (15:19 +0200)
committerBrian Paul <brianp@vmware.com>
Fri, 24 Jun 2011 15:38:24 +0000 (09:38 -0600)
This patch add the support for 24bpp in the dri/swrast implementation.

Signed-off-by: Marc Pignat <marc@pignat.org>
Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/drivers/dri/swrast/swrast.c
src/mesa/drivers/dri/swrast/swrast_priv.h
src/mesa/drivers/dri/swrast/swrast_span.c

index 719b406ec05feeef79ff22f8dace5ba3230d3954..90b5ef0fc210d2ae508d3551989a6e4e65466bcb 100644 (file)
@@ -233,10 +233,17 @@ choose_pixel_format(const struct gl_config *v)
        && v->blueMask  == 0x0000ff)
        return PF_A8R8G8B8;
     else if (depth == 24
-            && v->redMask   == 0xff0000
-            && v->greenMask == 0x00ff00
-            && v->blueMask  == 0x0000ff)
-       return PF_X8R8G8B8;
+             && v->depthBits == 32
+             && v->redMask   == 0xff0000
+             && v->greenMask == 0x00ff00
+             && v->blueMask  == 0x0000ff)
+        return PF_X8R8G8B8;
+    else if (depth == 24
+             && v->depthBits == 24
+             && v->redMask   == 0xff0000
+             && v->greenMask == 0x00ff00
+             && v->blueMask  == 0x0000ff)
+        return PF_R8G8B8;
     else if (depth == 16
             && v->redMask   == 0xf800
             && v->greenMask == 0x07e0
@@ -344,6 +351,13 @@ swrast_new_renderbuffer(const struct gl_config *visual, GLboolean front)
        xrb->Base.DataType = GL_UNSIGNED_BYTE;
        xrb->bpp = 32;
        break;
+    case PF_R8G8B8:
+        xrb->Base.Format = MESA_FORMAT_RGB888;
+        xrb->Base.InternalFormat = GL_RGB;
+        xrb->Base._BaseFormat = GL_RGB;
+        xrb->Base.DataType = GL_UNSIGNED_BYTE;
+        xrb->bpp = 24;
+        break;
     case PF_R5G6B5:
        xrb->Base.Format = MESA_FORMAT_RGB565;
        xrb->Base.InternalFormat = GL_RGB;
index bdb52ef26f10a093725b98e0015a1e141f888bf3..40f787f52df4caf0025de3b6f1261a1cfda14056 100644 (file)
@@ -123,6 +123,7 @@ swrast_renderbuffer(struct gl_renderbuffer *rb)
 #define PF_R5G6B5     2                /**< 16bpp TrueColor:  5-R, 6-G, 5-B bits */
 #define PF_R3G3B2     3                /**<  8bpp TrueColor:  3-R, 3-G, 2-B bits */
 #define PF_X8R8G8B8   4                /**< 32bpp TrueColor:  8-R, 8-G, 8-B bits */
+#define PF_R8G8B8     5         /**< 24bpp TrueColor:  8-R, 8-G, 8-B bits */
 
 
 /* swrast_span.c */
index c7d0bfdac72b6fdb8f11aae3fcd316923e942082..71aafbbe5d3049583936fd759ad6c24f0b216af2 100644 (file)
@@ -81,6 +81,22 @@ static const GLubyte kernel[16] = {
    DST[BCOMP] = *SRC & 0xff
 
 
+/* 24-bit BGR */
+#define STORE_PIXEL_R8G8B8(DST, X, Y, VALUE) \
+   DST[2] = VALUE[RCOMP]; \
+   DST[1] = VALUE[GCOMP]; \
+   DST[0] = VALUE[BCOMP]
+#define STORE_PIXEL_RGB_R8G8B8(DST, X, Y, VALUE) \
+   DST[2] = VALUE[RCOMP]; \
+   DST[1] = VALUE[GCOMP]; \
+   DST[0] = VALUE[BCOMP]
+#define FETCH_PIXEL_R8G8B8(DST, SRC) \
+   DST[ACOMP] = 0xff;                  \
+   DST[RCOMP] = (*SRC >> 16) & 0xff;   \
+   DST[GCOMP] = (*SRC >> 8) & 0xff;    \
+   DST[BCOMP] = *SRC & 0xff
+
+
 /* 16-bit BGR */
 #define STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) \
    do { \
@@ -157,6 +173,24 @@ static const GLubyte kernel[16] = {
 #include "swrast/s_spantemp.h"
 
 
+/* 24-bit BGR */
+#define NAME(FUNC) FUNC##_R8G8B8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (3*X);
+#define INC_PIXEL_PTR(P) P+=3
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+   STORE_PIXEL_R8G8B8(DST, X, Y, VALUE)
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+   STORE_PIXEL_RGB_R8G8B8(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+   FETCH_PIXEL_R8G8B8(DST, SRC)
+
+#include "swrast/s_spantemp.h"
+
+
 /* 16-bit BGR */
 #define NAME(FUNC) FUNC##_R5G6B5
 #define RB_TYPE GLubyte
@@ -229,6 +263,24 @@ static const GLubyte kernel[16] = {
 #include "swrast_spantemp.h"
 
 
+/* 24-bit BGR */
+#define NAME(FUNC) FUNC##_R8G8B8_front
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)row;
+#define INC_PIXEL_PTR(P) P+=3
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+   STORE_PIXEL_R8G8B8(DST, X, Y, VALUE)
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+   STORE_PIXEL_RGB_R8G8B8(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+   FETCH_PIXEL_R8G8B8(DST, SRC)
+
+#include "swrast_spantemp.h"
+
+
 /* 16-bit BGR */
 #define NAME(FUNC) FUNC##_R5G6B5_front
 #define RB_TYPE GLubyte
@@ -290,6 +342,15 @@ swrast_set_span_funcs_back(struct swrast_renderbuffer *xrb,
        xrb->Base.PutValues = put_values_X8R8G8B8;
        xrb->Base.PutMonoValues = put_mono_values_X8R8G8B8;
        break;
+   case PF_R8G8B8:
+        xrb->Base.GetRow = get_row_R8G8B8;
+        xrb->Base.GetValues = get_values_R8G8B8;
+        xrb->Base.PutRow = put_row_R8G8B8;
+        xrb->Base.PutRowRGB = put_row_rgb_R8G8B8;
+        xrb->Base.PutMonoRow = put_mono_row_R8G8B8;
+        xrb->Base.PutValues = put_values_R8G8B8;
+        xrb->Base.PutMonoValues = put_mono_values_R8G8B8;
+        break;
     case PF_R5G6B5:
        xrb->Base.GetRow = get_row_R5G6B5;
        xrb->Base.GetValues = get_values_R5G6B5;
@@ -346,6 +407,15 @@ swrast_set_span_funcs_front(struct swrast_renderbuffer *xrb,
        xrb->Base.PutValues = put_values_X8R8G8B8_front;
        xrb->Base.PutMonoValues = put_mono_values_X8R8G8B8_front;
        break;
+    case PF_R8G8B8:
+        xrb->Base.GetRow = get_row_R8G8B8_front;
+        xrb->Base.GetValues = get_values_R8G8B8_front;
+        xrb->Base.PutRow = put_row_R8G8B8_front;
+        xrb->Base.PutRowRGB = put_row_rgb_R8G8B8_front;
+        xrb->Base.PutMonoRow = put_mono_row_R8G8B8_front;
+        xrb->Base.PutValues = put_values_R8G8B8_front;
+        xrb->Base.PutMonoValues = put_mono_values_R8G8B8_front;
+        break;
     case PF_R5G6B5:
        xrb->Base.GetRow = get_row_R5G6B5_front;
        xrb->Base.GetValues = get_values_R5G6B5_front;