GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
+SOFTPIPE_LIB = $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a
+
.SUFFIXES : .cpp
.c.o:
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)
subdirs:
@ (cd x86 ; $(MAKE))
@ (cd x86-64 ; $(MAKE))
-
+ #(cd pipe/softpipe ; $(MAKE))
install: default
$(INSTALL) -d $(INSTALL_DIR)/include/GL
#include "swrast/swrast.h"
#include "vblank.h"
+#include "pipe/p_context.h"
/* This block can be removed when libdrm >= 2.3.1 is required */
/**
* 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;
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__);
}
/* HW stencil */
- if (mask & BUFFER_BIT_STENCIL) {
+ if (stencil) {
const struct pipe_region *stencilRegion
= intel_get_rb_region(fb, BUFFER_STENCIL);
if (stencilRegion) {
}
/* 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;
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
}
void
intelInitBufferFuncs(struct dd_function_table *functions)
{
+#if 0
functions->Clear = intelClear;
+#endif
functions->DrawBuffer = intelDrawBuffer;
functions->ReadBuffer = intelReadBuffer;
}
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 */
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);
#include "drivers/common/driverfuncs.h"
#include "state_tracker/st_public.h"
+#include "state_tracker/st_context.h"
#include "pipe/softpipe/sp_context.h"
/**
st_create_context( mesaCtx,
softpipe_create() );
+ mesaCtx->st->pipe->clear = xmesa_clear;
return c;
}
}
+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 */
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
#include "fbobject.h"
#include "state.h"
+#include "state_tracker/st_draw.h"
+
#define BAD_MASK ~0u
}
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
}
}
GLuint flag);
void *screen; /**< temporary */
+ void *glctx; /**< temporary */
};
*/
+#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);
+ }
+ }
}
}
+
+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)
{
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... */
}