mesa: Branch 'master' - 3 commits
Brian Paul
brianp at kemper.freedesktop.org
Mon Apr 2 00:32:25 UTC 2007
src/mesa/drivers/x11/xm_api.c | 52 +++++++++++++++++------------------------
src/mesa/drivers/x11/xm_line.c | 19 +++++++-------
src/mesa/drivers/x11/xm_tri.c | 44 ++++++++++++++++++++++++----------
src/mesa/drivers/x11/xmesaP.h | 8 +++---
4 files changed, 66 insertions(+), 57 deletions(-)
New commits:
diff-tree 3fd88089c03f2dbe634ba2611955c6d0a6b2ccd5 (from 0683e4ce4bbbe381cbf59122aaef4ae3671d45e9)
Author: Brian <brian at nostromo.localnet.net>
Date: Sun Apr 1 18:30:28 2007 -0600
Fix some bugs/issues related to alpha channel support. See bug 10483.
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 63b9ac5..24028a4 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -970,42 +970,33 @@ setup_truecolor(XMesaVisual v, XMesaBuff
&& GET_BLUEMASK(v) ==0xff0000
&& CHECK_BYTE_ORDER(v)
&& v->BitsPerPixel==32
- && sizeof(GLuint)==4
&& v->RedGamma==1.0 && v->GreenGamma==1.0 && v->BlueGamma==1.0) {
/* common 32 bpp config used on SGI, Sun */
- v->undithered_pf = v->dithered_pf = PF_8A8B8G8R;
+ v->undithered_pf = v->dithered_pf = PF_8A8B8G8R; /* ABGR */
}
- else if (GET_REDMASK(v) ==0xff0000
- && GET_GREENMASK(v)==0x00ff00
- && GET_BLUEMASK(v) ==0x0000ff
- && CHECK_BYTE_ORDER(v)
- && v->BitsPerPixel==32
- && sizeof(GLuint)==4
- && v->RedGamma==1.0 && v->GreenGamma==1.0 && v->BlueGamma==1.0) {
- /* common 32 bpp config used on Linux, HP, IBM */
- if (GET_VISUAL_DEPTH(v)==32)
- v->undithered_pf = v->dithered_pf = PF_8A8R8G8B;
- else
- v->undithered_pf = v->dithered_pf = PF_8R8G8B;
- }
- else if (GET_REDMASK(v) ==0xff0000
- && GET_GREENMASK(v)==0x00ff00
- && GET_BLUEMASK(v) ==0x0000ff
- && CHECK_BYTE_ORDER(v)
- && v->BitsPerPixel==24
- && sizeof(GLuint)==4
- && v->RedGamma==1.0 && v->GreenGamma==1.0 && v->BlueGamma==1.0) {
- /* common packed 24 bpp config used on Linux */
- v->undithered_pf = v->dithered_pf = PF_8R8G8B24;
+ else if (GET_REDMASK(v) == 0xff0000
+ && GET_GREENMASK(v)== 0x00ff00
+ && GET_BLUEMASK(v) == 0x0000ff
+ && CHECK_BYTE_ORDER(v)
+ && v->RedGamma == 1.0 && v->GreenGamma == 1.0 && v->BlueGamma == 1.0){
+ if (v->BitsPerPixel==32) {
+ /* if 32 bpp, and visual indicates 8 bpp alpha channel */
+ if (GET_VISUAL_DEPTH(v) == 32 && v->mesa_visual.alphaBits == 8)
+ v->undithered_pf = v->dithered_pf = PF_8A8R8G8B; /* ARGB */
+ else
+ v->undithered_pf = v->dithered_pf = PF_8R8G8B; /* xRGB */
+ }
+ else if (v->BitsPerPixel == 24) {
+ v->undithered_pf = v->dithered_pf = PF_8R8G8B24; /* RGB */
+ }
}
else if (GET_REDMASK(v) ==0xf800
&& GET_GREENMASK(v)==0x07e0
&& GET_BLUEMASK(v) ==0x001f
&& CHECK_BYTE_ORDER(v)
&& v->BitsPerPixel==16
- && sizeof(GLushort)==2
&& v->RedGamma==1.0 && v->GreenGamma==1.0 && v->BlueGamma==1.0) {
- /* 5-6-5 color weight on common PC VGA boards */
+ /* 5-6-5 RGB */
v->undithered_pf = PF_5R6G5B;
v->dithered_pf = PF_Dither_5R6G5B;
}
@@ -1013,6 +1004,7 @@ setup_truecolor(XMesaVisual v, XMesaBuff
&& GET_GREENMASK(v)==0x1c
&& GET_BLUEMASK(v) ==0x03
&& CHECK_FOR_HPCR(v)) {
+ /* 8-bit HP color recovery */
setup_8bit_hpcr( v );
}
}
@@ -1414,6 +1406,9 @@ XMesaVisual XMesaCreateVisual( XMesaDisp
v->mesa_visual.visualRating = visualCaveat;
+ if (alpha_flag)
+ v->mesa_visual.alphaBits = 8;
+
(void) initialize_visual_and_buffer( 0, v, NULL, rgb_flag, 0, 0 );
{
@@ -1422,7 +1417,6 @@ XMesaVisual XMesaCreateVisual( XMesaDisp
red_bits = _mesa_bitcount(GET_REDMASK(v));
green_bits = _mesa_bitcount(GET_GREENMASK(v));
blue_bits = _mesa_bitcount(GET_BLUEMASK(v));
- alpha_bits = 0;
}
else {
/* this is an approximation */
@@ -1436,11 +1430,9 @@ XMesaVisual XMesaCreateVisual( XMesaDisp
alpha_bits = 0;
assert( red_bits + green_bits + blue_bits == GET_VISUAL_DEPTH(v) );
}
+ alpha_bits = v->mesa_visual.alphaBits;
}
- if (alpha_flag && alpha_bits == 0)
- alpha_bits = 8;
-
_mesa_initialize_visual( &v->mesa_visual,
rgb_flag, db_flag, stereo_flag,
red_bits, green_bits,
diff-tree 0683e4ce4bbbe381cbf59122aaef4ae3671d45e9 (from ec42af9263bfba71074396f3850d5264083a5632)
Author: Brian <brian at nostromo.localnet.net>
Date: Sun Apr 1 18:28:28 2007 -0600
If using PF_8A8B8G8R, be sure alpha is correctly handled.
diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c
index c310542..8537256 100644
--- a/src/mesa/drivers/x11/xm_line.c
+++ b/src/mesa/drivers/x11/xm_line.c
@@ -147,7 +147,7 @@ void xmesa_choose_point( GLcontext *ctx
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
- GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
+ GLuint pixel = PACK_8A8B8G8R(color[0], color[1], color[2], color[3]);
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
@@ -164,7 +164,7 @@ void xmesa_choose_point( GLcontext *ctx
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
- GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
+ GLuint pixel = PACK_8A8R8G8B(color[0], color[1], color[2], color[3]);
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
@@ -331,7 +331,7 @@ void xmesa_choose_point( GLcontext *ctx
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
- GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
+ GLuint pixel = PACK_8A8B8G8R(color[0], color[1], color[2], color[3]);
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
@@ -354,7 +354,7 @@ void xmesa_choose_point( GLcontext *ctx
#define SETUP_CODE \
GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
- GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
+ GLuint pixel = PACK_8A8R8G8B(color[0], color[1], color[2], color[3]);
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
@@ -581,13 +581,11 @@ static swrast_line_func
get_line_func(GLcontext *ctx)
{
#if CHAN_BITS == 8
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
- struct xmesa_renderbuffer *xrb;
-
- if (CHAN_BITS != 8)
- return NULL;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+ const struct xmesa_renderbuffer *xrb;
if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
& (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
@@ -598,6 +596,7 @@ get_line_func(GLcontext *ctx)
if (ctx->Light.ShadeModel != GL_FLAT) return (swrast_line_func) NULL;
if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
+ if (xmbuf->swAlpha) return (swrast_line_func) NULL;
xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c
index 289ce11..2110e63 100644
--- a/src/mesa/drivers/x11/xm_tri.c
+++ b/src/mesa/drivers/x11/xm_tri.c
@@ -96,6 +96,7 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
+#define INTERP_ALPHA 1
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
@@ -106,13 +107,15 @@
for (i = 0; i < span.end; i++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
- pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
- FixedToInt(span.green), FixedToInt(span.blue)); \
+ pRow[i] = PACK_8A8B8G8R(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue), \
+ FixedToInt(span.alpha)); \
zRow[i] = z; \
} \
span.red += span.redStep; \
span.green += span.greenStep; \
span.blue += span.blueStep; \
+ span.alpha += span.alphaStep; \
span.z += span.zStep; \
}
@@ -127,6 +130,7 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
+#define INTERP_ALPHA 1
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
@@ -138,13 +142,15 @@
for (i = 0; i < span.end; i++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
- pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
- FixedToInt(span.green), FixedToInt(span.blue)); \
+ pRow[i] = PACK_8A8R8G8B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue), \
+ FixedToInt(span.alpha)); \
zRow[i] = z; \
} \
span.red += span.redStep; \
span.green += span.greenStep; \
span.blue += span.blueStep; \
+ span.alpha += span.alphaStep; \
span.z += span.zStep; \
}
@@ -473,7 +479,8 @@
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
GET_XRB(xrb); \
- GLuint p = PACK_8B8G8R( v2->color[0], v2->color[1], v2->color[2] );
+ GLuint p = PACK_8A8B8G8R( v2->color[0], v2->color[1],\
+ v2->color[2], v2->color[3]);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -499,7 +506,8 @@
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
GET_XRB(xrb); \
- GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
+ GLuint p = PACK_8A8R8G8B(v2->color[0], v2->color[1], \
+ v2->color[2], v2->color[3]);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -798,6 +806,7 @@
*/
#define NAME smooth_8A8B8G8R_triangle
#define INTERP_RGB 1
+#define INTERP_ALPHA 1
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
@@ -806,11 +815,13 @@
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
- pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
- FixedToInt(span.green), FixedToInt(span.blue) ); \
+ pRow[i] = PACK_8A8B8G8R(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue), \
+ FixedToInt(span.alpha)); \
span.red += span.redStep; \
span.green += span.greenStep; \
span.blue += span.blueStep; \
+ span.alpha += span.alphaStep; \
}
#include "swrast/s_tritemp.h"
@@ -821,6 +832,7 @@
*/
#define NAME smooth_8A8R8G8B_triangle
#define INTERP_RGB 1
+#define INTERP_ALPHA 1
#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
@@ -829,11 +841,13 @@
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
- pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
- FixedToInt(span.green), FixedToInt(span.blue) ); \
+ pRow[i] = PACK_8A8R8G8B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue), \
+ FixedToInt(span.alpha)); \
span.red += span.redStep; \
span.green += span.greenStep; \
span.blue += span.blueStep; \
+ span.alpha += span.alphaStep; \
}
#include "swrast/s_tritemp.h"
@@ -1419,6 +1433,7 @@ static const char *triFuncName = NULL;
#define USE(triFunc) \
do { \
triFuncName = #triFunc; \
+ printf("%s\n", triFuncName);\
return triFunc; \
} while (0)
@@ -1436,16 +1451,17 @@ do { \
static swrast_tri_func
get_triangle_func(GLcontext *ctx)
{
+#if CHAN_BITS == 8
SWcontext *swrast = SWRAST_CONTEXT(ctx);
XMesaContext xmesa = XMESA_CONTEXT(ctx);
- int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
- struct xmesa_renderbuffer *xrb;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+ const struct xmesa_renderbuffer *xrb;
#ifdef DEBUG
triFuncName = NULL;
#endif
-#if CHAN_BITS == 8
/* trivial fallback tests */
if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
& (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
@@ -1461,6 +1477,8 @@ get_triangle_func(GLcontext *ctx)
if (ctx->Polygon.CullFlag &&
ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
return (swrast_tri_func) NULL;
+ if (xmbuf->swAlpha)
+ return (swrast_tri_func) NULL;
xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
diff-tree ec42af9263bfba71074396f3850d5264083a5632 (from 00831b5b3bb35bbe5ead2399229495b8ef945406)
Author: Brian <brian at nostromo.localnet.net>
Date: Sun Apr 1 18:27:23 2007 -0600
re-order tokens, fix comments
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index aab138f..03acd4c 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -67,17 +67,17 @@ enum pixel_format {
PF_Index, /**< Color Index mode */
PF_Truecolor, /**< TrueColor or DirectColor, any depth */
PF_Dither_True, /**< TrueColor with dithering */
- PF_8A8B8G8R, /**< 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
+ PF_8A8R8G8B, /**< 32-bit TrueColor: 8-A, 8-R, 8-G, 8-B bits */
+ PF_8A8B8G8R, /**< 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R bits */
PF_8R8G8B, /**< 32-bit TrueColor: 8-R, 8-G, 8-B bits */
+ PF_8R8G8B24, /**< 24-bit TrueColor: 8-R, 8-G, 8-B bits */
PF_5R6G5B, /**< 16-bit TrueColor: 5-R, 6-G, 5-B bits */
PF_Dither, /**< Color-mapped RGB with dither */
PF_Lookup, /**< Color-mapped RGB without dither */
PF_HPCR, /**< HP Color Recovery (ad at lms.be 30/08/95) */
PF_1Bit, /**< monochrome dithering of RGB */
PF_Grayscale, /**< Grayscale or StaticGray */
- PF_8R8G8B24, /**< 24-bit TrueColor: 8-R, 8-G, 8-B bits */
- PF_Dither_5R6G5B, /**< 16-bit dithered TrueColor: 5-R, 6-G, 5-B */
- PF_8A8R8G8B /**< 32-bit TrueColor: 8-A, 8-R, 8-G, 8-B */
+ PF_Dither_5R6G5B /**< 16-bit dithered TrueColor: 5-R, 6-G, 5-B */
};
More information about the mesa-commit
mailing list