From: Marc Pignat Date: Fri, 24 Jun 2011 13:19:32 +0000 (+0200) Subject: Fix 24bpp software rendering X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0c0bb6cb140825f5bab3c40c0c9c0ec575fbc76;p=mesa.git Fix 24bpp software rendering This patch add the support for 24bpp in the dri/swrast implementation. Signed-off-by: Marc Pignat Signed-off-by: Brian Paul --- diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 719b406ec05..90b5ef0fc21 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -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; diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index bdb52ef26f1..40f787f52df 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -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 */ diff --git a/src/mesa/drivers/dri/swrast/swrast_span.c b/src/mesa/drivers/dri/swrast/swrast_span.c index c7d0bfdac72..71aafbbe5d3 100644 --- a/src/mesa/drivers/dri/swrast/swrast_span.c +++ b/src/mesa/drivers/dri/swrast/swrast_span.c @@ -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;