diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2005-05-05 00:10:18 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2005-05-05 00:10:18 +0000 |
commit | 286c4cc201390e868c4f9b5ebe14c40db2d74a5d (patch) | |
tree | 333685288a4f9127477cc0218b2ae63583a0dc1a /src | |
parent | b3e878ad900b9ab9d417fb31175a116c9dc1edc8 (diff) |
more updates for users of s_spantemp.h
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/fb/fb_dri.c | 153 | ||||
-rw-r--r-- | src/mesa/drivers/osmesa/osmesa.c | 26 | ||||
-rw-r--r-- | src/mesa/swrast/s_spantemp.h | 38 |
3 files changed, 129 insertions, 88 deletions
diff --git a/src/mesa/drivers/dri/fb/fb_dri.c b/src/mesa/drivers/dri/fb/fb_dri.c index dc049fddb5..9bfb1d1da3 100644 --- a/src/mesa/drivers/dri/fb/fb_dri.c +++ b/src/mesa/drivers/dri/fb/fb_dri.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 6.3 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -188,6 +188,7 @@ init_core_functions( struct dd_function_table *functions ) /* 24-bit BGR */ #define NAME(PREFIX) PREFIX##_B8G8R8 +#define FORMAT GL_RGBA8 #define SPAN_VARS \ const fbContextPtr fbdevctx = FB_CONTEXT(ctx); \ __DRIdrawablePrivate *dPriv = fbdevctx->dri.drawable; \ @@ -195,18 +196,22 @@ init_core_functions( struct dd_function_table *functions ) #define INIT_PIXEL_PTR(P, X, Y) \ GLubyte *P = (GLubyte *)fbdrawable->currentBuffer + (Y) * fbdrawable->currentPitch + (X) * 3 #define INC_PIXEL_PTR(P) P += 3 -#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ - P[0] = B; P[1] = G; P[2] = R -#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ - P[0] = B; P[1] = G; P[2] = R -#define FETCH_RGBA_PIXEL(R, G, B, A, P) \ - R = P[2]; G = P[1]; B = P[0]; A = CHAN_MAX +#define STORE_PIXEL(DST, X, Y, VALUE) \ + DST[0] = VALUE[BCOMP]; \ + DST[1] = VALUE[GCOMP]; \ + DST[2] = VALUE[RCOMP] +#define FETCH_PIXEL(DST, SRC) \ + DST[RCOMP] = SRC[2]; \ + DST[GCOMP] = SRC[1]; \ + DST[BCOMP] = SRC[0]; \ + DST[ACOMP] = 0xff #include "swrast/s_spantemp.h" /* 32-bit BGRA */ #define NAME(PREFIX) PREFIX##_B8G8R8A8 +#define FORMAT GL_RGBA8 #define SPAN_VARS \ const fbContextPtr fbdevctx = FB_CONTEXT(ctx); \ __DRIdrawablePrivate *dPriv = fbdevctx->dri.drawable; \ @@ -214,18 +219,28 @@ init_core_functions( struct dd_function_table *functions ) #define INIT_PIXEL_PTR(P, X, Y) \ GLubyte *P = (GLubyte *)fbdrawable->currentBuffer + (Y) * fbdrawable->currentPitch + (X) * 4; #define INC_PIXEL_PTR(P) P += 4 -#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ - P[0] = B; P[1] = G; P[2] = R; P[3] = 255 -#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ - P[0] = B; P[1] = G; P[2] = R; P[3] = A -#define FETCH_RGBA_PIXEL(R, G, B, A, P) \ - R = P[2]; G = P[1]; B = P[0]; A = P[3] +#define STORE_PIXEL(DST, X, Y, VALUE) \ + DST[0] = VALUE[BCOMP]; \ + DST[1] = VALUE[GCOMP]; \ + DST[2] = VALUE[RCOMP]; \ + DST[3] = VALUE[ACOMP] +#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ + DST[0] = VALUE[BCOMP]; \ + DST[1] = VALUE[GCOMP]; \ + DST[2] = VALUE[RCOMP]; \ + DST[3] = 0xff +#define FETCH_PIXEL(DST, SRC) \ + DST[RCOMP] = SRC[2]; \ + DST[GCOMP] = SRC[1]; \ + DST[BCOMP] = SRC[0]; \ + DST[ACOMP] = SRC[3] #include "swrast/s_spantemp.h" /* 16-bit BGR (XXX implement dithering someday) */ #define NAME(PREFIX) PREFIX##_B5G6R5 +#define FORMAT GL_RGBA8 #define SPAN_VARS \ const fbContextPtr fbdevctx = FB_CONTEXT(ctx); \ __DRIdrawablePrivate *dPriv = fbdevctx->dri.drawable; \ @@ -233,21 +248,20 @@ init_core_functions( struct dd_function_table *functions ) #define INIT_PIXEL_PTR(P, X, Y) \ GLushort *P = (GLushort *) ((char *)fbdrawable->currentBuffer + (Y) * fbdrawable->currentPitch + (X) * 2) #define INC_PIXEL_PTR(P) P += 1 -#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ - *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) ) -#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ - *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) ) -#define FETCH_RGBA_PIXEL(R, G, B, A, P) \ - R = ( (((*P) >> 8) & 0xf8) | (((*P) >> 11) & 0x7) ); \ - G = ( (((*P) >> 3) & 0xfc) | (((*P) >> 5) & 0x3) ); \ - B = ( (((*P) << 3) & 0xf8) | (((*P) ) & 0x7) ); \ - A = CHAN_MAX +#define STORE_PIXEL(DST, X, Y, VALUE) \ + DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) ) +#define FETCH_PIXEL(DST, SRC) \ + DST[RCOMP] = ( (((SRC[0]) >> 8) & 0xf8) | (((SRC[0]) >> 11) & 0x7) ); \ + DST[GCOMP] = ( (((SRC[0]) >> 3) & 0xfc) | (((SRC[0]) >> 5) & 0x3) ); \ + DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \ + DST[ACOMP] = 0xff #include "swrast/s_spantemp.h" /* 15-bit BGR (XXX implement dithering someday) */ #define NAME(PREFIX) PREFIX##_B5G5R5 +#define FORMAT GL_RGBA8 #define SPAN_VARS \ const fbContextPtr fbdevctx = FB_CONTEXT(ctx); \ __DRIdrawablePrivate *dPriv = fbdevctx->dri.drawable; \ @@ -255,21 +269,20 @@ init_core_functions( struct dd_function_table *functions ) #define INIT_PIXEL_PTR(P, X, Y) \ GLushort *P = (GLushort *) ((char *)fbdrawable->currentBuffer + (Y) * fbdrawable->currentPitch + (X) * 2) #define INC_PIXEL_PTR(P) P += 1 -#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ - *P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) ) -#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ - *P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) ) -#define FETCH_RGBA_PIXEL(R, G, B, A, P) \ - R = ( (((*P) >> 7) & 0xf8) | (((*P) >> 10) & 0x7) ); \ - G = ( (((*P) >> 2) & 0xf8) | (((*P) >> 5) & 0x7) ); \ - B = ( (((*P) << 3) & 0xf8) | (((*P) ) & 0x7) ); \ - A = CHAN_MAX +#define STORE_PIXEL(DST, X, Y, VALUE) \ + DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 7) | (((VALUE[GCOMP]) & 0xf8) << 2) | ((VALUE[BCOMP]) >> 3) ) +#define FETCH_PIXEL(DST, SRC) \ + DST[RCOMP] = ( (((SRC[0]) >> 7) & 0xf8) | (((SRC[0]) >> 10) & 0x7) ); \ + DST[GCOMP] = ( (((SRC[0]) >> 2) & 0xf8) | (((SRC[0]) >> 5) & 0x7) ); \ + DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \ + DST[ACOMP] = 0xff #include "swrast/s_spantemp.h" /* 8-bit color index */ #define NAME(PREFIX) PREFIX##_CI8 +#define FORMAT GL_COLOR_INDEX8_EXT #define SPAN_VARS \ const fbContextPtr fbdevctx = FB_CONTEXT(ctx); \ __DRIdrawablePrivate *dPriv = fbdevctx->dri.drawable; \ @@ -277,10 +290,10 @@ init_core_functions( struct dd_function_table *functions ) #define INIT_PIXEL_PTR(P, X, Y) \ GLubyte *P = (GLubyte *)fbdrawable->currentBuffer + (Y) * fbdrawable->currentPitch + (X) #define INC_PIXEL_PTR(P) P += 1 -#define STORE_CI_PIXEL(P, CI) \ - P[0] = CI -#define FETCH_CI_PIXEL(CI, P) \ - CI = P[0] +#define STORE_PIXEL(DST, X, Y, VALUE) \ + *DST = VALUE[0] +#define FETCH_PIXEL(DST, SRC) \ + DST = SRC[0] #include "swrast/s_spantemp.h" @@ -292,50 +305,50 @@ fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) ASSERT(drb->Base.InternalFormat == GL_RGBA); if (drb->Base.InternalFormat == GL_RGBA) { if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { - drb->Base.GetRow = read_rgba_span_B5G6R5; - drb->Base.GetValues = read_rgba_pixels_B5G6R5; - drb->Base.PutRow = write_rgba_span_B5G6R5; - drb->Base.PutMonoRow = write_monorgba_span_B5G6R5; - drb->Base.PutRowRGB = write_rgb_span_B5G6R5; - drb->Base.PutValues = write_rgba_pixels_B5G6R5; - drb->Base.PutMonoValues = write_monorgba_pixels_B5G6R5; + drb->Base.GetRow = get_row_B5G6R5; + drb->Base.GetValues = get_values_B5G6R5; + drb->Base.PutRow = put_row_B5G6R5; + drb->Base.PutMonoRow = put_mono_row_B5G6R5; + drb->Base.PutRowRGB = put_row_rgb_B5G6R5; + drb->Base.PutValues = put_values_B5G6R5; + drb->Base.PutMonoValues = put_mono_values_B5G6R5; } else if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) { - drb->Base.GetRow = read_rgba_span_B5G5R5; - drb->Base.GetValues = read_rgba_pixels_B5G5R5; - drb->Base.PutRow = write_rgba_span_B5G5R5; - drb->Base.PutMonoRow = write_monorgba_span_B5G5R5; - drb->Base.PutRowRGB = write_rgb_span_B5G5R5; - drb->Base.PutValues = write_rgba_pixels_B5G5R5; - drb->Base.PutMonoValues = write_monorgba_pixels_B5G5R5; + drb->Base.GetRow = get_row_B5G5R5; + drb->Base.GetValues = get_values_B5G5R5; + drb->Base.PutRow = put_row_B5G5R5; + drb->Base.PutMonoRow = put_mono_row_B5G5R5; + drb->Base.PutRowRGB = put_row_rgb_B5G5R5; + drb->Base.PutValues = put_values_B5G5R5; + drb->Base.PutMonoValues = put_mono_values_B5G5R5; } else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8 && vis->alphaBits == 8) { - drb->Base.GetRow = read_rgba_span_B8G8R8A8; - drb->Base.GetValues = read_rgba_pixels_B8G8R8A8; - drb->Base.PutRow = write_rgba_span_B8G8R8A8; - drb->Base.PutMonoRow = write_monorgba_span_B8G8R8A8; - drb->Base.PutRowRGB = write_rgb_span_B8G8R8A8; - drb->Base.PutValues = write_rgba_pixels_B8G8R8A8; - drb->Base.PutMonoValues = write_monorgba_pixels_B8G8R8A8; + drb->Base.GetRow = get_row_B8G8R8A8; + drb->Base.GetValues = get_values_B8G8R8A8; + drb->Base.PutRow = put_row_B8G8R8A8; + drb->Base.PutMonoRow = put_mono_row_B8G8R8A8; + drb->Base.PutRowRGB = put_row_rgb_B8G8R8A8; + drb->Base.PutValues = put_values_B8G8R8A8; + drb->Base.PutMonoValues = put_mono_values_B8G8R8A8; } else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8 && vis->alphaBits == 0) { - drb->Base.GetRow = read_rgba_span_B8G8R8; - drb->Base.GetValues = read_rgba_pixels_B8G8R8; - drb->Base.PutRow = write_rgba_span_B8G8R8; - drb->Base.PutMonoRow = write_monorgba_span_B8G8R8; - drb->Base.PutRowRGB = write_rgb_span_B8G8R8; - drb->Base.PutValues = write_rgba_pixels_B8G8R8; - drb->Base.PutMonoValues = write_monorgba_pixels_B8G8R8; + drb->Base.GetRow = get_row_B8G8R8; + drb->Base.GetValues = get_values_B8G8R8; + drb->Base.PutRow = put_row_B8G8R8; + drb->Base.PutMonoRow = put_mono_row_B8G8R8; + drb->Base.PutRowRGB = put_row_rgb_B8G8R8; + drb->Base.PutValues = put_values_B8G8R8; + drb->Base.PutMonoValues = put_mono_values_B8G8R8; } else if (vis->indexBits == 8) { - drb->Base.GetRow = read_index_span_CI8; - drb->Base.GetValues = read_index_pixels_CI8; - drb->Base.PutRow = write_index_span_CI8; - drb->Base.PutMonoRow = write_monoindex_span_CI8; - drb->Base.PutValues = write_index_pixels_CI8; - drb->Base.PutMonoValues = write_monoindex_pixels_CI8; + drb->Base.GetRow = get_row_CI8; + drb->Base.GetValues = get_values_CI8; + drb->Base.PutRow = put_row_CI8; + drb->Base.PutMonoRow = put_mono_row_CI8; + drb->Base.PutValues = put_values_CI8; + drb->Base.PutMonoValues = put_mono_values_CI8; } } else { diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 545602f46f..27c53f1008 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -166,12 +166,22 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) DST[1] = MAX2((VALUE[GCOMP]), 0.0F); \ DST[2] = MAX2((VALUE[BCOMP]), 0.0F); \ DST[3] = CLAMP((VALUE[ACOMP]), 0.0F, CHAN_MAXF) +#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ + DST[0] = MAX2((VALUE[RCOMP]), 0.0F); \ + DST[1] = MAX2((VALUE[GCOMP]), 0.0F); \ + DST[2] = MAX2((VALUE[BCOMP]), 0.0F); \ + DST[3] = CHAN_MAXF #else #define STORE_PIXEL(DST, X, Y, VALUE) \ DST[0] = VALUE[RCOMP]; \ DST[1] = VALUE[GCOMP]; \ DST[2] = VALUE[BCOMP]; \ DST[3] = VALUE[ACOMP] +#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ + DST[0] = VALUE[RCOMP]; \ + DST[1] = VALUE[GCOMP]; \ + DST[2] = VALUE[BCOMP]; \ + DST[3] = CHAN_MAX #endif #define FETCH_PIXEL(DST, SRC) \ DST[RCOMP] = SRC[0]; \ @@ -193,6 +203,11 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) DST[1] = VALUE[GCOMP]; \ DST[0] = VALUE[BCOMP]; \ DST[3] = VALUE[ACOMP] +#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ + DST[2] = VALUE[RCOMP]; \ + DST[1] = VALUE[GCOMP]; \ + DST[0] = VALUE[BCOMP]; \ + DST[3] = CHAN_MAX #define FETCH_PIXEL(DST, SRC) \ DST[RCOMP] = SRC[2]; \ DST[GCOMP] = SRC[1]; \ @@ -213,6 +228,11 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) DST[2] = VALUE[GCOMP]; \ DST[3] = VALUE[BCOMP]; \ DST[0] = VALUE[ACOMP] +#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ + DST[1] = VALUE[RCOMP]; \ + DST[2] = VALUE[GCOMP]; \ + DST[3] = VALUE[BCOMP]; \ + DST[0] = CHAN_MAX #define FETCH_PIXEL(DST, SRC) \ DST[RCOMP] = SRC[1]; \ DST[GCOMP] = SRC[2]; \ @@ -609,6 +629,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->GetRow = get_row_RGBA; rb->GetValues = get_values_RGBA; rb->PutRow = put_row_RGBA; + rb->PutRowRGB = put_row_rgb_RGBA; rb->PutMonoRow = put_mono_row_RGBA; rb->PutValues = put_values_RGBA; rb->PutMonoValues = put_mono_values_RGBA; @@ -617,6 +638,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->GetRow = get_row_BGRA; rb->GetValues = get_values_BGRA; rb->PutRow = put_row_BGRA; + rb->PutRowRGB = put_row_rgb_BGRA; rb->PutMonoRow = put_mono_row_BGRA; rb->PutValues = put_values_BGRA; rb->PutMonoValues = put_mono_values_BGRA; @@ -625,6 +647,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->GetRow = get_row_ARGB; rb->GetValues = get_values_ARGB; rb->PutRow = put_row_ARGB; + rb->PutRowRGB = put_row_rgb_ARGB; rb->PutMonoRow = put_mono_row_ARGB; rb->PutValues = put_values_ARGB; rb->PutMonoValues = put_mono_values_ARGB; @@ -633,6 +656,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->GetRow = get_row_RGB; rb->GetValues = get_values_RGB; rb->PutRow = put_row_RGB; + rb->PutRowRGB = put_row_rgb_RGB; rb->PutMonoRow = put_mono_row_RGB; rb->PutValues = put_values_RGB; rb->PutMonoValues = put_mono_values_RGB; @@ -641,6 +665,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->GetRow = get_row_BGR; rb->GetValues = get_values_BGR; rb->PutRow = put_row_BGR; + rb->PutRowRGB = put_row_rgb_BGR; rb->PutMonoRow = put_mono_row_BGR; rb->PutValues = put_values_BGR; rb->PutMonoValues = put_mono_values_BGR; @@ -650,6 +675,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->GetRow = get_row_RGB_565; rb->GetValues = get_values_RGB_565; rb->PutRow = put_row_RGB_565; + rb->PutRow = put_row_rgb_RGB_565; rb->PutMonoRow = put_mono_row_RGB_565; rb->PutValues = put_values_RGB_565; rb->PutMonoValues = put_mono_values_RGB_565; diff --git a/src/mesa/swrast/s_spantemp.h b/src/mesa/swrast/s_spantemp.h index a60d45fb90..4ccf031cb2 100644 --- a/src/mesa/swrast/s_spantemp.h +++ b/src/mesa/swrast/s_spantemp.h @@ -124,32 +124,33 @@ NAME(put_row)( GLcontext *ctx, struct gl_renderbuffer *rb, } } -#if 00 +#if (FORMAT == GL_RGBA) || (FORMAT == GL_RGBA8) static void -NAME(write_rgb_span)( const GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - CONST GLchan rgb[][3], const GLubyte mask[] ) +NAME(put_row_rgb)( GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, + const void *values, const GLubyte mask[] ) { #ifdef SPAN_VARS SPAN_VARS #endif +#if FORMAT == GL_RGBA + const GLchan (*src)[3] = (const GLchan (*)[3]) values; +#elif FORMAT == GL_RGBA8 + const GLubyte (*src)[3] = (const GLubyte (*)[3]) values; +#else +#error bad format +#endif GLuint i; INIT_PIXEL_PTR(pixel, x, y); - if (mask) { - for (i = 0; i < count; i++) { - if (mask[i]) { - STORE_RGB_PIXEL(pixel, x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], - rgb[i][BCOMP]); - } - INC_PIXEL_PTR(pixel); - } - } - else { - for (i = 0; i < count; i++) { - STORE_RGB_PIXEL(pixel, x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], - rgb[i][BCOMP]); - INC_PIXEL_PTR(pixel); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { +#ifdef STORE_PIXEL_RGB + STORE_PIXEL_RGB(pixel, x + i, y, src[i]); +#else + STORE_PIXEL(pixel, x + i, y, src[i]); +#endif } + INC_PIXEL_PTR(pixel); } } #endif @@ -245,5 +246,6 @@ NAME(put_mono_values)( GLcontext *ctx, struct gl_renderbuffer *rb, #undef INIT_PIXEL_PTR #undef INC_PIXEL_PTR #undef STORE_PIXEL +#undef STORE_PIXEL_RGB #undef FETCH_PIXEL #undef FORMAT |