diff options
author | Brian <brian@i915.localnet.net> | 2007-08-01 12:58:38 -0600 |
---|---|---|
committer | Brian <brian@i915.localnet.net> | 2007-08-01 12:58:38 -0600 |
commit | fb206809ba2a131fd9034e10a00592f2d0d81fce (patch) | |
tree | 16f5f207e20fdb15e69d6bdca9b078fb425cbe04 /src/mesa | |
parent | e99b673cb062a2fead92d1d7d373926d148ade71 (diff) |
Checkpoint: glClear changes - working, bug very rough.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/Makefile | 9 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915pipe/intel_buffers.c | 29 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915pipe/intel_buffers.h | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915pipe/intel_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 26 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xmesaP.h | 6 | ||||
-rw-r--r-- | src/mesa/main/buffers.c | 10 | ||||
-rw-r--r-- | src/mesa/pipe/p_context.h | 1 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_clear.c | 90 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_region.c | 55 |
11 files changed, 213 insertions, 22 deletions
diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 6943219036..3055564341 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -11,6 +11,8 @@ GL_MINOR = 5 GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) +SOFTPIPE_LIB = $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a + .SUFFIXES : .cpp .c.o: @@ -110,11 +112,12 @@ stand-alone: depend subdirs $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$ osmesa-only: depend subdirs $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) # Make the GL library -$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS) +$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS) $(SOFTPIPE_LIB) @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \ -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \ -install $(TOP)/$(LIB_DIR) \ - $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(STAND_ALONE_OBJECTS) + $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(STAND_ALONE_OBJECTS) \ + $(SOFTPIPE_LIB) # Make the OSMesa library $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECTS) @@ -146,7 +149,7 @@ depend: $(ALL_SOURCES) subdirs: @ (cd x86 ; $(MAKE)) @ (cd x86-64 ; $(MAKE)) - + #(cd pipe/softpipe ; $(MAKE)) install: default $(INSTALL) -d $(INSTALL_DIR)/include/GL diff --git a/src/mesa/drivers/dri/i915pipe/intel_buffers.c b/src/mesa/drivers/dri/i915pipe/intel_buffers.c index c03c009a3a..fb93151430 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_buffers.c +++ b/src/mesa/drivers/dri/i915pipe/intel_buffers.c @@ -40,6 +40,7 @@ #include "swrast/swrast.h" #include "vblank.h" +#include "pipe/p_context.h" /* This block can be removed when libdrm >= 2.3.1 is required */ @@ -298,9 +299,17 @@ intelWindowMoved(struct intel_context *intel) /** * Called by ctx->Driver.Clear. */ +#if 0 static void intelClear(GLcontext *ctx, GLbitfield mask) +#else +void +intelClear(struct pipe_context *pipe, + GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum) +#endif { + GLcontext *ctx = (GLcontext *) pipe->glctx; const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask); GLbitfield tri_mask = 0; GLbitfield blit_mask = 0; @@ -308,6 +317,13 @@ intelClear(GLcontext *ctx, GLbitfield mask) struct gl_framebuffer *fb = ctx->DrawBuffer; GLuint i; + GLbitfield mask; + + if (color) + mask = ctx->DrawBuffer->_ColorDrawBufferMask[0]; /*XXX temporary*/ + else + mask = 0x0; + if (0) fprintf(stderr, "%s\n", __FUNCTION__); @@ -323,7 +339,7 @@ intelClear(GLcontext *ctx, GLbitfield mask) } /* HW stencil */ - if (mask & BUFFER_BIT_STENCIL) { + if (stencil) { const struct pipe_region *stencilRegion = intel_get_rb_region(fb, BUFFER_STENCIL); if (stencilRegion) { @@ -340,7 +356,7 @@ intelClear(GLcontext *ctx, GLbitfield mask) } /* HW depth */ - if (mask & BUFFER_BIT_DEPTH) { + if (depth) { /* clear depth with whatever method is used for stencil (see above) */ if (tri_mask & BUFFER_BIT_STENCIL) tri_mask |= BUFFER_BIT_DEPTH; @@ -368,9 +384,14 @@ intelClear(GLcontext *ctx, GLbitfield mask) if (blit_mask) intelClearWithBlit(ctx, blit_mask); -#if 1 +#if 0 if (swrast_mask | tri_mask) _swrast_Clear(ctx, swrast_mask | tri_mask); +#else + softpipe_clear(pipe, GL_FALSE, + (swrast_mask | tri_mask) & BUFFER_BIT_DEPTH, + (swrast_mask | tri_mask) & BUFFER_BIT_STENCIL, + (swrast_mask | tri_mask) & BUFFER_BIT_ACCUM); #endif } @@ -786,7 +807,9 @@ intelReadBuffer(GLcontext * ctx, GLenum mode) void intelInitBufferFuncs(struct dd_function_table *functions) { +#if 0 functions->Clear = intelClear; +#endif functions->DrawBuffer = intelDrawBuffer; functions->ReadBuffer = intelReadBuffer; } diff --git a/src/mesa/drivers/dri/i915pipe/intel_buffers.h b/src/mesa/drivers/dri/i915pipe/intel_buffers.h index 5834e39501..f0602eebae 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_buffers.h +++ b/src/mesa/drivers/dri/i915pipe/intel_buffers.h @@ -52,4 +52,9 @@ extern void intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb); extern void intelInitBufferFuncs(struct dd_function_table *functions); +extern void +intelClear(struct pipe_context *pipe, + GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum); + #endif /* INTEL_BUFFERS_H */ diff --git a/src/mesa/drivers/dri/i915pipe/intel_context.c b/src/mesa/drivers/dri/i915pipe/intel_context.c index 0ccd22a4d0..6121f6bc60 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_context.c +++ b/src/mesa/drivers/dri/i915pipe/intel_context.c @@ -420,6 +420,8 @@ intelCreateContext(const __GLcontextModes * mesaVis, intel->pipe = intel->ctx.st->pipe; intel->pipe->screen = intelScreen; + intel->pipe->glctx = ctx; + intel->pipe->clear = intelClear; intelScreen->pipe = intel->pipe; intel_init_region_functions(intel->pipe); diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index f20e8104fb..92d37085d1 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -82,6 +82,7 @@ #include "drivers/common/driverfuncs.h" #include "state_tracker/st_public.h" +#include "state_tracker/st_context.h" #include "pipe/softpipe/sp_context.h" /** @@ -1572,6 +1573,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) st_create_context( mesaCtx, softpipe_create() ); + mesaCtx->st->pipe->clear = xmesa_clear; return c; } diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 5725414856..0aa47d55e4 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -435,6 +435,32 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) } +void +xmesa_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum) +{ + struct softpipe_context *sp = (struct softpipe_context *) pipe; + if (color) { + GET_CURRENT_CONTEXT(ctx); + GLuint i; + softpipe_update_derived(sp); + for (i = 0; i < sp->framebuffer.num_cbufs; i++) { + struct pipe_surface *ps = sp->framebuffer.cbufs[i]; + struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) ps->rb; + const GLint x = sp->cliprect.minx; + const GLint y = sp->cliprect.miny; + const GLint w = sp->cliprect.maxx - x; + const GLint h = sp->cliprect.maxy - y; + xrb->clearFunc(ctx, xrb, x, y, w, h); + } + color = GL_FALSE; + } + + softpipe_clear(pipe, color, depth, stencil, accum); +} + + + #ifndef XFree86Server /* XXX this was never tested in the Xserver environment */ diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 098b9218ae..fb1c1f8c3b 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -587,9 +587,13 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx ); struct pipe_surface; +struct pipe_context; -struct pipe_surface * +extern struct pipe_surface * xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb); +extern void +xmesa_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum); #endif diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 0e6ca8ea1c..bb019b5998 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -38,6 +38,8 @@ #include "fbobject.h" #include "state.h" +#include "state_tracker/st_draw.h" + #define BAD_MASK ~0u @@ -176,7 +178,15 @@ _mesa_Clear( GLbitfield mask ) } ASSERT(ctx->Driver.Clear); +#if 0 ctx->Driver.Clear(ctx, bufferMask); +#else + st_clear(ctx->st, + (mask & GL_COLOR_BUFFER_BIT) ? GL_TRUE : GL_FALSE, + (bufferMask & BUFFER_BIT_DEPTH) ? GL_TRUE : GL_FALSE, + (bufferMask & BUFFER_BIT_STENCIL) ? GL_TRUE : GL_FALSE, + (bufferMask & BUFFER_BIT_ACCUM) ? GL_TRUE : GL_FALSE); +#endif } } diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index b48c7775de..8517d7ab68 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -188,6 +188,7 @@ struct pipe_context { GLuint flag); void *screen; /**< temporary */ + void *glctx; /**< temporary */ }; diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c index e83bc053ef..40b1156715 100644 --- a/src/mesa/pipe/softpipe/sp_clear.c +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -30,42 +30,102 @@ */ +#include "pipe/p_defines.h" #include "sp_clear.h" #include "sp_context.h" #include "sp_surface.h" #include "colormac.h" +static GLuint +color_value(GLuint format, const GLfloat color[4]) +{ + GLubyte r, g, b, a; + + UNCLAMPED_FLOAT_TO_UBYTE(r, color[0]); + UNCLAMPED_FLOAT_TO_UBYTE(g, color[1]); + UNCLAMPED_FLOAT_TO_UBYTE(b, color[2]); + UNCLAMPED_FLOAT_TO_UBYTE(a, color[3]); + + switch (format) { + case PIPE_FORMAT_U_R8_G8_B8_A8: + return (r << 24) | (g << 16) | (b << 8) | a; + case PIPE_FORMAT_U_A8_R8_G8_B8: + return (a << 24) | (r << 16) | (g << 8) | b; + case PIPE_FORMAT_U_R5_G6_B5: + return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3); + default: + return 0; + } +} + + void softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, GLboolean stencil, GLboolean accum) { const struct softpipe_context *softpipe = softpipe_context(pipe); - const GLint x = softpipe->scissor.minx; - const GLint y = softpipe->scissor.miny; - const GLint w = softpipe->scissor.maxx - x; - const GLint h = softpipe->scissor.maxy - y; + const GLint x = softpipe->cliprect.minx; + const GLint y = softpipe->cliprect.miny; + const GLint w = softpipe->cliprect.maxx - x; + const GLint h = softpipe->cliprect.maxy - y; if (color) { GLuint i; - GLubyte clr[4]; - - UNCLAMPED_FLOAT_TO_UBYTE(clr[0], softpipe->clear_color.color[0]); - UNCLAMPED_FLOAT_TO_UBYTE(clr[1], softpipe->clear_color.color[1]); - UNCLAMPED_FLOAT_TO_UBYTE(clr[2], softpipe->clear_color.color[2]); - UNCLAMPED_FLOAT_TO_UBYTE(clr[3], softpipe->clear_color.color[3]); - for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) { struct pipe_surface *ps = softpipe->framebuffer.cbufs[i]; - struct softpipe_surface *sps = softpipe_surface(ps); - GLint j; - for (j = 0; j < h; j++) { - sps->write_mono_row_ub(sps, w, x, y + j, clr); + + if (softpipe->blend.colormask == (PIPE_MASK_R | PIPE_MASK_G | + PIPE_MASK_B | PIPE_MASK_A)) { + /* no masking */ + GLuint clearVal = color_value(ps->format, + softpipe->clear_color.color); + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal); + } + else { + /* masking */ + + /* + for (j = 0; j < h; j++) { + sps->write_mono_row_ub(sps, w, x, y + j, clr); + } + */ } } } if (depth) { + struct pipe_surface *ps = softpipe->framebuffer.zbuf; + GLuint clearVal; + + switch (ps->format) { + case PIPE_FORMAT_U_Z16: + clearVal = (GLuint) (softpipe->depth_test.clear * 65535.0); + break; + case PIPE_FORMAT_U_Z32: + clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffffff); + break; + case PIPE_FORMAT_Z24_S8: + clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff); + break; + default: + assert(0); + } + + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal); } + if (stencil) { + struct pipe_surface *ps = softpipe->framebuffer.sbuf; + GLuint clearVal = softpipe->stencil.clear_value; + if (softpipe->stencil.write_mask[0] /*== 0xff*/) { + /* no masking */ + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal); + } + else if (softpipe->stencil.write_mask[0] != 0x0) { + /* masking */ + /* fill with quad funcs */ + assert(0); + } + } } diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c index 04ae5e94f9..4d8b35d3e7 100644 --- a/src/mesa/pipe/softpipe/sp_region.c +++ b/src/mesa/pipe/softpipe/sp_region.c @@ -92,6 +92,59 @@ sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region) } + +static GLubyte * +get_pointer(struct pipe_region *dst, GLuint x, GLuint y) +{ + return dst->map + (y * dst->pitch + x) * dst->cpp; +} + + +static void +sp_region_fill(struct pipe_context *pipe, + struct pipe_region *dst, + GLuint dst_offset, + GLuint dstx, GLuint dsty, + GLuint width, GLuint height, GLuint value) +{ + GLuint i, j; + switch (dst->cpp) { + case 1: + { + GLubyte *row = get_pointer(dst, dstx, dsty); + for (i = 0; i < height; i++) { + memset(row, value, width); + row += dst->pitch; + } + } + break; + case 2: + { + GLushort *row = (GLushort *) get_pointer(dst, dstx, dsty); + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) + row[j] = value; + row += dst->pitch; + } + } + break; + case 4: + { + GLuint *row = (GLuint *) get_pointer(dst, dstx, dsty); + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) + row[j] = value; + row += dst->pitch; + } + } + break; + default: + assert(0); + + } +} + + void sp_init_region_functions(struct softpipe_context *sp) { @@ -101,5 +154,7 @@ sp_init_region_functions(struct softpipe_context *sp) sp->pipe.region_map = sp_region_map; sp->pipe.region_unmap = sp_region_unmap; + sp->pipe.region_fill = sp_region_fill; + /* XXX lots of other region functions needed... */ } |