diff options
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/Makefile.template | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_context.c | 12 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_blit.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_blit.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_pixel_bitmap.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/fbdev/glfbdev.c | 103 | ||||
-rw-r--r-- | src/mesa/drivers/x11/Makefile | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 17 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_span.c | 13 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_surface.c | 395 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_tri.c | 40 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xmesaP.h | 21 |
13 files changed, 569 insertions, 60 deletions
diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 6f2314ee8c..43c0e912bf 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -85,7 +85,7 @@ $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS) touch depend $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \ - $(ASM_SOURCES) 2>&1 /dev/null + $(ASM_SOURCES) 2> /dev/null # Emacs tags diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 531b4adde8..01373f0e40 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -60,6 +60,10 @@ #include "intel_buffer_objects.h" #include "intel_fbo.h" +#include "pipe/softpipe/sp_context.h" +#include "state_tracker/st_public.h" + + #include "drirenderbuffer.h" #include "vblank.h" #include "utils.h" @@ -256,6 +260,9 @@ intelInvalidateState(GLcontext * ctx, GLuint new_state) _vbo_InvalidateState(ctx, new_state); _tnl_InvalidateState(ctx, new_state); _tnl_invalidate_vertex_state(ctx, new_state); + + st_invalidate_state( ctx, new_state ); + intel_context(ctx)->NewGLState |= new_state; } @@ -509,6 +516,11 @@ intelInitContext(struct intel_context *intel, FALLBACK(intel, INTEL_FALLBACK_USER, 1); } + + st_create_context( &intel->ctx, + softpipe_create() ); + + return GL_TRUE; } diff --git a/src/mesa/drivers/dri/i965/intel_blit.c b/src/mesa/drivers/dri/i965/intel_blit.c index 173d1d5b6c..f88cbb2328 100644 --- a/src/mesa/drivers/dri/i965/intel_blit.c +++ b/src/mesa/drivers/dri/i965/intel_blit.c @@ -532,12 +532,15 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel, GLuint dst_offset, GLboolean dst_tiled, GLshort x, GLshort y, - GLshort w, GLshort h) + GLshort w, GLshort h, + GLenum logic_op) { struct xy_setup_blit setup; struct xy_text_immediate_blit text; int dwords = ((src_size + 7) & ~7) / 4; + assert( logic_op - GL_CLEAR >= 0 ); + assert( logic_op - GL_CLEAR < 0x10 ); if (w < 0 || h < 0) return; @@ -561,7 +564,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel, setup.br0.length = (sizeof(setup) / sizeof(int)) - 2; setup.br13.dest_pitch = dst_pitch; - setup.br13.rop = 0xcc; + setup.br13.rop = translate_raster_op(logic_op); setup.br13.color_depth = (cpp == 4) ? BR13_8888 : BR13_565; setup.br13.clipping_enable = 0; setup.br13.mono_source_transparency = 1; diff --git a/src/mesa/drivers/dri/i965/intel_blit.h b/src/mesa/drivers/dri/i965/intel_blit.h index 8b0cc65243..e361545c8f 100644 --- a/src/mesa/drivers/dri/i965/intel_blit.h +++ b/src/mesa/drivers/dri/i965/intel_blit.h @@ -72,6 +72,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel, GLuint dst_offset, GLboolean dst_tiled, GLshort dst_x, GLshort dst_y, - GLshort w, GLshort h); + GLshort w, GLshort h, + GLenum logic_op ); #endif diff --git a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c index 5841afaa3e..421fcc5e51 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c @@ -260,7 +260,9 @@ do_blit_bitmap( GLcontext *ctx, int h = MIN2(DY, box_h - py); int w = MIN2(DX, box_w - px); GLuint sz = align(align(w,8) * h, 64)/8; - + GLenum logic_op = ctx->Color.ColorLogicOpEnabled ? + ctx->Color.LogicOp : GL_COPY; + assert(sz <= sizeof(stipple)); memset(stipple, 0, sz); @@ -288,7 +290,8 @@ do_blit_bitmap( GLcontext *ctx, dst->tiled, rect.x1 + px, rect.y2 - (py + h), - w, h); + w, h, + logic_op); } } } diff --git a/src/mesa/drivers/fbdev/glfbdev.c b/src/mesa/drivers/fbdev/glfbdev.c index 6c6511b7e5..e95a424698 100644 --- a/src/mesa/drivers/fbdev/glfbdev.c +++ b/src/mesa/drivers/fbdev/glfbdev.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -63,6 +63,9 @@ #include "drivers/common/driverfuncs.h" +/** + * Pixel formats we support: + */ #define PF_B8G8R8 1 #define PF_B8G8R8A8 2 #define PF_B5G6R5 3 @@ -70,7 +73,7 @@ #define PF_CI8 5 -/* +/** * Derived from Mesa's GLvisual class. */ struct GLFBDevVisualRec { @@ -80,7 +83,7 @@ struct GLFBDevVisualRec { int pixelFormat; }; -/* +/** * Derived from Mesa's GLframebuffer class. */ struct GLFBDevBufferRec { @@ -92,7 +95,7 @@ struct GLFBDevBufferRec { GLuint bytesPerPixel; }; -/* +/** * Derived from Mesa's GLcontext class. */ struct GLFBDevContextRec { @@ -103,7 +106,7 @@ struct GLFBDevContextRec { GLFBDevBufferPtr curBuffer; }; -/* +/** * Derived from Mesa's gl_renderbuffer class. */ struct GLFBDevRenderbufferRec { @@ -114,11 +117,6 @@ struct GLFBDevRenderbufferRec { }; - -#define GLFBDEV_CONTEXT(CTX) ((GLFBDevContextPtr) (CTX)) -#define GLFBDEV_BUFFER(BUF) ((GLFBDevBufferPtr) (BUF)) - - /**********************************************************************/ /* Internal device driver functions */ /**********************************************************************/ @@ -151,7 +149,7 @@ update_state( GLcontext *ctx, GLuint new_state ) static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) { - const GLFBDevBufferPtr fbdevbuffer = GLFBDEV_BUFFER(buffer); + const GLFBDevBufferPtr fbdevbuffer = (GLFBDevBufferPtr) buffer; *width = fbdevbuffer->var.xres; *height = fbdevbuffer->var.yres; } @@ -389,8 +387,8 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, /* ignored for now */ break; case GLFBDEV_MULTISAMPLE: - numSamples = attrib[1]; - attrib++; + numSamples = attrib[1]; + attrib++; break; default: /* unexpected token */ @@ -406,36 +404,36 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, alphaBits = varInfo->transp.length; if (fixInfo->visual == FB_VISUAL_TRUECOLOR || - fixInfo->visual == FB_VISUAL_DIRECTCOLOR) { - if(varInfo->bits_per_pixel == 24 - && varInfo->red.offset == 16 - && varInfo->green.offset == 8 - && varInfo->blue.offset == 0) - vis->pixelFormat = PF_B8G8R8; - - else if(varInfo->bits_per_pixel == 32 - && varInfo->red.offset == 16 - && varInfo->green.offset == 8 - && varInfo->blue.offset == 0) - vis->pixelFormat = PF_B8G8R8A8; - - else if(varInfo->bits_per_pixel == 16 - && varInfo->red.offset == 11 - && varInfo->green.offset == 5 - && varInfo->blue.offset == 0) - vis->pixelFormat = PF_B5G6R5; - - else if(varInfo->bits_per_pixel == 16 - && varInfo->red.offset == 10 - && varInfo->green.offset == 5 - && varInfo->blue.offset == 0) - vis->pixelFormat = PF_B5G5R5; - - else { - _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n"); - _mesa_free(vis); - return NULL; - } + fixInfo->visual == FB_VISUAL_DIRECTCOLOR) { + if (varInfo->bits_per_pixel == 24 + && varInfo->red.offset == 16 + && varInfo->green.offset == 8 + && varInfo->blue.offset == 0) { + vis->pixelFormat = PF_B8G8R8; + } + else if (varInfo->bits_per_pixel == 32 + && varInfo->red.offset == 16 + && varInfo->green.offset == 8 + && varInfo->blue.offset == 0) { + vis->pixelFormat = PF_B8G8R8A8; + } + else if (varInfo->bits_per_pixel == 16 + && varInfo->red.offset == 11 + && varInfo->green.offset == 5 + && varInfo->blue.offset == 0) { + vis->pixelFormat = PF_B5G6R5; + } + else if (varInfo->bits_per_pixel == 16 + && varInfo->red.offset == 10 + && varInfo->green.offset == 5 + && varInfo->blue.offset == 0) { + vis->pixelFormat = PF_B5G5R5; + } + else { + _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n"); + _mesa_free(vis); + return NULL; + } } } else { @@ -578,7 +576,7 @@ new_glfbdev_renderbuffer(void *bufferStart, const GLFBDevVisualPtr visual) rb->rowStride = visual->var.xres_virtual * visual->var.bits_per_pixel / 8; rb->bottom = (GLubyte *) bufferStart - + (visual->var.yres - 1) * rb->rowStride; + + (visual->var.yres - 1) * rb->rowStride; rb->Base.Width = visual->var.xres; rb->Base.Height = visual->var.yres; @@ -635,7 +633,7 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo, &frontrb->Base); /* add back renderbuffer */ if (visual->glvisual.doubleBufferMode) { - int malloced = !backBuffer; + const int malloced = !backBuffer; if (malloced) { /* malloc a back buffer */ backBuffer = _mesa_malloc(size); @@ -647,8 +645,11 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo, } backrb = new_glfbdev_renderbuffer(backBuffer, visual); - if(malloced) - backrb->mallocedBuffer = GL_TRUE; + if (!backrb) { + /* out of mem */ + return NULL; + } + backrb->mallocedBuffer = malloced; _mesa_add_renderbuffer(&buf->glframebuffer, BUFFER_BACK_LEFT, &backrb->Base); @@ -682,16 +683,10 @@ glFBDevDestroyBuffer( GLFBDevBufferPtr buffer ) if (buffer == curDraw || buffer == curRead) { glFBDevMakeCurrent( NULL, NULL, NULL); } -#if 0 - /* free the software depth, stencil, accum buffers */ - _mesa_free_framebuffer_data(&buffer->glframebuffer); - _mesa_free(buffer); -#else { struct gl_framebuffer *fb = &buffer->glframebuffer; _mesa_unreference_framebuffer(&fb); } -#endif } } diff --git a/src/mesa/drivers/x11/Makefile b/src/mesa/drivers/x11/Makefile new file mode 100644 index 0000000000..0ab1dc6e6b --- /dev/null +++ b/src/mesa/drivers/x11/Makefile @@ -0,0 +1,2 @@ +default: + cd ../.. ; make
\ No newline at end of file diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index eaa277db4a..f20e8104fb 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -81,6 +81,9 @@ #include "tnl/t_pipeline.h" #include "drivers/common/driverfuncs.h" +#include "state_tracker/st_public.h" +#include "pipe/softpipe/sp_context.h" + /** * Global X driver lock */ @@ -1566,6 +1569,10 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) xmesa_register_swrast_functions( mesaCtx ); _swsetup_Wakeup(mesaCtx); + + st_create_context( mesaCtx, + softpipe_create() ); + return c; } diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index c8546236fb..5725414856 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -53,6 +53,10 @@ #include "tnl/tnl.h" #include "tnl/t_context.h" +#include "pipe/softpipe/sp_context.h" +#include "state_tracker/st_public.h" +#include "state_tracker/st_context.h" +#include "state_tracker/st_draw.h" /* @@ -391,6 +395,7 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) /* we can't handle color or index masking */ if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) { +#if 0 if (buffers & BUFFER_BIT_FRONT_LEFT) { /* clear front color buffer */ struct gl_renderbuffer *frontRb @@ -414,6 +419,15 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) buffers &= ~BUFFER_BIT_BACK_LEFT; } } +#else + /* Clear with state-tracker/pipe interface */ + struct st_context *st = st_context(ctx); + GLboolean color = (buffers & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) ? 1: 0; + GLboolean depth = (buffers & BUFFER_BIT_DEPTH) ? 1 : 0; + GLboolean stencil = (buffers & BUFFER_BIT_STENCIL) ? 1 : 0; + GLboolean accum = (buffers & BUFFER_BIT_ACCUM) ? 1 : 0; + st_clear(st, color, depth, stencil, accum); +#endif } } if (buffers) @@ -828,6 +842,9 @@ xmesa_update_state( GLcontext *ctx, GLbitfield new_state ) _vbo_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state ); + st_invalidate_state( ctx, new_state ); + + if (ctx->DrawBuffer->Name != 0) return; diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c index a24966b3ae..3776891e2e 100644 --- a/src/mesa/drivers/x11/xm_span.c +++ b/src/mesa/drivers/x11/xm_span.c @@ -1303,6 +1303,17 @@ static void put_row_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS ) } + +static void *get_pointer_4_ximage( GLcontext *ctx, + struct gl_renderbuffer *rb, + GLint x, GLint y ) +{ + GET_XRB(xrb); + return PIXEL_ADDR4(xrb, x, y); +} + + + /* * Write a span of PF_8A8B8G8R-format pixels to an ximage. */ @@ -4593,6 +4604,7 @@ xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb, xrb->Base.PutMonoRow = put_mono_row_8A8B8G8R_ximage; xrb->Base.PutValues = put_values_8A8B8G8R_ximage; xrb->Base.PutMonoValues = put_mono_values_8A8B8G8R_ximage; + xrb->Base.GetPointer = get_pointer_4_ximage; } break; case PF_8A8R8G8B: @@ -4609,6 +4621,7 @@ xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb, xrb->Base.PutMonoRow = put_mono_row_8A8R8G8B_ximage; xrb->Base.PutValues = put_values_8A8R8G8B_ximage; xrb->Base.PutMonoValues = put_mono_values_8A8R8G8B_ximage; + xrb->Base.GetPointer = get_pointer_4_ximage; } break; case PF_8R8G8B: diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c new file mode 100644 index 0000000000..58081a36a0 --- /dev/null +++ b/src/mesa/drivers/x11/xm_surface.c @@ -0,0 +1,395 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file xm_surface.h + * Code to allow the softpipe code to write to X windows/buffers. + * This is a bit of a hack for now. We've basically got two different + * abstractions for color buffers: gl_renderbuffer and softpipe_surface. + * They'll need to get merged someday... + * For now, they're separate things that point to each other. + */ + + +#include "glxheader.h" +#include "GL/xmesa.h" +#include "xmesaP.h" +#include "context.h" +#include "imports.h" +#include "macros.h" +#include "framebuffer.h" +#include "renderbuffer.h" + +#include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include "pipe/softpipe/sp_context.h" +#include "pipe/softpipe/sp_surface.h" + + +/** + * An xm_surface is derived from a softpipe_surface + */ +struct xmesa_surface +{ + struct softpipe_surface sps; + struct xmesa_renderbuffer *xrb; /** ptr back to matching xmesa_renderbuffer */ + struct gl_renderbuffer *rb; /* ptr to matching gl_renderbuffer */ +}; + + +/** + * Cast wrapper + */ +static INLINE struct xmesa_surface * +xmesa_surface(struct softpipe_surface *sps) +{ + return (struct xmesa_surface *) sps; +} + + +/** + * quad reading/writing + * These functions are just wrappers around the existing renderbuffer + * functions. + */ + +static void +read_quad_f(struct softpipe_surface *gs, GLint x, GLint y, + GLfloat (*rgba)[NUM_CHANNELS]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(gs); + struct xmesa_renderbuffer *xrb = xmsurf->xrb; + GLubyte temp[16]; + GLfloat *dst = (GLfloat *) rgba; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, temp); + xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, temp + 8); + for (i = 0; i < 16; i++) { + dst[i] = UBYTE_TO_FLOAT(temp[i]); + } +} + +static void +read_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y, + GLfloat (*rrrr)[QUAD_SIZE]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(gs); + struct xmesa_renderbuffer *xrb = xmsurf->xrb; + GLubyte temp[16]; + GLfloat *dst = (GLfloat *) rrrr; + GLuint i, j; + GET_CURRENT_CONTEXT(ctx); + xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, temp); + xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, temp + 8); + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + dst[j * 4 + i] = UBYTE_TO_FLOAT(temp[i * 4 + j]); + } + } +} + +static void +write_quad_f(struct softpipe_surface *gs, GLint x, GLint y, + GLfloat (*rgba)[NUM_CHANNELS]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(gs); + struct xmesa_renderbuffer *xrb = xmsurf->xrb; + GLubyte temp[16]; + const GLfloat *src = (const GLfloat *) rgba; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + for (i = 0; i < 16; i++) { + UNCLAMPED_FLOAT_TO_UBYTE(temp[i], src[i]); + } + xrb->Base.PutRow(ctx, &xrb->Base, 2, x, y, temp, NULL); + xrb->Base.PutRow(ctx, &xrb->Base, 2, x, y + 1, temp + 8, NULL); +} + +static void +write_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y, + GLfloat (*rrrr)[QUAD_SIZE]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(gs); + struct xmesa_renderbuffer *xrb = xmsurf->xrb; + GLubyte temp[16]; + const GLfloat *src = (const GLfloat *) rrrr; + GLuint i, j; + GET_CURRENT_CONTEXT(ctx); + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + i], src[i * 4 + j]); + } + } + xrb->Base.PutRow(ctx, &xrb->Base, 2, x, y, temp, NULL); + xrb->Base.PutRow(ctx, &xrb->Base, 2, x, y + 1, temp + 8, NULL); +} + +static void +read_quad_ub(struct softpipe_surface *gs, GLint x, GLint y, + GLubyte (*rgba)[NUM_CHANNELS]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(gs); + struct xmesa_renderbuffer *xrb = xmsurf->xrb; + GET_CURRENT_CONTEXT(ctx); + xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, rgba); + xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, rgba + 2); +} + +static void +write_quad_ub(struct softpipe_surface *gs, GLint x, GLint y, + GLubyte (*rgba)[NUM_CHANNELS]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(gs); + struct xmesa_renderbuffer *xrb = xmsurf->xrb; + GET_CURRENT_CONTEXT(ctx); + xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y, rgba); + xrb->Base.GetRow(ctx, &xrb->Base, 2, x, y + 1, rgba + 2); +} + +static void +write_mono_row_ub(struct softpipe_surface *gs, GLuint count, GLint x, GLint y, + GLubyte rgba[NUM_CHANNELS]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(gs); + struct xmesa_renderbuffer *xrb = xmsurf->xrb; + GET_CURRENT_CONTEXT(ctx); + xrb->Base.PutMonoRow(ctx, &xrb->Base, count, x, y, rgba, NULL); +} + + +static struct xmesa_surface * +create_surface(XMesaContext xmctx, struct xmesa_renderbuffer *xrb) +{ + struct xmesa_surface *xmsurf; + + xmsurf = CALLOC_STRUCT(xmesa_surface); + if (xmsurf) { + xmsurf->xrb = xrb; + xmsurf->sps.surface.width = xrb->Base.Width; + xmsurf->sps.surface.height = xrb->Base.Height; + + xmsurf->sps.read_quad_f = read_quad_f; + xmsurf->sps.read_quad_f_swz = read_quad_f_swz; + xmsurf->sps.read_quad_ub = read_quad_ub; + xmsurf->sps.write_quad_f = write_quad_f; + xmsurf->sps.write_quad_f_swz = write_quad_f_swz; + xmsurf->sps.write_quad_ub = write_quad_ub; + xmsurf->sps.write_mono_row_ub = write_mono_row_ub; + +#if 0 + if (xrb->ximage) { + xmsurf->sps.surface.ptr = (GLubyte *) xrb->ximage->data; + xmsurf->sps.surface.stride = xrb->ximage->bytes_per_line; + xmsurf->sps.surface.cpp = xrb->ximage->depth; + + } +#endif + } + return xmsurf; +} + + +static void +free_surface(struct softpipe_surface *sps) +{ + /* XXX may need to do more in the future */ + free(sps); +} + + +/** + * Return generic surface pointer corresponding to the current color buffer. + */ +struct pipe_surface * +xmesa_get_color_surface(GLcontext *ctx, GLuint buf) +{ + XMesaContext xmctx = XMESA_CONTEXT(ctx); + struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][buf]; + struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb); + struct softpipe_surface *sps = (struct softpipe_surface *) xrb->pSurface; + + if (!sps) { + xrb->pSurface = create_surface(xmctx, xrb); + } + else if (sps->surface.width != rb->Width || + sps->surface.height != rb->Height) { + free_surface(sps); + xrb->pSurface = create_surface(xmctx, xrb); + } + + return (struct pipe_surface *) xrb->pSurface; +} + + + + +static void +read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(sps); + struct gl_renderbuffer *rb = xmsurf->rb; + GLushort temp[4]; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + rb->GetRow(ctx, rb, 2, x, y, temp); + rb->GetRow(ctx, rb, 2, x, y + 1, temp + 2); + /* convert from GLushort to GLuint */ + for (i = 0; i < 4; i++) { + zzzz[i] = temp[i]; + } +} + +static void +write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(sps); + struct gl_renderbuffer *rb = xmsurf->rb; + GLushort temp[4]; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + /* convert from GLuint to GLushort */ + for (i = 0; i < 4; i++) { + temp[i] = zzzz[i]; + } + rb->PutRow(ctx, rb, 2, x, y, temp, NULL); + rb->PutRow(ctx, rb, 2, x, y + 1, temp + 2, NULL); +} + + +static struct xmesa_surface * +create_z_surface(XMesaContext xmctx, struct gl_renderbuffer *rb) +{ + struct xmesa_surface *xmsurf; + + xmsurf = CALLOC_STRUCT(xmesa_surface); + if (xmsurf) { + xmsurf->sps.surface.format = PIPE_FORMAT_U_Z16; + xmsurf->sps.surface.width = rb->Width; + xmsurf->sps.surface.height = rb->Height; + xmsurf->sps.read_quad_z = read_quad_z; + xmsurf->sps.write_quad_z = write_quad_z; + xmsurf->rb = rb; + } + return xmsurf; +} + + + + +static void +read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(sps); + struct gl_renderbuffer *rb = xmsurf->rb; + GET_CURRENT_CONTEXT(ctx); + rb->GetRow(ctx, rb, 2, x, y, ssss); + rb->GetRow(ctx, rb, 2, x, y + 1, ssss + 2); +} + +static void +write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + struct xmesa_surface *xmsurf = xmesa_surface(sps); + struct gl_renderbuffer *rb = xmsurf->rb; + GET_CURRENT_CONTEXT(ctx); + rb->PutRow(ctx, rb, 2, x, y, ssss, NULL); + rb->PutRow(ctx, rb, 2, x, y + 1, ssss + 2, NULL); +} + +static struct xmesa_surface * +create_stencil_surface(XMesaContext xmctx, struct gl_renderbuffer *rb) +{ + struct xmesa_surface *xmsurf; + + xmsurf = CALLOC_STRUCT(xmesa_surface); + if (xmsurf) { + xmsurf->sps.surface.format = PIPE_FORMAT_U_S8; + xmsurf->sps.surface.width = rb->Width; + xmsurf->sps.surface.height = rb->Height; + xmsurf->sps.read_quad_stencil = read_quad_stencil; + xmsurf->sps.write_quad_stencil = write_quad_stencil; + xmsurf->rb = rb; + } + return xmsurf; +} + + + + +/** + * Return a pipe_surface that wraps the current Z/depth buffer. + * XXX this is pretty much a total hack until gl_renderbuffers and + * pipe_surfaces are merged... + */ +struct pipe_surface * +xmesa_get_z_surface(GLcontext *ctx) +{ + XMesaContext xmctx = XMESA_CONTEXT(ctx); + struct gl_renderbuffer *rb = ctx->DrawBuffer->_DepthBuffer; + static struct xmesa_surface *xms = NULL; + + if (!rb) + return NULL; + + if (!xms) { + xms = create_z_surface(xmctx, rb); + } + else if (xms->sps.surface.width != rb->Width || + xms->sps.surface.height != rb->Height) { + free_surface(&xms->sps); + xms = create_z_surface(xmctx, rb); + } + + return (struct pipe_surface *) &xms->sps.surface; +} + + +struct pipe_surface * +xmesa_get_stencil_surface(GLcontext *ctx) +{ + XMesaContext xmctx = XMESA_CONTEXT(ctx); + struct gl_renderbuffer *rb = ctx->DrawBuffer->_StencilBuffer; + static struct xmesa_surface *xms = NULL; + + if (!rb) + return NULL; + + if (!xms) { + xms = create_stencil_surface(xmctx, rb); + } + else if (xms->sps.surface.width != rb->Width || + xms->sps.surface.height != rb->Height) { + free_surface(&xms->sps); + xms = create_stencil_surface(xmctx, rb); + } + + return (struct pipe_surface *) &xms->sps.surface; +} + diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c index 95c6d7c1d2..9f17083f90 100644 --- a/src/mesa/drivers/x11/xm_tri.c +++ b/src/mesa/drivers/x11/xm_tri.c @@ -1443,6 +1443,46 @@ do { \ #endif +#if 0 +GLboolean xmesa_get_cbuf_details( GLcontext *ctx, + void **ptr, + GLuint *cpp, + GLint *stride, + GLuint *format ) +{ + XMesaContext xmesa = XMESA_CONTEXT(ctx); + struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_renderbuffer *crb = fb->_ColorDrawBuffers[0][0]; + struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(crb->Wrapped); + + *ptr = crb->GetPointer(ctx, crb, 0, 0); + *stride = ((GLubyte *)crb->GetPointer(ctx, crb, 0, 1) - + (GLubyte *)crb->GetPointer(ctx, crb, 0, 0)); + + if (!ptr) + goto bad; + + switch (xmesa->pixelformat) { + case PF_8A8B8G8R: + case PF_8A8R8G8B: + *format = 1; /* whatever */ + *cpp = 4; + break; + default: + goto bad; + } + + return GL_TRUE; + + bad: + *ptr = NULL; + *stride = 0; + *format = 0; + return GL_FALSE; +} +#endif + + /** * Return pointer to line drawing function, or NULL if we should use a * swrast fallback. diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index e3d7cf381f..8648b19939 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -196,6 +196,8 @@ struct xmesa_renderbuffer GLint bottom; /* used for FLIP macro, equals height - 1 */ ClearFunc clearFunc; + + void *pSurface; /** pipe surface */ }; @@ -583,4 +585,23 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx ); #define ENABLE_EXT_timer_query 0 /* may not have 64-bit GLuint64EXT */ #endif +#if 0 +GLboolean xmesa_get_cbuf_details( GLcontext *ctx, + void **ptr, + GLuint *cpp, + GLint *stride, + GLuint *format ); +#endif + +struct pipe_surface; +struct pipe_surface * +xmesa_get_color_surface(GLcontext *ctx, GLuint buf); + +struct pipe_surface * +xmesa_get_z_surface(GLcontext *ctx); + +struct pipe_surface * +xmesa_get_stencil_surface(GLcontext *ctx); + + #endif |