From b939adfa155f2b3ca5c5226e86da85629654d79b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 24 May 2007 10:44:53 +0100 Subject: Use the x11 driver as a test harness for the softpipe/state_tracker code. This has some limitations as we currently require a mapped framebuffer, so it only really works with double-buffered ximage rgba8888 windows. --- src/mesa/drivers/x11/xmesaP.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 0198886747..8f0bd34f47 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -578,4 +578,11 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx ); #define ENABLE_EXT_timer_query 0 /* may not have 64-bit GLuint64EXT */ #endif + +GLboolean xmesa_get_cbuf_details( GLcontext *ctx, + void **ptr, + GLuint *cpp, + GLint *stride, + GLuint *format ); + #endif -- cgit v1.2.3 From af9b5ca0359b5712509d7815a7fbc81a3255f4af Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 19 Jun 2007 19:19:31 -0600 Subject: Re-org of surface/framebuffer state. We should be able to render to any depth/format of X window now. --- src/mesa/drivers/x11/xm_surface.c | 231 +++++++++++++++++++++++++++ src/mesa/drivers/x11/xmesaP.h | 7 + src/mesa/pipe/softpipe/sp_context.c | 1 - src/mesa/pipe/softpipe/sp_context.h | 7 - src/mesa/pipe/softpipe/sp_state.h | 3 - src/mesa/pipe/softpipe/sp_state_surface.c | 17 -- src/mesa/pipe/softpipe/sp_surface.h | 53 +----- src/mesa/pipe/softpipe/sp_tile_output.c | 45 +++--- src/mesa/sources | 4 - src/mesa/state_tracker/st_atom.c | 1 - src/mesa/state_tracker/st_atom.h | 1 - src/mesa/state_tracker/st_atom_framebuffer.c | 7 +- 12 files changed, 269 insertions(+), 108 deletions(-) create mode 100644 src/mesa/drivers/x11/xm_surface.c (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c new file mode 100644 index 0000000000..c0c56c093a --- /dev/null +++ b/src/mesa/drivers/x11/xm_surface.c @@ -0,0 +1,231 @@ +/* + * 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/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 */ +}; + + +/** + * 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++) { + temp[i] = FLOAT_TO_UBYTE(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++) { + temp[j * 4 + i] = FLOAT_TO_UBYTE(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 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; +#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; +} + diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 8f0bd34f47..c36b0966d9 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 */ }; @@ -585,4 +587,9 @@ GLboolean xmesa_get_cbuf_details( GLcontext *ctx, GLint *stride, GLuint *format ); + +struct pipe_surface; +struct pipe_surface * +xmesa_get_color_surface(GLcontext *ctx, GLuint buf); + #endif diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 9a054265fb..018f67302d 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -73,7 +73,6 @@ struct pipe_context *softpipe_create( void ) softpipe->pipe.set_scissor_rect = softpipe_set_scissor_rect; softpipe->pipe.set_fs_state = softpipe_set_fs_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; - softpipe->pipe.set_cbuf_state = softpipe_set_cbuf_state; softpipe->pipe.draw_vb = softpipe_draw_vb; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index efe453ea2c..a873301368 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -54,7 +54,6 @@ enum interp_mode { #define G_NEW_SETUP 0x2 #define G_NEW_FS 0x4 #define G_NEW_BLEND 0x8 -#define G_NEW_CBUF 0x10 #define G_NEW_CLIP 0x20 #define G_NEW_SCISSOR 0x40 #define G_NEW_STIPPLE 0x80 @@ -74,17 +73,11 @@ struct softpipe_context { struct pipe_fs_state fs; struct pipe_blend_state blend; struct pipe_alpha_test_state alpha_test; - struct pipe_surface cbuf; struct pipe_clip_state clip; struct pipe_scissor_rect scissor; struct pipe_poly_stipple poly_stipple; GLuint dirty; - - /* Cbuf derived state??? - */ - struct softpipe_surface *cbuf_surface; - /* Clip derived state: */ GLfloat plane[12][4]; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index bdf10112f6..5002ce88fc 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -56,9 +56,6 @@ void softpipe_set_fs_state( struct pipe_context *, void softpipe_set_polygon_stipple( struct pipe_context *, const struct pipe_poly_stipple * ); -void softpipe_set_cbuf_state( struct pipe_context *, - const struct pipe_surface * ); - void softpipe_update_derived( struct softpipe_context *softpipe ); #endif diff --git a/src/mesa/pipe/softpipe/sp_state_surface.c b/src/mesa/pipe/softpipe/sp_state_surface.c index d089fe0632..99332fdd52 100644 --- a/src/mesa/pipe/softpipe/sp_state_surface.c +++ b/src/mesa/pipe/softpipe/sp_state_surface.c @@ -34,23 +34,6 @@ #include "sp_surface.h" -/* This is all a total hack. - */ -void softpipe_set_cbuf_state( struct pipe_context *pipe, - const struct pipe_surface *surface ) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - - if (softpipe->cbuf_surface == NULL) { - softpipe->cbuf_surface = CALLOC_STRUCT(softpipe_surface); - softpipe->cbuf_surface->type = &gs_rgba8; - } - - softpipe->cbuf_surface->surface = *surface; - softpipe->dirty |= G_NEW_CBUF; -} - - /* * XXX this might get moved someday */ diff --git a/src/mesa/pipe/softpipe/sp_surface.h b/src/mesa/pipe/softpipe/sp_surface.h index 08b6889257..dde6b90448 100644 --- a/src/mesa/pipe/softpipe/sp_surface.h +++ b/src/mesa/pipe/softpipe/sp_surface.h @@ -38,12 +38,16 @@ struct softpipe_surface; #define G_SURFACE_RGBA_8888 0x1 -/* Internal structs and helpers for the primitive clip/setup pipeline: + +/** + * Softpipe surface is derived from pipe_surface. */ -struct softpipe_surface_type { - - GLuint format; +struct softpipe_surface { + struct pipe_surface surface; + /** + * Functions for read/writing surface data + */ void (*read_quad_f)( struct softpipe_surface *, GLint x, GLint y, GLfloat (*rgba)[NUM_CHANNELS] ); @@ -69,47 +73,6 @@ struct softpipe_surface_type { void (*write_quad_ub)( struct softpipe_surface *, GLint x, GLint y, GLubyte (*rgba)[NUM_CHANNELS] ); - - }; - -struct softpipe_surface { - struct softpipe_surface_type *type; - struct pipe_surface surface; -}; - - -static INLINE void gs_read_quad_f( struct softpipe_surface *gs, - GLint x, GLint y, - GLfloat (*rgba)[NUM_CHANNELS] ) -{ - gs->type->read_quad_f(gs, x, y, rgba); -} - -static INLINE void gs_read_quad_f_swz( struct softpipe_surface *gs, - GLint x, GLint y, - GLfloat (*rrrr)[QUAD_SIZE] ) -{ - gs->type->read_quad_f_swz(gs, x, y, rrrr); -} - -static INLINE void gs_write_quad_f( struct softpipe_surface *gs, - GLint x, GLint y, - GLfloat (*rgba)[NUM_CHANNELS] ) -{ - gs->type->write_quad_f(gs, x, y, rgba); -} - -static INLINE void gs_write_quad_f_swz( struct softpipe_surface *gs, - GLint x, GLint y, - GLfloat (*rrrr)[QUAD_SIZE] ) -{ - gs->type->write_quad_f_swz(gs, x, y, rrrr); -} - -/* Like this, or hidden? - */ -struct softpipe_surface_type gs_rgba8; - #endif diff --git a/src/mesa/pipe/softpipe/sp_tile_output.c b/src/mesa/pipe/softpipe/sp_tile_output.c index b1eb9e8c9f..d4add4b162 100644 --- a/src/mesa/pipe/softpipe/sp_tile_output.c +++ b/src/mesa/pipe/softpipe/sp_tile_output.c @@ -55,38 +55,35 @@ static void mask_copy( GLfloat (*dest)[4], } -/* Write to the output, taking mask into account. +/** + * Write quad to framebuffer, taking mask into account. * * Note that surfaces support only full quad reads and writes. */ void quad_output( struct softpipe_context *softpipe, struct quad_header *quad ) { + GLuint i; - if (quad->mask != MASK_ALL) - { - GLfloat tmp[4][QUAD_SIZE]; + for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) { + struct softpipe_surface *sps + = (struct softpipe_surface *) softpipe->framebuffer.cbufs[i]; - /* Yes, we'll probably have a masked write as well, but this is - * how blend will be done at least. - */ - gs_read_quad_f_swz( softpipe->cbuf_surface, - quad->x0, - quad->y0, - tmp ); - - mask_copy( tmp, quad->outputs.color, quad->mask ); + if (quad->mask != MASK_ALL) { + GLfloat tmp[4][QUAD_SIZE]; - gs_write_quad_f_swz( softpipe->cbuf_surface, - quad->x0, - quad->y0, - tmp ); - } - else - { - gs_write_quad_f_swz( softpipe->cbuf_surface, - quad->x0, - quad->y0, - quad->outputs.color ); + /* Yes, we'll probably have a masked write as well, but this is + * how blend will be done at least. + */ + + sps->read_quad_f_swz(sps, quad->x0, quad->y0, tmp); + + mask_copy( tmp, quad->outputs.color, quad->mask ); + + sps->write_quad_f_swz(sps, quad->x0, quad->y0, tmp); + } + else { + sps->write_quad_f_swz(sps, quad->x0, quad->y0, quad->outputs.color); + } } } diff --git a/src/mesa/sources b/src/mesa/sources index d07d4dabe8..eb67dd9f7b 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -169,7 +169,6 @@ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_state_fs.c \ pipe/softpipe/sp_state_setup.c \ pipe/softpipe/sp_state_surface.c \ - pipe/softpipe/sp_surface.c \ pipe/softpipe/sp_tile_fs.c \ pipe/softpipe/sp_tile_output.c @@ -177,7 +176,6 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom.c \ state_tracker/st_atom_alphatest.c \ state_tracker/st_atom_blend.c \ - state_tracker/st_atom_cbuf.c \ state_tracker/st_atom_clip.c \ state_tracker/st_atom_depth.c \ state_tracker/st_atom_fs.c \ @@ -190,8 +188,6 @@ STATETRACKER_SOURCES = \ state_tracker/st_draw.c \ state_tracker/st_context.c - - SHADER_SOURCES = \ shader/arbprogparse.c \ shader/arbprogram.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 02720804d4..228e7889b7 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -43,7 +43,6 @@ static const struct st_tracked_state *atoms[] = { &st_update_framebuffer, - &st_update_cbuf, &st_update_clip, &st_update_fs, &st_update_setup, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 8575bfea1a..8a75c9c6d5 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -45,7 +45,6 @@ void st_validate_state( struct st_context *st ); const struct st_tracked_state st_update_framebuffer; -const struct st_tracked_state st_update_cbuf; const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_depth; const struct st_tracked_state st_update_fs; diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 849616f81e..f203e1df60 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -36,11 +36,8 @@ #include "pipe/p_context.h" -static struct pipe_surface * -xmesa_get_color_surface(GLcontext *ctx, GLuint i) -{ - return NULL; -} +extern struct pipe_surface * +xmesa_get_color_surface(GLcontext *ctx, GLuint i); /** -- cgit v1.2.3 From ecfa794037e8be351ecfec0229d1e3b1677ae369 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Jun 2007 17:20:02 -0600 Subject: checkpoint: implement z/depth testing --- src/mesa/drivers/x11/xm_surface.c | 14 +++++ src/mesa/drivers/x11/xm_tri.c | 4 +- src/mesa/drivers/x11/xmesaP.h | 11 +++- src/mesa/pipe/softpipe/sp_context.c | 3 ++ src/mesa/pipe/softpipe/sp_context.h | 1 + src/mesa/pipe/softpipe/sp_quad.c | 6 +++ src/mesa/pipe/softpipe/sp_quad_depth_test.c | 79 +++++++++++++++++++++++----- src/mesa/pipe/softpipe/sp_state.h | 6 +++ src/mesa/pipe/softpipe/sp_state_blend.c | 26 +++++++++ src/mesa/pipe/softpipe/sp_state_derived.c | 2 +- src/mesa/pipe/softpipe/sp_surface.h | 5 ++ src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom_framebuffer.c | 14 +++++ 13 files changed, 153 insertions(+), 19 deletions(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index ee06b77377..a937df3ade 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -241,3 +241,17 @@ xmesa_get_color_surface(GLcontext *ctx, GLuint buf) return (struct pipe_surface *) xrb->pSurface; } + +struct pipe_surface * +xmesa_get_z_surface(GLcontext *ctx, GLuint i) +{ + return NULL; +} + + +struct pipe_surface * +xmesa_get_stencil_surface(GLcontext *ctx, GLuint i) +{ + return NULL; +} + diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c index 6158ef30f9..9f17083f90 100644 --- a/src/mesa/drivers/x11/xm_tri.c +++ b/src/mesa/drivers/x11/xm_tri.c @@ -1443,7 +1443,7 @@ do { \ #endif - +#if 0 GLboolean xmesa_get_cbuf_details( GLcontext *ctx, void **ptr, GLuint *cpp, @@ -1480,7 +1480,7 @@ GLboolean xmesa_get_cbuf_details( GLcontext *ctx, *format = 0; return GL_FALSE; } - +#endif /** diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index c36b0966d9..1d5df3d935 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -580,16 +580,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, GLuint i); + +struct pipe_surface * +xmesa_get_stencil_surface(GLcontext *ctx, GLuint i); + + #endif diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 593be0e132..f27d2dd8bc 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -65,9 +65,11 @@ struct pipe_context *softpipe_create( void ) softpipe->pipe.destroy = softpipe_destroy; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; + softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state; softpipe->pipe.set_blend_state = softpipe_set_blend_state; softpipe->pipe.set_clip_state = softpipe_set_clip_state; softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state; + softpipe->pipe.set_depth_state = softpipe_set_depth_test_state; softpipe->pipe.set_point_state = softpipe_set_point_state; softpipe->pipe.set_viewport = softpipe_set_viewport; softpipe->pipe.set_setup_state = softpipe_set_setup_state; @@ -87,6 +89,7 @@ struct pipe_context *softpipe_create( void ) softpipe->prim.cull = prim_cull( softpipe ); softpipe->quad.blend = sp_quad_blend_stage(softpipe); + softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe); softpipe->quad.shade = sp_quad_shade_stage(softpipe); softpipe->quad.output = sp_quad_output_stage(softpipe); diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index ebe39fa8bf..d01fc38b81 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -80,6 +80,7 @@ struct softpipe_context { struct pipe_alpha_test_state alpha_test; struct pipe_clip_state clip; struct pipe_clear_color_state clear_color; + struct pipe_depth_state depth_test; struct pipe_point_state point; struct pipe_scissor_rect scissor; struct pipe_poly_stipple poly_stipple; diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index 168872c64d..32085ab8c4 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -7,6 +7,7 @@ void sp_build_quad_pipeline(struct softpipe_context *sp) { + /* build up the pipeline in reverse order... */ sp->quad.first = sp->quad.output; @@ -15,6 +16,11 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.blend; } + if (sp->depth_test.enabled) { + sp->quad.depth_test->next = sp->quad.first; + sp->quad.first = sp->quad.depth_test; + } + /* XXX always enable shader? */ if (1) { sp->quad.shade->next = sp->quad.first; diff --git a/src/mesa/pipe/softpipe/sp_quad_depth_test.c b/src/mesa/pipe/softpipe/sp_quad_depth_test.c index 756141db17..76a6ee1bb6 100644 --- a/src/mesa/pipe/softpipe/sp_quad_depth_test.c +++ b/src/mesa/pipe/softpipe/sp_quad_depth_test.c @@ -32,29 +32,80 @@ #include "sp_headers.h" #include "sp_surface.h" #include "sp_quad.h" - +#include "pipe/p_defines.h" static void depth_test_quad(struct quad_stage *qs, struct quad_header *quad) { -#if 0 struct softpipe_context *softpipe = qs->softpipe; - GLfloat dest[4][QUAD_SIZE], result[4][QUAD_SIZE]; - GLuint i; - - /* XXX we're also looping in output_quad() !?! */ - - for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) { - struct softpipe_surface *sps - = softpipe_surface(softpipe->framebuffer.cbufs[i]); - - sps->read_quad_f_swz(sps, quad->x0, quad->y0, dest); + GLuint j; + struct softpipe_surface *sps = softpipe_surface(softpipe->framebuffer.zbuf); + GLfloat zzzz[QUAD_SIZE]; /**< Z for four pixels in quad */ - /* XXX do blend here */ +#if 0 + assert(sps); /* shouldn't get here if there's no zbuffer */ +#else + if (!sps) + return; +#endif + /* XXX get zquad from zbuffer */ + sps->read_quad_z(sps, quad->x0, quad->y0, zzzz); + + switch (softpipe->depth_test.func) { + case PIPE_FUNC_NEVER: + quad->mask = 0x0; + break; + case PIPE_FUNC_LESS: + for (j = 0; j < QUAD_SIZE; j++) { + if (quad->mask & (1 << j)) { + if (quad->outputs.depth[j] >= zzzz[j]) { + /* fail */ + quad->mask &= (1 << j); + } + else if (softpipe->depth_test.writemask) { + /* pass, and update Z buffer */ + zzzz[j] = quad->outputs.depth[j]; + } + } + } + break; + case PIPE_FUNC_EQUAL: + for (j = 0; j < QUAD_SIZE; j++) { + if (quad->mask & (1 << j)) { + if (quad->outputs.depth[j] != zzzz[j]) { + /* fail */ + quad->mask &= (1 << j); + } + else if (softpipe->depth_test.writemask) { + /* pass, and update Z buffer */ + zzzz[j] = quad->outputs.depth[j]; + } + } + } + break; + case PIPE_FUNC_LEQUAL: + for (j = 0; j < QUAD_SIZE; j++) { + if (quad->mask & (1 << j)) { + if (quad->outputs.depth[j] > zzzz[j]) { + /* fail */ + quad->mask &= (1 << j); + } + else if (softpipe->depth_test.writemask) { + /* pass, and update Z buffer */ + zzzz[j] = quad->outputs.depth[j]; + } + } + } + break; + /* XXX fill in remaining cases */ + default: + abort(); } -#endif + + /* XXX write updated zquad to zbuffer */ + sps->write_quad_z(sps, quad->x0, quad->y0, zzzz); qs->next->run(qs->next, quad); } diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 5a657c4a8f..6253b9c9e5 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -38,6 +38,9 @@ void softpipe_set_framebuffer_state( struct pipe_context *, const struct pipe_framebuffer_state * ); +void softpipe_set_alpha_test_state( struct pipe_context *, + const struct pipe_alpha_test_state * ); + void softpipe_set_blend_state( struct pipe_context *, const struct pipe_blend_state * ); @@ -47,6 +50,9 @@ void softpipe_set_clear_color_state( struct pipe_context *, void softpipe_set_clip_state( struct pipe_context *, const struct pipe_clip_state * ); +void softpipe_set_depth_test_state( struct pipe_context *, + const struct pipe_depth_state * ); + void softpipe_set_viewport( struct pipe_context *, const struct pipe_viewport * ); diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c index 1fd7a44105..c364d8a319 100644 --- a/src/mesa/pipe/softpipe/sp_state_blend.c +++ b/src/mesa/pipe/softpipe/sp_state_blend.c @@ -45,3 +45,29 @@ void softpipe_set_blend_state( struct pipe_context *pipe, softpipe->dirty |= G_NEW_BLEND; } + +/** XXX move someday? Or consolidate all these simple state setters + * into one file. + */ +void +softpipe_set_depth_test_state(struct pipe_context *pipe, + const struct pipe_depth_state *depth) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + + softpipe->depth_test = *depth; + + softpipe->dirty |= G_NEW_DEPTH_TEST; +} + +void +softpipe_set_alpha_test_state(struct pipe_context *pipe, + const struct pipe_alpha_test_state *alpha) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + + softpipe->alpha_test = *alpha; + + softpipe->dirty |= G_NEW_ALPHA_TEST; +} + diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 8ab325b72d..5aee4be6b8 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -134,7 +134,7 @@ void softpipe_update_derived( struct softpipe_context *softpipe ) if (softpipe->dirty & (G_NEW_SETUP | G_NEW_FS)) calculate_vertex_layout( softpipe ); - if (softpipe->dirty & (G_NEW_BLEND | G_NEW_FS)) + if (softpipe->dirty & (G_NEW_BLEND | G_NEW_DEPTH_TEST | G_NEW_ALPHA_TEST | G_NEW_FS)) sp_build_quad_pipeline(softpipe); softpipe->dirty = 0; diff --git a/src/mesa/pipe/softpipe/sp_surface.h b/src/mesa/pipe/softpipe/sp_surface.h index fc9557dee3..05b125d17b 100644 --- a/src/mesa/pipe/softpipe/sp_surface.h +++ b/src/mesa/pipe/softpipe/sp_surface.h @@ -77,6 +77,11 @@ struct softpipe_surface { void (*write_mono_row_ub)( struct softpipe_surface *, GLuint count, GLint x, GLint y, GLubyte rgba[NUM_CHANNELS] ); + + void (*read_quad_z)(struct softpipe_surface *, + GLint x, GLint y, GLfloat zzzz[QUAD_SIZE]); + void (*write_quad_z)(struct softpipe_surface *, + GLint x, GLint y, const GLfloat zzzz[QUAD_SIZE]); }; diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index e1d187f2db..5fcd9d7af5 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -44,6 +44,7 @@ static const struct st_tracked_state *atoms[] = { &st_update_framebuffer, &st_update_clear_color, + &st_update_depth, &st_update_clip, &st_update_fs, &st_update_point, diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index f203e1df60..8e98cbc2df 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -39,6 +39,12 @@ extern struct pipe_surface * xmesa_get_color_surface(GLcontext *ctx, GLuint i); +extern struct pipe_surface * +xmesa_get_z_surface(GLcontext *ctx, GLuint i); + +extern struct pipe_surface * +xmesa_get_stencil_surface(GLcontext *ctx, GLuint i); + /** * Update framebuffer state (color, depth, stencil, etc. buffers) @@ -58,6 +64,14 @@ update_framebuffer_state( struct st_context *st ) framebuffer.cbufs[i] = xmesa_get_color_surface(st->ctx, i); } + if (st->ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer) { + framebuffer.zbuf = xmesa_get_z_surface(st->ctx, i); + } + + if (st->ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer) { + framebuffer.sbuf = xmesa_get_stencil_surface(st->ctx, i); + } + if (memcmp(&framebuffer, &st->state.framebuffer, sizeof(framebuffer)) != 0) { st->state.framebuffer = framebuffer; st->pipe->set_framebuffer_state( st->pipe, &framebuffer ); -- cgit v1.2.3 From 8f6d06d037524f012416da5b56889e74bcf09f8f Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 25 Jun 2007 09:43:02 -0600 Subject: code for functional Z buffer surface --- src/mesa/drivers/x11/xm_surface.c | 77 ++++++++++++++++++++++++++-- src/mesa/drivers/x11/xmesaP.h | 4 +- src/mesa/state_tracker/st_atom_framebuffer.c | 10 ++-- 3 files changed, 81 insertions(+), 10 deletions(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index a937df3ade..30c9049cbf 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -54,6 +54,7 @@ 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 */ }; @@ -242,15 +243,85 @@ xmesa_get_color_surface(GLcontext *ctx, GLuint buf) } +static void +read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLfloat 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); + for (i = 0; i < 4; i++) { + zzzz[i] = USHORT_TO_FLOAT(temp[i]); + } +} + +static void +write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLfloat 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); + for (i = 0; i < 4; i++) { + CLAMPED_FLOAT_TO_USHORT(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.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; +} + +/** + * 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, GLuint i) +xmesa_get_z_surface(GLcontext *ctx) { - return NULL; + 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, GLuint i) +xmesa_get_stencil_surface(GLcontext *ctx) { return NULL; } diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 1d5df3d935..c0eed4c2a3 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -593,10 +593,10 @@ struct pipe_surface * xmesa_get_color_surface(GLcontext *ctx, GLuint buf); struct pipe_surface * -xmesa_get_z_surface(GLcontext *ctx, GLuint i); +xmesa_get_z_surface(GLcontext *ctx); struct pipe_surface * -xmesa_get_stencil_surface(GLcontext *ctx, GLuint i); +xmesa_get_stencil_surface(GLcontext *ctx); #endif diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 8e98cbc2df..595f390b28 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -40,10 +40,10 @@ extern struct pipe_surface * xmesa_get_color_surface(GLcontext *ctx, GLuint i); extern struct pipe_surface * -xmesa_get_z_surface(GLcontext *ctx, GLuint i); +xmesa_get_z_surface(GLcontext *ctx); extern struct pipe_surface * -xmesa_get_stencil_surface(GLcontext *ctx, GLuint i); +xmesa_get_stencil_surface(GLcontext *ctx); /** @@ -64,12 +64,12 @@ update_framebuffer_state( struct st_context *st ) framebuffer.cbufs[i] = xmesa_get_color_surface(st->ctx, i); } - if (st->ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer) { - framebuffer.zbuf = xmesa_get_z_surface(st->ctx, i); + if (st->ctx->DrawBuffer->_DepthBuffer/*Attachment[BUFFER_DEPTH].Renderbuffer*/) { + framebuffer.zbuf = xmesa_get_z_surface(st->ctx); } if (st->ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer) { - framebuffer.sbuf = xmesa_get_stencil_surface(st->ctx, i); + framebuffer.sbuf = xmesa_get_stencil_surface(st->ctx); } if (memcmp(&framebuffer, &st->state.framebuffer, sizeof(framebuffer)) != 0) { -- cgit v1.2.3 From 4576d754c98e3fb5d413e294d48fb70a893defcf Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 17:17:44 -0600 Subject: Lots of improvements to the surface-related code. Z testing now works with i915 driver. Add gl_renderbuffer::surface pointer (and reverse pointer). Remove intel_surface and xmesa_surface types - no longer used. --- src/mesa/drivers/dri/i915tex/intel_fbo.c | 18 ++ src/mesa/drivers/dri/i915tex/intel_fbo.h | 14 +- src/mesa/drivers/dri/i915tex/intel_surface.c | 231 ++++++++++++++------- src/mesa/drivers/x11/xm_buffer.c | 8 + src/mesa/drivers/x11/xm_surface.c | 288 +++++---------------------- src/mesa/drivers/x11/xmesaP.h | 14 +- src/mesa/main/mtypes.h | 3 + src/mesa/main/renderbuffer.c | 22 +- src/mesa/pipe/p_state.h | 16 +- src/mesa/pipe/softpipe/sp_context.c | 13 ++ src/mesa/pipe/softpipe/sp_z_surface.c | 118 +++++++++++ src/mesa/pipe/softpipe/sp_z_surface.h | 37 ++++ src/mesa/sources | 1 + src/mesa/state_tracker/st_atom_framebuffer.c | 19 +- 14 files changed, 449 insertions(+), 353 deletions(-) create mode 100644 src/mesa/pipe/softpipe/sp_z_surface.c create mode 100644 src/mesa/pipe/softpipe/sp_z_surface.h (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index a09db46163..5a93eb7ad1 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -289,6 +289,12 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, rb->Width = width; rb->Height = height; +#if 1 + /* update the surface's size too */ + rb->surface->width = width; + rb->surface->height = height; +#endif + /* This sets the Get/PutRow/Value functions */ intel_set_span_functions(&irb->Base); @@ -451,6 +457,12 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height, return irb; } + +/** + * Create a new renderbuffer which corresponds to an X window buffer + * (color, depth, stencil, etc) - not a user-created GL renderbuffer. + * The internal format is set at creation time and does not change. + */ struct gl_renderbuffer * intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat) { @@ -472,6 +484,9 @@ intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat) irb->Base.GetPointer = intel_get_pointer; /* span routines set in alloc_storage function */ + irb->Base.surface = intel_new_surface(intFormat); + irb->Base.surface->rb = irb; + return &irb->Base; } @@ -500,6 +515,9 @@ intel_new_renderbuffer(GLcontext * ctx, GLuint name) irb->Base.GetPointer = intel_get_pointer; /* span routines set in alloc_storage function */ + irb->Base.surface = intel_new_surface(0 /*unknown format*/); + irb->Base.surface->rb = irb; + return &irb->Base; } diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.h b/src/mesa/drivers/dri/i915tex/intel_fbo.h index 1642ce774f..86c8106084 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.h +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.h @@ -37,17 +37,6 @@ struct intel_context; struct intel_region; -/** - * Intel "pipe" surface. This is kind of a temporary thing as - * renderbuffers and surfaces should eventually become one. - */ -struct intel_surface -{ - struct softpipe_surface surface; /**< base class */ - struct intel_renderbuffer *rb; /**< ptr back to matching renderbuffer */ -}; - - /** * Intel framebuffer, derived from gl_framebuffer. */ @@ -129,5 +118,8 @@ extern struct intel_region *intel_get_rb_region(struct gl_framebuffer *fb, +extern struct pipe_surface * +intel_new_surface(GLuint intFormat); + #endif /* INTEL_FBO_H */ diff --git a/src/mesa/drivers/dri/i915tex/intel_surface.c b/src/mesa/drivers/dri/i915tex/intel_surface.c index 3be902cf9c..043c5aa5fe 100644 --- a/src/mesa/drivers/dri/i915tex/intel_surface.c +++ b/src/mesa/drivers/dri/i915tex/intel_surface.c @@ -23,27 +23,33 @@ * XXX a lof of this is a temporary kludge */ +/** + * Note: the arithmetic/addressing in these functions is a little + * tricky since we need to invert the Y axis. + */ static void read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { - struct intel_surface *is = (struct intel_surface *) sps; - struct intel_renderbuffer *irb = is->rb; - const GLubyte *src = (const GLubyte *) irb->region->map - + (y * irb->region->pitch + x) * irb->region->cpp; + const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp; + const GLint invY = sps->surface.height - y - 1; + const GLubyte *src = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp; GLfloat *dst = (GLfloat *) rrrr; GLubyte temp[16]; - GLuint i, j; + GLuint j; + + assert(sps->surface.format == PIPE_FORMAT_U_A8_R8_G8_B8); - memcpy(temp, src, 8); - memcpy(temp + 8, src + irb->region->pitch * irb->region->cpp, 8); + memcpy(temp + 8, src, 8); + memcpy(temp + 0, src + bytesPerRow, 8); - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - dst[j * 4 + i] = UBYTE_TO_FLOAT(temp[i * 4 + j]); - } + for (j = 0; j < 4; j++) { + dst[0 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 2]); /*R*/ + dst[1 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 1]); /*G*/ + dst[2 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 0]); /*B*/ + dst[3 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 3]); /*A*/ } } @@ -52,45 +58,128 @@ static void write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { - struct intel_surface *is = (struct intel_surface *) sps; - struct intel_renderbuffer *irb = is->rb; const GLfloat *src = (const GLfloat *) rrrr; - GLubyte *dst = (GLubyte *) irb->region->map - + (y * irb->region->pitch + x) * irb->region->cpp; + const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp; + const GLint invY = sps->surface.height - y - 1; + GLubyte *dst = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp; GLubyte temp[16]; - GLuint i, j; + GLuint j; + + assert(sps->surface.format == PIPE_FORMAT_U_A8_R8_G8_B8); - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + i], src[i * 4 + j]); - } + for (j = 0; j < 4; j++) { + UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 2], src[0 * 4 + j]); /*R*/ + UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 1], src[1 * 4 + j]); /*G*/ + UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 0], src[2 * 4 + j]); /*B*/ + UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 3], src[3 * 4 + j]); /*A*/ } - memcpy(dst, temp, 8); - memcpy(dst + irb->region->pitch * irb->region->cpp, temp + 8, 8); + memcpy(dst, temp + 8, 8); + memcpy(dst + bytesPerRow, temp + 0, 8); } +static void +read_quad_z24(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + static const GLuint mask = 0xffffff; + const GLint invY = sps->surface.height - y - 1; + const GLuint *src + = (GLuint *) (sps->surface.ptr + + (invY * sps->surface.stride + x) * sps->surface.cpp); + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + /* extract lower three bytes */ + zzzz[0] = src[0] & mask; + zzzz[1] = src[1] & mask; + zzzz[2] = src[-sps->surface.stride] & mask; + zzzz[3] = src[-sps->surface.stride + 1] & mask; +} + +static void +write_quad_z24(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + static const GLuint mask = 0xff000000; + const GLint invY = sps->surface.height - y - 1; + GLuint *dst + = (GLuint *) (sps->surface.ptr + + (invY * sps->surface.stride + x) * sps->surface.cpp); + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + /* write lower three bytes */ + dst[0] = (dst[0] & mask) | zzzz[0]; + dst[1] = (dst[1] & mask) | zzzz[1]; + dst -= sps->surface.stride; + dst[0] = (dst[0] & mask) | zzzz[2]; + dst[1] = (dst[1] & mask) | zzzz[3]; +} + + +static void +read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + const GLint invY = sps->surface.height - y - 1; + const GLuint *src = (const GLuint *) (sps->surface.ptr + + (invY * sps->surface.stride + x) * sps->surface.cpp); + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + /* extract high byte */ + ssss[0] = src[0] >> 24; + ssss[1] = src[1] >> 24; + ssss[2] = src[-sps->surface.width] >> 24; + ssss[3] = src[-sps->surface.width + 1] >> 24; +} + +static void +write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + static const GLuint mask = 0x00ffffff; + const GLint invY = sps->surface.height - y - 1; + GLuint *dst = (GLuint *) (sps->surface.ptr + + (invY * sps->surface.stride + x) * sps->surface.cpp); + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + /* write high byte */ + dst[0] = (dst[0] & mask) | (ssss[0] << 24); + dst[1] = (dst[1] & mask) | (ssss[1] << 24); + dst -= sps->surface.stride; + dst[0] = (dst[0] & mask) | (ssss[2] << 24); + dst[1] = (dst[1] & mask) | (ssss[3] << 24); +} + + static void * map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) { - struct intel_surface *is = (struct intel_surface *) pb; - struct intel_renderbuffer *irb = is->rb; - GET_CURRENT_CONTEXT(ctx); - struct intel_context *intel = intel_context(ctx); - + struct softpipe_surface *sps = (struct softpipe_surface *) pb; + struct intel_renderbuffer *irb = (struct intel_renderbuffer *) sps->surface.rb; assert(access_mode == PIPE_MAP_READ_WRITE); - intelFinish(&intel->ctx); - /*LOCK_HARDWARE(intel);*/ if (irb->region) { + GET_CURRENT_CONTEXT(ctx); + struct intel_context *intel = intel_context(ctx); +#if 0 + intelFinish(&intel->ctx); /* XXX need this? */ +#endif intel_region_map(intel->intelScreen, irb->region); } pb->ptr = irb->region->map; + sps->surface.stride = irb->region->pitch; + sps->surface.cpp = irb->region->cpp; + sps->surface.ptr = irb->region->map; + return pb->ptr; } @@ -98,69 +187,67 @@ map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) static void unmap_surface_buffer(struct pipe_buffer *pb) { - struct intel_surface *is = (struct intel_surface *) pb; - struct intel_renderbuffer *irb = is->rb; - GET_CURRENT_CONTEXT(ctx); - struct intel_context *intel = intel_context(ctx); + struct softpipe_surface *sps = (struct softpipe_surface *) pb; + struct intel_renderbuffer *irb = (struct intel_renderbuffer *) sps->surface.rb; if (irb->region) { + GET_CURRENT_CONTEXT(ctx); + struct intel_context *intel = intel_context(ctx); intel_region_unmap(intel->intelScreen, irb->region); } pb->ptr = NULL; + sps->surface.stride = 0; + sps->surface.cpp = 0; + sps->surface.ptr = NULL; + /*UNLOCK_HARDWARE(intel);*/ } struct pipe_surface * -xmesa_get_color_surface(GLcontext *ctx, GLuint i) +intel_new_surface(GLuint intFormat) { - struct intel_context *intel = intel_context(ctx); - struct intel_framebuffer *intel_fb; - struct intel_renderbuffer *intel_rb; - - intel_fb = (struct intel_framebuffer *) ctx->DrawBuffer; - intel_rb = intel_fb->color_rb[1]; - - if (!intel_rb->surface) { - /* create surface and attach to intel_rb */ - struct intel_surface *is; - is = CALLOC_STRUCT(intel_surface); - if (is) { - is->surface.surface.width = intel_rb->Base.Width; - is->surface.surface.height = intel_rb->Base.Height; - - is->surface.read_quad_f_swz = read_quad_f_swz; - is->surface.write_quad_f_swz = write_quad_f_swz; - - is->surface.surface.buffer.map = map_surface_buffer; - is->surface.surface.buffer.unmap = unmap_surface_buffer; - - is->rb = intel_rb; - } - intel_rb->surface = is; + struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface); + if (!sps) + return NULL; + + sps->surface.width = 0; /* set in intel_alloc_renderbuffer_storage() */ + sps->surface.height = 0; + + if (intFormat == GL_RGBA8) { + sps->surface.format = PIPE_FORMAT_U_A8_R8_G8_B8; + sps->read_quad_f_swz = read_quad_f_swz; + sps->write_quad_f_swz = write_quad_f_swz; } - else { - /* update surface size */ - struct intel_surface *is = intel_rb->surface; - is->surface.surface.width = intel_rb->Base.Width; - is->surface.surface.height = intel_rb->Base.Height; - /* sanity check */ - assert(is->surface.surface.buffer.map == map_surface_buffer); + else if (intFormat == GL_RGB5) { + sps->surface.format = PIPE_FORMAT_U_R5_G6_B5; + } + else if (intFormat == GL_DEPTH_COMPONENT16) { + sps->surface.format = PIPE_FORMAT_U_Z16; - return &intel_rb->surface->surface.surface; -} + } + else if (intFormat == GL_DEPTH24_STENCIL8_EXT) { + sps->surface.format = PIPE_FORMAT_Z24_S8; + sps->read_quad_z = read_quad_z24; + sps->write_quad_z = write_quad_z24; + sps->read_quad_stencil = read_quad_stencil; + sps->write_quad_stencil = write_quad_stencil; + } + else { + /* TBD / unknown */ + } -struct pipe_surface * -xmesa_get_z_surface(GLcontext *ctx) -{ - /* XXX fix */ - return NULL; + sps->surface.buffer.map = map_surface_buffer; + sps->surface.buffer.unmap = unmap_surface_buffer; + + return &sps->surface; } + struct pipe_surface * xmesa_get_stencil_surface(GLcontext *ctx) { diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 51d183bb43..8fbd9a783b 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -35,6 +35,7 @@ #include "imports.h" #include "framebuffer.h" #include "renderbuffer.h" +#include "pipe/p_state.h" #if defined(USE_XSHM) && !defined(XFree86Server) @@ -268,6 +269,8 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Height = height; rb->InternalFormat = internalFormat; + rb->surface->resize(rb->surface, width, height); + return GL_TRUE; } @@ -317,6 +320,8 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, xrb->origin4 = NULL; } + rb->surface->resize(rb->surface, width, height); + return GL_TRUE; } @@ -352,6 +357,9 @@ xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, xrb->Base.IndexBits = visual->indexBits; } /* only need to set Red/Green/EtcBits fields for user-created RBs */ + + xrb->Base.surface = xmesa_new_surface(xrb); + } return xrb; } diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 9d6db2b5ce..17f5f28a9d 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -24,7 +24,7 @@ /** - * \file xm_surface.h + * \file xm_surface.c * 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. @@ -48,31 +48,11 @@ #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; -} - - static void * map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) { /* no-op */ + return NULL; } @@ -83,6 +63,13 @@ unmap_surface_buffer(struct pipe_buffer *pb) } +static INLINE struct xmesa_renderbuffer * +xmesa_rb(struct softpipe_surface *sps) +{ + return (struct xmesa_renderbuffer *) sps->surface.rb; +} + + /** * quad reading/writing * These functions are just wrappers around the existing renderbuffer @@ -90,11 +77,10 @@ unmap_surface_buffer(struct pipe_buffer *pb) */ static void -read_quad_f(struct softpipe_surface *gs, GLint x, GLint y, +read_quad_f(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rgba)[NUM_CHANNELS]) { - struct xmesa_surface *xmsurf = xmesa_surface(gs); - struct xmesa_renderbuffer *xrb = xmsurf->xrb; + struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GLubyte temp[16]; GLfloat *dst = (GLfloat *) rgba; GLuint i; @@ -107,11 +93,10 @@ read_quad_f(struct softpipe_surface *gs, GLint x, GLint y, } static void -read_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y, +read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { - struct xmesa_surface *xmsurf = xmesa_surface(gs); - struct xmesa_renderbuffer *xrb = xmsurf->xrb; + struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GLubyte temp[16]; GLfloat *dst = (GLfloat *) rrrr; GLuint i, j; @@ -126,11 +111,10 @@ read_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y, } static void -write_quad_f(struct softpipe_surface *gs, GLint x, GLint y, +write_quad_f(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rgba)[NUM_CHANNELS]) { - struct xmesa_surface *xmsurf = xmesa_surface(gs); - struct xmesa_renderbuffer *xrb = xmsurf->xrb; + struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GLubyte temp[16]; const GLfloat *src = (const GLfloat *) rgba; GLuint i; @@ -143,11 +127,10 @@ write_quad_f(struct softpipe_surface *gs, GLint x, GLint y, } static void -write_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y, +write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { - struct xmesa_surface *xmsurf = xmesa_surface(gs); - struct xmesa_renderbuffer *xrb = xmsurf->xrb; + struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GLubyte temp[16]; const GLfloat *src = (const GLfloat *) rrrr; GLuint i, j; @@ -162,251 +145,70 @@ write_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y, } static void -read_quad_ub(struct softpipe_surface *gs, GLint x, GLint y, +read_quad_ub(struct softpipe_surface *sps, GLint x, GLint y, GLubyte (*rgba)[NUM_CHANNELS]) { - struct xmesa_surface *xmsurf = xmesa_surface(gs); - struct xmesa_renderbuffer *xrb = xmsurf->xrb; + struct xmesa_renderbuffer *xrb = xmesa_rb(sps); 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, +write_quad_ub(struct softpipe_surface *sps, GLint x, GLint y, GLubyte (*rgba)[NUM_CHANNELS]) { - struct xmesa_surface *xmsurf = xmesa_surface(gs); - struct xmesa_renderbuffer *xrb = xmsurf->xrb; + struct xmesa_renderbuffer *xrb = xmesa_rb(sps); 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, +write_mono_row_ub(struct softpipe_surface *sps, GLuint count, GLint x, GLint y, GLubyte rgba[NUM_CHANNELS]) { - struct xmesa_surface *xmsurf = xmesa_surface(gs); - struct xmesa_renderbuffer *xrb = xmsurf->xrb; + struct xmesa_renderbuffer *xrb = xmesa_rb(sps); 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; - - xmsurf->sps.surface.buffer.map = map_surface_buffer; - xmsurf->sps.surface.buffer.unmap = unmap_surface_buffer; - -#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]) +resize_surface(struct pipe_surface *ps, GLuint width, GLuint height) { - 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; + ps->width = width; + ps->height = height; } - - /** - * 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... + * Called to create a pipe_surface for each X renderbuffer. */ struct pipe_surface * -xmesa_get_z_surface(GLcontext *ctx) +xmesa_new_surface(struct xmesa_renderbuffer *xrb) { - XMesaContext xmctx = XMESA_CONTEXT(ctx); - struct gl_renderbuffer *rb = ctx->DrawBuffer->_DepthBuffer; - static struct xmesa_surface *xms = NULL; + struct softpipe_surface *sps; - if (!rb) + sps = CALLOC_STRUCT(softpipe_surface); + if (!sps) 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; -} + sps->surface.rb = xrb; + sps->surface.width = xrb->Base.Width; + sps->surface.height = xrb->Base.Height; + sps->read_quad_f = read_quad_f; + sps->read_quad_f_swz = read_quad_f_swz; + sps->read_quad_ub = read_quad_ub; + sps->write_quad_f = write_quad_f; + sps->write_quad_f_swz = write_quad_f_swz; + sps->write_quad_ub = write_quad_ub; + sps->write_mono_row_ub = write_mono_row_ub; -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; + sps->surface.buffer.map = map_surface_buffer; + sps->surface.buffer.unmap = unmap_surface_buffer; + sps->surface.resize = resize_surface; - 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; + return &sps->surface; } - diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 8648b19939..daf6a3f942 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -585,23 +585,11 @@ 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); +xmesa_new_surface(struct xmesa_renderbuffer *xrb); #endif diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 52448ee04e..d70df5d945 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -127,6 +127,7 @@ struct gl_texture_format; struct gl_texture_image; struct gl_texture_object; struct st_context; +struct pipe_surface; typedef struct __GLcontextRec GLcontext; typedef struct __GLcontextModesRec GLvisual; typedef struct gl_framebuffer GLframebuffer; @@ -2268,6 +2269,8 @@ struct gl_renderbuffer GLubyte StencilBits; GLvoid *Data; /**< This may not be used by some kinds of RBs */ + struct pipe_surface *surface; + /* Used to wrap one renderbuffer around another: */ struct gl_renderbuffer *Wrapped; diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 6f1d7c3960..a1412ef007 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -49,6 +49,9 @@ #include "rbadaptors.h" +#include "pipe/softpipe/sp_z_surface.h" +#include "pipe/p_state.h" + /* 32-bit color index format. Not a public format. */ #define COLOR_INDEX32 0x424243 @@ -1091,6 +1094,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->PutValues = put_values_ushort; rb->PutMonoValues = put_mono_values_ushort; rb->DepthBits = 8 * sizeof(GLushort); + rb->surface = (struct pipe_surface *) softpipe_new_z_surface(16); pixelSize = sizeof(GLushort); break; case GL_DEPTH_COMPONENT24: @@ -1193,13 +1197,27 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, /* free old buffer storage */ if (rb->Data) { - _mesa_free(rb->Data); + if (rb->surface) { + /* pipe surface */ + } + else { + /* legacy renderbuffer */ + _mesa_free(rb->Data); + } rb->Data = NULL; } if (width > 0 && height > 0) { /* allocate new buffer storage */ - rb->Data = _mesa_malloc(width * height * pixelSize); + if (rb->surface) { + /* pipe surface */ + rb->surface->resize(rb->surface, width, height); + rb->Data = rb->surface->buffer.ptr; + } + else { + /* legacy renderbuffer */ + rb->Data = _mesa_malloc(width * height * pixelSize); + } if (rb->Data == NULL) { rb->Width = 0; rb->Height = 0; diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 4ae8928018..9973a7b8dd 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -239,6 +239,7 @@ struct pipe_sampler_state /** * A mappable buffer (vertex data, pixel data, etc) + * XXX replace with "intel_region". */ struct pipe_buffer { @@ -247,7 +248,7 @@ struct pipe_buffer const void *src); void *(*map)(struct pipe_buffer *pb, GLuint access_mode); void (*unmap)(struct pipe_buffer *pb); - void *ptr; /**< address, only valid while mapped */ + GLubyte *ptr; /**< address, only valid while mapped */ GLuint mode; /**< PIPE_MAP_x, only valid while mapped */ }; @@ -261,12 +262,13 @@ struct pipe_surface struct pipe_buffer buffer; /**< surfaces can be mapped */ GLuint format:5; /**< PIPE_FORMAT_x */ GLuint width, height; -#if 0 - GLubyte *ptr; - GLint stride; - GLuint cpp; - GLuint format; -#endif + + GLint stride, cpp; + GLubyte *ptr; /**< only valid while mapped, may not equal buffer->ptr */ + + void *rb; /**< Ptr back to renderbuffer (temporary?) */ + + void (*resize)(struct pipe_surface *ps, GLuint width, GLuint height); }; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 6b44fabfa4..8655aa83fd 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -49,6 +49,13 @@ static void map_surfaces(struct softpipe_context *sp) struct pipe_buffer *buf = &sps->surface.buffer; buf->map(buf, PIPE_MAP_READ_WRITE); } + + if (sp->framebuffer.zbuf) { + struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.zbuf); + struct pipe_buffer *buf = &sps->surface.buffer; + buf->map(buf, PIPE_MAP_READ_WRITE); + } + /* XXX depth & stencil bufs */ } @@ -62,6 +69,12 @@ static void unmap_surfaces(struct softpipe_context *sp) struct pipe_buffer *buf = &sps->surface.buffer; buf->unmap(buf); } + + if (sp->framebuffer.zbuf) { + struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.zbuf); + struct pipe_buffer *buf = &sps->surface.buffer; + buf->unmap(buf); + } /* XXX depth & stencil bufs */ } diff --git a/src/mesa/pipe/softpipe/sp_z_surface.c b/src/mesa/pipe/softpipe/sp_z_surface.c new file mode 100644 index 0000000000..662a4a15ee --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_z_surface.c @@ -0,0 +1,118 @@ +/************************************************************************** + * + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + + +/** + * Software Z buffer/surface. + * + * \author Brian Paul + */ + + +#include "main/imports.h" +#include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include "sp_surface.h" +#include "sp_z_surface.h" + +static void* +z16_map(struct pipe_buffer *pb, GLuint access_mode) +{ + struct softpipe_surface *sps = (struct softpipe_surface *) pb; + sps->surface.ptr = pb->ptr; + return pb->ptr; +} + +static void +z16_unmap(struct pipe_buffer *pb) +{ + struct softpipe_surface *sps = (struct softpipe_surface *) pb; + sps->surface.ptr = NULL; +} + +static void +z16_resize(struct pipe_surface *ps, GLuint width, GLuint height) +{ + struct softpipe_surface *sps = (struct softpipe_surface *) ps; + + if (sps->surface.buffer.ptr) + free(sps->surface.buffer.ptr); + + ps->buffer.ptr = (GLubyte *) malloc(width * height * sizeof(GLushort)); + ps->width = width; + ps->height = height; + + sps->surface.stride = sps->surface.width; + sps->surface.cpp = 2; +} + +static void +z16_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLushort *src + = (GLushort *) sps->surface.ptr + y * sps->surface.stride + x; + + /* converting GLushort to GLuint: */ + zzzz[0] = src[0]; + zzzz[1] = src[1]; + zzzz[2] = src[sps->surface.width]; + zzzz[3] = src[sps->surface.width + 1]; +} + +static void +z16_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLushort *dst = (GLushort *) sps->surface.ptr + y * sps->surface.stride + x; + + /* converting GLuint to GLushort: */ + dst[0] = zzzz[0]; + dst[1] = zzzz[1]; + dst[sps->surface.width] = zzzz[2]; + dst[sps->surface.width + 1] = zzzz[3]; +} + +struct softpipe_surface * +softpipe_new_z_surface(GLuint depth) +{ + struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface); + if (!sps) + return NULL; + + /* XXX ignoring depth param for now */ + + sps->surface.format = PIPE_FORMAT_U_Z16; + + sps->surface.resize = z16_resize; + sps->surface.buffer.map = z16_map; + sps->surface.buffer.unmap = z16_unmap; + sps->read_quad_z = z16_read_quad_z; + sps->write_quad_z = z16_write_quad_z; + + return sps; +} diff --git a/src/mesa/pipe/softpipe/sp_z_surface.h b/src/mesa/pipe/softpipe/sp_z_surface.h new file mode 100644 index 0000000000..9c3c43ca57 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_z_surface.h @@ -0,0 +1,37 @@ +/************************************************************************** + * + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + + +#ifndef SP_Z_SURFACE_H +#define SP_Z_SURFACE_H + + +extern struct softpipe_surface * +softpipe_new_z_surface(GLuint depth); + + +#endif /* SP_Z_SURFACE_H */ diff --git a/src/mesa/sources b/src/mesa/sources index a589ae4373..32c2ff2350 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -176,6 +176,7 @@ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_state_sampler.c \ pipe/softpipe/sp_state_setup.c \ pipe/softpipe/sp_state_surface.c \ + pipe/softpipe/sp_z_surface.c \ pipe/softpipe/sp_prim_setup.c DRAW_SOURCES = \ diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 595f390b28..f5e3ce8b67 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -54,22 +54,31 @@ static void update_framebuffer_state( struct st_context *st ) { struct pipe_framebuffer_state framebuffer; + struct gl_renderbuffer *rb; GLuint i; + memset(&framebuffer, 0, sizeof(framebuffer)); + /* Examine Mesa's ctx->DrawBuffer->_ColorDrawBuffers state * to determine which surfaces to draw to */ framebuffer.num_cbufs = st->ctx->DrawBuffer->_NumColorDrawBuffers[0]; for (i = 0; i < framebuffer.num_cbufs; i++) { - framebuffer.cbufs[i] = xmesa_get_color_surface(st->ctx, i); + rb = st->ctx->DrawBuffer->_ColorDrawBuffers[0][i]; + assert(rb->surface); + framebuffer.cbufs[i] = rb->surface; } - if (st->ctx->DrawBuffer->_DepthBuffer/*Attachment[BUFFER_DEPTH].Renderbuffer*/) { - framebuffer.zbuf = xmesa_get_z_surface(st->ctx); + rb = st->ctx->DrawBuffer->_DepthBuffer; + if (rb) { + assert(rb->surface); + framebuffer.zbuf = rb->Wrapped->surface; } - if (st->ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer) { - framebuffer.sbuf = xmesa_get_stencil_surface(st->ctx); + rb = st->ctx->DrawBuffer->_StencilBuffer; + if (rb) { + assert(rb->surface); + framebuffer.sbuf = rb->Wrapped->surface; } if (memcmp(&framebuffer, &st->state.framebuffer, sizeof(framebuffer)) != 0) { -- cgit v1.2.3 From 20adf45c23dd9ec86a1439ad87c1473395bbb1a7 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 31 Jul 2007 17:42:03 -0600 Subject: Redesign pipe_surface in terms of pipe_region. struct pipe_buffer goes away. Added basic region functions to softpipe to allocate/release malloc'd regions. Surface-related code is fairly coherent now. --- src/mesa/drivers/dri/i915pipe/intel_fbo.c | 3 +- src/mesa/drivers/dri/i915pipe/intel_surface.c | 85 ++-------- src/mesa/drivers/x11/xm_buffer.c | 13 +- src/mesa/drivers/x11/xm_surface.c | 42 ++--- src/mesa/drivers/x11/xmesaP.h | 2 +- src/mesa/main/renderbuffer.c | 54 +++--- src/mesa/pipe/p_context.h | 8 + src/mesa/pipe/p_state.h | 53 ++---- src/mesa/pipe/softpipe/sp_context.c | 19 ++- src/mesa/pipe/softpipe/sp_region.c | 105 ++++++++++++ src/mesa/pipe/softpipe/sp_region.h | 40 +++++ src/mesa/pipe/softpipe/sp_surface.c | 236 ++++++++++++++++++++++++-- src/mesa/pipe/softpipe/sp_surface.h | 7 +- src/mesa/pipe/softpipe/sp_z_surface.c | 138 ++++++--------- src/mesa/sources | 3 +- 15 files changed, 538 insertions(+), 270 deletions(-) create mode 100644 src/mesa/pipe/softpipe/sp_region.c create mode 100644 src/mesa/pipe/softpipe/sp_region.h (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/dri/i915pipe/intel_fbo.c b/src/mesa/drivers/dri/i915pipe/intel_fbo.c index bac2ef8467..1470ce7d82 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_fbo.c +++ b/src/mesa/drivers/dri/i915pipe/intel_fbo.c @@ -291,11 +291,10 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, rb->Width = width; rb->Height = height; -#if 1 /* update the surface's size too */ rb->surface->width = width; rb->surface->height = height; -#endif + rb->surface->region = irb->region; /* This sets the Get/PutRow/Value functions */ intel_set_span_functions(&irb->Base); diff --git a/src/mesa/drivers/dri/i915pipe/intel_surface.c b/src/mesa/drivers/dri/i915pipe/intel_surface.c index 58f5cb5f96..936c9cb5e7 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_surface.c +++ b/src/mesa/drivers/dri/i915pipe/intel_surface.c @@ -33,9 +33,9 @@ static void read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { - const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp; + const GLint bytesPerRow = sps->surface.region->pitch * sps->surface.region->cpp; const GLint invY = sps->surface.height - y - 1; - const GLubyte *src = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp; + const GLubyte *src = sps->surface.region->map + invY * bytesPerRow + x * sps->surface.region->cpp; GLfloat *dst = (GLfloat *) rrrr; GLubyte temp[16]; GLuint j; @@ -59,9 +59,9 @@ write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { const GLfloat *src = (const GLfloat *) rrrr; - const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp; + const GLint bytesPerRow = sps->surface.region->pitch * sps->surface.region->cpp; const GLint invY = sps->surface.height - y - 1; - GLubyte *dst = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp; + GLubyte *dst = sps->surface.region->map + invY * bytesPerRow + x * sps->surface.region->cpp; GLubyte temp[16]; GLuint j; @@ -87,16 +87,16 @@ read_quad_z24(struct softpipe_surface *sps, static const GLuint mask = 0xffffff; const GLint invY = sps->surface.height - y - 1; const GLuint *src - = (GLuint *) (sps->surface.ptr - + (invY * sps->surface.stride + x) * sps->surface.cpp); + = (GLuint *) (sps->surface.region->map + + (invY * sps->surface.region->pitch + x) * sps->surface.region->cpp); assert(sps->surface.format == PIPE_FORMAT_Z24_S8); /* extract lower three bytes */ zzzz[0] = src[0] & mask; zzzz[1] = src[1] & mask; - zzzz[2] = src[-sps->surface.stride] & mask; - zzzz[3] = src[-sps->surface.stride + 1] & mask; + zzzz[2] = src[-sps->surface.region->pitch] & mask; + zzzz[3] = src[-sps->surface.region->pitch + 1] & mask; } static void @@ -106,15 +106,15 @@ write_quad_z24(struct softpipe_surface *sps, static const GLuint mask = 0xff000000; const GLint invY = sps->surface.height - y - 1; GLuint *dst - = (GLuint *) (sps->surface.ptr - + (invY * sps->surface.stride + x) * sps->surface.cpp); + = (GLuint *) (sps->surface.region->map + + (invY * sps->surface.region->pitch + x) * sps->surface.region->cpp); assert(sps->surface.format == PIPE_FORMAT_Z24_S8); /* write lower three bytes */ dst[0] = (dst[0] & mask) | zzzz[0]; dst[1] = (dst[1] & mask) | zzzz[1]; - dst -= sps->surface.stride; + dst -= sps->surface.region->pitch; dst[0] = (dst[0] & mask) | zzzz[2]; dst[1] = (dst[1] & mask) | zzzz[3]; } @@ -125,15 +125,15 @@ read_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) { const GLint invY = sps->surface.height - y - 1; - const GLuint *src = (const GLuint *) (sps->surface.ptr - + (invY * sps->surface.stride + x) * sps->surface.cpp); + const GLuint *src = (const GLuint *) (sps->surface.region->map + + (invY * sps->surface.region->pitch + x) * sps->surface.region->cpp); assert(sps->surface.format == PIPE_FORMAT_Z24_S8); /* extract high byte */ ssss[0] = src[0] >> 24; ssss[1] = src[1] >> 24; - src -= sps->surface.stride; + src -= sps->surface.region->pitch; ssss[2] = src[0] >> 24; ssss[3] = src[1] >> 24; } @@ -144,68 +144,20 @@ write_quad_stencil(struct softpipe_surface *sps, { static const GLuint mask = 0x00ffffff; const GLint invY = sps->surface.height - y - 1; - GLuint *dst = (GLuint *) (sps->surface.ptr - + (invY * sps->surface.stride + x) * sps->surface.cpp); + GLuint *dst = (GLuint *) (sps->surface.region->map + + (invY * sps->surface.region->pitch + x) * sps->surface.region->cpp); assert(sps->surface.format == PIPE_FORMAT_Z24_S8); /* write high byte */ dst[0] = (dst[0] & mask) | (ssss[0] << 24); dst[1] = (dst[1] & mask) | (ssss[1] << 24); - dst -= sps->surface.stride; + dst -= sps->surface.region->pitch; dst[0] = (dst[0] & mask) | (ssss[2] << 24); dst[1] = (dst[1] & mask) | (ssss[3] << 24); } -static void * -map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) pb; - struct intel_renderbuffer *irb = (struct intel_renderbuffer *) sps->surface.rb; - assert(access_mode == PIPE_MAP_READ_WRITE); - - /*LOCK_HARDWARE(intel);*/ - - if (irb->region) { - GET_CURRENT_CONTEXT(ctx); - struct intel_context *intel = intel_context(ctx); -#if 0 - intelFinish(&intel->ctx); /* XXX need this? */ -#endif - intel->pipe->region_map(intel->pipe, irb->region); - } - pb->ptr = irb->region->map; - - sps->surface.stride = irb->region->pitch; - sps->surface.cpp = irb->region->cpp; - sps->surface.ptr = irb->region->map; - - return pb->ptr; -} - - -static void -unmap_surface_buffer(struct pipe_buffer *pb) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) pb; - struct intel_renderbuffer *irb = (struct intel_renderbuffer *) sps->surface.rb; - - if (irb->region) { - GET_CURRENT_CONTEXT(ctx); - struct intel_context *intel = intel_context(ctx); - intel->pipe->region_unmap(intel->pipe, irb->region); - } - pb->ptr = NULL; - - sps->surface.stride = 0; - sps->surface.cpp = 0; - sps->surface.ptr = NULL; - - /*UNLOCK_HARDWARE(intel);*/ -} - - struct pipe_surface * intel_new_surface(GLuint intFormat) { @@ -241,8 +193,5 @@ intel_new_surface(GLuint intFormat) } - sps->surface.buffer.map = map_surface_buffer; - sps->surface.buffer.unmap = unmap_surface_buffer; - return &sps->surface; } diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 8fbd9a783b..5bba52da48 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -269,7 +269,10 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Height = height; rb->InternalFormat = internalFormat; - rb->surface->resize(rb->surface, width, height); + if (!xrb->Base.surface) + xrb->Base.surface = xmesa_new_surface(ctx, xrb); + xrb->Base.surface->width = width; + xrb->Base.surface->height = height; return GL_TRUE; } @@ -320,7 +323,10 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, xrb->origin4 = NULL; } - rb->surface->resize(rb->surface, width, height); + if (!xrb->Base.surface) + xrb->Base.surface = xmesa_new_surface(ctx, xrb); + xrb->Base.surface->width = width; + xrb->Base.surface->height = height; return GL_TRUE; } @@ -357,9 +363,6 @@ xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, xrb->Base.IndexBits = visual->indexBits; } /* only need to set Red/Green/EtcBits fields for user-created RBs */ - - xrb->Base.surface = xmesa_new_surface(xrb); - } return xrb; } diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 17f5f28a9d..e8e795c00f 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -42,25 +42,11 @@ #include "framebuffer.h" #include "renderbuffer.h" -#include "pipe/p_state.h" +#include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/softpipe/sp_context.h" #include "pipe/softpipe/sp_surface.h" - - -static void * -map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) -{ - /* no-op */ - return NULL; -} - - -static void -unmap_surface_buffer(struct pipe_buffer *pb) -{ - /* no-op */ -} +#include "state_tracker/st_context.h" static INLINE struct xmesa_renderbuffer * @@ -174,27 +160,22 @@ write_mono_row_ub(struct softpipe_surface *sps, GLuint count, GLint x, GLint y, } -static void -resize_surface(struct pipe_surface *ps, GLuint width, GLuint height) -{ - ps->width = width; - ps->height = height; -} - - /** * Called to create a pipe_surface for each X renderbuffer. + * Note: this is being used instead of pipe->surface_alloc() since we + * have special/unique quad read/write functions for X. */ struct pipe_surface * -xmesa_new_surface(struct xmesa_renderbuffer *xrb) +xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb) { + struct pipe_context *pipe = ctx->st->pipe; struct softpipe_surface *sps; sps = CALLOC_STRUCT(softpipe_surface); if (!sps) return NULL; - sps->surface.rb = xrb; + sps->surface.rb = xrb; /* XXX only needed for quad funcs above */ sps->surface.width = xrb->Base.Width; sps->surface.height = xrb->Base.Height; @@ -206,9 +187,12 @@ xmesa_new_surface(struct xmesa_renderbuffer *xrb) sps->write_quad_ub = write_quad_ub; sps->write_mono_row_ub = write_mono_row_ub; - sps->surface.buffer.map = map_surface_buffer; - sps->surface.buffer.unmap = unmap_surface_buffer; - sps->surface.resize = resize_surface; + /* Note, the region we allocate doesn't actually have any storage + * since we're drawing into an XImage or Pixmap. + * The region's size will get set in the xmesa_alloc_front/back_storage() + * functions. + */ + sps->surface.region = pipe->region_alloc(pipe, 0, 0, 0); return &sps->surface; } diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index daf6a3f942..098b9218ae 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -589,7 +589,7 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx ); struct pipe_surface; struct pipe_surface * -xmesa_new_surface(struct xmesa_renderbuffer *xrb); +xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb); #endif diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index a900de169e..7c35575d12 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -51,7 +51,9 @@ #include "pipe/softpipe/sp_z_surface.h" #include "pipe/p_state.h" +#include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "state_tracker/st_context.h" /* 32-bit color index format. Not a public format. */ @@ -949,6 +951,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { + struct pipe_context *pipe = ctx->st->pipe; GLuint pixelSize; /* first clear these fields */ @@ -1065,6 +1068,9 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->PutMonoValues = put_mono_values_ubyte; rb->StencilBits = 8 * sizeof(GLubyte); pixelSize = sizeof(GLubyte); + if (!rb->surface) + rb->surface = (struct pipe_surface *) + pipe->surface_alloc(pipe, PIPE_FORMAT_U_S8); break; case GL_STENCIL_INDEX16_EXT: rb->_ActualFormat = GL_STENCIL_INDEX16_EXT; @@ -1095,8 +1101,9 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->PutValues = put_values_ushort; rb->PutMonoValues = put_mono_values_ushort; rb->DepthBits = 8 * sizeof(GLushort); - rb->surface - = (struct pipe_surface *) softpipe_new_z_surface(PIPE_FORMAT_U_Z16); + if (!rb->surface) + rb->surface = (struct pipe_surface *) + pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z16); pixelSize = sizeof(GLushort); break; case GL_DEPTH_COMPONENT24: @@ -1119,8 +1126,9 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->_ActualFormat = GL_DEPTH_COMPONENT32; rb->DepthBits = 32; } - rb->surface - = (struct pipe_surface *) softpipe_new_z_surface(PIPE_FORMAT_U_Z32); + if (!rb->surface) + rb->surface = (struct pipe_surface *) + pipe->surface_alloc(pipe, PIPE_FORMAT_U_Z32); pixelSize = sizeof(GLuint); break; case GL_DEPTH_STENCIL_EXT: @@ -1138,8 +1146,9 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->PutMonoValues = put_mono_values_uint; rb->DepthBits = 24; rb->StencilBits = 8; - rb->surface - = (struct pipe_surface *) softpipe_new_z_surface(PIPE_FORMAT_Z24_S8); + if (!rb->surface) + rb->surface = (struct pipe_surface *) + pipe->surface_alloc(pipe, PIPE_FORMAT_Z24_S8); pixelSize = sizeof(GLuint); break; case GL_COLOR_INDEX8_EXT: @@ -1202,28 +1211,33 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, ASSERT(rb->PutMonoValues); /* free old buffer storage */ - if (rb->Data) { - if (rb->surface) { - /* pipe surface */ - } - else { - /* legacy renderbuffer */ - _mesa_free(rb->Data); - } - rb->Data = NULL; + if (rb->surface) { + /* pipe_surface/region */ } + else if (rb->Data) { + /* legacy renderbuffer (this will go away) */ + _mesa_free(rb->Data); + } + rb->Data = NULL; if (width > 0 && height > 0) { /* allocate new buffer storage */ if (rb->surface) { - /* pipe surface */ - rb->surface->resize(rb->surface, width, height); - rb->Data = rb->surface->buffer.ptr; + /* pipe_surface/region */ + if (rb->surface->region) { + pipe->region_unmap(pipe, rb->surface->region); + pipe->region_release(pipe, &rb->surface->region); + } + rb->surface->region = pipe->region_alloc(pipe, pixelSize, width, height); + /* XXX probably don't want to really map here */ + pipe->region_map(pipe, rb->surface->region); + rb->Data = rb->surface->region->map; } else { - /* legacy renderbuffer */ - rb->Data = _mesa_malloc(width * height * pixelSize); + /* legacy renderbuffer (this will go away) */ + rb->Data = malloc(width * height * pixelSize); } + if (rb->Data == NULL) { rb->Width = 0; rb->Height = 0; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index bfae55a4ba..b48c7775de 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -116,6 +116,14 @@ struct pipe_context { const struct pipe_viewport_state * ); + /* + * Surface functions + * This might go away... + */ + struct pipe_surface *(*surface_alloc)(struct pipe_context *pipe, + GLuint format); + + /* * Memory region functions * Some of these may go away... diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index d81c3f1778..0767fc2fcb 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -233,51 +233,17 @@ struct pipe_sampler_state /*** - *** Non-state Objects + *** Resource Objects ***/ -/** - * A mappable buffer (vertex data, pixel data, etc) - * XXX replace with "intel_region". - */ -struct pipe_buffer -{ - void (*buffer_data)(struct pipe_buffer *pb, GLuint size, const void *src); - void (*buffer_sub_data)(struct pipe_buffer *pb, GLuint offset, GLuint size, - const void *src); - void *(*map)(struct pipe_buffer *pb, GLuint access_mode); - void (*unmap)(struct pipe_buffer *pb); - GLubyte *ptr; /**< address, only valid while mapped */ - GLuint mode; /**< PIPE_MAP_x, only valid while mapped */ -}; - - -/** - * 2D surface. - * May be a renderbuffer, texture mipmap level, etc. - */ -struct pipe_surface -{ - struct pipe_buffer buffer; /**< surfaces can be mapped */ - GLuint format:5; /**< PIPE_FORMAT_x */ - GLuint width, height; - - GLint stride, cpp; - GLubyte *ptr; /**< only valid while mapped, may not equal buffer->ptr */ - - void *rb; /**< Ptr back to renderbuffer (temporary?) */ - - void (*resize)(struct pipe_surface *ps, GLuint width, GLuint height); -}; - - struct _DriBufferObject; struct intel_buffer_object; struct pipe_region { struct _DriBufferObject *buffer; /**< buffer manager's buffer ID */ + GLuint refcount; /**< Reference count for region */ GLuint cpp; /**< bytes per pixel */ GLuint pitch; /**< in pixels */ @@ -290,6 +256,21 @@ struct pipe_region struct intel_buffer_object *pbo; /* zero-copy uploads */ }; + +/** + * 2D surface. + * May be a renderbuffer, texture mipmap level, etc. + */ +struct pipe_surface +{ + struct pipe_region *region; + GLuint format:5; /**< PIPE_FORMAT_x */ + GLuint width, height; + + void *rb; /**< Ptr back to renderbuffer (temporary?) */ +}; + + /** * Texture object. * Mipmap levels, cube faces, 3D slices can be accessed as surfaces. diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 8655aa83fd..002fe73b59 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -35,6 +35,7 @@ #include "pipe/p_defines.h" #include "sp_context.h" #include "sp_clear.h" +#include "sp_region.h" #include "sp_state.h" #include "sp_surface.h" #include "sp_prim_setup.h" @@ -42,18 +43,16 @@ static void map_surfaces(struct softpipe_context *sp) { + struct pipe_context *pipe = &sp->pipe; GLuint i; for (i = 0; i < sp->framebuffer.num_cbufs; i++) { - struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.cbufs[i]); - struct pipe_buffer *buf = &sps->surface.buffer; - buf->map(buf, PIPE_MAP_READ_WRITE); + struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.cbufs[i]); pipe->region_map(pipe, sps->surface.region); } if (sp->framebuffer.zbuf) { struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.zbuf); - struct pipe_buffer *buf = &sps->surface.buffer; - buf->map(buf, PIPE_MAP_READ_WRITE); + pipe->region_map(pipe, sps->surface.region); } /* XXX depth & stencil bufs */ @@ -62,18 +61,17 @@ static void map_surfaces(struct softpipe_context *sp) static void unmap_surfaces(struct softpipe_context *sp) { + struct pipe_context *pipe = &sp->pipe; GLuint i; for (i = 0; i < sp->framebuffer.num_cbufs; i++) { struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.cbufs[i]); - struct pipe_buffer *buf = &sps->surface.buffer; - buf->unmap(buf); + pipe->region_unmap(pipe, sps->surface.region); } if (sp->framebuffer.zbuf) { struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.zbuf); - struct pipe_buffer *buf = &sps->surface.buffer; - buf->unmap(buf); + pipe->region_unmap(pipe, sps->surface.region); } /* XXX depth & stencil bufs */ } @@ -161,6 +159,9 @@ struct pipe_context *softpipe_create( void ) softpipe->draw = draw_create(); draw_set_setup_stage(softpipe->draw, sp_draw_render_stage(softpipe)); + sp_init_region_functions(softpipe); + sp_init_surface_functions(softpipe); + /* * XXX we could plug GL selection/feedback into the drawing pipeline * by specifying a different setup/render stage. diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c new file mode 100644 index 0000000000..04ae5e94f9 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_region.c @@ -0,0 +1,105 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +/** + * Software-based region allocation and management. + * A hardware driver would override these functions. + */ + + +#include "sp_context.h" +#include "sp_region.h" +#include "sp_surface.h" +#include "main/imports.h" + + +static struct pipe_region * +sp_region_alloc(struct pipe_context *pipe, + GLuint cpp, GLuint pitch, GLuint height) +{ + struct pipe_region *region = CALLOC_STRUCT(pipe_region); + if (!region) + return NULL; + + region->refcount = 1; + region->cpp = cpp; + region->pitch = pitch; + region->height = height; + region->map = malloc(cpp * pitch * height); + + return region; +} + + +static void +sp_region_release(struct pipe_context *pipe, struct pipe_region **region) +{ + assert((*region)->refcount > 0); + (*region)->refcount--; + + if ((*region)->refcount == 0) { + assert((*region)->map_refcount == 0); + +#if 0 + if ((*region)->pbo) + (*region)->pbo->region = NULL; + (*region)->pbo = NULL; +#endif + + free(*region); + } + *region = NULL; +} + + + +static GLubyte * +sp_region_map(struct pipe_context *pipe, struct pipe_region *region) +{ + region->map_refcount++; + return region->map; +} + + +static void +sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region) +{ + region->map_refcount--; +} + + +void +sp_init_region_functions(struct softpipe_context *sp) +{ + sp->pipe.region_alloc = sp_region_alloc; + sp->pipe.region_release = sp_region_release; + + sp->pipe.region_map = sp_region_map; + sp->pipe.region_unmap = sp_region_unmap; + + /* XXX lots of other region functions needed... */ +} diff --git a/src/mesa/pipe/softpipe/sp_region.h b/src/mesa/pipe/softpipe/sp_region.h new file mode 100644 index 0000000000..432746b27f --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_region.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + + +#ifndef SP_REGION_H +#define SP_REGION_H + + +struct softpipe_context; + + +extern void +sp_init_region_functions(struct softpipe_context *sp); + + +#endif /* SP_REGION_H */ diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index 16bbacb12b..cf89d28941 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -28,8 +28,22 @@ #include "sp_context.h" #include "sp_state.h" #include "sp_surface.h" -#include "sp_headers.h" +#include "pipe/p_defines.h" +#include "main/imports.h" + +/** + * Softpipe surface functions. + * Basically, create surface of a particular type, then plug in default + * read/write_quad functions. + * Note that these quad funcs assume the buffer/region is in a linear + * layout with Y=0=bottom. + * If we had swizzled/AOS buffers the read/write functions could be + * simplified a lot.... + */ + + +#if 000 /* OLD... should be recycled... */ static void rgba8_read_quad_f( struct softpipe_surface *gs, GLint x, GLint y, GLfloat (*rgba)[NUM_CHANNELS] ) @@ -98,9 +112,6 @@ static void rgba8_write_quad_f_swz( struct softpipe_surface *gs, } } - - - static void rgba8_read_quad_ub( struct softpipe_surface *gs, GLint x, GLint y, GLubyte (*rgba)[NUM_CHANNELS] ) @@ -118,7 +129,6 @@ static void rgba8_read_quad_ub( struct softpipe_surface *gs, } } - static void rgba8_write_quad_ub( struct softpipe_surface *gs, GLint x, GLint y, GLubyte (*rgba)[NUM_CHANNELS] ) @@ -136,18 +146,216 @@ static void rgba8_write_quad_ub( struct softpipe_surface *gs, } } +#endif + + + +static void +z16_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLushort *src + = (GLushort *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z16); + + /* converting GLushort to GLuint: */ + zzzz[0] = src[0]; + zzzz[1] = src[1]; + src += sps->surface.region->pitch; + zzzz[2] = src[0]; + zzzz[3] = src[1]; +} + +static void +z16_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLushort *dst = (GLushort *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z16); + + /* converting GLuint to GLushort: */ + dst[0] = zzzz[0]; + dst[1] = zzzz[1]; + dst += sps->surface.region->pitch; + dst[0] = zzzz[2]; + dst[1] = zzzz[3]; +} + +static void +z32_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z32); + + zzzz[0] = src[0]; + zzzz[1] = src[1]; + src += sps->surface.region->pitch; + zzzz[2] = src[0]; + zzzz[3] = src[1]; +} + +static void +z32_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_Z32); + + dst[0] = zzzz[0]; + dst[1] = zzzz[1]; + dst += sps->surface.region->pitch; + dst[0] = zzzz[2]; + dst[1] = zzzz[3]; +} + +static void +z24s8_read_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + zzzz[0] = src[0] >> 8; + zzzz[1] = src[1] >> 8; + src += sps->surface.region->pitch; + zzzz[2] = src[0] >> 8; + zzzz[3] = src[1] >> 8; +} + +static void +z24s8_write_quad_z(struct softpipe_surface *sps, + GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(zzzz[0] <= 0xffffff); + + dst[0] = (dst[0] & 0xff) | (zzzz[0] << 8); + dst[1] = (dst[1] & 0xff) | (zzzz[1] << 8); + dst += sps->surface.region->pitch; + dst[0] = (dst[0] & 0xff) | (zzzz[2] << 8); + dst[1] = (dst[1] & 0xff) | (zzzz[3] << 8); +} + +static void +z24s8_read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + const GLuint *src + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + + ssss[0] = src[0] & 0xff; + ssss[1] = src[1] & 0xff; + src += sps->surface.region->pitch; + ssss[2] = src[0] & 0xff; + ssss[3] = src[1] & 0xff; +} +static void +z24s8_write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + dst[0] = (dst[0] & 0xffffff00) | ssss[0]; + dst[1] = (dst[1] & 0xffffff00) | ssss[1]; + dst += sps->surface.region->pitch; + dst[0] = (dst[0] & 0xffffff00) | ssss[2]; + dst[1] = (dst[1] & 0xffffff00) | ssss[3]; +} -struct softpipe_surface_type gs_rgba8 = { - G_SURFACE_RGBA_8888, - rgba8_read_quad_f, - rgba8_read_quad_f_swz, - rgba8_read_quad_ub, - rgba8_write_quad_f, - rgba8_write_quad_f_swz, - rgba8_write_quad_ub, -}; +static void +s8_read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + const GLubyte *src + = sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_S8); + + ssss[0] = src[0]; + ssss[1] = src[1]; + src += sps->surface.region->pitch; + ssss[2] = src[0]; + ssss[3] = src[1]; +} + +static void +s8_write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + GLubyte *dst + = sps->surface.region->map + y * sps->surface.region->pitch + x; + assert(sps->surface.format == PIPE_FORMAT_U_S8); + dst[0] = ssss[0]; + dst[1] = ssss[1]; + dst += sps->surface.region->pitch; + dst[0] = ssss[2]; + dst[1] = ssss[3]; +} + + + +static void +init_quad_funcs(struct softpipe_surface *sps) +{ + switch (sps->surface.format) { + case PIPE_FORMAT_U_Z16: + sps->read_quad_z = z16_read_quad_z; + sps->write_quad_z = z16_write_quad_z; + break; + case PIPE_FORMAT_U_Z32: + sps->read_quad_z = z32_read_quad_z; + sps->write_quad_z = z32_write_quad_z; + break; + case PIPE_FORMAT_Z24_S8: + sps->read_quad_z = z24s8_read_quad_z; + sps->write_quad_z = z24s8_write_quad_z; + sps->read_quad_stencil = z24s8_read_quad_stencil; + sps->write_quad_stencil = z24s8_write_quad_stencil; + break; + case PIPE_FORMAT_U_S8: + sps->read_quad_stencil = s8_read_quad_stencil; + sps->write_quad_stencil = s8_write_quad_stencil; + break; + default: + assert(0); + } +} + + +static struct pipe_surface * +sp_surface_alloc(struct pipe_context *pipe, GLenum format) +{ + struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface); + if (!sps) + return NULL; + + sps->surface.format = format; + init_quad_funcs(sps); + + return &sps->surface; +} + + +void +sp_init_surface_functions(struct softpipe_context *sp) +{ + sp->pipe.surface_alloc = sp_surface_alloc; +} diff --git a/src/mesa/pipe/softpipe/sp_surface.h b/src/mesa/pipe/softpipe/sp_surface.h index 3ba732cebe..e8466256db 100644 --- a/src/mesa/pipe/softpipe/sp_surface.h +++ b/src/mesa/pipe/softpipe/sp_surface.h @@ -35,8 +35,7 @@ #include "sp_headers.h" struct softpipe_surface; - -#define G_SURFACE_RGBA_8888 0x1 +struct softpipe_context; /** @@ -98,4 +97,8 @@ softpipe_surface(struct pipe_surface *ps) } +extern void +sp_init_surface_functions(struct softpipe_context *sp); + + #endif /* SP_SURFACE_H */ diff --git a/src/mesa/pipe/softpipe/sp_z_surface.c b/src/mesa/pipe/softpipe/sp_z_surface.c index 744737cb6c..7ff1a0cbc8 100644 --- a/src/mesa/pipe/softpipe/sp_z_surface.c +++ b/src/mesa/pipe/softpipe/sp_z_surface.c @@ -40,75 +40,35 @@ #include "sp_surface.h" #include "sp_z_surface.h" -static void* -z_map(struct pipe_buffer *pb, GLuint access_mode) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) pb; - sps->surface.ptr = pb->ptr; - sps->surface.stride = sps->surface.width; - return pb->ptr; -} - -static void -z_unmap(struct pipe_buffer *pb) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) pb; - sps->surface.ptr = NULL; - sps->surface.stride = 0; -} - -static void -z_resize(struct pipe_surface *ps, GLuint width, GLuint height) -{ - struct softpipe_surface *sps = (struct softpipe_surface *) ps; - - if (sps->surface.buffer.ptr) - free(sps->surface.buffer.ptr); - - sps->surface.stride = sps->surface.width; - if (sps->surface.format == PIPE_FORMAT_U_Z16) - sps->surface.cpp = 2; - else if (sps->surface.format == PIPE_FORMAT_U_Z32 || - sps->surface.format == PIPE_FORMAT_Z24_S8) - sps->surface.cpp = 4; - else - assert(0); - - ps->buffer.ptr = (GLubyte *) malloc(width * height * sps->surface.cpp); - ps->width = width; - ps->height = height; - -} - static void z16_read_quad_z(struct softpipe_surface *sps, GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { const GLushort *src - = (GLushort *) sps->surface.ptr + y * sps->surface.stride + x; + = (GLushort *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_U_Z16); /* converting GLushort to GLuint: */ zzzz[0] = src[0]; zzzz[1] = src[1]; - zzzz[2] = src[sps->surface.width + 0]; - zzzz[3] = src[sps->surface.width + 1]; + zzzz[2] = src[sps->surface.region->pitch + 0]; + zzzz[3] = src[sps->surface.region->pitch + 1]; } static void z16_write_quad_z(struct softpipe_surface *sps, GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { - GLushort *dst = (GLushort *) sps->surface.ptr + y * sps->surface.stride + x; + GLushort *dst = (GLushort *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_U_Z16); /* converting GLuint to GLushort: */ dst[0] = zzzz[0]; dst[1] = zzzz[1]; - dst[sps->surface.width + 0] = zzzz[2]; - dst[sps->surface.width + 1] = zzzz[3]; + dst[sps->surface.region->pitch + 0] = zzzz[2]; + dst[sps->surface.region->pitch + 1] = zzzz[3]; } static void @@ -116,28 +76,28 @@ z32_read_quad_z(struct softpipe_surface *sps, GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { const GLuint *src - = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_U_Z32); zzzz[0] = src[0]; zzzz[1] = src[1]; - zzzz[2] = src[sps->surface.width + 0]; - zzzz[3] = src[sps->surface.width + 1]; + zzzz[2] = src[sps->surface.region->pitch + 0]; + zzzz[3] = src[sps->surface.region->pitch + 1]; } static void z32_write_quad_z(struct softpipe_surface *sps, GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { - GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_U_Z32); dst[0] = zzzz[0]; dst[1] = zzzz[1]; - dst[sps->surface.width + 0] = zzzz[2]; - dst[sps->surface.width + 1] = zzzz[3]; + dst[sps->surface.region->pitch + 0] = zzzz[2]; + dst[sps->surface.region->pitch + 1] = zzzz[3]; } static void @@ -145,28 +105,28 @@ z24s8_read_quad_z(struct softpipe_surface *sps, GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { const GLuint *src - = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_Z24_S8); zzzz[0] = src[0] >> 8; zzzz[1] = src[1] >> 8; - zzzz[2] = src[sps->surface.width + 0] >> 8; - zzzz[3] = src[sps->surface.width + 1] >> 8; + zzzz[2] = src[sps->surface.region->pitch + 0] >> 8; + zzzz[3] = src[sps->surface.region->pitch + 1] >> 8; } static void z24s8_write_quad_z(struct softpipe_surface *sps, GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { - GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_Z24_S8); assert(zzzz[0] <= 0xffffff); dst[0] = (dst[0] & 0xff) | (zzzz[0] << 8); dst[1] = (dst[1] & 0xff) | (zzzz[1] << 8); - dst += sps->surface.width; + dst += sps->surface.region->pitch; dst[0] = (dst[0] & 0xff) | (zzzz[2] << 8); dst[1] = (dst[1] & 0xff) | (zzzz[3] << 8); } @@ -176,32 +136,65 @@ z24s8_read_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) { const GLuint *src - = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_Z24_S8); ssss[0] = src[0] & 0xff; ssss[1] = src[1] & 0xff; - ssss[2] = src[sps->surface.width + 0] & 0xff; - ssss[3] = src[sps->surface.width + 1] & 0xff; + ssss[2] = src[sps->surface.region->pitch + 0] & 0xff; + ssss[3] = src[sps->surface.region->pitch + 1] & 0xff; } static void z24s8_write_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) { - GLuint *dst = (GLuint *) sps->surface.ptr + y * sps->surface.stride + x; + GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; assert(sps->surface.format == PIPE_FORMAT_Z24_S8); dst[0] = (dst[0] & 0xffffff00) | ssss[0]; dst[1] = (dst[1] & 0xffffff00) | ssss[1]; - dst += sps->surface.width; + dst += sps->surface.region->pitch; dst[0] = (dst[0] & 0xffffff00) | ssss[2]; dst[1] = (dst[1] & 0xffffff00) | ssss[3]; } +static void +s8_read_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) +{ + const GLubyte *src + = sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_S8); + + ssss[0] = src[0]; + ssss[1] = src[1]; + src += sps->surface.region->pitch; + ssss[2] = src[0]; + ssss[3] = src[1]; +} + +static void +s8_write_quad_stencil(struct softpipe_surface *sps, + GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) +{ + GLubyte *dst + = sps->surface.region->map + y * sps->surface.region->pitch + x; + + assert(sps->surface.format == PIPE_FORMAT_U_S8); + + dst[0] = ssss[0]; + dst[1] = ssss[1]; + dst += sps->surface.region->pitch; + dst[0] = ssss[2]; + dst[1] = ssss[3]; +} + + /** * Create a new software-based Z buffer. @@ -215,27 +208,6 @@ softpipe_new_z_surface(GLuint format) return NULL; sps->surface.format = format; - sps->surface.resize = z_resize; - sps->surface.buffer.map = z_map; - sps->surface.buffer.unmap = z_unmap; - - if (format == PIPE_FORMAT_U_Z16) { - sps->read_quad_z = z16_read_quad_z; - sps->write_quad_z = z16_write_quad_z; - } - else if (format == PIPE_FORMAT_U_Z32) { - sps->read_quad_z = z32_read_quad_z; - sps->write_quad_z = z32_write_quad_z; - } - else if (format == PIPE_FORMAT_Z24_S8) { - sps->read_quad_z = z24s8_read_quad_z; - sps->write_quad_z = z24s8_write_quad_z; - sps->read_quad_stencil = z24s8_read_quad_stencil; - sps->write_quad_stencil = z24s8_write_quad_stencil; - } - else { - assert(0); - } return sps; } diff --git a/src/mesa/sources b/src/mesa/sources index 32c2ff2350..3b820b71f0 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -157,6 +157,7 @@ VF_SOURCES = \ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_clear.c \ pipe/softpipe/sp_context.c \ + pipe/softpipe/sp_region.c \ pipe/softpipe/sp_quad.c \ pipe/softpipe/sp_quad_alpha_test.c \ pipe/softpipe/sp_quad_blend.c \ @@ -176,7 +177,7 @@ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_state_sampler.c \ pipe/softpipe/sp_state_setup.c \ pipe/softpipe/sp_state_surface.c \ - pipe/softpipe/sp_z_surface.c \ + pipe/softpipe/sp_surface.c \ pipe/softpipe/sp_prim_setup.c DRAW_SOURCES = \ -- cgit v1.2.3 From fb206809ba2a131fd9034e10a00592f2d0d81fce Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 1 Aug 2007 12:58:38 -0600 Subject: Checkpoint: glClear changes - working, bug very rough. --- src/mesa/Makefile | 9 ++- src/mesa/drivers/dri/i915pipe/intel_buffers.c | 29 ++++++++- src/mesa/drivers/dri/i915pipe/intel_buffers.h | 5 ++ src/mesa/drivers/dri/i915pipe/intel_context.c | 2 + src/mesa/drivers/x11/xm_api.c | 2 + src/mesa/drivers/x11/xm_dd.c | 26 ++++++++ src/mesa/drivers/x11/xmesaP.h | 6 +- src/mesa/main/buffers.c | 10 +++ src/mesa/pipe/p_context.h | 1 + src/mesa/pipe/softpipe/sp_clear.c | 90 ++++++++++++++++++++++----- src/mesa/pipe/softpipe/sp_region.c | 55 ++++++++++++++++ 11 files changed, 213 insertions(+), 22 deletions(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') 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... */ } -- cgit v1.2.3 From 47fdaf0ed9ef2f89cdaa97d0d48b1f1194d710c6 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 16:08:18 -0600 Subject: pipe->clear() now takes a surface, rather than color/depth/stencil flags. pipe->clear() only used to clear whole buffers (no scissor) w/out masking. Draw a colored quadrilateral in all other cases. --- src/mesa/drivers/x11/xm_api.c | 5 +- src/mesa/drivers/x11/xm_dd.c | 23 ++- src/mesa/drivers/x11/xmesaP.h | 7 +- src/mesa/pipe/p_context.h | 6 +- src/mesa/pipe/softpipe/sp_clear.c | 109 +------------- src/mesa/pipe/softpipe/sp_clear.h | 4 +- src/mesa/state_tracker/st_cb_clear.c | 274 ++++++++++++++++++++++++++++++----- 7 files changed, 270 insertions(+), 158 deletions(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 92d37085d1..7fb99df5f4 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1573,8 +1573,11 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) st_create_context( mesaCtx, softpipe_create() ); + mesaCtx->Driver.Clear = xmesa_clear_buffers; + /* 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 87f8ede50b..f64f8780cf 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -381,8 +381,8 @@ clear_nbit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, -static void -clear_buffers(GLcontext *ctx, GLbitfield buffers) +void +xmesa_clear_buffers(GLcontext *ctx, GLbitfield buffers) { if (ctx->DrawBuffer->Name == 0) { /* this is a window system framebuffer */ @@ -395,7 +395,6 @@ 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 @@ -419,14 +418,6 @@ 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; - st_clear(st, color, depth, stencil); -#endif } } if (buffers) @@ -434,6 +425,7 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) } +#if 0 void xmesa_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, GLboolean stencil, GLboolean accum) @@ -458,9 +450,14 @@ xmesa_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, xrb->clearFunc(ctx, xrb, x, y, w, h); } } - } +#endif + +void +xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value) +{ +} #ifndef XFree86Server @@ -1113,7 +1110,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual, driver->IndexMask = index_mask; driver->ColorMask = color_mask; driver->Enable = enable; - driver->Clear = clear_buffers; + driver->Clear = xmesa_clear_buffers; driver->Viewport = xmesa_viewport; #ifndef XFree86Server driver->CopyPixels = xmesa_CopyPixels; diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index fb1c1f8c3b..dd95aed4d0 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -593,7 +593,10 @@ 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); +xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value); + +extern void +xmesa_clear_buffers(GLcontext *ctx, GLbitfield buffers); + #endif diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 0972fd58b5..4f8bdae140 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -60,9 +60,9 @@ struct pipe_context { GLuint numVertex, const GLfloat *verts, GLuint numAttribs, const GLuint attribs[]); - /** Clear framebuffer */ - void (*clear)(struct pipe_context *pipe, GLboolean color, GLboolean depth, - GLboolean stencil); + /** Clear a surface to given value (no scissor; clear whole surface) */ + void (*clear)(struct pipe_context *pipe, struct pipe_surface *ps, + GLuint clearValue); /** occlusion counting (XXX this may be temporary - we should probably * have generic query objects with begin/end methods) diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c index e9b142e780..d7684d2044 100644 --- a/src/mesa/pipe/softpipe/sp_clear.c +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -38,32 +38,13 @@ #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; - } -} - - +/** + * Clear the given surface to the specified value. + * No masking, no scissor (clear entire buffer). + */ void -softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, - GLboolean stencil) +softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, + GLuint clearValue) { struct softpipe_context *softpipe = softpipe_context(pipe); GLint x, y, w, h; @@ -75,81 +56,5 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, w = softpipe->framebuffer.cbufs[0]->width; h = softpipe->framebuffer.cbufs[0]->height; - if (color) { - GLuint i; - for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) { - struct pipe_surface *ps = softpipe->framebuffer.cbufs[i]; - GLuint clearVal = color_value(ps->format, - softpipe->clear_color.color); - pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0); - } - } - - if (depth && stencil && - softpipe->framebuffer.zbuf == softpipe->framebuffer.sbuf) { - /* clear Z and stencil together */ - struct pipe_surface *ps = softpipe->framebuffer.zbuf; - if (ps->format == PIPE_FORMAT_S8_Z24) { - GLuint mask = (softpipe->stencil.write_mask[0] << 8) | 0xffffff; - GLuint clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff); - - assert (mask == ~0); - - clearVal |= (softpipe->stencil.clear_value << 24); - pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0); - } - else { - /* XXX Z24_S8 format? */ - assert(0); - } - } - else { - /* separate Z and stencil */ - 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_S8_Z24: - clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff); - break; - default: - assert(0); - } - - pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0); - } - - if (stencil) { - struct pipe_surface *ps = softpipe->framebuffer.sbuf; - GLuint clearVal = softpipe->stencil.clear_value; - - /* If this is not ~0, we shouldn't get here - clear should be - * done with geometry instead. - */ - GLuint mask = softpipe->stencil.write_mask[0]; - - assert((mask & 0xff) == 0xff); - - switch (ps->format) { - case PIPE_FORMAT_S8_Z24: - clearVal = clearVal << 24; - mask = mask << 24; - break; - case PIPE_FORMAT_U_S8: - /* nothing */ - break; - default: - assert(0); - } - - pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask); - } - } + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearValue, ~0); } diff --git a/src/mesa/pipe/softpipe/sp_clear.h b/src/mesa/pipe/softpipe/sp_clear.h index d41cc1d070..e706e731c2 100644 --- a/src/mesa/pipe/softpipe/sp_clear.h +++ b/src/mesa/pipe/softpipe/sp_clear.h @@ -36,8 +36,8 @@ struct pipe_context; extern void -softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, - GLboolean stencil); +softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, + GLuint clearValue); #endif /* SP_CLEAR_H */ diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 85df549404..bd58abc4d1 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -43,6 +43,65 @@ #include "vf/vf.h" + +static GLuint +color_value(GLuint pipeFormat, 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 (pipeFormat) { + 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; + } +} + + +static GLuint +depth_value(GLuint pipeFormat, GLfloat value) +{ + GLuint val; + switch (pipeFormat) { + case PIPE_FORMAT_U_Z16: + val = (GLuint) (value * 0xffffff); + break; + case PIPE_FORMAT_U_Z32: + val = (GLuint) (value * 0xffffffff); + break; + case PIPE_FORMAT_S8_Z24: + /*case PIPE_FORMAT_Z24_S8:*/ + val = (GLuint) (value * 0xffffff); + break; + default: + assert(0); + } + return val; +} + + +static GLboolean +is_depth_stencil_format(GLuint pipeFormat) +{ + switch (pipeFormat) { + case PIPE_FORMAT_S8_Z24: + /*case PIPE_FORMAT_Z24_S8:*/ + return GL_TRUE; + default: + return GL_FALSE; + } +} + + /** * Draw a screen-aligned quadrilateral. * Coords are window coords. @@ -92,7 +151,8 @@ draw_quad(GLcontext *ctx, * Do glClear by drawing a quadrilateral. */ static void -clear_with_quad(GLcontext *ctx, +clear_with_quad(GLcontext *ctx, GLuint x0, GLuint y0, + GLuint x1, GLuint y1, GLboolean color, GLboolean depth, GLboolean stencil) { struct st_context *st = ctx->st; @@ -133,6 +193,8 @@ clear_with_quad(GLcontext *ctx, /* setup state: nothing */ memset(&setup, 0, sizeof(setup)); + if (ctx->Scissor.Enabled) + setup.scissor = 1; st->pipe->set_setup_state(st->pipe, &setup); /* stencil state: always set to ref value */ @@ -145,18 +207,14 @@ clear_with_quad(GLcontext *ctx, stencil_test.front_zfail_op = PIPE_STENCIL_OP_REPLACE; stencil_test.ref_value[0] = ctx->Stencil.Clear; stencil_test.value_mask[0] = 0xff; - stencil_test.write_mask[0] = ctx->Stencil.WriteMask[0]; + stencil_test.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff; } st->pipe->set_stencil_state(st->pipe, &stencil_test); /* draw quad matching scissor rect (XXX verify coord round-off) */ - draw_quad(ctx, - ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.X + ctx->Scissor.Width, - ctx->Scissor.Y + ctx->Scissor.Height, - ctx->Depth.Clear, ctx->Color.ClearColor); + draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); - /* Restore GL state */ + /* Restore pipe state */ st->pipe->set_alpha_test_state(st->pipe, &st->state.alpha_test); st->pipe->set_blend_state(st->pipe, &st->state.blend); st->pipe->set_depth_state(st->pipe, &st->state.depth); @@ -168,6 +226,141 @@ clear_with_quad(GLcontext *ctx, } +static void +clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +{ + if (ctx->Color.ColorMask[0] && + ctx->Color.ColorMask[1] && + ctx->Color.ColorMask[2] && + ctx->Color.ColorMask[3] && + !ctx->Scissor.Enabled) + { + /* clear whole buffer w/out masking */ + GLuint clearValue + = color_value(rb->surface->format, ctx->Color.ClearColor); + ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); + } + else { + /* masking or scissoring */ + clear_with_quad(ctx, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmax, + ctx->DrawBuffer->_Ymax, + GL_TRUE, GL_FALSE, GL_FALSE); + } +} + + +static void +clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +{ + if (!ctx->Scissor.Enabled) { + /* clear whole buffer w/out masking */ + GLuint clearValue + = color_value(rb->surface->format, ctx->Accum.ClearColor); + /* Note that clearValue is 32 bits but the accum buffer will + * typically be 64bpp... + */ + ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); + } + else { + /* scissoring */ + /* XXX point framebuffer.cbufs[0] at the accum buffer */ + clear_with_quad(ctx, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmax, + ctx->DrawBuffer->_Ymax, + GL_TRUE, GL_FALSE, GL_FALSE); + } +} + + +static void +clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +{ + if (!ctx->Scissor.Enabled && + !is_depth_stencil_format(rb->surface->format)) { + /* clear whole depth buffer w/out masking */ + GLuint clearValue = depth_value(rb->surface->format, ctx->Depth.Clear); + ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); + } + else { + /* masking or scissoring or combined z/stencil buffer */ + clear_with_quad(ctx, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmax, + ctx->DrawBuffer->_Ymax, + GL_FALSE, GL_TRUE, GL_FALSE); + } +} + + +static void +clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +{ + const GLuint stencilMax = (1 << rb->StencilBits) - 1; + GLboolean maskStencil = ctx->Stencil.WriteMask[0] != stencilMax; + + if (!maskStencil && !ctx->Scissor.Enabled && + !is_depth_stencil_format(rb->surface->format)) { + /* clear whole stencil buffer w/out masking */ + GLuint clearValue = ctx->Stencil.Clear; + ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); + } + else { + /* masking or scissoring */ + clear_with_quad(ctx, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmax, + ctx->DrawBuffer->_Ymax, + GL_FALSE, GL_FALSE, GL_TRUE); + } +} + + +static void +clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +{ + const GLuint stencilMax = 1 << rb->StencilBits; + GLboolean maskStencil = ctx->Stencil.WriteMask[0] != stencilMax; + + assert(is_depth_stencil_format(rb->surface->format)); + + if (!maskStencil && !ctx->Scissor.Enabled) { + /* clear whole buffer w/out masking */ + GLuint clearValue = depth_value(rb->surface->format, ctx->Depth.Clear); + + switch (rb->surface->format) { + case PIPE_FORMAT_S8_Z24: + clearValue |= ctx->Stencil.Clear << 24; + break; +#if 0 + case PIPE_FORMAT_Z24_S8: + clearValue = (clearValue << 8) | clearVal; + break; +#endif + default: + assert(0); + } + + ctx->st->pipe->clear(ctx->st->pipe, rb->surface, clearValue); + } + else { + /* masking or scissoring */ + clear_with_quad(ctx, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmin, + ctx->DrawBuffer->_Xmax, + ctx->DrawBuffer->_Ymax, + GL_FALSE, GL_TRUE, GL_TRUE); + } +} + + /** * Called via ctx->Driver.Clear() @@ -176,41 +369,52 @@ clear_with_quad(GLcontext *ctx, */ static void st_clear(GLcontext *ctx, GLbitfield mask) { + static const GLbitfield BUFFER_BITS_DS + = (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); struct st_context *st = ctx->st; - GLboolean color = (mask & BUFFER_BITS_COLOR) ? GL_TRUE : GL_FALSE; - GLboolean depth = (mask & BUFFER_BIT_DEPTH) ? GL_TRUE : GL_FALSE; - GLboolean stencil = (mask & BUFFER_BIT_STENCIL) ? GL_TRUE : GL_FALSE; - GLboolean accum = (mask & BUFFER_BIT_ACCUM) ? GL_TRUE : GL_FALSE; - - GLboolean maskColor, maskStencil; - GLboolean fullscreen = !ctx->Scissor.Enabled; - GLuint stencilMax = stencil ? (1 << ctx->DrawBuffer->_StencilBuffer->StencilBits) : 0; + struct gl_renderbuffer *depthRb + = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; + struct gl_renderbuffer *stencilRb + = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; /* This makes sure the softpipe has the latest scissor, etc values */ st_validate_state( st ); - maskColor = color && st->state.blend.colormask != PIPE_MASK_RGBA; - maskStencil = stencil && ctx->Stencil.WriteMask[0] != stencilMax; - - if (fullscreen && !maskColor && !maskStencil) { - /* pipe->clear() should clear a particular surface, so that we - * can iterate over render buffers at this level and clear the - * ones GL is asking for. - * - * Will probably need something like pipe->clear_z_stencil() to - * cope with the special case of paired and unpaired z/stencil - * buffers, though could perhaps deal with them explicitly at - * this level. - */ - st->pipe->clear(st->pipe, color, depth, stencil); + /* + * XXX TO-DO: + * If we're going to use clear_with_quad() for any reason, use it to + * clear as many other buffers as possible. + * As it is now, we sometimes call clear_with_quad() three times to clear + * color/depth/stencil individually... + */ + + if (mask & BUFFER_BITS_COLOR) { + GLuint b; + for (b = 0; b < BUFFER_COUNT; b++) { + if (BUFFER_BITS_COLOR & mask & (1 << b)) { + clear_color_buffer(ctx, + ctx->DrawBuffer->Attachment[b].Renderbuffer); + } + } + } - /* And here we would do a clear on whatever surface we are using - * to implement accum buffers: - */ - assert(!accum); + if (mask & BUFFER_BIT_ACCUM) { + clear_accum_buffer(ctx, + ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); + } + + if ((mask & BUFFER_BITS_DS) == BUFFER_BITS_DS && depthRb == stencilRb) { + /* clearing combined depth + stencil */ + clear_depth_stencil_buffer(ctx, depthRb); } else { - clear_with_quad(ctx, color, depth, stencil); + /* separate depth/stencil clears */ + if (mask & BUFFER_BIT_DEPTH) { + clear_depth_buffer(ctx, depthRb); + } + if (mask & BUFFER_BIT_STENCIL) { + clear_stencil_buffer(ctx, stencilRb); + } } } -- cgit v1.2.3 From b1ad6289f83ce5c91da2ebc64d07506c25efa7e2 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 6 Aug 2007 16:17:26 -0600 Subject: use new xmesa_create_softpipe() --- src/mesa/drivers/x11/xm_api.c | 3 ++- src/mesa/drivers/x11/xmesaP.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 7fb99df5f4..6fbbb94f0f 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1572,7 +1572,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) st_create_context( mesaCtx, - softpipe_create() ); + xmesa_create_softpipe( c ) ); + mesaCtx->Driver.Clear = xmesa_clear_buffers; /* mesaCtx->st->pipe->clear = xmesa_clear; diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index dd95aed4d0..99c87da3c5 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -598,5 +598,8 @@ xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value); extern void xmesa_clear_buffers(GLcontext *ctx, GLbitfield buffers); +extern struct pipe_context * +xmesa_create_softpipe(XMesaContext xm); + #endif -- cgit v1.2.3 From 3a9eca5cc0a3a0c7f6198b37f61cc0d0ad45da1d Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 9 Aug 2007 22:56:50 +0100 Subject: asst changes to get softpipe rendering again (no zbuf support for now) --- src/mesa/drivers/x11/xm_api.c | 31 +++- src/mesa/drivers/x11/xm_buffer.c | 102 +++++++++--- src/mesa/drivers/x11/xm_dd.c | 9 +- src/mesa/drivers/x11/xm_span.c | 325 +++++++++++++++++++------------------- src/mesa/drivers/x11/xm_surface.c | 94 +++++++++-- src/mesa/drivers/x11/xmesaP.h | 24 ++- 6 files changed, 369 insertions(+), 216 deletions(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 88e6bf8d6d..cea790dc60 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -84,6 +84,7 @@ #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" #include "pipe/softpipe/sp_context.h" +#include "pipe/p_defines.h" /** * Global X driver lock @@ -385,7 +386,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, /* * Front renderbuffer */ - b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE); + b->frontxrb = xmesa_create_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE); if (!b->frontxrb) { _mesa_free(b); return NULL; @@ -394,13 +395,13 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->frontxrb->drawable = d; b->frontxrb->pixmap = (XMesaPixmap) d; _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT, - &b->frontxrb->Base); + &b->frontxrb->St.Base); /* * Back renderbuffer */ if (vis->mesa_visual.doubleBufferMode) { - b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE); + b->backxrb = xmesa_create_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE); if (!b->backxrb) { /* XXX free front xrb too */ _mesa_free(b); @@ -411,7 +412,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP; _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_BACK_LEFT, - &b->backxrb->Base); + &b->backxrb->St.Base); } /* @@ -429,12 +430,19 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->swAlpha = GL_FALSE; } + if (vis->mesa_visual.depthBits > 0) { + struct gl_renderbuffer *rb + = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT32); + _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_DEPTH, rb); + } + + /* * Other renderbuffer (depth, stencil, etc) */ _mesa_add_soft_renderbuffers(&b->mesa_buffer, GL_FALSE, /* color */ - vis->mesa_visual.haveDepthBuffer, + GL_FALSE,/*vis->mesa_visual.haveDepthBuffer,*/ vis->mesa_visual.haveStencilBuffer, vis->mesa_visual.haveAccumBuffer, b->swAlpha, @@ -1517,6 +1525,10 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) xmesa_init_driver_functions(v, &functions); st_init_driver_functions(&functions); + /* + functions.NewRenderbuffer = xmesa_new_renderbuffer; + */ + if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual, share_list ? &(share_list->mesa) : (GLcontext *) NULL, &functions, (void *) c)) { @@ -1576,10 +1588,15 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) st_create_context( mesaCtx, xmesa_create_softpipe( c ) ); + mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc; + mesaCtx->st->pipe->supported_formats = xmesa_supported_formats; + +#if 1 mesaCtx->Driver.Clear = xmesa_clear_buffers; - /* +#endif +#if 0 mesaCtx->st->pipe->clear = xmesa_clear; - */ +#endif return c; } diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 5bba52da48..fb6815ae1e 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -36,6 +36,8 @@ #include "framebuffer.h" #include "renderbuffer.h" #include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include "state_tracker/st_context.h" #if defined(USE_XSHM) && !defined(XFree86Server) @@ -269,10 +271,10 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Height = height; rb->InternalFormat = internalFormat; - if (!xrb->Base.surface) - xrb->Base.surface = xmesa_new_surface(ctx, xrb); - xrb->Base.surface->width = width; - xrb->Base.surface->height = height; + if (!xrb->St.surface) + xrb->St.surface = xmesa_new_surface(ctx, xrb); + xrb->St.surface->width = width; + xrb->St.surface->height = height; return GL_TRUE; } @@ -323,49 +325,101 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, xrb->origin4 = NULL; } - if (!xrb->Base.surface) - xrb->Base.surface = xmesa_new_surface(ctx, xrb); - xrb->Base.surface->width = width; - xrb->Base.surface->height = height; + if (!xrb->St.surface) + xrb->St.surface = xmesa_new_surface(ctx, xrb); + xrb->St.surface->width = width; + xrb->St.surface->height = height; return GL_TRUE; } +/** + * Called to create the front/back color renderbuffers, not user-created + * renderbuffers. + */ struct xmesa_renderbuffer * -xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, +xmesa_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, GLboolean backBuffer) +{ + struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer); + struct pipe_context *pipe = NULL;/*ctx->st->pipe;*/ + if (xrb) { + GLuint name = 0; + GLuint pipeFormat = 0; + struct xmesa_surface *xms; + + _mesa_init_renderbuffer(&xrb->St.Base, name); + + xrb->St.Base.Delete = xmesa_delete_renderbuffer; + if (backBuffer) + xrb->St.Base.AllocStorage = xmesa_alloc_back_storage; + else + xrb->St.Base.AllocStorage = xmesa_alloc_front_storage; + + if (visual->rgbMode) { + xrb->St.Base.InternalFormat = GL_RGBA; + xrb->St.Base._BaseFormat = GL_RGBA; + xrb->St.Base.DataType = GL_UNSIGNED_BYTE; + xrb->St.Base.RedBits = visual->redBits; + xrb->St.Base.GreenBits = visual->greenBits; + xrb->St.Base.BlueBits = visual->blueBits; + xrb->St.Base.AlphaBits = visual->alphaBits; + pipeFormat = PIPE_FORMAT_U_A8_R8_G8_B8; + } + else { + xrb->St.Base.InternalFormat = GL_COLOR_INDEX; + xrb->St.Base._BaseFormat = GL_COLOR_INDEX; + xrb->St.Base.DataType = GL_UNSIGNED_INT; + xrb->St.Base.IndexBits = visual->indexBits; + } + /* only need to set Red/Green/EtcBits fields for user-created RBs */ + + xrb->St.surface = xmesa_surface_alloc(pipe, pipeFormat); + xms = (struct xmesa_surface *) xrb->St.surface; + xms->xrb = xrb; + + } + return xrb; +} + + +#if 0 +struct gl_renderbuffer * +xmesa_new_renderbuffer(GLcontext *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, GLuint width, GLuint height) { struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer); if (xrb) { GLuint name = 0; - _mesa_init_renderbuffer(&xrb->Base, name); + _mesa_init_renderbuffer(&xrb->St.Base, name); - xrb->Base.Delete = xmesa_delete_renderbuffer; + xrb->St.Base.Delete = xmesa_delete_renderbuffer; if (backBuffer) - xrb->Base.AllocStorage = xmesa_alloc_back_storage; + xrb->St.Base.AllocStorage = xmesa_alloc_back_storage; else - xrb->Base.AllocStorage = xmesa_alloc_front_storage; + xrb->St.Base.AllocStorage = xmesa_alloc_front_storage; if (visual->rgbMode) { - xrb->Base.InternalFormat = GL_RGBA; - xrb->Base._BaseFormat = GL_RGBA; - xrb->Base.DataType = GL_UNSIGNED_BYTE; - xrb->Base.RedBits = visual->redBits; - xrb->Base.GreenBits = visual->greenBits; - xrb->Base.BlueBits = visual->blueBits; - xrb->Base.AlphaBits = visual->alphaBits; + xrb->St.Base.InternalFormat = GL_RGBA; + xrb->St.Base._BaseFormat = GL_RGBA; + xrb->St.Base.DataType = GL_UNSIGNED_BYTE; + xrb->St.Base.RedBits = visual->redBits; + xrb->St.Base.GreenBits = visual->greenBits; + xrb->St.Base.BlueBits = visual->blueBits; + xrb->St.Base.AlphaBits = visual->alphaBits; } else { - xrb->Base.InternalFormat = GL_COLOR_INDEX; - xrb->Base._BaseFormat = GL_COLOR_INDEX; - xrb->Base.DataType = GL_UNSIGNED_INT; - xrb->Base.IndexBits = visual->indexBits; + xrb->St.Base.InternalFormat = GL_COLOR_INDEX; + xrb->St.Base._BaseFormat = GL_COLOR_INDEX; + xrb->St.Base.DataType = GL_UNSIGNED_INT; + xrb->St.Base.IndexBits = visual->indexBits; } /* only need to set Red/Green/EtcBits fields for user-created RBs */ } return xrb; } +#endif /** diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index f64f8780cf..6eb6d32d19 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -224,7 +224,7 @@ clear_pixmap(GLcontext *ctx, struct xmesa_renderbuffer *xrb, assert(xmbuf->cleargc); XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc, - x, xrb->Base.Height - y - height, + x, xrb->St.Base.Height - y - height, width, height ); } @@ -335,9 +335,9 @@ clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb, | ((pixel << 24) & 0xff000000); } - if (width == xrb->Base.Width && height == xrb->Base.Height) { + if (width == xrb->St.Base.Width && height == xrb->St.Base.Height) { /* clearing whole buffer */ - const GLuint n = xrb->Base.Width * xrb->Base.Height; + const GLuint n = xrb->St.Base.Width * xrb->St.Base.Height; GLuint *ptr4 = (GLuint *) xrb->ximage->data; if (pixel == 0) { /* common case */ @@ -490,7 +490,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx, ctx->Pixel.ZoomX == 1.0 && /* no zooming */ ctx->Pixel.ZoomY == 1.0 && xrb->pixmap && - xrb->Base.AlphaBits == 0) + xrb->St.Base.AlphaBits == 0) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); @@ -1134,6 +1134,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual, driver->BeginQuery = xmesa_begin_query; driver->EndQuery = xmesa_end_query; #endif + } diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c index 3776891e2e..ce54a18a27 100644 --- a/src/mesa/drivers/x11/xm_span.c +++ b/src/mesa/drivers/x11/xm_span.c @@ -4539,259 +4539,260 @@ xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb, enum pixel_format pixelformat, GLint depth) { const GLboolean pixmap = xrb->pixmap ? GL_TRUE : GL_FALSE; + struct gl_renderbuffer *rb = &xrb->St.Base; switch (pixelformat) { case PF_Index: - ASSERT(xrb->Base.DataType == GL_UNSIGNED_INT); + ASSERT(rb->DataType == GL_UNSIGNED_INT); if (pixmap) { - xrb->Base.PutRow = put_row_ci_pixmap; - xrb->Base.PutRowRGB = NULL; - xrb->Base.PutMonoRow = put_mono_row_ci_pixmap; - xrb->Base.PutValues = put_values_ci_pixmap; - xrb->Base.PutMonoValues = put_mono_values_ci_pixmap; + rb->PutRow = put_row_ci_pixmap; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ci_pixmap; + rb->PutValues = put_values_ci_pixmap; + rb->PutMonoValues = put_mono_values_ci_pixmap; } else { - xrb->Base.PutRow = put_row_ci_ximage; - xrb->Base.PutRowRGB = NULL; - xrb->Base.PutMonoRow = put_mono_row_ci_ximage; - xrb->Base.PutValues = put_values_ci_ximage; - xrb->Base.PutMonoValues = put_mono_values_ci_ximage; + rb->PutRow = put_row_ci_ximage; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ci_ximage; + rb->PutValues = put_values_ci_ximage; + rb->PutMonoValues = put_mono_values_ci_ximage; } break; case PF_Truecolor: if (pixmap) { - xrb->Base.PutRow = put_row_TRUECOLOR_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_TRUECOLOR_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_TRUECOLOR_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_TRUECOLOR_pixmap; + rb->PutRowRGB = put_row_rgb_TRUECOLOR_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_TRUECOLOR_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_TRUECOLOR_ximage; - xrb->Base.PutRowRGB = put_row_rgb_TRUECOLOR_ximage; - xrb->Base.PutMonoRow = put_mono_row_ximage; - xrb->Base.PutValues = put_values_TRUECOLOR_ximage; - xrb->Base.PutMonoValues = put_mono_values_ximage; + rb->PutRow = put_row_TRUECOLOR_ximage; + rb->PutRowRGB = put_row_rgb_TRUECOLOR_ximage; + rb->PutMonoRow = put_mono_row_ximage; + rb->PutValues = put_values_TRUECOLOR_ximage; + rb->PutMonoValues = put_mono_values_ximage; } break; case PF_Dither_True: if (pixmap) { - xrb->Base.PutRow = put_row_TRUEDITHER_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_TRUEDITHER_pixmap; - xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_pixmap; - xrb->Base.PutValues = put_values_TRUEDITHER_pixmap; - xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_pixmap; + rb->PutRow = put_row_TRUEDITHER_pixmap; + rb->PutRowRGB = put_row_rgb_TRUEDITHER_pixmap; + rb->PutMonoRow = put_mono_row_TRUEDITHER_pixmap; + rb->PutValues = put_values_TRUEDITHER_pixmap; + rb->PutMonoValues = put_mono_values_TRUEDITHER_pixmap; } else { - xrb->Base.PutRow = put_row_TRUEDITHER_ximage; - xrb->Base.PutRowRGB = put_row_rgb_TRUEDITHER_ximage; - xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_ximage; - xrb->Base.PutValues = put_values_TRUEDITHER_ximage; - xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_ximage; + rb->PutRow = put_row_TRUEDITHER_ximage; + rb->PutRowRGB = put_row_rgb_TRUEDITHER_ximage; + rb->PutMonoRow = put_mono_row_TRUEDITHER_ximage; + rb->PutValues = put_values_TRUEDITHER_ximage; + rb->PutMonoValues = put_mono_values_TRUEDITHER_ximage; } break; case PF_8A8B8G8R: if (pixmap) { - xrb->Base.PutRow = put_row_8A8B8G8R_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_8A8B8G8R_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_8A8B8G8R_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_8A8B8G8R_pixmap; + rb->PutRowRGB = put_row_rgb_8A8B8G8R_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_8A8B8G8R_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_8A8B8G8R_ximage; - xrb->Base.PutRowRGB = put_row_rgb_8A8B8G8R_ximage; - 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; + rb->PutRow = put_row_8A8B8G8R_ximage; + rb->PutRowRGB = put_row_rgb_8A8B8G8R_ximage; + rb->PutMonoRow = put_mono_row_8A8B8G8R_ximage; + rb->PutValues = put_values_8A8B8G8R_ximage; + rb->PutMonoValues = put_mono_values_8A8B8G8R_ximage; + rb->GetPointer = get_pointer_4_ximage; } break; case PF_8A8R8G8B: if (pixmap) { - xrb->Base.PutRow = put_row_8A8R8G8B_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_8A8R8G8B_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_8A8R8G8B_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_8A8R8G8B_pixmap; + rb->PutRowRGB = put_row_rgb_8A8R8G8B_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_8A8R8G8B_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_8A8R8G8B_ximage; - xrb->Base.PutRowRGB = put_row_rgb_8A8R8G8B_ximage; - 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; + rb->PutRow = put_row_8A8R8G8B_ximage; + rb->PutRowRGB = put_row_rgb_8A8R8G8B_ximage; + rb->PutMonoRow = put_mono_row_8A8R8G8B_ximage; + rb->PutValues = put_values_8A8R8G8B_ximage; + rb->PutMonoValues = put_mono_values_8A8R8G8B_ximage; + rb->GetPointer = get_pointer_4_ximage; } break; case PF_8R8G8B: if (pixmap) { - xrb->Base.PutRow = put_row_8R8G8B_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_8R8G8B_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_8R8G8B_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_8R8G8B_pixmap; + rb->PutRowRGB = put_row_rgb_8R8G8B_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_8R8G8B_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_8R8G8B_ximage; - xrb->Base.PutRowRGB = put_row_rgb_8R8G8B_ximage; - xrb->Base.PutMonoRow = put_mono_row_8R8G8B_ximage; - xrb->Base.PutValues = put_values_8R8G8B_ximage; - xrb->Base.PutMonoValues = put_mono_values_8R8G8B_ximage; + rb->PutRow = put_row_8R8G8B_ximage; + rb->PutRowRGB = put_row_rgb_8R8G8B_ximage; + rb->PutMonoRow = put_mono_row_8R8G8B_ximage; + rb->PutValues = put_values_8R8G8B_ximage; + rb->PutMonoValues = put_mono_values_8R8G8B_ximage; } break; case PF_8R8G8B24: if (pixmap) { - xrb->Base.PutRow = put_row_8R8G8B24_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_8R8G8B24_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_8R8G8B24_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_8R8G8B24_pixmap; + rb->PutRowRGB = put_row_rgb_8R8G8B24_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_8R8G8B24_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_8R8G8B24_ximage; - xrb->Base.PutRowRGB = put_row_rgb_8R8G8B24_ximage; - xrb->Base.PutMonoRow = put_mono_row_8R8G8B24_ximage; - xrb->Base.PutValues = put_values_8R8G8B24_ximage; - xrb->Base.PutMonoValues = put_mono_values_8R8G8B24_ximage; + rb->PutRow = put_row_8R8G8B24_ximage; + rb->PutRowRGB = put_row_rgb_8R8G8B24_ximage; + rb->PutMonoRow = put_mono_row_8R8G8B24_ximage; + rb->PutValues = put_values_8R8G8B24_ximage; + rb->PutMonoValues = put_mono_values_8R8G8B24_ximage; } break; case PF_5R6G5B: if (pixmap) { - xrb->Base.PutRow = put_row_5R6G5B_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_5R6G5B_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_5R6G5B_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_5R6G5B_pixmap; + rb->PutRowRGB = put_row_rgb_5R6G5B_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_5R6G5B_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_5R6G5B_ximage; - xrb->Base.PutRowRGB = put_row_rgb_5R6G5B_ximage; - xrb->Base.PutMonoRow = put_mono_row_ximage; - xrb->Base.PutValues = put_values_5R6G5B_ximage; - xrb->Base.PutMonoValues = put_mono_values_ximage; + rb->PutRow = put_row_5R6G5B_ximage; + rb->PutRowRGB = put_row_rgb_5R6G5B_ximage; + rb->PutMonoRow = put_mono_row_ximage; + rb->PutValues = put_values_5R6G5B_ximage; + rb->PutMonoValues = put_mono_values_ximage; } break; case PF_Dither_5R6G5B: if (pixmap) { - xrb->Base.PutRow = put_row_DITHER_5R6G5B_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_DITHER_5R6G5B_pixmap; - xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_pixmap; - xrb->Base.PutValues = put_values_DITHER_5R6G5B_pixmap; - xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_pixmap; + rb->PutRow = put_row_DITHER_5R6G5B_pixmap; + rb->PutRowRGB = put_row_rgb_DITHER_5R6G5B_pixmap; + rb->PutMonoRow = put_mono_row_TRUEDITHER_pixmap; + rb->PutValues = put_values_DITHER_5R6G5B_pixmap; + rb->PutMonoValues = put_mono_values_TRUEDITHER_pixmap; } else { - xrb->Base.PutRow = put_row_DITHER_5R6G5B_ximage; - xrb->Base.PutRowRGB = put_row_rgb_DITHER_5R6G5B_ximage; - xrb->Base.PutMonoRow = put_mono_row_DITHER_5R6G5B_ximage; - xrb->Base.PutValues = put_values_DITHER_5R6G5B_ximage; - xrb->Base.PutMonoValues = put_mono_values_DITHER_5R6G5B_ximage; + rb->PutRow = put_row_DITHER_5R6G5B_ximage; + rb->PutRowRGB = put_row_rgb_DITHER_5R6G5B_ximage; + rb->PutMonoRow = put_mono_row_DITHER_5R6G5B_ximage; + rb->PutValues = put_values_DITHER_5R6G5B_ximage; + rb->PutMonoValues = put_mono_values_DITHER_5R6G5B_ximage; } break; case PF_Dither: if (pixmap) { - xrb->Base.PutRow = put_row_DITHER_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_DITHER_pixmap; - xrb->Base.PutMonoRow = put_mono_row_DITHER_pixmap; - xrb->Base.PutValues = put_values_DITHER_pixmap; - xrb->Base.PutMonoValues = put_mono_values_DITHER_pixmap; + rb->PutRow = put_row_DITHER_pixmap; + rb->PutRowRGB = put_row_rgb_DITHER_pixmap; + rb->PutMonoRow = put_mono_row_DITHER_pixmap; + rb->PutValues = put_values_DITHER_pixmap; + rb->PutMonoValues = put_mono_values_DITHER_pixmap; } else { if (depth == 8) { - xrb->Base.PutRow = put_row_DITHER8_ximage; - xrb->Base.PutRowRGB = put_row_rgb_DITHER8_ximage; - xrb->Base.PutMonoRow = put_mono_row_DITHER8_ximage; - xrb->Base.PutValues = put_values_DITHER8_ximage; - xrb->Base.PutMonoValues = put_mono_values_DITHER8_ximage; + rb->PutRow = put_row_DITHER8_ximage; + rb->PutRowRGB = put_row_rgb_DITHER8_ximage; + rb->PutMonoRow = put_mono_row_DITHER8_ximage; + rb->PutValues = put_values_DITHER8_ximage; + rb->PutMonoValues = put_mono_values_DITHER8_ximage; } else { - xrb->Base.PutRow = put_row_DITHER_ximage; - xrb->Base.PutRowRGB = put_row_rgb_DITHER_ximage; - xrb->Base.PutMonoRow = put_mono_row_DITHER_ximage; - xrb->Base.PutValues = put_values_DITHER_ximage; - xrb->Base.PutMonoValues = put_mono_values_DITHER_ximage; + rb->PutRow = put_row_DITHER_ximage; + rb->PutRowRGB = put_row_rgb_DITHER_ximage; + rb->PutMonoRow = put_mono_row_DITHER_ximage; + rb->PutValues = put_values_DITHER_ximage; + rb->PutMonoValues = put_mono_values_DITHER_ximage; } } break; case PF_1Bit: if (pixmap) { - xrb->Base.PutRow = put_row_1BIT_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_1BIT_pixmap; - xrb->Base.PutMonoRow = put_mono_row_1BIT_pixmap; - xrb->Base.PutValues = put_values_1BIT_pixmap; - xrb->Base.PutMonoValues = put_mono_values_1BIT_pixmap; + rb->PutRow = put_row_1BIT_pixmap; + rb->PutRowRGB = put_row_rgb_1BIT_pixmap; + rb->PutMonoRow = put_mono_row_1BIT_pixmap; + rb->PutValues = put_values_1BIT_pixmap; + rb->PutMonoValues = put_mono_values_1BIT_pixmap; } else { - xrb->Base.PutRow = put_row_1BIT_ximage; - xrb->Base.PutRowRGB = put_row_rgb_1BIT_ximage; - xrb->Base.PutMonoRow = put_mono_row_1BIT_ximage; - xrb->Base.PutValues = put_values_1BIT_ximage; - xrb->Base.PutMonoValues = put_mono_values_1BIT_ximage; + rb->PutRow = put_row_1BIT_ximage; + rb->PutRowRGB = put_row_rgb_1BIT_ximage; + rb->PutMonoRow = put_mono_row_1BIT_ximage; + rb->PutValues = put_values_1BIT_ximage; + rb->PutMonoValues = put_mono_values_1BIT_ximage; } break; case PF_HPCR: if (pixmap) { - xrb->Base.PutRow = put_row_HPCR_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_HPCR_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_HPCR_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_HPCR_pixmap; + rb->PutRowRGB = put_row_rgb_HPCR_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_HPCR_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { - xrb->Base.PutRow = put_row_HPCR_ximage; - xrb->Base.PutRowRGB = put_row_rgb_HPCR_ximage; - xrb->Base.PutMonoRow = put_mono_row_HPCR_ximage; - xrb->Base.PutValues = put_values_HPCR_ximage; - xrb->Base.PutMonoValues = put_mono_values_HPCR_ximage; + rb->PutRow = put_row_HPCR_ximage; + rb->PutRowRGB = put_row_rgb_HPCR_ximage; + rb->PutMonoRow = put_mono_row_HPCR_ximage; + rb->PutValues = put_values_HPCR_ximage; + rb->PutMonoValues = put_mono_values_HPCR_ximage; } break; case PF_Lookup: if (pixmap) { - xrb->Base.PutRow = put_row_LOOKUP_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_LOOKUP_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_LOOKUP_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_LOOKUP_pixmap; + rb->PutRowRGB = put_row_rgb_LOOKUP_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_LOOKUP_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { if (depth==8) { - xrb->Base.PutRow = put_row_LOOKUP8_ximage; - xrb->Base.PutRowRGB = put_row_rgb_LOOKUP8_ximage; - xrb->Base.PutMonoRow = put_mono_row_LOOKUP8_ximage; - xrb->Base.PutValues = put_values_LOOKUP8_ximage; - xrb->Base.PutMonoValues = put_mono_values_LOOKUP8_ximage; + rb->PutRow = put_row_LOOKUP8_ximage; + rb->PutRowRGB = put_row_rgb_LOOKUP8_ximage; + rb->PutMonoRow = put_mono_row_LOOKUP8_ximage; + rb->PutValues = put_values_LOOKUP8_ximage; + rb->PutMonoValues = put_mono_values_LOOKUP8_ximage; } else { - xrb->Base.PutRow = put_row_LOOKUP_ximage; - xrb->Base.PutRowRGB = put_row_rgb_LOOKUP_ximage; - xrb->Base.PutMonoRow = put_mono_row_ximage; - xrb->Base.PutValues = put_values_LOOKUP_ximage; - xrb->Base.PutMonoValues = put_mono_values_ximage; + rb->PutRow = put_row_LOOKUP_ximage; + rb->PutRowRGB = put_row_rgb_LOOKUP_ximage; + rb->PutMonoRow = put_mono_row_ximage; + rb->PutValues = put_values_LOOKUP_ximage; + rb->PutMonoValues = put_mono_values_ximage; } } break; case PF_Grayscale: if (pixmap) { - xrb->Base.PutRow = put_row_GRAYSCALE_pixmap; - xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE_pixmap; - xrb->Base.PutMonoRow = put_mono_row_pixmap; - xrb->Base.PutValues = put_values_GRAYSCALE_pixmap; - xrb->Base.PutMonoValues = put_mono_values_pixmap; + rb->PutRow = put_row_GRAYSCALE_pixmap; + rb->PutRowRGB = put_row_rgb_GRAYSCALE_pixmap; + rb->PutMonoRow = put_mono_row_pixmap; + rb->PutValues = put_values_GRAYSCALE_pixmap; + rb->PutMonoValues = put_mono_values_pixmap; } else { if (depth == 8) { - xrb->Base.PutRow = put_row_GRAYSCALE8_ximage; - xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE8_ximage; - xrb->Base.PutMonoRow = put_mono_row_GRAYSCALE8_ximage; - xrb->Base.PutValues = put_values_GRAYSCALE8_ximage; - xrb->Base.PutMonoValues = put_mono_values_GRAYSCALE8_ximage; + rb->PutRow = put_row_GRAYSCALE8_ximage; + rb->PutRowRGB = put_row_rgb_GRAYSCALE8_ximage; + rb->PutMonoRow = put_mono_row_GRAYSCALE8_ximage; + rb->PutValues = put_values_GRAYSCALE8_ximage; + rb->PutMonoValues = put_mono_values_GRAYSCALE8_ximage; } else { - xrb->Base.PutRow = put_row_GRAYSCALE_ximage; - xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE_ximage; - xrb->Base.PutMonoRow = put_mono_row_ximage; - xrb->Base.PutValues = put_values_GRAYSCALE_ximage; - xrb->Base.PutMonoValues = put_mono_values_ximage; + rb->PutRow = put_row_GRAYSCALE_ximage; + rb->PutRowRGB = put_row_rgb_GRAYSCALE_ximage; + rb->PutMonoRow = put_mono_row_ximage; + rb->PutValues = put_values_GRAYSCALE_ximage; + rb->PutMonoValues = put_mono_values_ximage; } } break; @@ -4803,12 +4804,12 @@ xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb, /* Get functions */ if (pixelformat == PF_Index) { - xrb->Base.GetRow = get_row_ci; - xrb->Base.GetValues = get_values_ci; + rb->GetRow = get_row_ci; + rb->GetValues = get_values_ci; } else { - xrb->Base.GetRow = get_row_rgba; - xrb->Base.GetValues = get_values_rgba; + rb->GetRow = get_row_rgba; + rb->GetValues = get_values_rgba; } } diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 6b52b33bf2..9d7d25667e 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -45,14 +45,21 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/softpipe/sp_context.h" -#include "pipe/softpipe/sp_surface.h" #include "state_tracker/st_context.h" +static INLINE struct xmesa_surface * +xmesa_surf(struct softpipe_surface *sps) +{ + return (struct xmesa_surface *) sps; +} + + static INLINE struct xmesa_renderbuffer * xmesa_rb(struct softpipe_surface *sps) { - return (struct xmesa_renderbuffer *) sps->surface.rb; + struct xmesa_surface *xms = xmesa_surf(sps); + return xms->xrb; } @@ -66,13 +73,14 @@ static void read_quad_f(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rgba)[NUM_CHANNELS]) { + struct xmesa_surface *xms = xmesa_surf(sps); struct xmesa_renderbuffer *xrb = xmesa_rb(sps); 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); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, temp); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8); for (i = 0; i < 16; i++) { dst[i] = UBYTE_TO_FLOAT(temp[i]); } @@ -82,13 +90,14 @@ static void read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, GLfloat (*rrrr)[QUAD_SIZE]) { + struct xmesa_surface *xms = xmesa_surf(sps); struct xmesa_renderbuffer *xrb = xmesa_rb(sps); 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); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, temp); + xrb->St.Base.GetRow(ctx, &xrb->St.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]); @@ -108,8 +117,8 @@ write_quad_f(struct softpipe_surface *sps, GLint x, GLint y, 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); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y, temp, NULL); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8, NULL); } static void @@ -126,8 +135,8 @@ write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, 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); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y, temp, NULL); + xrb->St.Base.PutRow(ctx, &xrb->St.Base, 2, x, y + 1, temp + 8, NULL); } static void @@ -136,8 +145,8 @@ read_quad_ub(struct softpipe_surface *sps, GLint x, GLint y, { struct xmesa_renderbuffer *xrb = xmesa_rb(sps); 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); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, rgba); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, rgba + 2); } static void @@ -146,8 +155,8 @@ write_quad_ub(struct softpipe_surface *sps, GLint x, GLint y, { struct xmesa_renderbuffer *xrb = xmesa_rb(sps); 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); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y, rgba); + xrb->St.Base.GetRow(ctx, &xrb->St.Base, 2, x, y + 1, rgba + 2); } #if 0 @@ -157,7 +166,7 @@ write_mono_row_ub(struct softpipe_surface *sps, GLuint count, GLint x, GLint y, { struct xmesa_renderbuffer *xrb = xmesa_rb(sps); GET_CURRENT_CONTEXT(ctx); - xrb->Base.PutMonoRow(ctx, &xrb->Base, count, x, y, rgba, NULL); + xrb->St.Base.PutMonoRow(ctx, &xrb->St.Base, count, x, y, rgba, NULL); } #endif @@ -177,9 +186,11 @@ xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb) if (!sps) return NULL; +#if 0 sps->surface.rb = xrb; /* XXX only needed for quad funcs above */ - sps->surface.width = xrb->Base.Width; - sps->surface.height = xrb->Base.Height; +#endif + sps->surface.width = xrb->St.Base.Width; + sps->surface.height = xrb->St.Base.Height; sps->read_quad_f = read_quad_f; sps->read_quad_f_swz = read_quad_f_swz; @@ -197,3 +208,52 @@ xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb) return &sps->surface; } + + +struct pipe_surface * +xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) +{ + struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface); + + assert(pipeFormat); + + xms->surface.surface.format = pipeFormat; + + switch (pipeFormat) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + xms->surface.read_quad_f_swz = read_quad_f; + xms->surface.read_quad_f = read_quad_f; + xms->surface.read_quad_f_swz = read_quad_f_swz; + xms->surface.read_quad_ub = read_quad_ub; + xms->surface.write_quad_f = write_quad_f; + xms->surface.write_quad_f_swz = write_quad_f_swz; + xms->surface.write_quad_ub = write_quad_ub; + break; + case PIPE_FORMAT_S8_Z24: + softpipe_init_surface_funcs(&xms->surface); + /* + xms->surface.read_quad_z = 1; + xms->surface.write_quad_z = 1; + */ + break; + default: + abort(); + } + + return &xms->surface.surface; +} + + +const GLuint * +xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats) +{ + static const GLuint formats[] = { + PIPE_FORMAT_U_A8_R8_G8_B8, + PIPE_FORMAT_S8_Z24 + }; + + *numFormats = 2; + + return formats; +} + diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 99c87da3c5..361c657354 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -36,6 +36,9 @@ #ifdef XFree86Server #include "xm_image.h" #endif +#include "state_tracker/st_cb_fbo.h" +#include "pipe/softpipe/sp_context.h" +#include "pipe/softpipe/sp_surface.h" extern _glthread_Mutex _xmesa_lock; @@ -177,7 +180,11 @@ typedef enum { */ struct xmesa_renderbuffer { +#if 0 struct gl_renderbuffer Base; /* Base class */ +#else + struct st_renderbuffer St; /**< Base class */ +#endif XMesaBuffer Parent; /**< The XMesaBuffer this renderbuffer belongs to */ XMesaDrawable drawable; /* Usually the X window ID */ @@ -493,8 +500,8 @@ extern const int xmesa_kernel1[16]; */ extern struct xmesa_renderbuffer * -xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, - GLboolean backBuffer); +xmesa_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, + GLboolean backBuffer); extern void xmesa_delete_framebuffer(struct gl_framebuffer *fb); @@ -589,6 +596,13 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx ); struct pipe_surface; struct pipe_context; +struct xmesa_surface +{ + struct softpipe_surface surface; + struct xmesa_renderbuffer *xrb; +}; + + extern struct pipe_surface * xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb); @@ -601,5 +615,11 @@ xmesa_clear_buffers(GLcontext *ctx, GLbitfield buffers); extern struct pipe_context * xmesa_create_softpipe(XMesaContext xm); +extern struct pipe_surface * +xmesa_surface_alloc(struct pipe_context *pipe, GLuint format); + +extern const GLuint * +xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats); + #endif -- cgit v1.2.3 From 0095be534d633848bc12d73ed9dcc1b9aa41f00a Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 11 Aug 2007 21:21:12 +0100 Subject: Change/fix surface allocation functions. Use xmesa_new_color_surface() for front/back renderbuffer surfaces. Use xmesa_surface_alloc() for everything else (textures, other renderbuffers) --- src/mesa/drivers/x11/xm_buffer.c | 7 +--- src/mesa/drivers/x11/xm_softpipe.c | 2 + src/mesa/drivers/x11/xm_surface.c | 80 +++++++++++++++++++------------------- src/mesa/drivers/x11/xmesaP.h | 6 +-- 4 files changed, 45 insertions(+), 50 deletions(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 4cd2ab7c6b..52629aca18 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -252,10 +252,6 @@ static void finish_surface_init(GLcontext *ctx, struct xmesa_renderbuffer *xrb) { struct pipe_context *pipe = ctx->st->pipe; - - if (!xrb->St.surface) { - xrb->St.surface = xmesa_new_surface(ctx, xrb); - } if (!xrb->St.surface->region) { xrb->St.surface->region = pipe->region_alloc(pipe, 1, 0, 0, 0x0); } @@ -391,10 +387,9 @@ xmesa_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual, } /* only need to set Red/Green/EtcBits fields for user-created RBs */ - xrb->St.surface = xmesa_surface_alloc(pipe, pipeFormat); + xrb->St.surface = xmesa_new_color_surface(pipe, pipeFormat); xms = (struct xmesa_surface *) xrb->St.surface; xms->xrb = xrb; - } return xrb; } diff --git a/src/mesa/drivers/x11/xm_softpipe.c b/src/mesa/drivers/x11/xm_softpipe.c index 2f93ff3309..a08673444f 100644 --- a/src/mesa/drivers/x11/xm_softpipe.c +++ b/src/mesa/drivers/x11/xm_softpipe.c @@ -130,6 +130,8 @@ xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, struct xm_buffer *xm_buf = xm_bo(buf); assert(!xm_buf->data); xm_buf->data = malloc(size); + if (data) + memcpy(xm_buf->data, data, size); } static void diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index c6057e5154..6f6c549c07 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -172,7 +172,18 @@ static void get_tile(struct pipe_surface *ps, GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p) { - + struct xmesa_renderbuffer *xrb = xmesa_rb((struct softpipe_surface *) ps); + GLubyte tmp[MAX_WIDTH * 4]; + GLuint i, j; + GET_CURRENT_CONTEXT(ctx); + FLIP(y); + for (i = 0; i < h; i++) { + xrb->St.Base.GetRow(ctx, &xrb->St.Base, w, x, y - i, tmp); + for (j = 0; j < w * 4; j++) { + p[j] = UBYTE_TO_FLOAT(tmp[j]); + } + p += w * 4; + } } @@ -180,7 +191,7 @@ static void put_tile(struct pipe_surface *ps, GLuint x, GLuint y, GLuint w, GLuint h, const GLfloat *p) { - + assert(0); } @@ -191,45 +202,7 @@ put_tile(struct pipe_surface *ps, * have special/unique quad read/write functions for X. */ struct pipe_surface * -xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb) -{ - struct pipe_context *pipe = ctx->st->pipe; - struct softpipe_surface *sps; - - sps = CALLOC_STRUCT(softpipe_surface); - if (!sps) - return NULL; - -#if 0 - sps->surface.rb = xrb; /* XXX only needed for quad funcs above */ -#endif - sps->surface.refcount = 1; - - sps->surface.width = xrb->St.Base.Width; - sps->surface.height = xrb->St.Base.Height; - - sps->read_quad_f = read_quad_f; - sps->read_quad_f_swz = read_quad_f_swz; - sps->read_quad_ub = read_quad_ub; - sps->write_quad_f = write_quad_f; - sps->write_quad_f_swz = write_quad_f_swz; - sps->write_quad_ub = write_quad_ub; - sps->surface.get_tile = get_tile; - sps->surface.put_tile = put_tile; - - /* Note, the region we allocate doesn't actually have any storage - * since we're drawing into an XImage or Pixmap. - * The region's size will get set in the xmesa_alloc_front/back_storage() - * functions. - */ - sps->surface.region = pipe->region_alloc(pipe, 0, 0, 0, 0x0); - - return &sps->surface; -} - - -struct pipe_surface * -xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) +xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat) { struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface); @@ -273,6 +246,31 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) } +/** + * Called via pipe->surface_alloc() to create new surfaces (textures, + * renderbuffers, etc. + */ +struct pipe_surface * +xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) +{ + struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface); + + assert(pipeFormat); + + xms->surface.surface.format = pipeFormat; + xms->surface.surface.refcount = 1; + /* + * This is really just a softpipe surface, not an XImage/Pixmap surface. + */ + softpipe_init_surface_funcs(&xms->surface); + + assert(pipe); + xms->surface.surface.region = pipe->region_alloc(pipe, 1, 0, 0, 0x0); + + return &xms->surface.surface; +} + + const GLuint * xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats) { diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 361c657354..9cbe8670f9 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -603,9 +603,6 @@ struct xmesa_surface }; -extern struct pipe_surface * -xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb); - extern void xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value); @@ -618,6 +615,9 @@ xmesa_create_softpipe(XMesaContext xm); extern struct pipe_surface * xmesa_surface_alloc(struct pipe_context *pipe, GLuint format); +extern struct pipe_surface * +xmesa_new_color_surface(struct pipe_context *pipe, GLuint format); + extern const GLuint * xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats); -- cgit v1.2.3 From e4f6f0ec02133e9297c3f2db787dee14bf0ae6e1 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 26 Oct 2007 10:45:42 -0600 Subject: surface_alloc() is now a winsys function. This allows surfaces to be allocated without a rendering context. A few loose ends to resolve, but in working condition. --- .../drivers/dri/intel_winsys/intel_winsys_pipe.c | 14 ++ src/mesa/drivers/x11/xm_api.c | 7 + src/mesa/drivers/x11/xm_surface.c | 123 +++++++++----- src/mesa/drivers/x11/xm_winsys.c | 27 +++ src/mesa/drivers/x11/xmesaP.h | 13 +- src/mesa/pipe/failover/fo_context.c | 2 + src/mesa/pipe/i915simple/i915_surface.c | 189 ++++++++++++++++----- src/mesa/pipe/p_context.h | 9 +- src/mesa/pipe/p_winsys.h | 4 + src/mesa/pipe/softpipe/sp_surface.c | 107 +++++++++--- src/mesa/pipe/softpipe/sp_surface.h | 15 +- src/mesa/state_tracker/st_cb_fbo.c | 2 +- 12 files changed, 393 insertions(+), 119 deletions(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c index 6f244e1100..4569b1e3bf 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c @@ -253,6 +253,18 @@ intel_i915_region_release(struct pipe_winsys *winsys, } +static struct pipe_surface * +intel_i915_surface_alloc(struct pipe_winsys *winsys, unsigned format) +{ + struct pipe_surface *surf = CALLOC_STRUCT(pipe_surface); + if (surf) { + surf->format = format; + surf->refcount = 1; + } + return surf; +} + + static void intel_printf( struct pipe_winsys *sws, const char *fmtString, ... ) { @@ -298,5 +310,7 @@ intel_create_pipe_winsys( struct intel_context *intel ) iws->winsys.region_alloc = intel_i915_region_alloc; iws->winsys.region_release = intel_i915_region_release; + iws->winsys.surface_alloc = intel_i915_surface_alloc; + return &iws->winsys; } diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 187663e66c..1d2b93d100 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1610,8 +1610,15 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) st_create_context( mesaCtx, xmesa_create_softpipe( c ) ); + /* override these functions, as if the xlib driver were derived from + * the softpipe driver. + */ +#if 0 mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc; +#endif mesaCtx->st->pipe->supported_formats = xmesa_supported_formats; + mesaCtx->st->pipe->get_tile_rgba = xmesa_get_tile_rgba; + mesaCtx->st->pipe->put_tile_rgba = xmesa_put_tile_rgba; mesaCtx->st->haveFramebufferRegions = GL_FALSE; diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 337033f8ad..3655a55e4e 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -48,6 +48,7 @@ #include "pipe/softpipe/sp_context.h" #include "pipe/softpipe/sp_clear.h" #include "pipe/softpipe/sp_tile_cache.h" +#include "pipe/softpipe/sp_surface.h" #include "state_tracker/st_context.h" @@ -67,6 +68,13 @@ xmesa_surf(struct softpipe_surface *sps) } +static INLINE struct xmesa_surface * +xmesa_surface(struct pipe_surface *ps) +{ + return (struct xmesa_surface *) ps; +} + + static INLINE struct xmesa_renderbuffer * xmesa_rb(struct softpipe_surface *sps) { @@ -78,53 +86,71 @@ xmesa_rb(struct softpipe_surface *sps) #define FLIP(Y) Y = xrb->St.Base.Height - (Y) - 1; -static void -get_tile(struct pipe_surface *ps, - uint x, uint y, uint w, uint h, float *p) +void +xmesa_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps, + uint x, uint y, uint w, uint h, float *p) { - struct xmesa_renderbuffer *xrb = xmesa_rb((struct softpipe_surface *) ps); - GLubyte tmp[MAX_WIDTH * 4]; - GLuint i, j; - uint w0 = w; - GET_CURRENT_CONTEXT(ctx); - - CLIP_TILE; - - FLIP(y); - for (i = 0; i < h; i++) { - xrb->St.Base.GetRow(ctx, &xrb->St.Base, w, x, y - i, tmp); - for (j = 0; j < w * 4; j++) { - p[j] = UBYTE_TO_FLOAT(tmp[j]); + struct xmesa_surface *xms = xmesa_surface(ps); + struct xmesa_renderbuffer *xrb = xms->xrb; + + if (xrb) { + /* this is a front/back color buffer */ + GLubyte tmp[MAX_WIDTH * 4]; + GLuint i, j; + uint w0 = w; + GET_CURRENT_CONTEXT(ctx); + + CLIP_TILE; + + FLIP(y); + for (i = 0; i < h; i++) { + xrb->St.Base.GetRow(ctx, &xrb->St.Base, w, x, y - i, tmp); + for (j = 0; j < w * 4; j++) { + p[j] = UBYTE_TO_FLOAT(tmp[j]); + } + p += w0 * 4; } - p += w0 * 4; + } + else { + /* other softpipe surface */ + softpipe_get_tile_rgba(pipe, ps, x, y, w, h, p); } } -static void -put_tile(struct pipe_surface *ps, - uint x, uint y, uint w, uint h, const float *p) +void +xmesa_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps, + uint x, uint y, uint w, uint h, const float *p) { - struct xmesa_renderbuffer *xrb = xmesa_rb((struct softpipe_surface *) ps); - GLubyte tmp[MAX_WIDTH * 4]; - GLuint i, j; - uint w0 = w; - GET_CURRENT_CONTEXT(ctx); - CLIP_TILE; - FLIP(y); - for (i = 0; i < h; i++) { - for (j = 0; j < w * 4; j++) { - UNCLAMPED_FLOAT_TO_UBYTE(tmp[j], p[j]); + struct xmesa_surface *xms = xmesa_surface(ps); + struct xmesa_renderbuffer *xrb = xms->xrb; + + if (xrb) { + /* this is a front/back color buffer */ + GLubyte tmp[MAX_WIDTH * 4]; + GLuint i, j; + uint w0 = w; + GET_CURRENT_CONTEXT(ctx); + CLIP_TILE; + FLIP(y); + for (i = 0; i < h; i++) { + for (j = 0; j < w * 4; j++) { + UNCLAMPED_FLOAT_TO_UBYTE(tmp[j], p[j]); + } + xrb->St.Base.PutRow(ctx, &xrb->St.Base, w, x, y - i, tmp, NULL); + p += w0 * 4; } - xrb->St.Base.PutRow(ctx, &xrb->St.Base, w, x, y - i, tmp, NULL); - p += w0 * 4; - } #if 0 /* debug: flush */ - { - XMesaContext xm = XMESA_CONTEXT(ctx); - XSync(xm->display, 0); - } + { + XMesaContext xm = XMESA_CONTEXT(ctx); + XSync(xm->display, 0); + } #endif + } + else { + /* other softpipe surface */ + softpipe_put_tile_rgba(pipe, ps, x, y, w, h, p); + } } @@ -141,12 +167,15 @@ xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat) assert(pipeFormat); - xms->surface.surface.format = pipeFormat; - xms->surface.surface.refcount = 1; + xms->surface.format = pipeFormat; + xms->surface.refcount = 1; +#if 0 /* some of the functions plugged in by this call will get overridden */ softpipe_init_surface_funcs(&xms->surface); +#endif +#if 0 switch (pipeFormat) { case PIPE_FORMAT_U_A8_R8_G8_B8: xms->surface.get_tile = get_tile; @@ -157,6 +186,7 @@ xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat) default: abort(); } +#endif /* Note, the region we allocate doesn't actually have any storage * since we're drawing into an XImage or Pixmap. @@ -164,10 +194,10 @@ xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat) * functions. */ if (pipe) - xms->surface.surface.region = pipe->winsys->region_alloc(pipe->winsys, - 1, 0, 0, 0x0); + xms->surface.region = pipe->winsys->region_alloc(pipe->winsys, + 1, 0, 0, 0x0); - return &xms->surface.surface; + return &xms->surface; } @@ -183,14 +213,15 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) assert(pipe); assert(pipeFormat); - xms->surface.surface.format = pipeFormat; - xms->surface.surface.refcount = 1; + xms->surface.format = pipeFormat; + xms->surface.refcount = 1; +#if 0 /* * This is really just a softpipe surface, not an XImage/Pixmap surface. */ softpipe_init_surface_funcs(&xms->surface); - - return &xms->surface.surface; +#endif + return &xms->surface; } diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c index 624d28dd01..36805437f0 100644 --- a/src/mesa/drivers/x11/xm_winsys.c +++ b/src/mesa/drivers/x11/xm_winsys.c @@ -289,6 +289,31 @@ xm_region_release(struct pipe_winsys *winsys, struct pipe_region **region) } +/** + * Called via pipe->surface_alloc() to create new surfaces (textures, + * renderbuffers, etc. + */ +static struct pipe_surface * +xm_surface_alloc(struct pipe_winsys *ws, GLuint pipeFormat) +{ + struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface); + + assert(ws); + assert(pipeFormat); + + xms->surface.format = pipeFormat; + xms->surface.refcount = 1; +#if 0 + /* + * This is really just a softpipe surface, not an XImage/Pixmap surface. + */ + softpipe_init_surface_funcs(&xms->surface); +#endif + return &xms->surface; +} + + + struct xmesa_pipe_winsys { @@ -320,6 +345,8 @@ xmesa_create_pipe_winsys( XMesaContext xmesa ) xws->winsys.region_alloc = xm_region_alloc; xws->winsys.region_release = xm_region_release; + xws->winsys.surface_alloc = xm_surface_alloc; + xws->winsys.flush_frontbuffer = xm_flush_frontbuffer; xws->winsys.wait_idle = xm_wait_idle; xws->winsys.printf = xm_printf; diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 9cbe8670f9..8af95504fb 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -598,7 +598,7 @@ struct pipe_context; struct xmesa_surface { - struct softpipe_surface surface; + struct pipe_surface surface; struct xmesa_renderbuffer *xrb; }; @@ -618,8 +618,15 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint format); extern struct pipe_surface * xmesa_new_color_surface(struct pipe_context *pipe, GLuint format); -extern const GLuint * -xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats); +extern const uint * +xmesa_supported_formats(struct pipe_context *pipe, uint *numFormats); +extern void +xmesa_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps, + uint x, uint y, uint w, uint h, float *p); + +extern void +xmesa_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps, + uint x, uint y, uint w, uint h, const float *p); #endif diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c index a3a0296598..7e02b751bb 100644 --- a/src/mesa/pipe/failover/fo_context.c +++ b/src/mesa/pipe/failover/fo_context.c @@ -134,7 +134,9 @@ struct pipe_context *failover_create( struct pipe_context *hw, failover_init_state_functions( failover ); +#if 0 failover->pipe.surface_alloc = hw->surface_alloc; +#endif failover->pipe.get_tex_surface = hw->get_tex_surface; failover->pipe.region_map = hw->region_map; diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c index a07a21c13b..b4b5bd1ce5 100644 --- a/src/mesa/pipe/i915simple/i915_surface.c +++ b/src/mesa/pipe/i915simple/i915_surface.c @@ -29,13 +29,20 @@ #include "i915_state.h" #include "pipe/p_defines.h" #include "pipe/p_util.h" +#include "pipe/p_winsys.h" -struct i915_surface -{ - struct pipe_surface surface; - /* anything else? */ -}; +#define CLIP_TILE \ + do { \ + if (x >= ps->width) \ + return; \ + if (y >= ps->height) \ + return; \ + if (x + w > ps->width) \ + w = ps->width - x; \ + if (y + h > ps->height) \ + h = ps->height -y; \ + } while(0) /** @@ -53,30 +60,44 @@ i915_get_tile_rgba(struct pipe_context *pipe, unsigned i, j; unsigned w0 = w; - assert(ps->format == PIPE_FORMAT_U_A8_R8_G8_B8); - -#if 0 - assert(x + w <= ps->width); - assert(y + h <= ps->height); -#else - /* temp clipping hack */ - if (x + w > ps->width) - w = ps->width - x; - if (y + h > ps->height) - h = ps->height -y; -#endif - for (i = 0; i < h; i++) { - float *pRow = p; - for (j = 0; j < w; j++) { - const unsigned pixel = src[j]; - pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff); - pRow[1] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff); - pRow[2] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff); - pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff); - pRow += 4; + CLIP_TILE; + + switch (ps->format) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + for (i = 0; i < h; i++) { + float *pRow = p; + for (j = 0; j < w; j++) { + const unsigned pixel = src[j]; + pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff); + pRow[1] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff); + pRow[2] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff); + pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff); + pRow += 4; + } + src += ps->region->pitch; + p += w0 * 4; + } + break; + case PIPE_FORMAT_S8_Z24: + { + const float scale = 1.0 / (float) 0xffffff; + for (i = 0; i < h; i++) { + float *pRow = p; + for (j = 0; j < w; j++) { + const unsigned pixel = src[j]; + pRow[0] = + pRow[1] = + pRow[2] = + pRow[3] = (pixel & 0xffffff) * scale; + pRow += 4; + } + src += ps->region->pitch; + p += w0 * 4; + } } - src += ps->region->pitch; - p += w0 * 4; + break; + default: + assert(0); } } @@ -86,34 +107,122 @@ i915_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps, uint x, uint y, uint w, uint h, const float *p) { - /* any need to put tiles into i915 surfaces? */ + /* TODO */ assert(0); } +/* + * XXX note: same as code in sp_surface.c + */ +static void +i915_get_tile(struct pipe_context *pipe, + struct pipe_surface *ps, + uint x, uint y, uint w, uint h, + void *p, int dst_stride) +{ + const uint cpp = ps->region->cpp; + const uint w0 = w; + const ubyte *pSrc; + ubyte *pDest; + uint i; -static struct pipe_surface * -i915_surface_alloc(struct pipe_context *pipe, unsigned format) + assert(ps->region->map); + + CLIP_TILE; + + if (dst_stride == 0) { + dst_stride = w0 * cpp; + } + + pSrc = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp; + pDest = (ubyte *) p; + + for (i = 0; i < h; i++) { + memcpy(pDest, pSrc, w0 * cpp); + pDest += dst_stride; + pSrc += ps->region->pitch * cpp; + } +} + + +/* + * XXX note: same as code in sp_surface.c + */ +static void +i915_put_tile(struct pipe_context *pipe, + struct pipe_surface *ps, + uint x, uint y, uint w, uint h, + const void *p, int src_stride) { - struct i915_surface *surf = CALLOC_STRUCT(i915_surface); + const uint cpp = ps->region->cpp; + const uint w0 = w; + const ubyte *pSrc; + ubyte *pDest; + uint i; + + assert(ps->region->map); + + CLIP_TILE; + + if (src_stride == 0) { + src_stride = w0 * cpp; + } + + pSrc = (const ubyte *) p; + pDest = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp; + + for (i = 0; i < h; i++) { + memcpy(pDest, pSrc, w0 * cpp); + pDest += ps->region->pitch * cpp; + pSrc += src_stride; + } +} - if (!surf) - return NULL; - surf->surface.format = format; - surf->surface.refcount = 1; +/* + * XXX note: same as code in sp_surface.c + */ +static struct pipe_surface * +i915_get_tex_surface(struct pipe_context *pipe, + struct pipe_mipmap_tree *mt, + unsigned face, unsigned level, unsigned zslice) +{ + struct pipe_surface *ps; + unsigned offset; /* in bytes */ - // surf->surface.get_tile = i915_get_tile; - // surf->surface.put_tile = i915_put_tile; + offset = mt->level[level].level_offset; - return &surf->surface; + if (mt->target == PIPE_TEXTURE_CUBE) { + offset += mt->level[level].image_offset[face] * mt->cpp; + } + else if (mt->target == PIPE_TEXTURE_3D) { + offset += mt->level[level].image_offset[zslice] * mt->cpp; + } + else { + assert(face == 0); + assert(zslice == 0); + } + + ps = pipe->winsys->surface_alloc(pipe->winsys, mt->format); + if (ps) { + assert(ps->format); + assert(ps->refcount); + pipe_region_reference(&ps->region, mt->region); + ps->width = mt->level[level].width; + ps->height = mt->level[level].height; + ps->offset = offset; + } + return ps; } void i915_init_surface_functions(struct i915_context *i915) { - i915->pipe.surface_alloc = i915_surface_alloc; + i915->pipe.get_tex_surface = i915_get_tex_surface; + i915->pipe.get_tile = i915_get_tile; + i915->pipe.put_tile = i915_put_tile; i915->pipe.get_tile_rgba = i915_get_tile_rgba; i915->pipe.put_tile_rgba = i915_put_tile_rgba; } diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index b9de3667e5..3a041f158b 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -176,13 +176,7 @@ struct pipe_context { unsigned index, const struct pipe_feedback_buffer *); - /* - * Surface functions - * This might go away... - */ - struct pipe_surface *(*surface_alloc)(struct pipe_context *pipe, - unsigned format); - + /** Get a surface which is a "view" into a texture */ struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe, struct pipe_mipmap_tree *texture, unsigned face, unsigned level, @@ -198,7 +192,6 @@ struct pipe_context { struct pipe_surface *ps, uint x, uint y, uint w, uint h, const void *p, int src_stride); - /* XXX temporary here, move these to softpipe */ void (*get_tile_rgba)(struct pipe_context *pipe, struct pipe_surface *ps, uint x, uint y, uint w, uint h, float *p); diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index 3b04c44733..10a2caf1a2 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -77,6 +77,10 @@ struct pipe_winsys void (*region_release)(struct pipe_winsys *ws, struct pipe_region **r); + /** allocate a new surface (no context dependency) */ + struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws, + unsigned format); + /** * The buffer manager is modeled after the dri_bufmgr interface, which * in turn is modeled after the ARB_vertex_buffer_object extension, diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index 4accafa384..d1aa2aba97 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -27,6 +27,7 @@ #include "pipe/p_defines.h" #include "pipe/p_util.h" +#include "pipe/p_winsys.h" #include "sp_context.h" #include "sp_state.h" #include "sp_surface.h" @@ -361,7 +362,7 @@ i8_get_tile(struct pipe_surface *ps, static void a8_l8_get_tile(struct pipe_surface *ps, - unsigned x, unsigned y, unsigned w, unsigned h, float *p) + unsigned x, unsigned y, unsigned w, unsigned h, float *p) { const ushort *src = ((const ushort *) (ps->region->map + ps->offset)) @@ -466,7 +467,7 @@ void softpipe_init_surface_funcs(struct softpipe_surface *sps) { assert(sps->surface.format); - +#if 0 switch (sps->surface.format) { case PIPE_FORMAT_U_A8_R8_G8_B8: sps->get_tile = a8r8g8b8_get_tile; @@ -507,6 +508,7 @@ softpipe_init_surface_funcs(struct softpipe_surface *sps) default: assert(0); } +#endif } @@ -555,7 +557,7 @@ softpipe_get_tex_surface(struct pipe_context *pipe, assert(zslice == 0); } - ps = pipe->surface_alloc(pipe, mt->format); + ps = pipe->winsys->surface_alloc(pipe->winsys, mt->format); if (ps) { assert(ps->format); assert(ps->refcount); @@ -637,26 +639,90 @@ softpipe_put_tile(struct pipe_context *pipe, /* XXX TEMPORARY */ -static void -get_tile_rgba_generic(struct pipe_context *pipe, - struct pipe_surface *ps, - uint x, uint y, uint w, uint h, - float *p) +void +softpipe_get_tile_rgba(struct pipe_context *pipe, + struct pipe_surface *ps, + uint x, uint y, uint w, uint h, + float *p) { - struct softpipe_surface *sps = softpipe_surface(ps); - sps->get_tile(ps, x, y, w, h, p); + switch (ps->format) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + a8r8g8b8_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_A1_R5_G5_B5: + a1r5g5b5_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_L8: + l8_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_A8: + a8_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_I8: + i8_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_A8_L8: + a8_l8_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_S_R16_G16_B16_A16: + r16g16b16a16_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_Z16: + z16_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_Z32: + z32_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_S8_Z24: + s8z24_get_tile(ps, x, y, w, h, p); + break; + default: + assert(0); + } } /* XXX TEMPORARY */ -static void -put_tile_rgba_generic(struct pipe_context *pipe, - struct pipe_surface *ps, - uint x, uint y, uint w, uint h, - const float *p) +void +softpipe_put_tile_rgba(struct pipe_context *pipe, + struct pipe_surface *ps, + uint x, uint y, uint w, uint h, + const float *p) { - struct softpipe_surface *sps = softpipe_surface(ps); - sps->put_tile(ps, x, y, w, h, p); + switch (ps->format) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + a8r8g8b8_put_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_A1_R5_G5_B5: + /*a1r5g5b5_put_tile(ps, x, y, w, h, p);*/ + break; + case PIPE_FORMAT_U_L8: + /*l8_put_tile(ps, x, y, w, h, p);*/ + break; + case PIPE_FORMAT_U_A8: + /*a8_put_tile(ps, x, y, w, h, p);*/ + break; + case PIPE_FORMAT_U_I8: + /*i8_put_tile(ps, x, y, w, h, p);*/ + break; + case PIPE_FORMAT_U_A8_L8: + /*a8_l8_put_tile(ps, x, y, w, h, p);*/ + break; + case PIPE_FORMAT_S_R16_G16_B16_A16: + r16g16b16a16_put_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_U_Z16: + /*z16_put_tile(ps, x, y, w, h, p);*/ + break; + case PIPE_FORMAT_U_Z32: + /*z32_put_tile(ps, x, y, w, h, p);*/ + break; + case PIPE_FORMAT_S8_Z24: + /*s8z24_put_tile(ps, x, y, w, h, p);*/ + break; + default: + assert(0); + } } @@ -664,11 +730,12 @@ put_tile_rgba_generic(struct pipe_context *pipe, void sp_init_surface_functions(struct softpipe_context *sp) { +#if 0 sp->pipe.surface_alloc = softpipe_surface_alloc; - +#endif sp->pipe.get_tile = softpipe_get_tile; sp->pipe.put_tile = softpipe_put_tile; - sp->pipe.get_tile_rgba = get_tile_rgba_generic; - sp->pipe.put_tile_rgba = put_tile_rgba_generic; + sp->pipe.get_tile_rgba = softpipe_get_tile_rgba; + sp->pipe.put_tile_rgba = softpipe_put_tile_rgba; } diff --git a/src/mesa/pipe/softpipe/sp_surface.h b/src/mesa/pipe/softpipe/sp_surface.h index af6533d4f0..359a438c86 100644 --- a/src/mesa/pipe/softpipe/sp_surface.h +++ b/src/mesa/pipe/softpipe/sp_surface.h @@ -46,20 +46,33 @@ struct softpipe_tile_cache; struct softpipe_surface { struct pipe_surface surface; +#if 0 /* XXX these are temporary here */ void (*get_tile)(struct pipe_surface *ps, uint x, uint y, uint w, uint h, float *p); void (*put_tile)(struct pipe_surface *ps, uint x, uint y, uint w, uint h, const float *p); +#endif }; - extern struct pipe_surface * softpipe_get_tex_surface(struct pipe_context *pipe, struct pipe_mipmap_tree *mt, unsigned face, unsigned level, unsigned zslice); +extern void +softpipe_get_tile_rgba(struct pipe_context *pipe, + struct pipe_surface *ps, + uint x, uint y, uint w, uint h, + float *p); + +extern void +softpipe_put_tile_rgba(struct pipe_context *pipe, + struct pipe_surface *ps, + uint x, uint y, uint w, uint h, + const float *p); + extern void softpipe_init_surface_funcs(struct softpipe_surface *sps); diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index f22132b3cf..160edc4274 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -84,7 +84,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, cpp = info->size; if (!strb->surface) { - strb->surface = pipe->surface_alloc(pipe, pipeFormat); + strb->surface = pipe->winsys->surface_alloc(pipe->winsys, pipeFormat); assert(strb->surface); if (!strb->surface) return GL_FALSE; -- cgit v1.2.3 From 3c8121967224f91bfcd5431b4069d66eecbc5952 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sun, 28 Oct 2007 17:19:39 +0000 Subject: Replace supported_formats with is_format_supported interface. The old supported_formats interface returned a list of formats supported by a pipe/winsys implementation. This was reasonable when gallium had a fixed list of predefined format. Now things has changed and the definition of PIPE_FORMAT is more flexible. The new shiny is_format_supported interface gets PIPE_FORMAT as an argument and returns a boolean whether this particular format is supported. --- src/mesa/drivers/x11/xm_api.c | 2 +- src/mesa/drivers/x11/xm_surface.c | 18 ++++---- src/mesa/drivers/x11/xmesaP.h | 4 +- src/mesa/pipe/failover/fo_context.c | 2 +- src/mesa/pipe/i915simple/i915_context.c | 24 +++++------ src/mesa/pipe/p_context.h | 4 +- src/mesa/pipe/softpipe/sp_context.c | 12 +++--- src/mesa/pipe/softpipe/sp_winsys.h | 4 +- src/mesa/state_tracker/st_cb_drawpixels.c | 33 +++++++-------- src/mesa/state_tracker/st_format.c | 70 ++++++++++++------------------- 10 files changed, 75 insertions(+), 98 deletions(-) (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 1d2b93d100..4b31447bbd 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1616,7 +1616,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) #if 0 mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc; #endif - mesaCtx->st->pipe->supported_formats = xmesa_supported_formats; + mesaCtx->st->pipe->is_format_supported = xmesa_is_format_supported; mesaCtx->st->pipe->get_tile_rgba = xmesa_get_tile_rgba; mesaCtx->st->pipe->put_tile_rgba = xmesa_put_tile_rgba; diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index dbbf26e33f..5533158ece 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -195,18 +195,16 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) } -const GLuint * -xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats) +boolean +xmesa_is_format_supported(struct pipe_context *pipe, uint format) { - static const GLuint formats[] = { - PIPE_FORMAT_U_A8_R8_G8_B8, - PIPE_FORMAT_S_R16_G16_B16_A16, - PIPE_FORMAT_S8_Z24 + switch( format ) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + case PIPE_FORMAT_S_R16_G16_B16_A16: + case PIPE_FORMAT_S8_Z24: + return TRUE; }; - - *numFormats = sizeof(formats) / sizeof(formats[0]); - - return formats; + return FALSE; } diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 8af95504fb..4709d63394 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -618,8 +618,8 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint format); extern struct pipe_surface * xmesa_new_color_surface(struct pipe_context *pipe, GLuint format); -extern const uint * -xmesa_supported_formats(struct pipe_context *pipe, uint *numFormats); +extern boolean +xmesa_is_format_supported(struct pipe_context *pipe, uint format); extern void xmesa_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps, diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c index 7e02b751bb..aa5d0885e6 100644 --- a/src/mesa/pipe/failover/fo_context.c +++ b/src/mesa/pipe/failover/fo_context.c @@ -116,7 +116,7 @@ struct pipe_context *failover_create( struct pipe_context *hw, failover->pipe.winsys = hw->winsys; failover->pipe.destroy = failover_destroy; - failover->pipe.supported_formats = hw->supported_formats; + failover->pipe.is_format_supported = hw->is_format_supported; failover->pipe.max_texture_size = hw->max_texture_size; failover->pipe.get_name = hw->get_name; failover->pipe.get_vendor = hw->get_vendor; diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 161f8ce697..6541f0e848 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -40,16 +40,16 @@ /** - * Return list of supported surface/texture formats. + * Query format support. * If we find texture and drawable support differs, add a selector * parameter or another function. */ -static const unsigned * -i915_supported_formats(struct pipe_context *pipe, -// unsigned type, - unsigned *numFormats) +static boolean +i915_is_format_supported( struct pipe_context *pipe, + uint format ) { #if 0 + /* XXX: This is broken -- rewrite if still needed. */ static const unsigned tex_supported[] = { PIPE_FORMAT_U_R8_G8_B8_A8, PIPE_FORMAT_U_A8_R8_G8_B8, @@ -97,13 +97,13 @@ i915_supported_formats(struct pipe_context *pipe, return NULL; } #else - static const unsigned render_supported[] = { - PIPE_FORMAT_U_A8_R8_G8_B8, - PIPE_FORMAT_U_R5_G6_B5, - PIPE_FORMAT_S8_Z24, + switch( format ) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + case PIPE_FORMAT_U_R5_G6_B5: + case PIPE_FORMAT_S8_Z24: + return TRUE; }; - *numFormats = 3; - return render_supported; + return FALSE; #endif } @@ -303,7 +303,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys, i915->pipe.winsys = pipe_winsys; i915->pipe.destroy = i915_destroy; - i915->pipe.supported_formats = i915_supported_formats; + i915->pipe.is_format_supported = i915_is_format_supported; i915->pipe.max_texture_size = i915_max_texture_size; i915->pipe.get_param = i915_get_param; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index dbbf48c576..a1441a7e43 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -44,8 +44,8 @@ struct pipe_context { /* * Queries */ - const unsigned *(*supported_formats)(struct pipe_context *pipe, - unsigned *numFormats); + boolean (*is_format_supported)( struct pipe_context *pipe, + uint format ); void (*max_texture_size)(struct pipe_context *pipe, unsigned textureType, /* PIPE_TEXTURE_x */ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 3a1861cb62..f67588783b 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -46,14 +46,16 @@ /** - * Return list of supported surface/texture formats. + * Query format support. * If we find texture and drawable support differs, add a selector * parameter or another function. */ -static const unsigned * -softpipe_supported_formats(struct pipe_context *pipe, unsigned *numFormats) +static boolean +softpipe_is_format_supported( struct pipe_context *pipe, + uint format ) { #if 0 + /* XXX: This is broken -- rewrite if still needed. */ static const unsigned supported[] = { PIPE_FORMAT_U_R8_G8_B8_A8, PIPE_FORMAT_U_A8_R8_G8_B8, @@ -76,7 +78,7 @@ softpipe_supported_formats(struct pipe_context *pipe, unsigned *numFormats) return supported; #else struct softpipe_context *softpipe = softpipe_context( pipe ); - return softpipe->winsys->supported_formats( softpipe->winsys, numFormats ); + return softpipe->winsys->is_format_supported( softpipe->winsys, format ); #endif } @@ -298,7 +300,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.destroy = softpipe_destroy; /* queries */ - softpipe->pipe.supported_formats = softpipe_supported_formats; + softpipe->pipe.is_format_supported = softpipe_is_format_supported; softpipe->pipe.max_texture_size = softpipe_max_texture_size; softpipe->pipe.get_param = softpipe_get_param; diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h index 726e4c8bb6..d8ae971188 100644 --- a/src/mesa/pipe/softpipe/sp_winsys.h +++ b/src/mesa/pipe/softpipe/sp_winsys.h @@ -35,8 +35,8 @@ */ struct softpipe_winsys { - const unsigned *(*supported_formats)(struct softpipe_winsys *sws, - unsigned *numFormats); + boolean (*is_format_supported)( struct softpipe_winsys *sws, + uint format ); }; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 896ba2b905..99e1e3ed25 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -937,31 +937,26 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, { struct pipe_context *pipe = ctx->st->pipe; const uint flags = PIPE_SURFACE_FLAG_TEXTURE; - uint numFormats, i, format = 0, cpp, comp, pitch; - const uint *formats = ctx->st->pipe->supported_formats(pipe, &numFormats); + uint format = 0, cpp, comp, pitch; ubyte *dest; struct pipe_mipmap_tree *mt; int row, col; /* find a texture format we know */ - for (i = 0; i < numFormats; i++) { - switch (formats[i]) { - case PIPE_FORMAT_U_I8: - format = formats[i]; - cpp = 1; - comp = 0; - break; - case PIPE_FORMAT_U_A8_R8_G8_B8: - format = formats[i]; - cpp = 4; - comp = 3; /* alpha channel */ /*XXX little-endian dependency */ - break; - default: - /* XXX support more formats */ - ; - } + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8 )) { + format = PIPE_FORMAT_U_I8; + cpp = 1; + comp = 0; + } + else if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) { + format = PIPE_FORMAT_U_A8_R8_G8_B8; + cpp = 4; + comp = 3; /* alpha channel */ /*XXX little-endian dependency */ + } + else { + /* XXX support more formats */ + assert( 0 ); } - assert(format); /** * Create a mipmap tree. diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 5a50d2d63a..c0e1a79bad 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -342,24 +342,6 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat) } } -/* XXX: This function should be implemented by pipe object. */ -static GLboolean -allow_format( - struct pipe_context *pipe, - unsigned format ) -{ - const GLuint *supported; - GLuint i, n; - - supported = pipe->supported_formats( pipe, &n ); - for (i = 0; i < n; i++) { - if (supported[i] == format) { - return GL_TRUE; - } - } - return GL_FALSE; -} - /** * Search list of formats for first RGBA format. */ @@ -367,13 +349,13 @@ static GLuint default_rgba_format( struct pipe_context *pipe ) { - if (allow_format( pipe, PIPE_FORMAT_U_R8_G8_B8_A8 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R8_G8_B8_A8 )) { return PIPE_FORMAT_U_R8_G8_B8_A8; } - if (allow_format( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) { return PIPE_FORMAT_U_A8_R8_G8_B8; } - if (allow_format( pipe, PIPE_FORMAT_U_R5_G6_B5 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R5_G6_B5 )) { return PIPE_FORMAT_U_R5_G6_B5; } return PIPE_FORMAT_NONE; @@ -387,7 +369,7 @@ static GLuint default_deep_rgba_format( struct pipe_context *pipe ) { - if (allow_format( pipe, PIPE_FORMAT_S_R16_G16_B16_A16 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S_R16_G16_B16_A16 )) { return PIPE_FORMAT_S_R16_G16_B16_A16; } return PIPE_FORMAT_NONE; @@ -401,13 +383,13 @@ static GLuint default_depth_format( struct pipe_context *pipe ) { - if (allow_format( pipe, PIPE_FORMAT_U_Z16 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z16 )) { return PIPE_FORMAT_U_Z16; } - if (allow_format( pipe, PIPE_FORMAT_U_Z32 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z32 )) { return PIPE_FORMAT_U_Z32; } - if (allow_format( pipe, PIPE_FORMAT_S8_Z24 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) { return PIPE_FORMAT_S8_Z24; } return PIPE_FORMAT_NONE; @@ -437,15 +419,15 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_COMPRESSED_RGBA: if (format == GL_BGRA) { if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) { - if (allow_format( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) return PIPE_FORMAT_U_A8_R8_G8_B8; } else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) { - if (allow_format( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 )) return PIPE_FORMAT_U_A4_R4_G4_B4; } else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { - if (allow_format( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) return PIPE_FORMAT_U_A1_R5_G5_B5; } } @@ -455,7 +437,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_RGB: case GL_COMPRESSED_RGB: if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { - if (allow_format( pipe, PIPE_FORMAT_U_R5_G6_B5 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R5_G6_B5 )) return PIPE_FORMAT_U_R5_G6_B5; } return default_rgba_format( pipe ); @@ -469,12 +451,12 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_RGBA4: case GL_RGBA2: - if (allow_format( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 )) return PIPE_FORMAT_U_A4_R4_G4_B4; return default_rgba_format( pipe ); case GL_RGB5_A1: - if (allow_format( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) return PIPE_FORMAT_U_A1_R5_G5_B5; return default_rgba_format( pipe ); @@ -487,7 +469,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_RGB5: case GL_RGB4: case GL_R3_G3_B2: - if (allow_format( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) return PIPE_FORMAT_U_A1_R5_G5_B5; return default_rgba_format( pipe ); @@ -497,7 +479,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_ALPHA12: case GL_ALPHA16: case GL_COMPRESSED_ALPHA: - if (allow_format( pipe, PIPE_FORMAT_U_A8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8 )) return PIPE_FORMAT_U_A8; return default_rgba_format( pipe ); @@ -508,7 +490,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_LUMINANCE12: case GL_LUMINANCE16: case GL_COMPRESSED_LUMINANCE: - if (allow_format( pipe, PIPE_FORMAT_U_A8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8 )) return PIPE_FORMAT_U_A8; return default_rgba_format( pipe ); @@ -521,7 +503,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: case GL_COMPRESSED_LUMINANCE_ALPHA: - if (allow_format( pipe, PIPE_FORMAT_U_A8_L8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_L8 )) return PIPE_FORMAT_U_A8_L8; return default_rgba_format( pipe ); @@ -531,17 +513,17 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_INTENSITY12: case GL_INTENSITY16: case GL_COMPRESSED_INTENSITY: - if (allow_format( pipe, PIPE_FORMAT_U_I8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8 )) return PIPE_FORMAT_U_I8; return default_rgba_format( pipe ); case GL_YCBCR_MESA: if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE) { - if (allow_format( pipe, PIPE_FORMAT_YCBCR )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR )) return PIPE_FORMAT_YCBCR; } else { - if (allow_format( pipe, PIPE_FORMAT_YCBCR_REV )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR_REV )) return PIPE_FORMAT_YCBCR_REV; } return PIPE_FORMAT_NONE; @@ -570,15 +552,15 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, #endif case GL_DEPTH_COMPONENT16: - if (allow_format( pipe, PIPE_FORMAT_U_Z16 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z16 )) return PIPE_FORMAT_U_Z16; /* fall-through */ case GL_DEPTH_COMPONENT24: - if (allow_format( pipe, PIPE_FORMAT_S8_Z24 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; /* fall-through */ case GL_DEPTH_COMPONENT32: - if (allow_format( pipe, PIPE_FORMAT_U_Z32 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z32 )) return PIPE_FORMAT_U_Z32; /* fall-through */ case GL_DEPTH_COMPONENT: @@ -589,15 +571,15 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_STENCIL_INDEX4_EXT: case GL_STENCIL_INDEX8_EXT: case GL_STENCIL_INDEX16_EXT: - if (allow_format( pipe, PIPE_FORMAT_U_S8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_S8 )) return PIPE_FORMAT_U_S8; - if (allow_format( pipe, PIPE_FORMAT_S8_Z24 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; return PIPE_FORMAT_NONE; case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - if (allow_format( pipe, PIPE_FORMAT_S8_Z24 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; return PIPE_FORMAT_NONE; -- cgit v1.2.3 From 6acd63a4980951727939c0dd545a0324965b3834 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 15 Feb 2008 17:50:12 +0900 Subject: Code reorganization: update build. Update the Makefiles and includes for the new paths. Note that there hasn't been no separation of the Makefiles yet, and make is jumping all over the place. That will be taken care shortly. But for now, make should work. It was tested with linux and linux-dri. Linux-cell and linux-llvm might require some minor tweaks. --- configs/beos | 2 +- configs/darwin | 2 +- configs/darwin-x86ppc | 2 +- configs/default | 2 +- configs/freebsd-dri | 2 +- configs/linux-cell | 2 +- configs/linux-directfb | 2 +- configs/linux-dri | 6 +- configs/linux-dri-xcb | 4 +- configs/linux-fbdev | 2 +- configs/linux-osmesa | 2 +- configs/linux-osmesa16 | 2 +- configs/linux-osmesa16-static | 2 +- configs/linux-osmesa32 | 2 +- configs/linux-solo | 2 +- src/gallium/Makefile | 12 +-- src/gallium/Makefile.template | 7 +- src/gallium/aux/Makefile | 24 +++++ src/gallium/aux/draw/draw_private.h | 2 +- src/gallium/aux/draw/draw_vertex.c | 4 +- src/gallium/aux/draw/draw_vertex_shader.c | 4 +- src/gallium/aux/llvm/Makefile | 4 +- src/gallium/aux/llvm/gallivm.cpp | 4 +- src/gallium/aux/llvm/gallivm_cpu.cpp | 4 +- src/gallium/aux/llvm/tgsitollvm.cpp | 10 +- src/gallium/aux/pipebuffer/Makefile | 2 +- src/gallium/aux/tgsi/exec/tgsi_exec.c | 4 +- src/gallium/aux/tgsi/exec/tgsi_sse2.c | 4 +- src/gallium/aux/tgsi/util/tgsi_transform.h | 4 +- src/gallium/drivers/Makefile | 24 +++++ src/gallium/drivers/cell/ppu/Makefile | 7 +- src/gallium/drivers/cell/ppu/cell_clear.c | 2 +- src/gallium/drivers/cell/ppu/cell_context.c | 6 +- src/gallium/drivers/cell/ppu/cell_context.h | 6 +- src/gallium/drivers/cell/ppu/cell_draw_arrays.c | 2 +- src/gallium/drivers/cell/ppu/cell_flush.c | 2 +- src/gallium/drivers/cell/ppu/cell_render.c | 2 +- src/gallium/drivers/cell/ppu/cell_spu.c | 2 +- src/gallium/drivers/cell/ppu/cell_spu.h | 2 +- src/gallium/drivers/cell/ppu/cell_state_blend.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_clip.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_derived.c | 4 +- src/gallium/drivers/cell/ppu/cell_state_fs.c | 8 +- .../drivers/cell/ppu/cell_state_rasterizer.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_sampler.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_vertex.c | 2 +- src/gallium/drivers/cell/ppu/cell_surface.c | 2 +- src/gallium/drivers/cell/ppu/cell_vbuf.c | 2 +- src/gallium/drivers/cell/ppu/cell_vertex_shader.c | 6 +- src/gallium/drivers/cell/spu/Makefile | 6 +- src/gallium/drivers/cell/spu/spu_exec.c | 4 +- src/gallium/drivers/cell/spu/spu_exec.h | 2 +- src/gallium/drivers/cell/spu/spu_main.c | 2 +- src/gallium/drivers/cell/spu/spu_main.h | 4 +- src/gallium/drivers/cell/spu/spu_render.c | 2 +- src/gallium/drivers/cell/spu/spu_render.h | 2 +- src/gallium/drivers/cell/spu/spu_tile.h | 2 +- src/gallium/drivers/cell/spu/spu_util.c | 4 +- src/gallium/drivers/cell/spu/spu_vertex_shader.c | 6 +- src/gallium/drivers/failover/Makefile | 2 +- src/gallium/drivers/i915simple/Makefile | 2 +- src/gallium/drivers/i915simple/i915_context.c | 2 +- src/gallium/drivers/i915simple/i915_context.h | 2 +- .../drivers/i915simple/i915_fpc_translate.c | 4 +- src/gallium/drivers/i915simple/i915_prim_emit.c | 2 +- src/gallium/drivers/i915simple/i915_prim_vbuf.c | 2 +- src/gallium/drivers/i915simple/i915_state.c | 2 +- .../drivers/i915simple/i915_state_derived.c | 4 +- src/gallium/drivers/i915simple/i915_strings.c | 2 +- src/gallium/drivers/i915simple/i915_surface.c | 2 +- src/gallium/drivers/i965simple/Makefile | 2 +- src/gallium/drivers/i965simple/brw_shader_info.c | 2 +- src/gallium/drivers/i965simple/brw_state.c | 2 +- src/gallium/drivers/i965simple/brw_strings.c | 2 +- src/gallium/drivers/i965simple/brw_surface.c | 2 +- src/gallium/drivers/i965simple/brw_vs_emit.c | 2 +- src/gallium/drivers/i965simple/brw_wm_decl.c | 2 +- src/gallium/drivers/i965simple/brw_wm_glsl.c | 2 +- src/gallium/drivers/softpipe/Makefile | 2 +- src/gallium/drivers/softpipe/sp_context.c | 2 +- src/gallium/drivers/softpipe/sp_context.h | 2 +- src/gallium/drivers/softpipe/sp_draw_arrays.c | 2 +- src/gallium/drivers/softpipe/sp_flush.c | 2 +- src/gallium/drivers/softpipe/sp_headers.h | 2 +- src/gallium/drivers/softpipe/sp_prim_setup.c | 4 +- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 6 +- src/gallium/drivers/softpipe/sp_quad_fs.c | 2 +- src/gallium/drivers/softpipe/sp_query.c | 2 +- src/gallium/drivers/softpipe/sp_state_clip.c | 2 +- src/gallium/drivers/softpipe/sp_state_derived.c | 6 +- src/gallium/drivers/softpipe/sp_state_fs.c | 8 +- src/gallium/drivers/softpipe/sp_state_rasterizer.c | 2 +- src/gallium/drivers/softpipe/sp_state_sampler.c | 4 +- src/gallium/drivers/softpipe/sp_state_vertex.c | 2 +- src/gallium/drivers/softpipe/sp_surface.c | 2 +- src/gallium/drivers/softpipe/sp_tex_sample.c | 2 +- src/gallium/drivers/softpipe/sp_tile_cache.c | 2 +- src/gallium/winsys/dri/Makefile | 38 +++++++ src/gallium/winsys/dri/Makefile.template | 113 +++++++++++++++++++++ src/gallium/winsys/dri/intel/Makefile | 8 +- src/gallium/winsys/dri/intel/intel_winsys_i915.c | 2 +- .../winsys/dri/intel/intel_winsys_softpipe.c | 2 +- src/gallium/winsys/xlib/xm_winsys.c | 6 +- src/gallium/winsys/xlib/xm_winsys_aub.c | 2 +- src/mesa/Makefile | 16 ++- src/mesa/drivers/x11/xm_api.c | 2 +- src/mesa/drivers/x11/xm_dd.c | 2 +- src/mesa/drivers/x11/xm_surface.c | 8 +- src/mesa/drivers/x11/xm_winsys.c | 2 +- src/mesa/drivers/x11/xmesaP.h | 4 +- src/mesa/sources | 83 +++++++-------- src/mesa/state_tracker/st_atom_shader.c | 2 +- src/mesa/state_tracker/st_cache.c | 4 +- src/mesa/state_tracker/st_cache.h | 2 +- src/mesa/state_tracker/st_cb_accum.c | 2 +- src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_cb_feedback.c | 6 +- src/mesa/state_tracker/st_cb_program.c | 4 +- src/mesa/state_tracker/st_cb_rasterpos.c | 4 +- src/mesa/state_tracker/st_cb_readpixels.c | 2 +- src/mesa/state_tracker/st_cb_texture.c | 2 +- src/mesa/state_tracker/st_context.c | 4 +- src/mesa/state_tracker/st_debug.c | 4 +- src/mesa/state_tracker/st_draw.c | 4 +- src/mesa/state_tracker/st_gen_mipmap.c | 2 +- src/mesa/state_tracker/st_mesa_to_tgsi.c | 6 +- src/mesa/state_tracker/st_program.c | 4 +- 127 files changed, 445 insertions(+), 241 deletions(-) create mode 100644 src/gallium/aux/Makefile create mode 100644 src/gallium/drivers/Makefile create mode 100644 src/gallium/winsys/dri/Makefile create mode 100644 src/gallium/winsys/dri/Makefile.template (limited to 'src/mesa/drivers/x11/xmesaP.h') diff --git a/configs/beos b/configs/beos index f07973d0c7..2b74af739d 100644 --- a/configs/beos +++ b/configs/beos @@ -86,7 +86,7 @@ else endif # Directories -SRC_DIRS = mesa glu glut/beos +SRC_DIRS = gallium mesa glu glut/beos GLU_DIRS = sgi DRIVER_DIRS = beos PROGRAM_DIRS = beos samples redbook demos tests diff --git a/configs/darwin b/configs/darwin index 7826ecc605..bba7802696 100644 --- a/configs/darwin +++ b/configs/darwin @@ -25,5 +25,5 @@ GLW_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXt $(TOP)/lib/GL.dylib APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm # omit glw lib for now: -SRC_DIRS = mesa glu glut/glx +SRC_DIRS = gallium mesa glu glut/glx diff --git a/configs/darwin-x86ppc b/configs/darwin-x86ppc index 13172327a7..ebeb25051f 100644 --- a/configs/darwin-x86ppc +++ b/configs/darwin-x86ppc @@ -29,5 +29,5 @@ GLW_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXt $(TOP)/lib/GL.dylib APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm # omit glw lib for now: -SRC_DIRS = mesa glu glut/glx +SRC_DIRS = gallium mesa glu glut/glx diff --git a/configs/default b/configs/default index 166205a1d3..25a87e66a1 100644 --- a/configs/default +++ b/configs/default @@ -60,7 +60,7 @@ GLW_SOURCES = GLwDrawA.c # Directories to build LIB_DIR = lib -SRC_DIRS = mesa glu glut/glx glw +SRC_DIRS = gallium mesa glu glut/glx glw GLU_DIRS = sgi DRIVER_DIRS = x11 osmesa # Which subdirs under $(TOP)/progs/ to enter: diff --git a/configs/freebsd-dri b/configs/freebsd-dri index 402883d1de..67d253b869 100644 --- a/configs/freebsd-dri +++ b/configs/freebsd-dri @@ -36,7 +36,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -lGL -lXt -lX11 # Directories -SRC_DIRS = glx/x11 mesa glu glut/glx glw +SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw DRIVER_DIRS = dri PROGRAM_DIRS = WINDOW_SYSTEM=dri diff --git a/configs/linux-cell b/configs/linux-cell index 3d874491e4..fdf20deeeb 100644 --- a/configs/linux-cell +++ b/configs/linux-cell @@ -21,7 +21,7 @@ CFLAGS = $(OPT_FLAGS) -Wall -Winline -fPIC -m32 -mabi=altivec -maltivec -I. -I$( CXXFLAGS = $(CFLAGS) # Omitting glw here: -SRC_DIRS = mesa glu glut/glx +SRC_DIRS = gallium mesa glu glut/glx MKDEP_OPTIONS = -fdepend -Y diff --git a/configs/linux-directfb b/configs/linux-directfb index 09332f4808..dff27f7850 100644 --- a/configs/linux-directfb +++ b/configs/linux-directfb @@ -22,7 +22,7 @@ ifeq ($(HAVE_X86), yes) endif # Directories -SRC_DIRS = mesa glu glut/directfb +SRC_DIRS = gallium mesa glu glut/directfb GLU_DIRS = sgi DRIVER_DIRS = directfb PROGRAM_DIRS = demos directfb diff --git a/configs/linux-dri b/configs/linux-dri index 936fce9982..e6135856fc 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -54,10 +54,10 @@ USING_EGL=0 # Directories ifeq ($(USING_EGL), 1) -SRC_DIRS = egl glx/x11 mesa glu glut/glx glw +SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glw PROGRAM_DIRS = egl else -SRC_DIRS = glx/x11 mesa glu glut/glx glw +SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw PROGRAM_DIRS = endif @@ -66,4 +66,4 @@ WINDOW_SYSTEM=dri # gamma are missing because they have not been converted to use the new # interface. -DRI_DIRS = intel_winsys +DRI_DIRS = intel diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb index aa292a13ec..ea4bdf1864 100644 --- a/configs/linux-dri-xcb +++ b/configs/linux-dri-xcb @@ -53,10 +53,10 @@ USING_EGL=0 # Directories ifeq ($(USING_EGL), 1) -SRC_DIRS = egl glx/x11 mesa glu glut/glx glw +SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glw PROGRAM_DIRS = egl else -SRC_DIRS = glx/x11 mesa glu glut/glx glw +SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw PROGRAM_DIRS = endif diff --git a/configs/linux-fbdev b/configs/linux-fbdev index e36d20a702..1ddccb3f52 100644 --- a/configs/linux-fbdev +++ b/configs/linux-fbdev @@ -6,7 +6,7 @@ CONFIG_NAME = linux-fbdev CFLAGS = -O3 -ffast-math -ansi -pedantic -fPIC -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS -DUSE_GLFBDEV_DRIVER -SRC_DIRS = mesa glu glut/fbdev +SRC_DIRS = gallium mesa glu glut/fbdev DRIVER_DIRS = fbdev osmesa PROGRAM_DIRS = fbdev demos redbook samples diff --git a/configs/linux-osmesa b/configs/linux-osmesa index cc1fbbd109..0382a19553 100644 --- a/configs/linux-osmesa +++ b/configs/linux-osmesa @@ -14,7 +14,7 @@ CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOUR # Directories -SRC_DIRS = mesa glu +SRC_DIRS = gallium mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = osdemos diff --git a/configs/linux-osmesa16 b/configs/linux-osmesa16 index 1fb0186d31..9a527592f1 100644 --- a/configs/linux-osmesa16 +++ b/configs/linux-osmesa16 @@ -17,7 +17,7 @@ OSMESA_LIB_NAME = libOSMesa16.so # Directories -SRC_DIRS = mesa glu +SRC_DIRS = gallium mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = diff --git a/configs/linux-osmesa16-static b/configs/linux-osmesa16-static index 6645504478..1e6380b02e 100644 --- a/configs/linux-osmesa16-static +++ b/configs/linux-osmesa16-static @@ -18,7 +18,7 @@ OSMESA_LIB_NAME = libOSMesa16.a # Directories -SRC_DIRS = mesa glu +SRC_DIRS = gallium mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = diff --git a/configs/linux-osmesa32 b/configs/linux-osmesa32 index a1e5a358d6..f0ef1831b0 100644 --- a/configs/linux-osmesa32 +++ b/configs/linux-osmesa32 @@ -17,7 +17,7 @@ OSMESA_LIB_NAME = libOSMesa32.so # Directories -SRC_DIRS = mesa glu +SRC_DIRS = gallium mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = diff --git a/configs/linux-solo b/configs/linux-solo index 220fe58b9a..d49b972228 100644 --- a/configs/linux-solo +++ b/configs/linux-solo @@ -43,7 +43,7 @@ GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lpthread # Directories -SRC_DIRS = glx/mini mesa glu glut/mini +SRC_DIRS = glx/mini gallium mesa glu glut/mini DRIVER_DIRS = dri PROGRAM_DIRS = miniglx diff --git a/src/gallium/Makefile b/src/gallium/Makefile index d880d090c1..a13b9a52d3 100644 --- a/src/gallium/Makefile +++ b/src/gallium/Makefile @@ -1,16 +1,8 @@ -TOP = ../../.. +TOP = ../.. include $(TOP)/configs/current -ifeq ($(CONFIG_NAME), linux-cell) -CELL_DIR = cell -endif - -ifeq ($(CONFIG_NAME), linux-llvm) -LLVM_DIR = llvm -endif - -SUBDIRS = softpipe i915simple i965simple failover pipebuffer $(CELL_DIR) $(LLVM_DIR) +SUBDIRS = aux drivers default: subdirs diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 8e84f8eb2d..0717ed8dd2 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -15,7 +15,10 @@ OBJECTS = $(C_SOURCES:.c=.o) \ ### Include directories INCLUDES = \ -I. \ - -I$(TOP)/src/mesa/pipe \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/include/pipe \ + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/mesa \ -I$(TOP)/include \ $(DRIVER_INCLUDES) @@ -38,7 +41,7 @@ INCLUDES = \ default: depend symlinks $(LIBNAME) -$(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/mesa/pipe/Makefile.template +$(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template $(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS) diff --git a/src/gallium/aux/Makefile b/src/gallium/aux/Makefile new file mode 100644 index 0000000000..da68498aa1 --- /dev/null +++ b/src/gallium/aux/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +include $(TOP)/configs/current + + +ifeq ($(CONFIG_NAME), linux-llvm) +LLVM_DIR = llvm +endif + +SUBDIRS = pipebuffer $(LLVM_DIR) + + +default: subdirs + + +subdirs: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1 ; \ + fi \ + done + + +clean: + rm -f `find . -name \*.[oa]` diff --git a/src/gallium/aux/draw/draw_private.h b/src/gallium/aux/draw/draw_private.h index b17eaaed65..3d09aef87c 100644 --- a/src/gallium/aux/draw/draw_private.h +++ b/src/gallium/aux/draw/draw_private.h @@ -45,7 +45,7 @@ #include "pipe/p_defines.h" #include "x86/rtasm/x86sse.h" -#include "pipe/tgsi/exec/tgsi_exec.h" +#include "tgsi/exec/tgsi_exec.h" struct gallivm_prog; diff --git a/src/gallium/aux/draw/draw_vertex.c b/src/gallium/aux/draw/draw_vertex.c index 2d6592150f..daf1ef4b80 100644 --- a/src/gallium/aux/draw/draw_vertex.c +++ b/src/gallium/aux/draw/draw_vertex.c @@ -34,8 +34,8 @@ */ -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_private.h" +#include "draw/draw_vertex.h" /** diff --git a/src/gallium/aux/draw/draw_vertex_shader.c b/src/gallium/aux/draw/draw_vertex_shader.c index c824c1407e..377ecbb931 100644 --- a/src/gallium/aux/draw/draw_vertex_shader.c +++ b/src/gallium/aux/draw/draw_vertex_shader.c @@ -34,13 +34,13 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" #if defined(__i386__) || defined(__386__) -#include "pipe/tgsi/exec/tgsi_sse2.h" +#include "tgsi/exec/tgsi_sse2.h" #endif #include "draw_private.h" #include "draw_context.h" #include "x86/rtasm/x86sse.h" -#include "pipe/llvm/gallivm.h" +#include "llvm/gallivm.h" #define DBG_VS 0 diff --git a/src/gallium/aux/llvm/Makefile b/src/gallium/aux/llvm/Makefile index 9c6e16d86b..e6ac399d08 100644 --- a/src/gallium/aux/llvm/Makefile +++ b/src/gallium/aux/llvm/Makefile @@ -30,7 +30,9 @@ OBJECTS = $(C_SOURCES:.c=.o) \ ### Include directories INCLUDES = \ -I. \ - -I$(TOP)/src/mesa/pipe \ + -I$(TOP)/src/gallium/drivers + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/include \ -I$(TOP)/src/mesa \ -I$(TOP)/include diff --git a/src/gallium/aux/llvm/gallivm.cpp b/src/gallium/aux/llvm/gallivm.cpp index da0105c2c9..d14bb3b99a 100644 --- a/src/gallium/aux/llvm/gallivm.cpp +++ b/src/gallium/aux/llvm/gallivm.cpp @@ -42,8 +42,8 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/exec/tgsi_exec.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/exec/tgsi_exec.h" +#include "tgsi/util/tgsi_dump.h" #include #include diff --git a/src/gallium/aux/llvm/gallivm_cpu.cpp b/src/gallium/aux/llvm/gallivm_cpu.cpp index dc4d92a72a..8f9830d0b1 100644 --- a/src/gallium/aux/llvm/gallivm_cpu.cpp +++ b/src/gallium/aux/llvm/gallivm_cpu.cpp @@ -42,8 +42,8 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/exec/tgsi_exec.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/exec/tgsi_exec.h" +#include "tgsi/util/tgsi_dump.h" #include #include diff --git a/src/gallium/aux/llvm/tgsitollvm.cpp b/src/gallium/aux/llvm/tgsitollvm.cpp index 0de595e678..2cb4acce32 100644 --- a/src/gallium/aux/llvm/tgsitollvm.cpp +++ b/src/gallium/aux/llvm/tgsitollvm.cpp @@ -10,11 +10,11 @@ #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/exec/tgsi_exec.h" -#include "pipe/tgsi/util/tgsi_util.h" -#include "pipe/tgsi/util/tgsi_build.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/exec/tgsi_exec.h" +#include "tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_build.h" +#include "tgsi/util/tgsi_dump.h" #include diff --git a/src/gallium/aux/pipebuffer/Makefile b/src/gallium/aux/pipebuffer/Makefile index 75764a9a18..588629e870 100644 --- a/src/gallium/aux/pipebuffer/Makefile +++ b/src/gallium/aux/pipebuffer/Makefile @@ -17,7 +17,7 @@ C_SOURCES = \ ASM_SOURCES = -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/aux/tgsi/exec/tgsi_exec.c b/src/gallium/aux/tgsi/exec/tgsi_exec.c index 37e6007068..a8f64c2287 100644 --- a/src/gallium/aux/tgsi/exec/tgsi_exec.c +++ b/src/gallium/aux/tgsi/exec/tgsi_exec.c @@ -54,8 +54,8 @@ #include "pipe/p_state.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_util.h" #include "tgsi_exec.h" #define TILE_TOP_LEFT 0 diff --git a/src/gallium/aux/tgsi/exec/tgsi_sse2.c b/src/gallium/aux/tgsi/exec/tgsi_sse2.c index 1e56e4afb6..593464db3e 100755 --- a/src/gallium/aux/tgsi/exec/tgsi_sse2.c +++ b/src/gallium/aux/tgsi/exec/tgsi_sse2.c @@ -27,8 +27,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_util.h" #include "tgsi_exec.h" #include "tgsi_sse2.h" diff --git a/src/gallium/aux/tgsi/util/tgsi_transform.h b/src/gallium/aux/tgsi/util/tgsi_transform.h index 365d8c298c..fcf85d603b 100644 --- a/src/gallium/aux/tgsi/util/tgsi_transform.h +++ b/src/gallium/aux/tgsi/util/tgsi_transform.h @@ -31,8 +31,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_build.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_build.h" diff --git a/src/gallium/drivers/Makefile b/src/gallium/drivers/Makefile new file mode 100644 index 0000000000..c0345a9cb5 --- /dev/null +++ b/src/gallium/drivers/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +include $(TOP)/configs/current + + +ifeq ($(CONFIG_NAME), linux-cell) +CELL_DIR = cell +endif + +SUBDIRS = softpipe i915simple i965simple failover pipebuffer $(CELL_DIR) + + +default: subdirs + + +subdirs: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1 ; \ + fi \ + done + + +clean: + rm -f `find . -name \*.[oa]` diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile index 50060f5cd3..011863c11e 100644 --- a/src/gallium/drivers/cell/ppu/Makefile +++ b/src/gallium/drivers/cell/ppu/Makefile @@ -40,8 +40,11 @@ SOURCES = \ OBJECTS = $(SOURCES:.c=.o) \ -INCLUDE_DIRS = -I$(TOP)/src/mesa - +INCLUDE_DIRS = \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/drivers .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c index 07b908eec5..e588a30d5b 100644 --- a/src/gallium/drivers/cell/ppu/cell_clear.c +++ b/src/gallium/drivers/cell/ppu/cell_clear.c @@ -35,7 +35,7 @@ #include #include "pipe/p_inlines.h" #include "pipe/p_util.h" -#include "pipe/cell/common.h" +#include "cell/common.h" #include "cell_clear.h" #include "cell_context.h" #include "cell_batch.h" diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index bbe1fd7a11..e1eb22f468 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -37,9 +37,9 @@ #include "pipe/p_format.h" #include "pipe/p_util.h" #include "pipe/p_winsys.h" -#include "pipe/cell/common.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" +#include "cell/common.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" #include "cell_clear.h" #include "cell_context.h" #include "cell_draw_arrays.h" diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index 3b63419b5e..6196c0c72f 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -32,10 +32,10 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "pipe/draw/draw_vertex.h" -#include "pipe/draw/draw_vbuf.h" +#include "draw/draw_vertex.h" +#include "draw/draw_vbuf.h" #include "cell_winsys.h" -#include "pipe/cell/common.h" +#include "cell/common.h" struct cell_vbuf_render; diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index 717cd8370f..f12613649b 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -39,7 +39,7 @@ #include "cell_draw_arrays.h" #include "cell_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" diff --git a/src/gallium/drivers/cell/ppu/cell_flush.c b/src/gallium/drivers/cell/ppu/cell_flush.c index f62bc4650c..20f27531fc 100644 --- a/src/gallium/drivers/cell/ppu/cell_flush.c +++ b/src/gallium/drivers/cell/ppu/cell_flush.c @@ -31,7 +31,7 @@ #include "cell_flush.h" #include "cell_spu.h" #include "cell_render.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void diff --git a/src/gallium/drivers/cell/ppu/cell_render.c b/src/gallium/drivers/cell/ppu/cell_render.c index 4ab277a4b2..b663b37622 100644 --- a/src/gallium/drivers/cell/ppu/cell_render.c +++ b/src/gallium/drivers/cell/ppu/cell_render.c @@ -34,7 +34,7 @@ #include "cell_render.h" #include "cell_spu.h" #include "pipe/p_util.h" -#include "pipe/draw/draw_private.h" +#include "draw/draw_private.h" struct render_stage { diff --git a/src/gallium/drivers/cell/ppu/cell_spu.c b/src/gallium/drivers/cell/ppu/cell_spu.c index 7c83a47e57..419e74dc40 100644 --- a/src/gallium/drivers/cell/ppu/cell_spu.c +++ b/src/gallium/drivers/cell/ppu/cell_spu.c @@ -31,7 +31,7 @@ #include "cell_spu.h" #include "pipe/p_format.h" #include "pipe/p_state.h" -#include "pipe/cell/common.h" +#include "cell/common.h" /* diff --git a/src/gallium/drivers/cell/ppu/cell_spu.h b/src/gallium/drivers/cell/ppu/cell_spu.h index 19eff94f96..137f26612e 100644 --- a/src/gallium/drivers/cell/ppu/cell_spu.h +++ b/src/gallium/drivers/cell/ppu/cell_spu.h @@ -31,7 +31,7 @@ #include #include -#include "pipe/cell/common.h" +#include "cell/common.h" #include "cell_context.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_blend.c b/src/gallium/drivers/cell/ppu/cell_state_blend.c index 4fc60548c8..b6d6d71f0c 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_blend.c +++ b/src/gallium/drivers/cell/ppu/cell_state_blend.c @@ -29,7 +29,7 @@ */ #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "cell_context.h" #include "cell_state.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_clip.c b/src/gallium/drivers/cell/ppu/cell_state_clip.c index 4f43665941..0482f87e88 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_clip.c +++ b/src/gallium/drivers/cell/ppu/cell_state_clip.c @@ -30,7 +30,7 @@ #include "cell_context.h" #include "cell_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void cell_set_clip_state( struct pipe_context *pipe, diff --git a/src/gallium/drivers/cell/ppu/cell_state_derived.c b/src/gallium/drivers/cell/ppu/cell_state_derived.c index 56daf5dfde..0c46829258 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_derived.c +++ b/src/gallium/drivers/cell/ppu/cell_state_derived.c @@ -27,8 +27,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_context.h" +#include "draw/draw_vertex.h" #include "cell_context.h" #include "cell_batch.h" #include "cell_state.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_fs.c b/src/gallium/drivers/cell/ppu/cell_state_fs.c index 3f46a87d18..b2ed699a5b 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_fs.c +++ b/src/gallium/drivers/cell/ppu/cell_state_fs.c @@ -29,12 +29,12 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #if 0 #include "pipe/p_shader_tokens.h" -#include "pipe/llvm/gallivm.h" -#include "pipe/tgsi/util/tgsi_dump.h" -#include "pipe/tgsi/exec/tgsi_sse2.h" +#include "llvm/gallivm.h" +#include "tgsi/util/tgsi_dump.h" +#include "tgsi/exec/tgsi_sse2.h" #endif #include "cell_context.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c b/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c index d8128ece54..7eca5b5765 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c +++ b/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c @@ -27,7 +27,7 @@ #include "pipe/p_defines.h" #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "cell_context.h" #include "cell_state.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_sampler.c b/src/gallium/drivers/cell/ppu/cell_state_sampler.c index ade6cc8338..a33421a4ad 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_sampler.c +++ b/src/gallium/drivers/cell/ppu/cell_state_sampler.c @@ -30,7 +30,7 @@ */ #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "cell_context.h" #include "cell_state.h" #include "cell_texture.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c index 0f01e920f9..563831b62d 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c +++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c @@ -32,7 +32,7 @@ #include "cell_context.h" #include "cell_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void diff --git a/src/gallium/drivers/cell/ppu/cell_surface.c b/src/gallium/drivers/cell/ppu/cell_surface.c index fca93e4742..a35db0ef99 100644 --- a/src/gallium/drivers/cell/ppu/cell_surface.c +++ b/src/gallium/drivers/cell/ppu/cell_surface.c @@ -29,7 +29,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "cell_context.h" #include "cell_surface.h" diff --git a/src/gallium/drivers/cell/ppu/cell_vbuf.c b/src/gallium/drivers/cell/ppu/cell_vbuf.c index e9fafe492e..cc727ff4ed 100644 --- a/src/gallium/drivers/cell/ppu/cell_vbuf.c +++ b/src/gallium/drivers/cell/ppu/cell_vbuf.c @@ -36,7 +36,7 @@ #include "cell_flush.h" #include "cell_spu.h" #include "cell_vbuf.h" -#include "pipe/draw/draw_vbuf.h" +#include "draw/draw_vbuf.h" /** Allow vertex data to be inlined after RENDER command */ diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c index 80dd500b34..0ba4506505 100644 --- a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c +++ b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c @@ -38,9 +38,9 @@ #include "cell_spu.h" #include "cell_batch.h" -#include "pipe/cell/common.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" +#include "cell/common.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" /** * Run the vertex shader on all vertices in the vertex queue. diff --git a/src/gallium/drivers/cell/spu/Makefile b/src/gallium/drivers/cell/spu/Makefile index f202971d73..7aa947299e 100644 --- a/src/gallium/drivers/cell/spu/Makefile +++ b/src/gallium/drivers/cell/spu/Makefile @@ -31,7 +31,11 @@ SPU_OBJECTS = $(SOURCES:.c=.o) \ SPU_ASM_OUT = $(SOURCES:.c=.s) \ -INCLUDE_DIRS = -I$(TOP)/src/mesa +INCLUDE_DIRS = \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/drivers .c.o: diff --git a/src/gallium/drivers/cell/spu/spu_exec.c b/src/gallium/drivers/cell/spu/spu_exec.c index e51008b9b3..109540b1f7 100644 --- a/src/gallium/drivers/cell/spu/spu_exec.c +++ b/src/gallium/drivers/cell/spu/spu_exec.c @@ -67,8 +67,8 @@ #include "pipe/p_state.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_util.h" #include "spu_exec.h" #include "spu_main.h" #include "spu_vertex_shader.h" diff --git a/src/gallium/drivers/cell/spu/spu_exec.h b/src/gallium/drivers/cell/spu/spu_exec.h index b4c7661ef6..3e17c490d2 100644 --- a/src/gallium/drivers/cell/spu/spu_exec.h +++ b/src/gallium/drivers/cell/spu/spu_exec.h @@ -29,7 +29,7 @@ #define SPU_EXEC_H #include "pipe/p_compiler.h" -#include "pipe/tgsi/exec/tgsi_exec.h" +#include "tgsi/exec/tgsi_exec.h" #if defined __cplusplus extern "C" { diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c index e375197fe6..1e7243b863 100644 --- a/src/gallium/drivers/cell/spu/spu_main.c +++ b/src/gallium/drivers/cell/spu/spu_main.c @@ -38,7 +38,7 @@ #include "spu_tile.h" //#include "spu_test.h" #include "spu_vertex_shader.h" -#include "pipe/cell/common.h" +#include "cell/common.h" #include "pipe/p_defines.h" diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h index 1710a17512..5c95d112ac 100644 --- a/src/gallium/drivers/cell/spu/spu_main.h +++ b/src/gallium/drivers/cell/spu/spu_main.h @@ -31,8 +31,8 @@ #include -#include "pipe/cell/common.h" -#include "pipe/draw/draw_vertex.h" +#include "cell/common.h" +#include "draw/draw_vertex.h" #include "pipe/p_state.h" diff --git a/src/gallium/drivers/cell/spu/spu_render.c b/src/gallium/drivers/cell/spu/spu_render.c index 932fb500b3..20e77aa2e6 100644 --- a/src/gallium/drivers/cell/spu/spu_render.c +++ b/src/gallium/drivers/cell/spu/spu_render.c @@ -34,7 +34,7 @@ #include "spu_render.h" #include "spu_tri.h" #include "spu_tile.h" -#include "pipe/cell/common.h" +#include "cell/common.h" diff --git a/src/gallium/drivers/cell/spu/spu_render.h b/src/gallium/drivers/cell/spu/spu_render.h index fbcdc5ec31..493434f087 100644 --- a/src/gallium/drivers/cell/spu/spu_render.h +++ b/src/gallium/drivers/cell/spu/spu_render.h @@ -29,7 +29,7 @@ #ifndef SPU_RENDER_H #define SPU_RENDER_H -#include "pipe/cell/common.h" +#include "cell/common.h" extern void cmd_render(const struct cell_command_render *render, uint *pos_incr); diff --git a/src/gallium/drivers/cell/spu/spu_tile.h b/src/gallium/drivers/cell/spu/spu_tile.h index e53340a55a..3105b848fd 100644 --- a/src/gallium/drivers/cell/spu/spu_tile.h +++ b/src/gallium/drivers/cell/spu/spu_tile.h @@ -32,7 +32,7 @@ #include #include #include "spu_main.h" -#include "pipe/cell/common.h" +#include "cell/common.h" diff --git a/src/gallium/drivers/cell/spu/spu_util.c b/src/gallium/drivers/cell/spu/spu_util.c index ac373240c1..ea4274a0a7 100644 --- a/src/gallium/drivers/cell/spu/spu_util.c +++ b/src/gallium/drivers/cell/spu/spu_util.c @@ -1,8 +1,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" //#include "tgsi_build.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_util.h" unsigned tgsi_util_get_src_register_swizzle( diff --git a/src/gallium/drivers/cell/spu/spu_vertex_shader.c b/src/gallium/drivers/cell/spu/spu_vertex_shader.c index c1cbbb6d1e..3f5bf41aa2 100644 --- a/src/gallium/drivers/cell/spu/spu_vertex_shader.c +++ b/src/gallium/drivers/cell/spu/spu_vertex_shader.c @@ -39,9 +39,9 @@ #include "pipe/p_shader_tokens.h" #include "spu_vertex_shader.h" #include "spu_exec.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_context.h" -#include "pipe/cell/common.h" +#include "draw/draw_private.h" +#include "draw/draw_context.h" +#include "cell/common.h" #include "spu_main.h" static INLINE unsigned diff --git a/src/gallium/drivers/failover/Makefile b/src/gallium/drivers/failover/Makefile index 72d0895c74..14389bd055 100644 --- a/src/gallium/drivers/failover/Makefile +++ b/src/gallium/drivers/failover/Makefile @@ -15,7 +15,7 @@ C_SOURCES = \ ASM_SOURCES = -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile index 2f91de3afc..ee22ba86f9 100644 --- a/src/gallium/drivers/i915simple/Makefile +++ b/src/gallium/drivers/i915simple/Makefile @@ -32,7 +32,7 @@ C_SOURCES = \ ASM_SOURCES = -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c index 497623a700..7f71f8fd4f 100644 --- a/src/gallium/drivers/i915simple/i915_context.c +++ b/src/gallium/drivers/i915simple/i915_context.c @@ -32,7 +32,7 @@ #include "i915_texture.h" #include "i915_reg.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" #include "pipe/p_util.h" diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h index b4ea63c3e7..2d876925b2 100644 --- a/src/gallium/drivers/i915simple/i915_context.h +++ b/src/gallium/drivers/i915simple/i915_context.h @@ -33,7 +33,7 @@ #include "pipe/p_defines.h" #include "pipe/p_state.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_vertex.h" #define I915_TEX_UNITS 8 diff --git a/src/gallium/drivers/i915simple/i915_fpc_translate.c b/src/gallium/drivers/i915simple/i915_fpc_translate.c index 868f0c7e04..6c1524c768 100644 --- a/src/gallium/drivers/i915simple/i915_fpc_translate.c +++ b/src/gallium/drivers/i915simple/i915_fpc_translate.c @@ -33,9 +33,9 @@ #include "i915_fpc.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_vertex.h" /** diff --git a/src/gallium/drivers/i915simple/i915_prim_emit.c b/src/gallium/drivers/i915simple/i915_prim_emit.c index c4a706c37d..44c4325936 100644 --- a/src/gallium/drivers/i915simple/i915_prim_emit.c +++ b/src/gallium/drivers/i915simple/i915_prim_emit.c @@ -26,7 +26,7 @@ **************************************************************************/ -#include "pipe/draw/draw_private.h" +#include "draw/draw_private.h" #include "pipe/p_util.h" #include "i915_context.h" diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c index e069773fd4..c5bf6174f6 100644 --- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c +++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c @@ -38,7 +38,7 @@ */ -#include "pipe/draw/draw_vbuf.h" +#include "draw/draw_vbuf.h" #include "pipe/p_debug.h" #include "pipe/p_util.h" #include "pipe/p_inlines.h" diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c index abd5571b88..294e6fad03 100644 --- a/src/gallium/drivers/i915simple/i915_state.c +++ b/src/gallium/drivers/i915simple/i915_state.c @@ -29,7 +29,7 @@ */ -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_winsys.h" #include "pipe/p_util.h" diff --git a/src/gallium/drivers/i915simple/i915_state_derived.c b/src/gallium/drivers/i915simple/i915_state_derived.c index 653983e4a9..4767584fc6 100644 --- a/src/gallium/drivers/i915simple/i915_state_derived.c +++ b/src/gallium/drivers/i915simple/i915_state_derived.c @@ -27,8 +27,8 @@ #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_context.h" +#include "draw/draw_vertex.h" #include "i915_context.h" #include "i915_state.h" #include "i915_reg.h" diff --git a/src/gallium/drivers/i915simple/i915_strings.c b/src/gallium/drivers/i915simple/i915_strings.c index c713bf7208..301fedea19 100644 --- a/src/gallium/drivers/i915simple/i915_strings.c +++ b/src/gallium/drivers/i915simple/i915_strings.c @@ -70,7 +70,7 @@ static const char *i915_get_name( struct pipe_context *pipe ) break; } - sprintf(buffer, "pipe/i915 (chipset: %s)", chipset); + sprintf(buffer, "i915 (chipset: %s)", chipset); return buffer; } diff --git a/src/gallium/drivers/i915simple/i915_surface.c b/src/gallium/drivers/i915simple/i915_surface.c index de0cc5fe06..17fd27895a 100644 --- a/src/gallium/drivers/i915simple/i915_surface.c +++ b/src/gallium/drivers/i915simple/i915_surface.c @@ -33,7 +33,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" /* diff --git a/src/gallium/drivers/i965simple/Makefile b/src/gallium/drivers/i965simple/Makefile index 48c00ab50b..1dec1f9749 100644 --- a/src/gallium/drivers/i965simple/Makefile +++ b/src/gallium/drivers/i965simple/Makefile @@ -61,6 +61,6 @@ ASM_SOURCES = DRIVER_DEFINES = -I. -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/drivers/i965simple/brw_shader_info.c b/src/gallium/drivers/i965simple/brw_shader_info.c index 431b45466a..a762a870fe 100644 --- a/src/gallium/drivers/i965simple/brw_shader_info.c +++ b/src/gallium/drivers/i965simple/brw_shader_info.c @@ -3,7 +3,7 @@ #include "brw_state.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c index 95dfce88e4..f746d1cc57 100644 --- a/src/gallium/drivers/i965simple/brw_state.c +++ b/src/gallium/drivers/i965simple/brw_state.c @@ -33,7 +33,7 @@ #include "pipe/p_winsys.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/util/tgsi_dump.h" #include "brw_context.h" #include "brw_defines.h" diff --git a/src/gallium/drivers/i965simple/brw_strings.c b/src/gallium/drivers/i965simple/brw_strings.c index 29a41ed1e9..3d9c50961f 100644 --- a/src/gallium/drivers/i965simple/brw_strings.c +++ b/src/gallium/drivers/i965simple/brw_strings.c @@ -59,7 +59,7 @@ static const char *brw_get_name( struct pipe_context *pipe ) break; } - sprintf(buffer, "pipe/i965 (chipset: %s)", chipset); + sprintf(buffer, "i965 (chipset: %s)", chipset); return buffer; } diff --git a/src/gallium/drivers/i965simple/brw_surface.c b/src/gallium/drivers/i965simple/brw_surface.c index 518845e4b2..376a42b1a6 100644 --- a/src/gallium/drivers/i965simple/brw_surface.c +++ b/src/gallium/drivers/i965simple/brw_surface.c @@ -32,7 +32,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" /* diff --git a/src/gallium/drivers/i965simple/brw_vs_emit.c b/src/gallium/drivers/i965simple/brw_vs_emit.c index 98915ba101..05df4860ed 100644 --- a/src/gallium/drivers/i965simple/brw_vs_emit.c +++ b/src/gallium/drivers/i965simple/brw_vs_emit.c @@ -33,7 +33,7 @@ #include "brw_vs.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" struct brw_prog_info { unsigned num_temps; diff --git a/src/gallium/drivers/i965simple/brw_wm_decl.c b/src/gallium/drivers/i965simple/brw_wm_decl.c index b45a333a2e..97418a52e7 100644 --- a/src/gallium/drivers/i965simple/brw_wm_decl.c +++ b/src/gallium/drivers/i965simple/brw_wm_decl.c @@ -4,7 +4,7 @@ #include "brw_wm.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" static struct brw_reg alloc_tmp(struct brw_wm_compile *c) { diff --git a/src/gallium/drivers/i965simple/brw_wm_glsl.c b/src/gallium/drivers/i965simple/brw_wm_glsl.c index d95645d108..44f946ea74 100644 --- a/src/gallium/drivers/i965simple/brw_wm_glsl.c +++ b/src/gallium/drivers/i965simple/brw_wm_glsl.c @@ -4,7 +4,7 @@ #include "brw_wm.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile index 31438a882e..2304ea4246 100644 --- a/src/gallium/drivers/softpipe/Makefile +++ b/src/gallium/drivers/softpipe/Makefile @@ -44,7 +44,7 @@ C_SOURCES = \ ASM_SOURCES = -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index cea6b90104..5e98f190bb 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -29,7 +29,7 @@ * Keith Whitwell */ -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_util.h" diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index aff8c2cc5d..8c79cb3ce4 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -34,7 +34,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_vertex.h" #include "sp_quad.h" diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 71a303a8b5..2049afda34 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -38,7 +38,7 @@ #include "sp_context.h" #include "sp_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index ced0d5d098..2cbd0d7cab 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -31,7 +31,7 @@ #include "pipe/p_defines.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "sp_flush.h" #include "sp_context.h" #include "sp_surface.h" diff --git a/src/gallium/drivers/softpipe/sp_headers.h b/src/gallium/drivers/softpipe/sp_headers.h index 0ae31d8796..9cf8222133 100644 --- a/src/gallium/drivers/softpipe/sp_headers.h +++ b/src/gallium/drivers/softpipe/sp_headers.h @@ -31,7 +31,7 @@ #ifndef SP_HEADERS_H #define SP_HEADERS_H -#include "pipe/tgsi/exec/tgsi_exec.h" +#include "tgsi/exec/tgsi_exec.h" #define PRIM_POINT 1 #define PRIM_LINE 2 diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c index 2772048661..d73521ccbe 100644 --- a/src/gallium/drivers/softpipe/sp_prim_setup.c +++ b/src/gallium/drivers/softpipe/sp_prim_setup.c @@ -38,8 +38,8 @@ #include "sp_quad.h" #include "sp_state.h" #include "sp_prim_setup.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_private.h" +#include "draw/draw_vertex.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 7f71fdb6a9..69bea8a8f5 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -39,9 +39,9 @@ #include "sp_context.h" #include "sp_state.h" #include "sp_prim_vbuf.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_vbuf.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" +#include "draw/draw_vbuf.h" #define SP_MAX_VBUF_INDEXES 1024 diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index 3316858413..b4c01a7ea8 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -42,7 +42,7 @@ #include "x86/rtasm/x86sse.h" #ifdef MESA_LLVM -#include "pipe/llvm/gallivm.h" +#include "llvm/gallivm.h" #endif #include "sp_context.h" diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c index 6a8a43aeda..adf9ccf64c 100644 --- a/src/gallium/drivers/softpipe/sp_query.c +++ b/src/gallium/drivers/softpipe/sp_query.c @@ -29,7 +29,7 @@ * Keith Whitwell */ -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_util.h" diff --git a/src/gallium/drivers/softpipe/sp_state_clip.c b/src/gallium/drivers/softpipe/sp_state_clip.c index 08c5f06d05..c797c0dd3b 100644 --- a/src/gallium/drivers/softpipe/sp_state_clip.c +++ b/src/gallium/drivers/softpipe/sp_state_clip.c @@ -29,7 +29,7 @@ */ #include "sp_context.h" #include "sp_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void softpipe_set_clip_state( struct pipe_context *pipe, diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c index 372597869f..9d8fd8b750 100644 --- a/src/gallium/drivers/softpipe/sp_state_derived.c +++ b/src/gallium/drivers/softpipe/sp_state_derived.c @@ -27,9 +27,9 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_vertex.h" -#include "pipe/draw/draw_private.h" +#include "draw/draw_context.h" +#include "draw/draw_vertex.h" +#include "draw/draw_private.h" #include "sp_context.h" #include "sp_state.h" diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index 0b814fc284..1e3cadd43d 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -32,11 +32,11 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_shader_tokens.h" -#include "pipe/llvm/gallivm.h" -#include "pipe/tgsi/util/tgsi_dump.h" -#include "pipe/tgsi/exec/tgsi_sse2.h" +#include "llvm/gallivm.h" +#include "tgsi/util/tgsi_dump.h" +#include "tgsi/exec/tgsi_sse2.h" void * diff --git a/src/gallium/drivers/softpipe/sp_state_rasterizer.c b/src/gallium/drivers/softpipe/sp_state_rasterizer.c index 53755099dd..98e04352db 100644 --- a/src/gallium/drivers/softpipe/sp_state_rasterizer.c +++ b/src/gallium/drivers/softpipe/sp_state_rasterizer.c @@ -29,7 +29,7 @@ #include "pipe/p_util.h" #include "sp_context.h" #include "sp_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index ea348c7e95..460adccec4 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -31,14 +31,14 @@ #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "sp_context.h" #include "sp_context.h" #include "sp_state.h" #include "sp_texture.h" #include "sp_tile_cache.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c index 09ff540ccf..f01a10de3b 100644 --- a/src/gallium/drivers/softpipe/sp_state_vertex.c +++ b/src/gallium/drivers/softpipe/sp_state_vertex.c @@ -33,7 +33,7 @@ #include "sp_state.h" #include "sp_surface.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c index 8802ced187..653449c4f1 100644 --- a/src/gallium/drivers/softpipe/sp_surface.c +++ b/src/gallium/drivers/softpipe/sp_surface.c @@ -29,7 +29,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "sp_context.h" #include "sp_surface.h" diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 325bdb86da..2f82fd6abe 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -40,7 +40,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_util.h" -#include "pipe/tgsi/exec/tgsi_exec.h" +#include "tgsi/exec/tgsi_exec.h" /* diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 1597361b82..dde3fabc81 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -34,7 +34,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "sp_context.h" #include "sp_surface.h" #include "sp_tile_cache.h" diff --git a/src/gallium/winsys/dri/Makefile b/src/gallium/winsys/dri/Makefile new file mode 100644 index 0000000000..f466ce6c3c --- /dev/null +++ b/src/gallium/winsys/dri/Makefile @@ -0,0 +1,38 @@ +# src/mesa/drivers/dri/Makefile + +TOP = ../../../.. + +include $(TOP)/configs/current + + + +default: $(TOP)/$(LIB_DIR) subdirs + + +$(TOP)/$(LIB_DIR): + -mkdir $(TOP)/$(LIB_DIR) + + +subdirs: + @for dir in $(DRI_DIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1 ; \ + fi \ + done + + +install: + @for dir in $(DRI_DIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) install) || exit 1 ; \ + fi \ + done + + +clean: + @for dir in $(DRI_DIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) clean) ; \ + fi \ + done + -rm -f common/*.o diff --git a/src/gallium/winsys/dri/Makefile.template b/src/gallium/winsys/dri/Makefile.template new file mode 100644 index 0000000000..b96305c094 --- /dev/null +++ b/src/gallium/winsys/dri/Makefile.template @@ -0,0 +1,113 @@ +# -*-makefile-*- + +MESA_MODULES = $(TOP)/src/mesa/libmesa.a + +COMMON_GALLIUM_SOURCES = \ + $(TOP)/src/mesa/drivers/dri/common/utils.c \ + $(TOP)/src/mesa/drivers/dri/common/vblank.c \ + $(TOP)/src/mesa/drivers/dri/common/dri_util.c \ + $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c + +COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \ + $(TOP)/src/mesa/drivers/common/driverfuncs.c \ + $(TOP)/src/mesa/drivers/dri/common/texmem.c \ + $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c + +COMMON_BM_SOURCES = \ + $(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \ + $(TOP)/src/mesa/drivers/dri/common/dri_drmpool.c + + +ifeq ($(WINDOW_SYSTEM),dri) +WINOBJ= +WINLIB= +INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES) + +OBJECTS = $(C_SOURCES:.c=.o) \ + $(ASM_SOURCES:.S=.o) + +else +# miniglx +WINOBJ= +WINLIB=-L$(MESA)/src/glx/mini +MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini +INCLUDES = $(MINIGLX_INCLUDES) \ + $(SHARED_INCLUDES) \ + $(PCIACCESS_CFLAGS) + +OBJECTS = $(C_SOURCES:.c=.o) \ + $(MINIGLX_SOURCES:.c=.o) \ + $(ASM_SOURCES:.S=.o) +endif + + +### Include directories +SHARED_INCLUDES = \ + -I. \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -Iserver \ + -I$(TOP)/include \ + -I$(TOP)/include/GL/internal \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mesa/main \ + -I$(TOP)/src/mesa/glapi \ + -I$(TOP)/src/mesa/math \ + -I$(TOP)/src/mesa/transform \ + -I$(TOP)/src/mesa/shader \ + -I$(TOP)/src/mesa/swrast \ + -I$(TOP)/src/mesa/swrast_setup \ + -I$(TOP)/src/egl/main \ + -I$(TOP)/src/egl/drivers/dri \ + $(LIBDRM_CFLAGS) + + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + + +##### TARGETS ##### + +default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME) + + +$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template + $(TOP)/bin/mklib -noprefix -o $@ \ + $(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS) + + +$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) + $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) + + +depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS) + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \ + $(ASM_SOURCES) 2> /dev/null + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` + + +# Remove .o and backup files +clean: + -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS) + -rm -f depend depend.bak + + +install: $(LIBNAME) + $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR) + $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR) + + +include depend diff --git a/src/gallium/winsys/dri/intel/Makefile b/src/gallium/winsys/dri/intel/Makefile index 9ae0f01325..40654bb2ac 100644 --- a/src/gallium/winsys/dri/intel/Makefile +++ b/src/gallium/winsys/dri/intel/Makefile @@ -7,8 +7,8 @@ LIBNAME = i915tex_dri.so MINIGLX_SOURCES = server/intel_dri.c PIPE_DRIVERS = \ - $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a \ - $(TOP)/src/mesa/pipe/i915simple/libi915simple.a + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/i915simple/libi915simple.a DRIVER_SOURCES = \ intel_winsys_pipe.c \ @@ -28,11 +28,11 @@ C_SOURCES = \ ASM_SOURCES = -DRIVER_DEFINES = -I../intel $(shell pkg-config libdrm --atleast-version=2.3.1 \ +DRIVER_DEFINES = -I$(TOP)/src/mesa/drivers/dri/intel $(shell pkg-config libdrm --atleast-version=2.3.1 \ && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") include ../Makefile.template -intel_tex_layout.o: ../intel/intel_tex_layout.c +intel_tex_layout.o: $(TOP)/src/mesa/drivers/dri/intel/intel_tex_layout.c symlinks: diff --git a/src/gallium/winsys/dri/intel/intel_winsys_i915.c b/src/gallium/winsys/dri/intel/intel_winsys_i915.c index 1ba6a9e1b2..0ed3890e93 100644 --- a/src/gallium/winsys/dri/intel/intel_winsys_i915.c +++ b/src/gallium/winsys/dri/intel/intel_winsys_i915.c @@ -39,7 +39,7 @@ #include "intel_winsys.h" #include "pipe/p_util.h" -#include "pipe/i915simple/i915_winsys.h" +#include "i915simple/i915_winsys.h" struct intel_i915_winsys { diff --git a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c b/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c index cec3437831..9e483bdc9f 100644 --- a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c +++ b/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c @@ -34,7 +34,7 @@ #include "pipe/p_defines.h" #include "pipe/p_util.h" #include "pipe/p_format.h" -#include "pipe/softpipe/sp_winsys.h" +#include "softpipe/sp_winsys.h" struct intel_softpipe_winsys { diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c index c3cd22eea3..8da596d419 100644 --- a/src/gallium/winsys/xlib/xm_winsys.c +++ b/src/gallium/winsys/xlib/xm_winsys.c @@ -41,11 +41,11 @@ #include "pipe/p_context.h" #include "pipe/p_util.h" #include "pipe/p_inlines.h" -#include "pipe/softpipe/sp_winsys.h" +#include "softpipe/sp_winsys.h" #ifdef GALLIUM_CELL -#include "pipe/cell/ppu/cell_context.h" -#include "pipe/cell/ppu/cell_winsys.h" +#include "cell/ppu/cell_context.h" +#include "cell/ppu/cell_winsys.h" #else #define TILE_SIZE 32 /* avoid compilation errors */ #endif diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.c b/src/gallium/winsys/xlib/xm_winsys_aub.c index bf41570257..dbfd37bda2 100644 --- a/src/gallium/winsys/xlib/xm_winsys_aub.c +++ b/src/gallium/winsys/xlib/xm_winsys_aub.c @@ -39,7 +39,7 @@ #include "pipe/p_winsys.h" #include "pipe/p_util.h" #include "pipe/p_inlines.h" -#include "pipe/i965simple/brw_winsys.h" +#include "i965simple/brw_winsys.h" #include "brw_aub.h" #include "xm_winsys_aub.h" diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 720f1b2e02..561608fedd 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -12,16 +12,16 @@ GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) PIPE_LIB = \ - $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a \ - $(TOP)/src/mesa/pipe/i965simple/libi965simple.a + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/i965simple/libi965simple.a ifeq ($(CONFIG_NAME), linux-cell) -CELL_LIB = $(TOP)/src/mesa/pipe/cell/ppu/libcell.a -CELL_LIB_SPU = $(TOP)/src/mesa/pipe/cell/spu/g3d_spu.a +CELL_LIB = $(TOP)/src/gallium/drivers/cell/ppu/libcell.a +CELL_LIB_SPU = $(TOP)/src/gallium/drivers/cell/spu/g3d_spu.a endif ifeq ($(CONFIG_NAME), linux-llvm) -LLVM_LIB = $(TOP)/src/mesa/pipe/llvm/libgallivm.a +LLVM_LIB = $(TOP)/src/gallium/aux/llvm/libgallivm.a endif .SUFFIXES : .cpp @@ -71,7 +71,7 @@ libmesa.a: $(SOLO_OBJECTS) fi linux-solo: depend subdirs libmesa.a - cd drivers/dri ; $(MAKE) + cd $(TOP)/src/gallium/winsys/dri ; $(MAKE) ##################################################################### @@ -165,7 +165,6 @@ depend: $(ALL_SOURCES) subdirs: @ (cd x86 ; $(MAKE)) @ (cd x86-64 ; $(MAKE)) - (cd pipe ; $(MAKE)) install: default $(INSTALL) -d $(INSTALL_DIR)/include/GL @@ -178,7 +177,7 @@ install: default $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \ fi @if [ "${DRIVER_DIRS}" = "dri" ] ; then \ - cd drivers/dri ; $(MAKE) install ; \ + cd $(TOP)/gallium/winsys/dri ; $(MAKE) install ; \ fi ## NOT INSTALLED YET: @@ -198,7 +197,6 @@ clean: (cd drivers/dri && $(MAKE) clean) (cd x86 && $(MAKE) clean) (cd x86-64 && $(MAKE) clean) - (cd pipe ; $(MAKE) clean ) include depend diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 08c98eab48..18b033666f 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -85,7 +85,7 @@ #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" -#include "pipe/softpipe/sp_context.h" +#include "softpipe/sp_context.h" #include "pipe/p_defines.h" /** diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 8ae243ae66..34287effe1 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -53,7 +53,7 @@ #include "tnl/tnl.h" #include "tnl/t_context.h" -#include "pipe/softpipe/sp_context.h" +#include "softpipe/sp_context.h" #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" #include "state_tracker/st_draw.h" diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 5533158ece..81616b92d9 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -45,10 +45,10 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "pipe/softpipe/sp_context.h" -#include "pipe/softpipe/sp_clear.h" -#include "pipe/softpipe/sp_tile_cache.h" -#include "pipe/softpipe/sp_surface.h" +#include "softpipe/sp_context.h" +#include "softpipe/sp_clear.h" +#include "softpipe/sp_tile_cache.h" +#include "softpipe/sp_surface.h" #include "state_tracker/st_context.h" diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c index a690df2772..2edc697693 100644 --- a/src/mesa/drivers/x11/xm_winsys.c +++ b/src/mesa/drivers/x11/xm_winsys.c @@ -38,7 +38,7 @@ #include "main/macros.h" #include "pipe/p_winsys.h" -#include "pipe/softpipe/sp_winsys.h" +#include "softpipe/sp_winsys.h" /** diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 4709d63394..fd2dfcd79a 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -37,8 +37,8 @@ #include "xm_image.h" #endif #include "state_tracker/st_cb_fbo.h" -#include "pipe/softpipe/sp_context.h" -#include "pipe/softpipe/sp_surface.h" +#include "softpipe/sp_context.h" +#include "softpipe/sp_surface.h" extern _glthread_Mutex _xmesa_lock; diff --git a/src/mesa/sources b/src/mesa/sources index 1165425183..2d07738210 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -158,45 +158,45 @@ VF_SOURCES = \ DRAW_SOURCES = \ - pipe/draw/draw_clip.c \ - pipe/draw/draw_context.c\ - pipe/draw/draw_cull.c \ - pipe/draw/draw_debug.c \ - pipe/draw/draw_flatshade.c \ - pipe/draw/draw_offset.c \ - pipe/draw/draw_prim.c \ - pipe/draw/draw_stipple.c \ - pipe/draw/draw_twoside.c \ - pipe/draw/draw_unfilled.c \ - pipe/draw/draw_validate.c \ - pipe/draw/draw_vbuf.c \ - pipe/draw/draw_vertex.c \ - pipe/draw/draw_vertex_cache.c \ - pipe/draw/draw_vertex_fetch.c \ - pipe/draw/draw_vertex_shader.c \ - pipe/draw/draw_vf.c \ - pipe/draw/draw_vf_generic.c \ - pipe/draw/draw_vf_sse.c \ - pipe/draw/draw_wide_prims.c + $(TOP)/src/gallium/aux/draw/draw_clip.c \ + $(TOP)/src/gallium/aux/draw/draw_context.c\ + $(TOP)/src/gallium/aux/draw/draw_cull.c \ + $(TOP)/src/gallium/aux/draw/draw_debug.c \ + $(TOP)/src/gallium/aux/draw/draw_flatshade.c \ + $(TOP)/src/gallium/aux/draw/draw_offset.c \ + $(TOP)/src/gallium/aux/draw/draw_prim.c \ + $(TOP)/src/gallium/aux/draw/draw_stipple.c \ + $(TOP)/src/gallium/aux/draw/draw_twoside.c \ + $(TOP)/src/gallium/aux/draw/draw_unfilled.c \ + $(TOP)/src/gallium/aux/draw/draw_validate.c \ + $(TOP)/src/gallium/aux/draw/draw_vbuf.c \ + $(TOP)/src/gallium/aux/draw/draw_vertex.c \ + $(TOP)/src/gallium/aux/draw/draw_vertex_cache.c \ + $(TOP)/src/gallium/aux/draw/draw_vertex_fetch.c \ + $(TOP)/src/gallium/aux/draw/draw_vertex_shader.c \ + $(TOP)/src/gallium/aux/draw/draw_vf.c \ + $(TOP)/src/gallium/aux/draw/draw_vf_generic.c \ + $(TOP)/src/gallium/aux/draw/draw_vf_sse.c \ + $(TOP)/src/gallium/aux/draw/draw_wide_prims.c TGSIEXEC_SOURCES = \ - pipe/tgsi/exec/tgsi_exec.c \ - pipe/tgsi/exec/tgsi_sse2.c + $(TOP)/src/gallium/aux/tgsi/exec/tgsi_exec.c \ + $(TOP)/src/gallium/aux/tgsi/exec/tgsi_sse2.c TGSIUTIL_SOURCES = \ - pipe/tgsi/util/tgsi_build.c \ - pipe/tgsi/util/tgsi_dump.c \ - pipe/tgsi/util/tgsi_parse.c \ - pipe/tgsi/util/tgsi_util.c + $(TOP)/src/gallium/aux/tgsi/util/tgsi_build.c \ + $(TOP)/src/gallium/aux/tgsi/util/tgsi_dump.c \ + $(TOP)/src/gallium/aux/tgsi/util/tgsi_parse.c \ + $(TOP)/src/gallium/aux/tgsi/util/tgsi_util.c STATECACHE_SOURCES = \ - pipe/cso_cache/cso_hash.c \ - pipe/cso_cache/cso_cache.c + $(TOP)/src/gallium/aux/cso_cache/cso_hash.c \ + $(TOP)/src/gallium/aux/cso_cache/cso_cache.c PIPEUTIL_SOURCES = \ - pipe/util/p_debug.c \ - pipe/util/p_tile.c \ - pipe/util/p_util.c + $(TOP)/src/gallium/aux/util/p_debug.c \ + $(TOP)/src/gallium/aux/util/p_tile.c \ + $(TOP)/src/gallium/aux/util/p_util.c STATETRACKER_SOURCES = \ state_tracker/st_atom.c \ @@ -331,13 +331,13 @@ __COMMON_DRIVER_SOURCES = \ drivers/common/driverfuncs.c X11_DRIVER_SOURCES = \ - pipe/xlib/glxapi.c \ - pipe/xlib/fakeglx.c \ - pipe/xlib/xfonts.c \ - pipe/xlib/xm_api.c \ - pipe/xlib/xm_winsys.c \ - pipe/xlib/xm_winsys_aub.c \ - pipe/xlib/brw_aub.c + $(TOP)/src/gallium/winsys/xlib/glxapi.c \ + $(TOP)/src/gallium/winsys/xlib/fakeglx.c \ + $(TOP)/src/gallium/winsys/xlib/xfonts.c \ + $(TOP)/src/gallium/winsys/xlib/xm_api.c \ + $(TOP)/src/gallium/winsys/xlib/xm_winsys.c \ + $(TOP)/src/gallium/winsys/xlib/xm_winsys_aub.c \ + $(TOP)/src/gallium/winsys/xlib/brw_aub.c OSMESA_DRIVER_SOURCES = \ drivers/osmesa/osmesa.c @@ -425,7 +425,10 @@ FBDEV_DRIVER_OBJECTS = $(FBDEV_DRIVER_SOURCES:.c=.o) INCLUDE_DIRS = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main + -I$(TOP)/src/mesa/main \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/aux OLD_INCLUDE_DIRS = \ -I$(TOP)/src/mesa/tnl \ @@ -435,4 +438,4 @@ OLD_INCLUDE_DIRS = \ -I$(TOP)/src/mesa/shader \ -I$(TOP)/src/mesa/shader/grammar \ -I$(TOP)/src/mesa/shader/slang \ - -I$(TOP)/src/mesa/pipe/tgsi + -I$(TOP)/s$(TOP)/src/gallium/aux/tgsi diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 2c6ec8421b..b67b620eaa 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -43,7 +43,7 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" #include "st_context.h" #include "st_cache.h" diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index e0965b217a..2979e7fae5 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -36,8 +36,8 @@ #include "pipe/p_state.h" -#include "pipe/cso_cache/cso_cache.h" -#include "pipe/cso_cache/cso_hash.h" +#include "cso_cache/cso_cache.h" +#include "cso_cache/cso_hash.h" /* Those function will either find the state of the given template diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index e0c176b0ff..b81de316ec 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -33,7 +33,7 @@ #ifndef ST_CACHE_H #define ST_CACHE_H -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" struct pipe_blend_state; struct pipe_sampler_state; diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 3a3bf9016d..663c4f205d 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -43,7 +43,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #define UNCLAMPED_FLOAT_TO_SHORT(us, f) \ diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index f13199a3c0..e2d4e06da1 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -56,7 +56,7 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "shader/prog_instruction.h" diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 31744151f1..5315294c07 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -53,10 +53,10 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" /** diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index af3ee65504..61d4f4c41c 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -39,8 +39,8 @@ #include "shader/programopt.h" #include "shader/shader_api.h" -#include "pipe/cso_cache/cso_cache.h" -#include "pipe/draw/draw_context.h" +#include "cso_cache/cso_cache.h" +#include "draw/draw_context.h" #include "st_context.h" #include "st_program.h" diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 7e347c4893..5b0eb6022b 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -44,8 +44,8 @@ #include "st_draw.h" #include "st_cb_rasterpos.h" #include "st_draw.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" #include "shader/prog_instruction.h" #include "vbo/vbo.h" diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 868c5f3c5f..c89c74229e 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -40,7 +40,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "st_context.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 91a40288cc..03dbb30b0f 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -47,7 +47,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #define DBG if (0) printf diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index bf4618bed8..09e389f9dc 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -54,8 +54,8 @@ #include "pipe/p_context.h" #include "pipe/p_winsys.h" #include "pipe/p_inlines.h" -#include "pipe/draw/draw_context.h" -#include "pipe/cso_cache/cso_cache.h" +#include "draw/draw_context.h" +#include "cso_cache/cso_cache.h" /** diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 57450e52bf..5888bcb98a 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -31,9 +31,9 @@ #include "pipe/p_state.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/util/tgsi_dump.h" -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" #include "st_context.h" #include "st_debug.h" diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index ae9f5c8b11..1c0fa8c6aa 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -47,8 +47,8 @@ #include "pipe/p_winsys.h" #include "pipe/p_inlines.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_private.h" +#include "draw/draw_context.h" static GLuint double_types[4] = { diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 459941cca8..6c09b86033 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -37,7 +37,7 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" #include "st_context.h" #include "st_draw.h" diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 325aa20173..97206752af 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -32,9 +32,9 @@ #include "pipe/p_compiler.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_build.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_build.h" +#include "tgsi/util/tgsi_util.h" #include "st_mesa_to_tgsi.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index c8297baded..dc992ee9c2 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -38,8 +38,8 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" -#include "pipe/draw/draw_context.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "draw/draw_context.h" +#include "tgsi/util/tgsi_dump.h" #include "st_context.h" #include "st_cache.h" -- cgit v1.2.3