diff options
author | Keith Whitwell <[email protected]> | 2009-02-16 19:50:48 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2009-02-16 19:50:48 +0000 |
commit | 59d54334c96f44ed1d8bf660dc96221362a77d04 (patch) | |
tree | e9ab34e568256bcdc2a88602c47072ab769211e8 /src/mesa/drivers/dri/swrast | |
parent | 7c8836e9ef49d938aa55a1c385b95c6371c301f1 (diff) | |
parent | c5c383596ddb26cd75e4b355918ad16915283b59 (diff) |
Merge branch 'master' into gallium-texture-transfer
Conflicts:
src/mesa/state_tracker/st_cb_accum.c
src/mesa/state_tracker/st_cb_drawpixels.c
Diffstat (limited to 'src/mesa/drivers/dri/swrast')
-rw-r--r-- | src/mesa/drivers/dri/swrast/swrast.c | 84 | ||||
-rw-r--r-- | src/mesa/drivers/dri/swrast/swrast_priv.h | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/swrast/swrast_span.c | 72 |
3 files changed, 129 insertions, 37 deletions
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 15b57244dcd..2e7f11327e6 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -72,7 +72,7 @@ #define need_GL_EXT_framebuffer_blit #define need_GL_EXT_gpu_program_parameters #define need_GL_EXT_paletted_texture -#define need_GL_IBM_multimode_draw_arrays +#define need_GL_EXT_stencil_two_side #define need_GL_MESA_resize_buffers #define need_GL_NV_vertex_program #define need_GL_NV_fragment_program @@ -103,7 +103,7 @@ const struct dri_extension card_extensions[] = { "GL_EXT_framebuffer_blit", GL_EXT_framebuffer_blit_functions }, { "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions }, { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions }, - { "GL_IBM_multimode_draw_arrays", GL_IBM_multimode_draw_arrays_functions }, + { "GL_EXT_stencil_two_side", GL_EXT_stencil_two_side_functions }, { "GL_MESA_resize_buffers", GL_MESA_resize_buffers_functions }, { "GL_NV_vertex_program", GL_NV_vertex_program_functions }, { "GL_NV_fragment_program", GL_NV_fragment_program_functions }, @@ -147,6 +147,7 @@ swrastFillInModes(__DRIscreen *psp, uint8_t depth_bits_array[4]; uint8_t stencil_bits_array[4]; + uint8_t msaa_samples_array[1]; depth_bits_array[0] = 0; depth_bits_array[1] = 0; @@ -161,26 +162,38 @@ swrastFillInModes(__DRIscreen *psp, stencil_bits_array[2] = 0; stencil_bits_array[3] = (stencil_bits == 0) ? 8 : stencil_bits; + msaa_samples_array[0] = 0; + depth_buffer_factor = 4; back_buffer_factor = 2; - if (pixel_bits == 8) { + switch (pixel_bits) { + case 8: fb_format = GL_RGB; fb_type = GL_UNSIGNED_BYTE_2_3_3_REV; - } - else if (pixel_bits == 16) { + break; + case 16: fb_format = GL_RGB; fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { + break; + case 24: + fb_format = GL_BGR; + fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + case 32: fb_format = GL_BGRA; fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + default: + fprintf(stderr, "[%s:%u] bad depth %d\n", __func__, __LINE__, + pixel_bits); + return NULL; } configs = driCreateConfigs(fb_format, fb_type, depth_bits_array, stencil_bits_array, depth_buffer_factor, back_buffer_modes, - back_buffer_factor); + back_buffer_factor, msaa_samples_array, 1); if (configs == NULL) { fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__); @@ -196,7 +209,7 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions, { static const __DRIextension *emptyExtensionList[] = { NULL }; __DRIscreen *psp; - __DRIconfig **configs8, **configs16, **configs32; + __DRIconfig **configs8, **configs16, **configs24, **configs32; (void) data; @@ -213,11 +226,13 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions, configs8 = swrastFillInModes(psp, 8, 8, 0, 1); configs16 = swrastFillInModes(psp, 16, 16, 0, 1); + configs24 = swrastFillInModes(psp, 24, 24, 8, 1); configs32 = swrastFillInModes(psp, 32, 24, 8, 1); - configs16 = (__DRIconfig **)driConcatConfigs(configs8, configs16); - - *driver_configs = driConcatConfigs(configs16, configs32); + configs16 = driConcatConfigs(configs8, configs16); + configs24 = driConcatConfigs(configs16, configs24); + *driver_configs = (const __DRIconfig **) + driConcatConfigs(configs24, configs32); driInitExtensions( NULL, card_extensions, GL_FALSE ); @@ -249,19 +264,24 @@ static GLuint choose_pixel_format(const GLvisual *v) { if (v->rgbMode) { - int bpp = v->rgbBits; + int depth = v->rgbBits; - if (bpp == 32 + if (depth == 32 && v->redMask == 0xff0000 && v->greenMask == 0x00ff00 && v->blueMask == 0x0000ff) return PF_A8R8G8B8; - else if (bpp == 16 + else if (depth == 24 + && v->redMask == 0xff0000 + && v->greenMask == 0x00ff00 + && v->blueMask == 0x0000ff) + return PF_X8R8G8B8; + else if (depth == 16 && v->redMask == 0xf800 && v->greenMask == 0x07e0 && v->blueMask == 0x001f) return PF_R5G6B5; - else if (bpp == 8 + else if (depth == 8 && v->redMask == 0x07 && v->greenMask == 0x38 && v->blueMask == 0xc0) @@ -290,7 +310,6 @@ swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); - int bpp; unsigned mask = PITCH_ALIGN_BITS - 1; TRACE; @@ -299,23 +318,8 @@ swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Width = width; rb->Height = height; - switch (internalFormat) { - case GL_RGB: - bpp = rb->RedBits + rb->GreenBits + rb->BlueBits; - break; - case GL_RGBA: - bpp = rb->RedBits + rb->GreenBits + rb->BlueBits + rb->AlphaBits; - break; - case GL_COLOR_INDEX8_EXT: - bpp = rb->IndexBits; - break; - default: - _mesa_problem( NULL, "unexpected format in %s", __FUNCTION__ ); - return GL_FALSE; - } - /* always pad to PITCH_ALIGN_BITS */ - xrb->pitch = ((width * bpp + mask) & ~mask) / 8; + xrb->pitch = ((width * xrb->bpp + mask) & ~mask) / 8; return GL_TRUE; } @@ -371,6 +375,17 @@ swrast_new_renderbuffer(const GLvisual *visual, GLboolean front) xrb->Base.GreenBits = 8 * sizeof(GLubyte); xrb->Base.BlueBits = 8 * sizeof(GLubyte); xrb->Base.AlphaBits = 8 * sizeof(GLubyte); + xrb->bpp = 32; + break; + case PF_X8R8G8B8: + xrb->Base.InternalFormat = GL_RGB; + xrb->Base._BaseFormat = GL_RGB; + xrb->Base.DataType = GL_UNSIGNED_BYTE; + xrb->Base.RedBits = 8 * sizeof(GLubyte); + xrb->Base.GreenBits = 8 * sizeof(GLubyte); + xrb->Base.BlueBits = 8 * sizeof(GLubyte); + xrb->Base.AlphaBits = 0; + xrb->bpp = 32; break; case PF_R5G6B5: xrb->Base.InternalFormat = GL_RGB; @@ -380,6 +395,7 @@ swrast_new_renderbuffer(const GLvisual *visual, GLboolean front) xrb->Base.GreenBits = 6 * sizeof(GLubyte); xrb->Base.BlueBits = 5 * sizeof(GLubyte); xrb->Base.AlphaBits = 0; + xrb->bpp = 16; break; case PF_R3G3B2: xrb->Base.InternalFormat = GL_RGB; @@ -389,12 +405,14 @@ swrast_new_renderbuffer(const GLvisual *visual, GLboolean front) xrb->Base.GreenBits = 3 * sizeof(GLubyte); xrb->Base.BlueBits = 2 * sizeof(GLubyte); xrb->Base.AlphaBits = 0; + xrb->bpp = 8; break; case PF_CI8: xrb->Base.InternalFormat = GL_COLOR_INDEX8_EXT; xrb->Base._BaseFormat = GL_COLOR_INDEX; xrb->Base.DataType = GL_UNSIGNED_BYTE; xrb->Base.IndexBits = 8 * sizeof(GLubyte); + xrb->bpp = 8; break; default: return NULL; diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index a707ffc40a8..1a5fb31d5a8 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -90,6 +90,8 @@ struct swrast_renderbuffer { /* renderbuffer pitch (in bytes) */ GLuint pitch; + /* bits per pixel of storage */ + GLuint bpp; }; static INLINE __DRIcontext * @@ -115,10 +117,10 @@ swrast_renderbuffer(struct gl_renderbuffer *rb) * Pixel formats we support */ #define PF_CI8 1 /**< Color Index mode */ -#define PF_A8R8G8B8 2 /**< 32-bit TrueColor: 8-A, 8-R, 8-G, 8-B bits */ -#define PF_R5G6B5 3 /**< 16-bit TrueColor: 5-R, 6-G, 5-B bits */ -#define PF_R3G3B2 4 /**< 8-bit TrueColor: 3-R, 3-G, 2-B bits */ - +#define PF_A8R8G8B8 2 /**< 32bpp TrueColor: 8-A, 8-R, 8-G, 8-B bits */ +#define PF_R5G6B5 3 /**< 16bpp TrueColor: 5-R, 6-G, 5-B bits */ +#define PF_R3G3B2 4 /**< 8bpp TrueColor: 3-R, 3-G, 2-B bits */ +#define PF_X8R8G8B8 5 /**< 32bpp TrueColor: 8-R, 8-G, 8-B bits */ /** * Renderbuffer pitch alignment (in bits). diff --git a/src/mesa/drivers/dri/swrast/swrast_span.c b/src/mesa/drivers/dri/swrast/swrast_span.c index 5e990368b2e..2d3c25dcbef 100644 --- a/src/mesa/drivers/dri/swrast/swrast_span.c +++ b/src/mesa/drivers/dri/swrast/swrast_span.c @@ -79,6 +79,24 @@ static const GLubyte kernel[16] = { DST[BCOMP] = SRC[0] +/* 32-bit BGRX */ +#define STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE) \ + DST[3] = 0xff; \ + DST[2] = VALUE[RCOMP]; \ + DST[1] = VALUE[GCOMP]; \ + DST[0] = VALUE[BCOMP] +#define STORE_PIXEL_RGB_X8R8G8B8(DST, X, Y, VALUE) \ + DST[3] = 0xff; \ + DST[2] = VALUE[RCOMP]; \ + DST[1] = VALUE[GCOMP]; \ + DST[0] = VALUE[BCOMP] +#define FETCH_PIXEL_X8R8G8B8(DST, SRC) \ + DST[ACOMP] = 0xff; \ + DST[RCOMP] = SRC[2]; \ + DST[GCOMP] = SRC[1]; \ + DST[BCOMP] = SRC[0] + + /* 16-bit BGR */ #define STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) \ do { \ @@ -139,6 +157,24 @@ static const GLubyte kernel[16] = { #include "swrast/s_spantemp.h" +/* 32-bit BGRX */ +#define NAME(FUNC) FUNC##_X8R8G8B8 +#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 + (X) * 4; +#define INC_PIXEL_PTR(P) P += 4 +#define STORE_PIXEL(DST, X, Y, VALUE) \ + STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE) +#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ + STORE_PIXEL_RGB_X8R8G8B8(DST, X, Y, VALUE) +#define FETCH_PIXEL(DST, SRC) \ + FETCH_PIXEL_X8R8G8B8(DST, SRC) + +#include "swrast/s_spantemp.h" + + /* 16-bit BGR */ #define NAME(FUNC) FUNC##_R5G6B5 #define RB_TYPE GLubyte @@ -210,6 +246,24 @@ static const GLubyte kernel[16] = { #include "swrast_spantemp.h" +/* 32-bit BGRX */ +#define NAME(FUNC) FUNC##_X8R8G8B8_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 += 4 +#define STORE_PIXEL(DST, X, Y, VALUE) \ + STORE_PIXEL_X8R8G8B8(DST, X, Y, VALUE) +#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \ + STORE_PIXEL_RGB_X8R8G8B8(DST, X, Y, VALUE) +#define FETCH_PIXEL(DST, SRC) \ + FETCH_PIXEL_X8R8G8B8(DST, SRC) + +#include "swrast_spantemp.h" + + /* 16-bit BGR */ #define NAME(FUNC) FUNC##_R5G6B5_front #define RB_TYPE GLubyte @@ -279,6 +333,15 @@ swrast_set_span_funcs_back(struct swrast_renderbuffer *xrb, xrb->Base.PutValues = put_values_A8R8G8B8; xrb->Base.PutMonoValues = put_mono_values_A8R8G8B8; break; + case PF_X8R8G8B8: + xrb->Base.GetRow = get_row_X8R8G8B8; + xrb->Base.GetValues = get_values_X8R8G8B8; + xrb->Base.PutRow = put_row_X8R8G8B8; + xrb->Base.PutRowRGB = put_row_rgb_X8R8G8B8; + xrb->Base.PutMonoRow = put_mono_row_X8R8G8B8; + xrb->Base.PutValues = put_values_X8R8G8B8; + xrb->Base.PutMonoValues = put_mono_values_X8R8G8B8; + break; case PF_R5G6B5: xrb->Base.GetRow = get_row_R5G6B5; xrb->Base.GetValues = get_values_R5G6B5; @@ -334,6 +397,15 @@ swrast_set_span_funcs_front(struct swrast_renderbuffer *xrb, xrb->Base.PutValues = put_values_A8R8G8B8_front; xrb->Base.PutMonoValues = put_mono_values_A8R8G8B8_front; break; + case PF_X8R8G8B8: + xrb->Base.GetRow = get_row_X8R8G8B8_front; + xrb->Base.GetValues = get_values_X8R8G8B8_front; + xrb->Base.PutRow = put_row_X8R8G8B8_front; + xrb->Base.PutRowRGB = put_row_rgb_X8R8G8B8_front; + xrb->Base.PutMonoRow = put_mono_row_X8R8G8B8_front; + xrb->Base.PutValues = put_values_X8R8G8B8_front; + xrb->Base.PutMonoValues = put_mono_values_X8R8G8B8_front; + break; case PF_R5G6B5: xrb->Base.GetRow = get_row_R5G6B5_front; xrb->Base.GetValues = get_values_R5G6B5_front; |