From 6393cda6766b707ef01e925d378239a66d143ae0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 14 Jun 2007 18:11:48 +0100 Subject: Renamed softpipe directories and files to something less confusing. softpipe/state_tracker --> state_tracker/ softpipe/ --> pipe/ softpipe/generic --> pipe/softpipe/ I don't think pipe is a great name, but I disliked all the others too. Luckily it's fairly easy to rename with git, so this can be revisited later. --- src/mesa/state_tracker/st_atom.c | 171 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 src/mesa/state_tracker/st_atom.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c new file mode 100644 index 0000000000..fdbfb9021d --- /dev/null +++ b/src/mesa/state_tracker/st_atom.c @@ -0,0 +1,171 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + + +#include "glheader.h" +#include "context.h" + +#include "st_context.h" +#include "st_atom.h" + + + +/* This is used to initialize st->atoms[]. We could use this list + * directly except for a single atom, st_update_constants, which has a + * .dirty value which changes according to the parameters of the + * current fragment and vertex programs, and so cannot be a static + * value. + */ +static const struct st_tracked_state *atoms[] = +{ + &st_update_cbuf, + &st_update_clip, + &st_update_fs, + &st_update_setup, + &st_update_viewport, + &st_update_scissor, + &st_update_blend, + &st_update_stencil, + /* will be patched out at runtime */ +/* &st_update_constants */ +}; + + +void st_init_atoms( struct st_context *st ) +{ + GLuint i; + + st->atoms = _mesa_malloc(sizeof(atoms)); + st->nr_atoms = sizeof(atoms)/sizeof(*atoms); + memcpy(st->atoms, atoms, sizeof(atoms)); + + /* Patch in a pointer to the dynamic state atom: + */ + for (i = 0; i < st->nr_atoms; i++) + if (st->atoms[i] == &st_update_constants) + st->atoms[i] = &st->constants.tracked_state; + + memcpy(&st->constants.tracked_state, + &st_update_constants, + sizeof(st_update_constants)); +} + + +void st_destroy_atoms( struct st_context *st ) +{ + if (st->atoms) { + _mesa_free(st->atoms); + st->atoms = NULL; + } +} + + +/*********************************************************************** + */ + +static GLboolean check_state( const struct st_state_flags *a, + const struct st_state_flags *b ) +{ + return ((a->mesa & b->mesa) || + (a->st & b->st)); +} + +static void accumulate_state( struct st_state_flags *a, + const struct st_state_flags *b ) +{ + a->mesa |= b->mesa; + a->st |= b->st; +} + + +static void xor_states( struct st_state_flags *result, + const struct st_state_flags *a, + const struct st_state_flags *b ) +{ + result->mesa = a->mesa ^ b->mesa; + result->st = a->st ^ b->st; +} + + +/*********************************************************************** + * Update all derived state: + */ + +void st_validate_state( struct st_context *st ) +{ + struct st_state_flags *state = &st->dirty; + GLuint i; + + if (state->st == 0) + return; + + if (1) { + /* Debug version which enforces various sanity checks on the + * state flags which are generated and checked to help ensure + * state atoms are ordered correctly in the list. + */ + struct st_state_flags examined, prev; + _mesa_memset(&examined, 0, sizeof(examined)); + prev = *state; + + for (i = 0; i < st->nr_atoms; i++) { + const struct st_tracked_state *atom = st->atoms[i]; + struct st_state_flags generated; + + assert(atom->dirty.mesa || + atom->dirty.st); + assert(atom->update); + + if (check_state(state, &atom->dirty)) { + st->atoms[i]->update( st ); + } + + accumulate_state(&examined, &atom->dirty); + + /* generated = (prev ^ state) + * if (examined & generated) + * fail; + */ + xor_states(&generated, &prev, state); + assert(!check_state(&examined, &generated)); + prev = *state; + } + } + else { + const GLuint nr = st->nr_atoms; + + for (i = 0; i < nr; i++) { + if (check_state(state, &st->atoms[i]->dirty)) + st->atoms[i]->update( st ); + } + } + + memset(state, 0, sizeof(*state)); +} + + + -- cgit v1.2.3 From 3cdd8bfe8e5afa57001c605b42bfac1f3fbc4eb8 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 15 Jun 2007 10:55:12 -0600 Subject: Added st_update_framebuffer struct/object. --- src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom.h | 1 + 2 files changed, 2 insertions(+) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index fdbfb9021d..5b3d32cce3 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -42,6 +42,7 @@ */ static const struct st_tracked_state *atoms[] = { + &st_update_framebuffer, &st_update_cbuf, &st_update_clip, &st_update_fs, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 1d8da46336..8575bfea1a 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -44,6 +44,7 @@ void st_destroy_atoms( struct st_context *st ); 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; -- cgit v1.2.3 From 0e9838263c88d2b88abbedcd338491d08d61a6ac Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 19 Jun 2007 08:45:34 -0600 Subject: just use regular malloc(), free(), memcpy() --- src/mesa/state_tracker/st_atom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 5b3d32cce3..02720804d4 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -60,7 +60,7 @@ void st_init_atoms( struct st_context *st ) { GLuint i; - st->atoms = _mesa_malloc(sizeof(atoms)); + st->atoms = malloc(sizeof(atoms)); st->nr_atoms = sizeof(atoms)/sizeof(*atoms); memcpy(st->atoms, atoms, sizeof(atoms)); @@ -79,7 +79,7 @@ void st_init_atoms( struct st_context *st ) void st_destroy_atoms( struct st_context *st ) { if (st->atoms) { - _mesa_free(st->atoms); + free(st->atoms); st->atoms = NULL; } } @@ -130,7 +130,7 @@ void st_validate_state( struct st_context *st ) * state atoms are ordered correctly in the list. */ struct st_state_flags examined, prev; - _mesa_memset(&examined, 0, sizeof(examined)); + memset(&examined, 0, sizeof(examined)); prev = *state; for (i = 0; i < st->nr_atoms; i++) { -- 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/state_tracker/st_atom.c') 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 6cb2d0cb71d2019bd2c941a8c042e56275b22c1c Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 19 Jun 2007 19:52:25 -0600 Subject: hook up point state --- src/mesa/pipe/p_context.h | 3 + src/mesa/pipe/softpipe/sp_context.c | 1 + src/mesa/pipe/softpipe/sp_context.h | 3 + src/mesa/pipe/softpipe/sp_prim_setup.c | 131 ++++++++++++++++++-------------- src/mesa/pipe/softpipe/sp_state.h | 3 + src/mesa/pipe/softpipe/sp_state_point.c | 47 ++++++++++++ src/mesa/sources | 2 + src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom.h | 1 + src/mesa/state_tracker/st_atom_point.c | 70 +++++++++++++++++ src/mesa/state_tracker/st_context.h | 2 +- 11 files changed, 204 insertions(+), 60 deletions(-) create mode 100644 src/mesa/pipe/softpipe/sp_state_point.c create mode 100644 src/mesa/state_tracker/st_atom_point.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index f7374a8380..3e0c61eda2 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -71,6 +71,9 @@ struct pipe_context { void (*set_depth_state)( struct pipe_context *, const struct pipe_depth_state * ); + void (*set_point_state)( struct pipe_context *, + const struct pipe_point_state * ); + void (*set_framebuffer_state)( struct pipe_context *, const struct pipe_framebuffer_state * ); diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 018f67302d..e0acf4177b 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -68,6 +68,7 @@ struct pipe_context *softpipe_create( void ) softpipe->pipe.destroy = softpipe_destroy; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_clip_state = softpipe_set_clip_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; softpipe->pipe.set_scissor_rect = softpipe_set_scissor_rect; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index a873301368..43cb6f3f0b 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -54,11 +54,13 @@ enum interp_mode { #define G_NEW_SETUP 0x2 #define G_NEW_FS 0x4 #define G_NEW_BLEND 0x8 +#define G_NEW_POINT 0x10 #define G_NEW_CLIP 0x20 #define G_NEW_SCISSOR 0x40 #define G_NEW_STIPPLE 0x80 #define G_NEW_FRAMEBUFFER 0x100 #define G_NEW_ALPHA_TEST 0x200 +#define G_NEW_DEPTH_TEST 0x400 struct softpipe_context { @@ -74,6 +76,7 @@ struct softpipe_context { struct pipe_blend_state blend; struct pipe_alpha_test_state alpha_test; struct pipe_clip_state clip; + struct pipe_point_state point; struct pipe_scissor_rect scissor; struct pipe_poly_stipple poly_stipple; GLuint dirty; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index a1addc4ee1..8ef0fcbf9c 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -769,17 +769,12 @@ static void setup_point(struct prim_stage *stage, struct prim_header *prim) { struct setup_stage *setup = setup_stage( stage ); - GLfloat halfSize = 7.3; /*XXX this is a vertex attrib */ - GLfloat halfSizeSquared = halfSize * halfSize; + /*XXX this should be a vertex attrib! */ + GLfloat halfSize = 0.5 * setup->stage.softpipe->point.size; + GLboolean round = setup->stage.softpipe->point.smooth; const struct vertex_header *v0 = prim->v[0]; const GLfloat x = v0->data[FRAG_ATTRIB_WPOS][0]; const GLfloat y = v0->data[FRAG_ATTRIB_WPOS][1]; - const GLint ixmin = block((GLint) (x - halfSize)); - const GLint ixmax = block((GLint) (x + halfSize)); - const GLint iymin = block((GLint) (y - halfSize)); - const GLint iymax = block((GLint) (y + halfSize)); - GLboolean round = GL_TRUE; - GLint ix, iy; GLuint slot, j; /* For points, all interpolants are constant-valued. @@ -808,57 +803,75 @@ setup_point(struct prim_stage *stage, struct prim_header *prim) /* XXX need to clip against scissor bounds too */ - for (iy = iymin; iy <= iymax; iy += 2) { - for (ix = ixmin; ix <= ixmax; ix += 2) { - - if (round) { - /* rounded points */ - /* XXX for GL_SMOOTH, need to compute per-fragment coverage too */ - GLfloat dx, dy; - - setup->quad.mask = 0x0; - - dx = (ix + 0.5) - x; - dy = (iy + 0.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) - setup->quad.mask |= MASK_BOTTOM_LEFT; - - dx = (ix + 1.5) - x; - dy = (iy + 0.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) - setup->quad.mask |= MASK_BOTTOM_RIGHT; - - dx = (ix + 0.5) - x; - dy = (iy + 1.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) - setup->quad.mask |= MASK_TOP_LEFT; - - dx = (ix + 1.5) - x; - dy = (iy + 1.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) - setup->quad.mask |= MASK_TOP_RIGHT; - } - else { - /* square points */ - setup->quad.mask = 0xf; - - if (ix + 0.5 < x - halfSize) - setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT); - - if (ix + 1.5 > x + halfSize) - setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT); - - if (iy + 0.5 < y - halfSize) - setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT); - - if (iy + 1.5 > y + halfSize) - setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT); - } - - if (setup->quad.mask) { - setup->quad.x0 = ix; - setup->quad.y0 = iy; - quad_shade( setup->stage.softpipe, &setup->quad ); + if (halfSize <= 0.5 && !round) { + /* special case for 1-pixel points */ + const GLint ix = ((GLint) x) & 1; + const GLint iy = ((GLint) y) & 1; + setup->quad.x0 = x - ix; + setup->quad.y0 = y - iy; + setup->quad.mask = (1 << ix) << (2 * iy); + quad_shade(setup->stage.softpipe, &setup->quad); + } + else { + const GLint ixmin = block((GLint) (x - halfSize)); + const GLint ixmax = block((GLint) (x + halfSize)); + const GLint iymin = block((GLint) (y - halfSize)); + const GLint iymax = block((GLint) (y + halfSize)); + GLfloat halfSizeSquared = halfSize * halfSize; + GLint ix, iy; + + for (iy = iymin; iy <= iymax; iy += 2) { + for (ix = ixmin; ix <= ixmax; ix += 2) { + + if (round) { + /* rounded points */ + /* XXX for GL_SMOOTH, need to compute per-fragment coverage too */ + GLfloat dx, dy; + + setup->quad.mask = 0x0; + + dx = (ix + 0.5) - x; + dy = (iy + 0.5) - y; + if (dx * dx + dy * dy <= halfSizeSquared) + setup->quad.mask |= MASK_BOTTOM_LEFT; + + dx = (ix + 1.5) - x; + dy = (iy + 0.5) - y; + if (dx * dx + dy * dy <= halfSizeSquared) + setup->quad.mask |= MASK_BOTTOM_RIGHT; + + dx = (ix + 0.5) - x; + dy = (iy + 1.5) - y; + if (dx * dx + dy * dy <= halfSizeSquared) + setup->quad.mask |= MASK_TOP_LEFT; + + dx = (ix + 1.5) - x; + dy = (iy + 1.5) - y; + if (dx * dx + dy * dy <= halfSizeSquared) + setup->quad.mask |= MASK_TOP_RIGHT; + } + else { + /* square points */ + setup->quad.mask = 0xf; + + if (ix + 0.5 < x - halfSize) + setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT); + + if (ix + 1.5 > x + halfSize) + setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT); + + if (iy + 0.5 < y - halfSize) + setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT); + + if (iy + 1.5 > y + halfSize) + setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT); + } + + if (setup->quad.mask) { + setup->quad.x0 = ix; + setup->quad.y0 = iy; + quad_shade( setup->stage.softpipe, &setup->quad ); + } } } } diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 5002ce88fc..4d18e80b38 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -53,6 +53,9 @@ void softpipe_set_scissor_rect( struct pipe_context *, void softpipe_set_fs_state( struct pipe_context *, const struct pipe_fs_state * ); +void softpipe_set_point_state( struct pipe_context *, + const struct pipe_point_state * ); + void softpipe_set_polygon_stipple( struct pipe_context *, const struct pipe_poly_stipple * ); diff --git a/src/mesa/pipe/softpipe/sp_state_point.c b/src/mesa/pipe/softpipe/sp_state_point.c new file mode 100644 index 0000000000..566b33e696 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_state_point.c @@ -0,0 +1,47 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +/* Authors: Keith Whitwell + */ +#include "imports.h" + +#include "sp_context.h" +#include "sp_state.h" +#include "sp_draw.h" + + + +void softpipe_set_point_state( struct pipe_context *pipe, + const struct pipe_point_state *point ) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + + softpipe->point = *point; + + softpipe->dirty |= G_NEW_POINT; +} + diff --git a/src/mesa/sources b/src/mesa/sources index eb67dd9f7b..0bf7dbceb3 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -167,6 +167,7 @@ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_state_clip.c \ pipe/softpipe/sp_state_derived.c \ pipe/softpipe/sp_state_fs.c \ + pipe/softpipe/sp_state_point.c \ pipe/softpipe/sp_state_setup.c \ pipe/softpipe/sp_state_surface.c \ pipe/softpipe/sp_tile_fs.c \ @@ -180,6 +181,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_depth.c \ state_tracker/st_atom_fs.c \ state_tracker/st_atom_framebuffer.c \ + state_tracker/st_atom_point.c \ state_tracker/st_atom_scissor.c \ state_tracker/st_atom_stencil.c \ state_tracker/st_atom_setup.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 228e7889b7..8ac435041d 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -45,6 +45,7 @@ static const struct st_tracked_state *atoms[] = &st_update_framebuffer, &st_update_clip, &st_update_fs, + &st_update_point, &st_update_setup, &st_update_viewport, &st_update_scissor, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 8a75c9c6d5..56c33f3076 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -48,6 +48,7 @@ const struct st_tracked_state st_update_framebuffer; const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_depth; const struct st_tracked_state st_update_fs; +const struct st_tracked_state st_update_point; const struct st_tracked_state st_update_setup; const struct st_tracked_state st_update_viewport; const struct st_tracked_state st_update_constants; diff --git a/src/mesa/state_tracker/st_atom_point.c b/src/mesa/state_tracker/st_atom_point.c new file mode 100644 index 0000000000..7299142932 --- /dev/null +++ b/src/mesa/state_tracker/st_atom_point.c @@ -0,0 +1,70 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + + /* + * Authors: + * Keith Whitwell + * Brian Paul + */ + + +#include "st_context.h" +#include "st_atom.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" + + +static void +update_point( struct st_context *st ) +{ + struct pipe_point_state point; + + memset(&point, 0, sizeof(point)); + + point.smooth = st->ctx->Point.SmoothFlag; + point.size = st->ctx->Point.Size; + point.min_size = st->ctx->Point.MinSize; + point.max_size = st->ctx->Point.MaxSize; + point.attenuation[0] = st->ctx->Point.Params[0]; + point.attenuation[1] = st->ctx->Point.Params[1]; + point.attenuation[2] = st->ctx->Point.Params[2]; + + if (memcmp(&point, &st->state.point, sizeof(point)) != 0) { + /* state has changed */ + st->state.point = point; /* struct copy */ + st->pipe->set_point_state(st->pipe, &point); /* set new state */ + } +} + + +const struct st_tracked_state st_update_point = { + .dirty = { + .mesa = (_NEW_POINT), + .st = 0, + }, + .update = update_point +}; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index d98dd3aada..94388f1aee 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -71,9 +71,9 @@ struct st_context struct pipe_fs_state fs; struct pipe_alpha_test_state alpha_test; struct pipe_blend_state blend; - struct pipe_surface cbuf; struct pipe_clip_state clip; struct pipe_depth_state depth; + struct pipe_point_state point; struct pipe_scissor_rect scissor; struct pipe_poly_stipple poly_stipple; struct pipe_stencil_state stencil; -- cgit v1.2.3 From 73f96c51052bf5233191d852ef463462306bf1d5 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Jun 2007 08:47:09 -0600 Subject: Initial work for glClear(), clear color state. --- src/mesa/pipe/p_context.h | 10 +++-- src/mesa/pipe/p_state.h | 5 +++ src/mesa/pipe/softpipe/sp_clear.c | 47 +++++++++++++++++++++ src/mesa/pipe/softpipe/sp_clear.h | 43 +++++++++++++++++++ src/mesa/pipe/softpipe/sp_context.c | 4 +- src/mesa/pipe/softpipe/sp_context.h | 1 + src/mesa/pipe/softpipe/sp_state.h | 3 ++ src/mesa/pipe/softpipe/sp_state_surface.c | 15 ++++++- src/mesa/sources | 2 + src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom.h | 1 + src/mesa/state_tracker/st_atom_clear_color.c | 62 ++++++++++++++++++++++++++++ src/mesa/state_tracker/st_context.h | 1 + 13 files changed, 189 insertions(+), 6 deletions(-) create mode 100644 src/mesa/pipe/softpipe/sp_clear.c create mode 100644 src/mesa/pipe/softpipe/sp_clear.h create mode 100644 src/mesa/state_tracker/st_atom_clear_color.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 3e0c61eda2..32444343be 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -53,6 +53,10 @@ struct pipe_context { void (*draw_vb)( struct pipe_context *pipe, struct vertex_buffer *VB ); + /** Clear framebuffer */ + void (*clear)(struct pipe_context *pipe, GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum); + /* * State functions */ @@ -62,12 +66,12 @@ struct pipe_context { void (*set_blend_state)( struct pipe_context *, const struct pipe_blend_state * ); - void (*set_cbuf_state)( struct pipe_context *, - const struct pipe_surface * ); - void (*set_clip_state)( struct pipe_context *, const struct pipe_clip_state * ); + void (*set_clear_color_state)( struct pipe_context *, + const struct pipe_clear_color_state * ); + void (*set_depth_state)( struct pipe_context *, const struct pipe_depth_state * ); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index c88c0de6ad..c4bf0d2195 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -133,6 +133,11 @@ struct pipe_blend_color { GLfloat color[4]; }; +struct pipe_clear_color_state +{ + GLfloat color[4]; +}; + struct pipe_line_state { GLuint smooth:1; diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c new file mode 100644 index 0000000000..c7fbca4229 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -0,0 +1,47 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +/* Author: + * Brian Paul + */ + + +#include "sp_clear.h" + + +void +softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum) +{ + /* validate state (scissor)? */ + + if (color) { + } + if (depth) { + } + +} diff --git a/src/mesa/pipe/softpipe/sp_clear.h b/src/mesa/pipe/softpipe/sp_clear.h new file mode 100644 index 0000000000..f9db99dd32 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_clear.h @@ -0,0 +1,43 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +/* Author: + * Brian Paul + */ + +#ifndef SP_CLEAR_H +#define SP_CLEAR_H + +#include "pipe/p_state.h" +struct pipe_context; + +extern void +softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum); + + +#endif /* SP_CLEAR_H */ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index e0acf4177b..7ab65162bd 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -36,6 +36,7 @@ #include "vf/vf.h" #include "sp_context.h" +#include "sp_clear.h" #include "sp_prim.h" #include "sp_state.h" #include "sp_draw.h" @@ -68,6 +69,7 @@ struct pipe_context *softpipe_create( void ) softpipe->pipe.destroy = softpipe_destroy; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_clip_state = softpipe_set_clip_state; + softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_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; @@ -75,7 +77,7 @@ struct pipe_context *softpipe_create( void ) softpipe->pipe.set_fs_state = softpipe_set_fs_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; softpipe->pipe.draw_vb = softpipe_draw_vb; - + softpipe->pipe.clear = softpipe_clear; softpipe->prim.setup = prim_setup( softpipe ); diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 43cb6f3f0b..0a183ea385 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -76,6 +76,7 @@ struct softpipe_context { struct pipe_blend_state blend; struct pipe_alpha_test_state alpha_test; struct pipe_clip_state clip; + struct pipe_clear_color_state clear_color; struct pipe_point_state point; struct pipe_scissor_rect scissor; struct pipe_poly_stipple poly_stipple; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 4d18e80b38..bc5a3512ae 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_clear_color_state( struct pipe_context *, + const struct pipe_clear_color_state * ); + void softpipe_set_clip_state( struct pipe_context *, const struct pipe_clip_state * ); diff --git a/src/mesa/pipe/softpipe/sp_state_surface.c b/src/mesa/pipe/softpipe/sp_state_surface.c index 99332fdd52..4d27814e1b 100644 --- a/src/mesa/pipe/softpipe/sp_state_surface.c +++ b/src/mesa/pipe/softpipe/sp_state_surface.c @@ -37,8 +37,9 @@ /* * XXX this might get moved someday */ -void softpipe_set_framebuffer_state( struct pipe_context *pipe, - const struct pipe_framebuffer_state *fb ) +void +softpipe_set_framebuffer_state(struct pipe_context *pipe, + const struct pipe_framebuffer_state *fb) { struct softpipe_context *softpipe = softpipe_context(pipe); @@ -48,3 +49,13 @@ void softpipe_set_framebuffer_state( struct pipe_context *pipe, } + + +void +softpipe_set_clear_color_state(struct pipe_context *pipe, + const struct pipe_clear_color_state *clear) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + + softpipe->clear_color = *clear; /* struct copy */ +} diff --git a/src/mesa/sources b/src/mesa/sources index 0bf7dbceb3..97801648c4 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -155,6 +155,7 @@ VF_SOURCES = \ vf/vf_sse.c SOFTPIPE_SOURCES = \ + pipe/softpipe/sp_clear.c \ pipe/softpipe/sp_context.c \ pipe/softpipe/sp_draw.c \ pipe/softpipe/sp_prim_clip.c \ @@ -177,6 +178,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom.c \ state_tracker/st_atom_alphatest.c \ state_tracker/st_atom_blend.c \ + state_tracker/st_atom_clear_color.c \ state_tracker/st_atom_clip.c \ state_tracker/st_atom_depth.c \ state_tracker/st_atom_fs.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 8ac435041d..e1d187f2db 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -43,6 +43,7 @@ static const struct st_tracked_state *atoms[] = { &st_update_framebuffer, + &st_update_clear_color, &st_update_clip, &st_update_fs, &st_update_point, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 56c33f3076..8c1219fefd 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -46,6 +46,7 @@ void st_validate_state( struct st_context *st ); const struct st_tracked_state st_update_framebuffer; const struct st_tracked_state st_update_clip; +const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth; const struct st_tracked_state st_update_fs; const struct st_tracked_state st_update_point; diff --git a/src/mesa/state_tracker/st_atom_clear_color.c b/src/mesa/state_tracker/st_atom_clear_color.c new file mode 100644 index 0000000000..adf730cd8c --- /dev/null +++ b/src/mesa/state_tracker/st_atom_clear_color.c @@ -0,0 +1,62 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + + /* + * Authors: + * Keith Whitwell + * Brian Paul + */ + +#include "st_context.h" +#include "st_atom.h" +#include "pipe/p_context.h" + + +static void +update_clear_color_state( struct st_context *st ) +{ + struct pipe_clear_color_state clear; + + clear.color[0] = st->ctx->Color.ClearColor[0]; + clear.color[1] = st->ctx->Color.ClearColor[1]; + clear.color[2] = st->ctx->Color.ClearColor[2]; + clear.color[3] = st->ctx->Color.ClearColor[3]; + + if (memcmp(&clear, &st->state.clear_color, sizeof(clear)) != 0) { + st->state.clear_color = clear; + st->pipe->set_clear_color_state( st->pipe, &clear ); + } +} + + +const struct st_tracked_state st_update_clear_color = { + .dirty = { + .mesa = _NEW_COLOR, + .st = 0, + }, + .update = update_clear_color_state +}; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 94388f1aee..0f1fa2327b 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -71,6 +71,7 @@ struct st_context struct pipe_fs_state fs; struct pipe_alpha_test_state alpha_test; struct pipe_blend_state blend; + struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_depth_state depth; struct pipe_point_state point; -- 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/state_tracker/st_atom.c') 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 1be17dc446aa6b0770d76a3eccf79d0faf6608c0 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 26 Jun 2007 17:35:24 -0600 Subject: consolidate point/line state into pipe_setup_state --- src/mesa/pipe/p_context.h | 3 --- src/mesa/pipe/p_state.h | 31 +++++++++++-------------------- src/mesa/pipe/softpipe/sp_context.c | 1 - src/mesa/pipe/softpipe/sp_context.h | 1 - src/mesa/pipe/softpipe/sp_prim_setup.c | 4 ++-- src/mesa/pipe/softpipe/sp_state.h | 3 --- src/mesa/sources | 6 ++---- src/mesa/state_tracker/st_atom.c | 1 - src/mesa/state_tracker/st_atom.h | 1 - src/mesa/state_tracker/st_atom_setup.c | 28 +++++++++++++++++++++------- src/mesa/state_tracker/st_context.h | 1 - 11 files changed, 36 insertions(+), 44 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index d9546a24d2..93dbbe6ab7 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -75,9 +75,6 @@ struct pipe_context { void (*set_depth_state)( struct pipe_context *, const struct pipe_depth_state * ); - void (*set_point_state)( struct pipe_context *, - const struct pipe_point_state * ); - void (*set_framebuffer_state)( struct pipe_context *, const struct pipe_framebuffer_state * ); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 3e3da7cce6..e0fa4d54c3 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -70,9 +70,19 @@ struct pipe_setup_state GLuint offset_ccw:1; GLuint scissor:1; - GLuint poly_stipple:1; + GLuint poly_smooth:1; + GLuint poly_stipple_enable:1; + + GLuint line_smooth:1; + GLuint line_stipple_enable:1; + + GLuint point_smooth:1; + GLubyte line_stipple_factor; /**< [1..255] only */ + GLushort line_stipple_pattern; + GLfloat line_width; + GLfloat point_size; /**< used when no per-vertex size */ GLfloat offset_units; GLfloat offset_scale; }; @@ -147,25 +157,6 @@ struct pipe_clear_color_state GLfloat color[4]; }; -/** XXXX probably merge into pipe_setup_state */ -struct pipe_line_state -{ - GLuint smooth:1; - GLuint stipple:1; - GLushort stipple_pattern; - GLint stipple_factor; - GLfloat width; -}; - -/** XXXX probably merge into pipe_setup_state */ -struct pipe_point_state -{ - GLuint smooth:1; - GLfloat size; - GLfloat min_size, max_size; - GLfloat attenuation[3]; -}; - struct pipe_stencil_state { GLuint front_enabled:1; GLuint front_func:3; /**< PIPE_FUNC_x */ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 0d00c7eb6c..7a0aad0973 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -70,7 +70,6 @@ struct pipe_context *softpipe_create( void ) 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; softpipe->pipe.set_scissor_rect = softpipe_set_scissor_rect; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 7c816dbc1a..c38102e2fd 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -83,7 +83,6 @@ struct softpipe_context { 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; struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS]; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index a559b31a52..3f4602feb0 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -782,8 +782,8 @@ setup_point(struct prim_stage *stage, struct prim_header *prim) { struct setup_stage *setup = setup_stage( stage ); /*XXX this should be a vertex attrib! */ - GLfloat halfSize = 0.5 * setup->stage.softpipe->point.size; - GLboolean round = setup->stage.softpipe->point.smooth; + GLfloat halfSize = 0.5 * setup->stage.softpipe->setup.point_size; + GLboolean round = setup->stage.softpipe->setup.point_smooth; const struct vertex_header *v0 = prim->v[0]; const GLfloat x = v0->data[FRAG_ATTRIB_WPOS][0]; const GLfloat y = v0->data[FRAG_ATTRIB_WPOS][1]; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 735d039748..4086c16bcc 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -73,9 +73,6 @@ void softpipe_set_scissor_rect( struct pipe_context *, void softpipe_set_fs_state( struct pipe_context *, const struct pipe_fs_state * ); -void softpipe_set_point_state( struct pipe_context *, - const struct pipe_point_state * ); - void softpipe_set_polygon_stipple( struct pipe_context *, const struct pipe_poly_stipple * ); diff --git a/src/mesa/sources b/src/mesa/sources index 3887e9f3c2..c0c4b35355 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -175,9 +175,8 @@ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_state_clip.c \ pipe/softpipe/sp_state_derived.c \ pipe/softpipe/sp_state_fs.c \ - pipe/softpipe/sp_state_point.c \ - pipe/softpipe/sp_state_setup.c \ pipe/softpipe/sp_state_sampler.c \ + pipe/softpipe/sp_state_setup.c \ pipe/softpipe/sp_state_surface.c STATETRACKER_SOURCES = \ @@ -189,11 +188,10 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_depth.c \ state_tracker/st_atom_fs.c \ state_tracker/st_atom_framebuffer.c \ - state_tracker/st_atom_point.c \ state_tracker/st_atom_sampler.c \ state_tracker/st_atom_scissor.c \ - state_tracker/st_atom_stencil.c \ state_tracker/st_atom_setup.c \ + state_tracker/st_atom_stencil.c \ state_tracker/st_atom_viewport.c \ state_tracker/st_cb_program.c \ state_tracker/st_draw.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 5fcd9d7af5..88c6c776a3 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -47,7 +47,6 @@ static const struct st_tracked_state *atoms[] = &st_update_depth, &st_update_clip, &st_update_fs, - &st_update_point, &st_update_setup, &st_update_viewport, &st_update_scissor, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 8c1219fefd..7ea3301ea5 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -49,7 +49,6 @@ const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth; const struct st_tracked_state st_update_fs; -const struct st_tracked_state st_update_point; const struct st_tracked_state st_update_setup; const struct st_tracked_state st_update_viewport; const struct st_tracked_state st_update_constants; diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c index fcda2b3a41..23adf0b7c8 100644 --- a/src/mesa/state_tracker/st_atom_setup.c +++ b/src/mesa/state_tracker/st_atom_setup.c @@ -101,12 +101,6 @@ static void update_setup_state( struct st_context *st ) ctx->Light.Model.TwoSide) setup.light_twoside = 1; - if (ctx->Polygon.SmoothFlag) - setup.poly_smooth = 1; - - if (ctx->Polygon.StippleFlag) - setup.poly_stipple = 1; - /* _NEW_POLYGON */ if (ctx->Polygon.CullFlag) { @@ -158,6 +152,12 @@ static void update_setup_state( struct st_context *st ) if (setup.fill_ccw != PIPE_POLYGON_MODE_FILL) setup.offset_ccw = get_offset_flag( setup.fill_ccw, &ctx->Polygon ); + if (ctx->Polygon.SmoothFlag) + setup.poly_smooth = 1; + + if (ctx->Polygon.StippleFlag) + setup.poly_stipple_enable = 1; + /* _NEW_BUFFERS, _NEW_POLYGON */ @@ -173,6 +173,19 @@ static void update_setup_state( struct st_context *st ) st->polygon_offset_scale); } + /* _NEW_POINT + */ + setup.point_size = ctx->Point.Size; + setup.point_smooth = ctx->Point.SmoothFlag; + + /* _NEW_LINE + */ + setup.line_width = ctx->Line.Width; + setup.line_smooth = ctx->Line.SmoothFlag; + setup.line_stipple_enable = ctx->Line.StippleFlag; + setup.line_stipple_pattern = ctx->Line.StipplePattern; + setup.line_stipple_factor = ctx->Line.StippleFactor; + if (memcmp(&setup, &st->state.setup, sizeof(setup)) != 0) { st->state.setup = setup; @@ -182,7 +195,8 @@ static void update_setup_state( struct st_context *st ) const struct st_tracked_state st_update_setup = { .dirty = { - .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_BUFFERS), + .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | + _NEW_POINT | _NEW_BUFFERS), .st = 0, }, .update = update_setup_state diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 582d586a73..48ea7f12ee 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -74,7 +74,6 @@ struct st_context struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_depth_state depth; - struct pipe_point_state point; struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS]; struct pipe_scissor_rect scissor; struct pipe_poly_stipple poly_stipple; -- cgit v1.2.3 From e89bd0fbc56ecfb96f3aff926c5891c45221dd37 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 11 Jul 2007 11:34:19 -0600 Subject: Implement polygon stipple state tracking, application. --- src/mesa/pipe/softpipe/sp_context.c | 1 + src/mesa/pipe/softpipe/sp_context.h | 1 + src/mesa/pipe/softpipe/sp_prim_setup.c | 3 ++ src/mesa/pipe/softpipe/sp_quad.c | 4 ++ src/mesa/pipe/softpipe/sp_quad.h | 1 + src/mesa/pipe/softpipe/sp_quad_stipple.c | 56 ++++++++++++++++++++++++++++ src/mesa/pipe/softpipe/sp_state_derived.c | 7 +++- src/mesa/sources | 2 + src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom.h | 1 + src/mesa/state_tracker/st_atom_stipple.c | 62 +++++++++++++++++++++++++++++++ 11 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/mesa/pipe/softpipe/sp_quad_stipple.c create mode 100644 src/mesa/state_tracker/st_atom_stipple.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 50434600c3..a5bd61b784 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -83,6 +83,7 @@ struct pipe_context *softpipe_create( void ) softpipe->pipe.draw_vb = softpipe_draw_vb; softpipe->pipe.clear = softpipe_clear; + softpipe->quad.polygon_stipple = sp_quad_polygon_stipple_stage(softpipe); softpipe->quad.shade = sp_quad_shade_stage(softpipe); softpipe->quad.alpha_test = sp_quad_alpha_test_stage(softpipe); softpipe->quad.blend = sp_quad_blend_stage(softpipe); diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 2379a99b81..21d6108ac6 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -117,6 +117,7 @@ struct softpipe_context { /** Software quad rendering pipeline */ struct { + struct quad_stage *polygon_stipple; struct quad_stage *shade; struct quad_stage *alpha_test; struct quad_stage *stencil_test; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 332113979c..0148a26259 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -922,6 +922,9 @@ static void setup_end( struct prim_stage *stage ) } +/** + * Create a new primitive setup/render stage. + */ struct prim_stage *prim_setup( struct softpipe_context *softpipe ) { struct setup_stage *setup = CALLOC_STRUCT(setup_stage); diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index 31278f529d..aba5ab280e 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -37,4 +37,8 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.shade; } + if (sp->setup.poly_stipple_enable) { + sp->quad.polygon_stipple->next = sp->quad.first; + sp->quad.first = sp->quad.polygon_stipple; + } } diff --git a/src/mesa/pipe/softpipe/sp_quad.h b/src/mesa/pipe/softpipe/sp_quad.h index df416dfa7f..8b8e12261b 100644 --- a/src/mesa/pipe/softpipe/sp_quad.h +++ b/src/mesa/pipe/softpipe/sp_quad.h @@ -46,6 +46,7 @@ struct quad_stage { }; +struct quad_stage *sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe ); struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe ); struct quad_stage *sp_quad_alpha_test_stage( struct softpipe_context *softpipe ); struct quad_stage *sp_quad_stencil_test_stage( struct softpipe_context *softpipe ); diff --git a/src/mesa/pipe/softpipe/sp_quad_stipple.c b/src/mesa/pipe/softpipe/sp_quad_stipple.c new file mode 100644 index 0000000000..f9a3c0ba26 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_quad_stipple.c @@ -0,0 +1,56 @@ + +/** + * quad polygon stipple stage + */ + +#include "glheader.h" +#include "imports.h" +#include "sp_context.h" +#include "sp_headers.h" +#include "sp_quad.h" +#include "pipe/p_defines.h" + + +/** + * Apply polygon stipple to quads produced by triangle rasterization + */ +static void +stipple_quad(struct quad_stage *qs, struct quad_header *quad) +{ + struct softpipe_context *softpipe = qs->softpipe; + const GLint col0 = quad->x0 % 32; + const GLint row0 = quad->y0 % 32; + const GLuint stipple0 = softpipe->poly_stipple.stipple[row0]; + const GLuint stipple1 = softpipe->poly_stipple.stipple[row0 + 1]; + GLbitfield mask = 0x0; + + /* XXX this could be optimize a bit to use just two conditionals */ + if ((1 << col0) & stipple0) + mask |= MASK_BOTTOM_LEFT; + + if ((2 << col0) & stipple0) + mask |= MASK_BOTTOM_RIGHT; + + if ((1 << col0) & stipple1) + mask |= MASK_TOP_LEFT; + + if ((2 << col0) & stipple1) + mask |= MASK_TOP_RIGHT; + + quad->mask &= mask; + + if (quad->mask) + qs->next->run(qs->next, quad); +} + + +struct quad_stage * +sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe ) +{ + struct quad_stage *stage = CALLOC_STRUCT(quad_stage); + + stage->softpipe = softpipe; + stage->run = stipple_quad; + + return stage; +} diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 429ae55397..34c893e396 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -137,7 +137,12 @@ void softpipe_update_derived( struct softpipe_context *softpipe ) if (softpipe->dirty & (SP_NEW_SETUP | SP_NEW_FS)) calculate_vertex_layout( softpipe ); - if (softpipe->dirty & (SP_NEW_BLEND | SP_NEW_DEPTH_TEST | SP_NEW_ALPHA_TEST | SP_NEW_FS)) + if (softpipe->dirty & (SP_NEW_BLEND | + SP_NEW_DEPTH_TEST | + SP_NEW_ALPHA_TEST | + SP_NEW_STENCIL | + SP_NEW_SETUP | + SP_NEW_FS)) sp_build_quad_pipeline(softpipe); softpipe->dirty = 0; diff --git a/src/mesa/sources b/src/mesa/sources index 1ffac8df0a..a7d132f4fd 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -163,6 +163,7 @@ SOFTPIPE_SOURCES = \ pipe/softpipe/sp_quad_depth_test.c \ pipe/softpipe/sp_quad_fs.c \ pipe/softpipe/sp_quad_output.c \ + pipe/softpipe/sp_quad_stipple.c \ pipe/softpipe/sp_quad_stencil.c \ pipe/softpipe/sp_state_blend.c \ pipe/softpipe/sp_state_clip.c \ @@ -206,6 +207,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_scissor.c \ state_tracker/st_atom_setup.c \ state_tracker/st_atom_stencil.c \ + state_tracker/st_atom_stipple.c \ state_tracker/st_atom_viewport.c \ state_tracker/st_cb_program.c \ state_tracker/st_draw.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 88c6c776a3..dfebfb4768 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -48,6 +48,7 @@ static const struct st_tracked_state *atoms[] = &st_update_clip, &st_update_fs, &st_update_setup, + &st_update_polygon_stipple, &st_update_viewport, &st_update_scissor, &st_update_blend, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 7ea3301ea5..a56483ac39 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -50,6 +50,7 @@ const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth; const struct st_tracked_state st_update_fs; const struct st_tracked_state st_update_setup; +const struct st_tracked_state st_update_polygon_stipple; const struct st_tracked_state st_update_viewport; const struct st_tracked_state st_update_constants; const struct st_tracked_state st_update_scissor; diff --git a/src/mesa/state_tracker/st_atom_stipple.c b/src/mesa/state_tracker/st_atom_stipple.c new file mode 100644 index 0000000000..dd04d2158c --- /dev/null +++ b/src/mesa/state_tracker/st_atom_stipple.c @@ -0,0 +1,62 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + + /* + * \brief polygon stipple state + * + * Authors: + * Brian Paul + */ + + +#include "st_context.h" +#include "st_atom.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" + + +static void +update_stipple( struct st_context *st ) +{ + const GLuint sz = sizeof(st->state.poly_stipple.stipple); + assert(sz == sizeof(st->ctx->PolygonStipple)); + + if (memcmp(&st->state.poly_stipple.stipple, st->ctx->PolygonStipple, sz)) { + /* state has changed */ + memcpy(st->state.poly_stipple.stipple, st->ctx->PolygonStipple, sz); + st->pipe->set_polygon_stipple(st->pipe, &st->state.poly_stipple); + } +} + + +const struct st_tracked_state st_update_polygon_stipple = { + .dirty = { + .mesa = (_NEW_POLYGONSTIPPLE), + .st = 0, + }, + .update = update_stipple +}; -- cgit v1.2.3 From 4824c342c864e870251a7d343c95e51274e50d23 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 19 Jul 2007 20:24:55 +0100 Subject: Trigger tgsi compilation for fragment programs. Not sure the generated program looks correct though... --- src/mesa/pipe/p_state.h | 5 ++- src/mesa/pipe/softpipe/sp_state_derived.c | 4 +-- src/mesa/pipe/tgsi/core/tgsi_dump.c | 4 +++ src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h | 2 ++ src/mesa/sources | 1 + src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom.h | 1 + src/mesa/state_tracker/st_atom_fs.c | 27 ++++++++++++-- src/mesa/state_tracker/st_atom_vs.c | 49 +++++++++++++++++++++++++ src/mesa/state_tracker/st_cb_program.c | 59 ++++++++++++++----------------- src/mesa/state_tracker/st_context.h | 1 + src/mesa/state_tracker/st_program.h | 38 +++++++++++++++++++- 12 files changed, 152 insertions(+), 40 deletions(-) create mode 100644 src/mesa/state_tracker/st_atom_vs.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index fd5e7ad3af..e3f62a80ad 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -121,8 +121,11 @@ struct pipe_clip_state { GLuint nr; }; + struct pipe_fs_state { - struct gl_fragment_program *fp; + GLuint inputs_read; /* FRAG_ATTRIB_* */ + const struct tgsi_token *tokens; + }; struct pipe_constant_buffer { diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 18dfb50e38..fcdedb54a9 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -28,7 +28,6 @@ #include "main/glheader.h" #include "main/macros.h" #include "main/enums.h" -#include "shader/program.h" #include "vf/vf.h" #include "pipe/draw/draw_context.h" @@ -68,8 +67,7 @@ static const GLuint frag_to_vf[FRAG_ATTRIB_MAX] = */ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { - struct gl_fragment_program *fp = softpipe->fs.fp; - const GLuint inputsRead = fp->Base.InputsRead; + const GLuint inputsRead = softpipe->fs.inputs_read; GLuint slot_to_vf_attr[VF_ATTRIB_MAX]; GLbitfield attr_mask = 0x0; GLuint i; diff --git a/src/mesa/pipe/tgsi/core/tgsi_dump.c b/src/mesa/pipe/tgsi/core/tgsi_dump.c index fecb246ab1..0345fd93f7 100644 --- a/src/mesa/pipe/tgsi/core/tgsi_dump.c +++ b/src/mesa/pipe/tgsi/core/tgsi_dump.c @@ -400,12 +400,16 @@ tgsi_dump( GLuint deflt = !(flags & TGSI_DUMP_NO_DEFAULT); { +#if 0 static GLuint counter = 0; char buffer[64]; sprintf( buffer, "sbir-dump-%.4u.txt", counter++ ); dump.file = fopen( buffer, "wt" ); +#else + dump.file = stderr; dump.tabs = 0; +#endif } tgsi_parse_init( &parse, tokens ); diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h index 4c1141e579..9256318997 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h @@ -5,6 +5,8 @@ extern "C" { #endif // defined __cplusplus +struct tgsi_token; + GLboolean tgsi_mesa_compile_fp_program( const struct gl_fragment_program *program, diff --git a/src/mesa/sources b/src/mesa/sources index a76e41bdda..a589ae4373 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -206,6 +206,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_clip.c \ state_tracker/st_atom_depth.c \ state_tracker/st_atom_fs.c \ + state_tracker/st_atom_vs.c \ state_tracker/st_atom_framebuffer.c \ state_tracker/st_atom_sampler.c \ state_tracker/st_atom_scissor.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index dfebfb4768..85c99bc182 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -46,6 +46,7 @@ static const struct st_tracked_state *atoms[] = &st_update_clear_color, &st_update_depth, &st_update_clip, + &st_update_vs, &st_update_fs, &st_update_setup, &st_update_polygon_stipple, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index a56483ac39..1b70e27933 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -49,6 +49,7 @@ const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth; const struct st_tracked_state st_update_fs; +const struct st_tracked_state st_update_vs; const struct st_tracked_state st_update_setup; const struct st_tracked_state st_update_polygon_stipple; const struct st_tracked_state st_update_viewport; diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index 9c6bc1ce2a..6fa4f53c73 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -32,15 +32,38 @@ #include "st_context.h" #include "pipe/p_context.h" #include "st_atom.h" +#include "st_program.h" +#include "pipe/tgsi/mesa/mesa_to_tgsi.h" +#include "pipe/tgsi/core/tgsi_dump.h" + +static void compile_fs( struct st_context *st, + struct st_fragment_program *fs ) +{ + /* XXX: fix static allocation of tokens: + */ + tgsi_mesa_compile_fp_program( &fs->Base, fs->tokens, ST_FP_MAX_TOKENS ); + + tgsi_dump( fs->tokens, TGSI_DUMP_VERBOSE ); +} static void update_fs( struct st_context *st ) { struct pipe_fs_state fs; + struct st_fragment_program *fp = st_fragment_program(st->ctx->FragmentProgram._Current); + + memset( &fs, 0, sizeof(fs) ); - fs.fp = st->ctx->FragmentProgram._Current; + if (fp->dirty) + compile_fs( st, fp ); + + fs.inputs_read = fp->Base.Base.InputsRead; + fs.tokens = &fp->tokens[0]; - if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0) { + if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 || + fp->dirty) + { + fp->dirty = 0; st->state.fs = fs; st->pipe->set_fs_state(st->pipe, &fs); } diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c new file mode 100644 index 0000000000..6a26bfdd19 --- /dev/null +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -0,0 +1,49 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + /* + * Authors: + * Keith Whitwell + */ + +#include "st_context.h" +#include "pipe/p_context.h" +#include "st_atom.h" + + + +static void update_vs( struct st_context *st ) +{ +} + + +const struct st_tracked_state st_update_vs = { + .dirty = { + .mesa = 0, + .st = ST_NEW_VERTEX_PROGRAM, + }, + .update = update_vs +}; diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 327b627722..18061ca69c 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -52,6 +52,7 @@ static void st_bind_program( GLcontext *ctx, switch (target) { case GL_VERTEX_PROGRAM_ARB: + st->dirty.st |= ST_NEW_VERTEX_PROGRAM; break; case GL_FRAGMENT_PROGRAM_ARB: st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; @@ -66,16 +67,23 @@ static struct gl_program *st_new_program( GLcontext *ctx, struct st_context *st = st_context(ctx); switch (target) { - case GL_VERTEX_PROGRAM_ARB: - return _mesa_init_vertex_program(ctx, - CALLOC_STRUCT(gl_vertex_program), - target, - id); + case GL_VERTEX_PROGRAM_ARB: { + struct st_vertex_program *prog = CALLOC_STRUCT(st_vertex_program); + + prog->id = st->program_id++; + prog->dirty = 1; + + return _mesa_init_vertex_program( ctx, + &prog->Base, + target, + id ); + } case GL_FRAGMENT_PROGRAM_ARB: { struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program); prog->id = st->program_id++; + prog->dirty = 1; return _mesa_init_fragment_program( ctx, &prog->Base, @@ -106,40 +114,25 @@ static void st_program_string_notify( GLcontext *ctx, GLenum target, struct gl_program *prog ) { - if (target == GL_FRAGMENT_PROGRAM_ARB) { - struct st_context *st = st_context(ctx); + struct st_context *st = st_context(ctx); - if (prog == &st->ctx->FragmentProgram._Current->Base) - { - struct st_fragment_program *p = - (struct st_fragment_program *) prog; + if (target == GL_FRAGMENT_PROGRAM_ARB) { + struct st_fragment_program *p = (struct st_fragment_program *)prog; + if (prog == &ctx->FragmentProgram._Current->Base) st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; - p->id = st->program_id++; -#if 0 - p->param_state = p->Base.Base.Parameters->StateFlags; - p->translated = 0; -#endif - - /* Gack! do this in the compiler: - */ - if (p->Base.FogOption) { - /* add extra instructions to do fog, then turn off FogOption field */ - _mesa_append_fog_code(ctx, &p->Base); - p->Base.FogOption = GL_NONE; - } - - /* XXX: Not hooked-up yet. */ - { - struct tgsi_token tokens[1024]; - - tgsi_mesa_compile_fp_program( prog, tokens, 1024 ); - tgsi_dump( tokens, TGSI_DUMP_VERBOSE ); - } - } + p->id = st->program_id++; + p->param_state = p->Base.Base.Parameters->StateFlags; } else if (target == GL_VERTEX_PROGRAM_ARB) { + struct st_vertex_program *p = (struct st_vertex_program *)prog; + + if (prog == &ctx->VertexProgram._Current->Base) + st->dirty.st |= ST_NEW_VERTEX_PROGRAM; + + p->id = st->program_id++; + p->param_state = p->Base.Base.Parameters->StateFlags; /* Also tell tnl about it: */ diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index c1d868604c..ef3cdb3b09 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -40,6 +40,7 @@ struct st_fragment_program; #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 +#define ST_NEW_VERTEX_PROGRAM 0x4 struct st_state_flags { GLuint mesa; diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index a47059d7a6..b28887946d 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -34,6 +34,12 @@ #ifndef ST_PROGRAM_H #define ST_PROGRAM_H +#include "mtypes.h" +#include "pipe/tgsi/core/tgsi_token.h" + +#define ST_FP_MAX_TOKENS 1024 + + struct st_fragment_program { struct gl_fragment_program Base; @@ -43,6 +49,11 @@ struct st_fragment_program * ProgramStringNotify changes. */ + + struct tgsi_token tokens[ST_FP_MAX_TOKENS]; + GLboolean dirty; + + #if 0 GLfloat (*cbuffer)[4]; GLuint nr_constants; @@ -56,13 +67,38 @@ struct st_fragment_program const GLfloat *values; /* Pointer to tracked values */ } *param; GLuint nr_params; +#endif GLuint param_state; -#endif }; +struct st_vertex_program +{ + struct gl_vertex_program Base; + GLboolean error; /* If program is malformed for any reason. */ + + GLuint id; /* String id, for tracking + * ProgramStringNotify changes. + */ + + GLboolean dirty; + GLuint param_state; +}; + void st_init_cb_program( struct st_context *st ); void st_destroy_cb_program( struct st_context *st ); +static inline struct st_fragment_program * +st_fragment_program( struct gl_fragment_program *fp ) +{ + return (struct st_fragment_program *)fp; +} + +static inline struct st_vertex_program * +st_vertex_program( struct gl_vertex_program *vp ) +{ + return (struct st_vertex_program *)vp; +} + #endif -- cgit v1.2.3 From d78dab126724e6e9d475289a086fb6f85adc3985 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 7 Aug 2007 15:12:22 -0600 Subject: plug in texture/sampler state update --- src/mesa/state_tracker/st_atom.c | 2 ++ src/mesa/state_tracker/st_atom.h | 2 ++ src/mesa/state_tracker/st_atom_sampler.c | 14 ++++++++------ src/mesa/state_tracker/st_atom_texture.c | 5 ++++- src/mesa/state_tracker/st_cb_texture.c | 8 ++++++++ src/mesa/state_tracker/st_cb_texture.h | 4 ++++ 6 files changed, 28 insertions(+), 7 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 85c99bc182..32b8b8f277 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -54,6 +54,8 @@ static const struct st_tracked_state *atoms[] = &st_update_scissor, &st_update_blend, &st_update_stencil, + &st_update_sampler, + &st_update_texture, /* will be patched out at runtime */ /* &st_update_constants */ }; diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 1b70e27933..2f628206ca 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -57,6 +57,8 @@ const struct st_tracked_state st_update_constants; const struct st_tracked_state st_update_scissor; const struct st_tracked_state st_update_blend; const struct st_tracked_state st_update_stencil; +const struct st_tracked_state st_update_sampler; +const struct st_tracked_state st_update_texture; #endif diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 1aa9da8484..a49698cda4 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -103,14 +103,16 @@ update_samplers(struct st_context *st) memset(&sampler, 0, sizeof(sampler)); - sampler.wrap_s = gl_wrap_to_sp(texobj->WrapS); - sampler.wrap_t = gl_wrap_to_sp(texobj->WrapT); - sampler.wrap_r = gl_wrap_to_sp(texobj->WrapR); + if (texobj) { + sampler.wrap_s = gl_wrap_to_sp(texobj->WrapS); + sampler.wrap_t = gl_wrap_to_sp(texobj->WrapT); + sampler.wrap_r = gl_wrap_to_sp(texobj->WrapR); - sampler.min_filter = gl_filter_to_sp(texobj->MinFilter); - sampler.mag_filter = gl_filter_to_sp(texobj->MagFilter); + sampler.min_filter = gl_filter_to_sp(texobj->MinFilter); + sampler.mag_filter = gl_filter_to_sp(texobj->MagFilter); - /* XXX more sampler state here */ + /* XXX more sampler state here */ + } if (memcmp(&sampler, &st->state.sampler[u], sizeof(sampler)) != 0) { /* state has changed */ diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index bb83f7d121..f82c33e572 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -39,7 +39,10 @@ #include "pipe/p_defines.h" - +/** + * XXX This needs some work yet.... + * Need to "upload" texture images at appropriate times. + */ static void update_textures(struct st_context *st) { diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 5872ae3e74..42d6b75cb3 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -104,6 +104,14 @@ st_texture_image(struct gl_texture_image *img) } +struct pipe_mipmap_tree * +st_get_texobj_mipmap_tree(struct gl_texture_object *texObj) +{ + struct st_texture_object *stObj = st_texture_object(texObj); + return stObj->mt; +} + + static int intel_compressed_num_bytes(GLuint mesaFormat) { diff --git a/src/mesa/state_tracker/st_cb_texture.h b/src/mesa/state_tracker/st_cb_texture.h index c732881c39..dc68aa3d97 100644 --- a/src/mesa/state_tracker/st_cb_texture.h +++ b/src/mesa/state_tracker/st_cb_texture.h @@ -2,6 +2,10 @@ #define ST_CB_TEXTURE_H +extern struct pipe_mipmap_tree * +st_get_texobj_mipmap_tree(struct gl_texture_object *texObj); + + extern GLuint st_finalize_mipmap_tree(GLcontext *ctx, struct pipe_context *pipe, GLuint unit, -- cgit v1.2.3 From b3f067e8593b9fda0474041f32479b20cd64e728 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 18 Aug 2007 16:04:49 +0100 Subject: added tnl state atom --- src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom.h | 1 + src/mesa/state_tracker/st_atom_vs.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 32b8b8f277..d67291e50b 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -46,6 +46,7 @@ static const struct st_tracked_state *atoms[] = &st_update_clear_color, &st_update_depth, &st_update_clip, + &st_update_tnl, &st_update_vs, &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 2f628206ca..51da489f6d 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -48,6 +48,7 @@ const struct st_tracked_state st_update_framebuffer; const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth; +const struct st_tracked_state st_update_tnl; const struct st_tracked_state st_update_fs; const struct st_tracked_state st_update_vs; const struct st_tracked_state st_update_setup; diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index cef6e38d56..c8bd805e02 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -27,9 +27,11 @@ /* * Authors: * Keith Whitwell + * Brian Paul */ #include "shader/prog_parameter.h" +#include "tnl/t_vp_build.h" #include "pipe/p_context.h" #include "pipe/tgsi/mesa/mesa_to_tgsi.h" @@ -39,6 +41,7 @@ #include "st_atom.h" #include "st_program.h" + #define TGSI_DEBUG 0 static void compile_vs( struct st_context *st, @@ -59,8 +62,10 @@ static void update_vs( struct st_context *st ) struct st_vertex_program *vp = NULL; struct gl_program_parameter_list *params = NULL; +#if 0 if (st->ctx->VertexProgram._MaintainTnlProgram) _tnl_UpdateFixedFunctionProgram( st->ctx ); +#endif if (st->ctx->Shader.CurrentProgram && st->ctx->Shader.CurrentProgram->LinkStatus && @@ -83,6 +88,7 @@ static void update_vs( struct st_context *st ) if (vp && params) { /* load program's constants array */ + /* XXX this should probably be done elsewhere/separately */ _mesa_load_state_parameters(st->ctx, params); vp->constants.nr_constants = params->NumParameters; @@ -117,3 +123,26 @@ const struct st_tracked_state st_update_vs = { }, .update = update_vs }; + + + + + +/** + * When TnL state has changed, need to generate new vertex program. + * This should be done before updating the vertes shader (vs) state. + */ +static void update_tnl( struct st_context *st ) +{ + if (st->ctx->VertexProgram._MaintainTnlProgram) + _tnl_UpdateFixedFunctionProgram( st->ctx ); +} + + +const struct st_tracked_state st_update_tnl = { + .dirty = { + .mesa = _NEW_PROGRAM | _NEW_LIGHT | _NEW_TEXTURE, /* XXX more? */ + .st = ST_NEW_MESA, /* XXX correct? */ + }, + .update = update_tnl +}; -- cgit v1.2.3 From 07d97e80e616d9fdc437d3b41055c347d5c54932 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 24 Aug 2007 18:30:00 +0100 Subject: checkpoint in constant tracking rework --- src/mesa/sources | 6 +- src/mesa/state_tracker/st_atom.c | 51 ++++++++++---- src/mesa/state_tracker/st_atom.h | 3 +- src/mesa/state_tracker/st_atom_cbuf.c | 72 ------------------- src/mesa/state_tracker/st_atom_fs.c | 84 ++++++++-------------- src/mesa/state_tracker/st_atom_vs.c | 124 ++++++++++----------------------- src/mesa/state_tracker/st_cb_program.c | 16 ++++- src/mesa/state_tracker/st_context.h | 5 +- src/mesa/state_tracker/st_program.h | 20 +----- src/mesa/tnl/t_vp_build.h | 7 ++ 10 files changed, 134 insertions(+), 254 deletions(-) delete mode 100644 src/mesa/state_tracker/st_atom_cbuf.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/sources b/src/mesa/sources index 61a8d580ad..53969774f9 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -186,10 +186,11 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_blend.c \ state_tracker/st_atom_clear_color.c \ state_tracker/st_atom_clip.c \ + state_tracker/st_atom_constbuf.c \ state_tracker/st_atom_depth.c \ - state_tracker/st_atom_fs.c \ - state_tracker/st_atom_vs.c \ + state_tracker/st_atom_fixedfunction.c \ state_tracker/st_atom_framebuffer.c \ + state_tracker/st_atom_fs.c \ state_tracker/st_atom_sampler.c \ state_tracker/st_atom_scissor.c \ state_tracker/st_atom_setup.c \ @@ -197,6 +198,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_stipple.c \ state_tracker/st_atom_texture.c \ state_tracker/st_atom_viewport.c \ + state_tracker/st_atom_vs.c \ state_tracker/st_cb_bufferobjects.c \ state_tracker/st_cb_clear.c \ state_tracker/st_cb_flush.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index d67291e50b..99fcbdfda7 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -29,8 +29,10 @@ #include "glheader.h" #include "context.h" +#include "pipe/p_defines.h" #include "st_context.h" #include "st_atom.h" +#include "st_program.h" @@ -46,9 +48,11 @@ static const struct st_tracked_state *atoms[] = &st_update_clear_color, &st_update_depth, &st_update_clip, + &st_update_tnl, &st_update_vs, &st_update_fs, + &st_update_setup, &st_update_polygon_stipple, &st_update_viewport, @@ -57,8 +61,8 @@ static const struct st_tracked_state *atoms[] = &st_update_stencil, &st_update_sampler, &st_update_texture, - /* will be patched out at runtime */ -/* &st_update_constants */ + &st_update_vs_constants, + &st_update_fs_constants, }; @@ -72,13 +76,17 @@ void st_init_atoms( struct st_context *st ) /* Patch in a pointer to the dynamic state atom: */ - for (i = 0; i < st->nr_atoms; i++) - if (st->atoms[i] == &st_update_constants) - st->atoms[i] = &st->constants.tracked_state; + for (i = 0; i < st->nr_atoms; i++) { + if (st->atoms[i] == &st_update_vs_constants) { + st->atoms[i] = &st->constants.tracked_state[PIPE_SHADER_VERTEX]; + st->atoms[i][0] = st_update_vs_constants; + } - memcpy(&st->constants.tracked_state, - &st_update_constants, - sizeof(st_update_constants)); + if (st->atoms[i] == &st_update_fs_constants) { + st->atoms[i] = &st->constants.tracked_state[PIPE_SHADER_FRAGMENT]; + st->atoms[i][0] = st_update_fs_constants; + } + } } @@ -118,6 +126,21 @@ static void xor_states( struct st_state_flags *result, } +/* Too complex to figure out, just check every time: + */ +static void check_program_state( struct st_context *st ) +{ + GLcontext *ctx = st->ctx; + + if (ctx->VertexProgram._Current != &st->vp->Base) + st->dirty.st |= ST_NEW_VERTEX_PROGRAM; + + if (ctx->FragmentProgram._Current != &st->fp->Base) + st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; + +} + + /*********************************************************************** * Update all derived state: */ @@ -127,6 +150,8 @@ void st_validate_state( struct st_context *st ) struct st_state_flags *state = &st->dirty; GLuint i; + check_program_state( st ); + if (state->st == 0) return; @@ -142,10 +167,12 @@ void st_validate_state( struct st_context *st ) for (i = 0; i < st->nr_atoms; i++) { const struct st_tracked_state *atom = st->atoms[i]; struct st_state_flags generated; - - assert(atom->dirty.mesa || - atom->dirty.st); - assert(atom->update); + + if (!(atom->dirty.mesa || atom->dirty.st) || + !atom->update) { + _mesa_printf("malformed atom %d\n", i); + assert(0); + } if (check_state(state, &atom->dirty)) { st->atoms[i]->update( st ); diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 51da489f6d..447430bfef 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -54,12 +54,13 @@ const struct st_tracked_state st_update_vs; const struct st_tracked_state st_update_setup; const struct st_tracked_state st_update_polygon_stipple; const struct st_tracked_state st_update_viewport; -const struct st_tracked_state st_update_constants; const struct st_tracked_state st_update_scissor; const struct st_tracked_state st_update_blend; const struct st_tracked_state st_update_stencil; const struct st_tracked_state st_update_sampler; const struct st_tracked_state st_update_texture; +const struct st_tracked_state st_update_fs_constants; +const struct st_tracked_state st_update_vs_constants; #endif diff --git a/src/mesa/state_tracker/st_atom_cbuf.c b/src/mesa/state_tracker/st_atom_cbuf.c deleted file mode 100644 index 0f90aa7646..0000000000 --- a/src/mesa/state_tracker/st_atom_cbuf.c +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - - /* - * Authors: - * Keith Whitwell - */ - -#include "st_context.h" -#include "pipe/p_context.h" -#include "st_atom.h" - -extern GLboolean xmesa_get_cbuf_details( GLcontext *ctx, - void **ptr, - GLuint *cpp, - GLint *stride, - GLuint *format ); - - -/* This is a hack to work with the X11 driver as a test harness - */ -static void update_cbuf_state( struct st_context *st ) -{ - struct pipe_surface cbuf; - GLboolean ok; - - ok = xmesa_get_cbuf_details( st->ctx, - (void **)&cbuf.ptr, - &cbuf.cpp, - &cbuf.stride, - &cbuf.format ); - - assert(ok); - - if (memcmp(&cbuf, &st->state.cbuf, sizeof(cbuf)) != 0) { - st->state.cbuf = cbuf; - st->pipe->set_cbuf_state( st->pipe, &cbuf ); - } -} - -const struct st_tracked_state st_update_cbuf = { - .dirty = { - .mesa = _NEW_BUFFERS, - .st = 0, - }, - .update = update_cbuf_state -}; - diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index a164ded184..f706761198 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -43,92 +43,64 @@ #define TGSI_DEBUG 0 -static void compile_fs( struct st_context *st, - struct st_fragment_program *fs ) +static void compile_fs( struct st_context *st ) { + struct st_fragment_program *fp = st->fp; + /* XXX: fix static allocation of tokens: */ - tgsi_mesa_compile_fp_program( &fs->Base, fs->tokens, ST_FP_MAX_TOKENS ); - - if (TGSI_DEBUG) - tgsi_dump( fs->tokens, TGSI_DUMP_VERBOSE ); -} - - -static void -update_fs_constants(struct st_context *st, - struct gl_program_parameter_list *params) - -{ - const uint paramBytes = params->NumParameters * sizeof(GLfloat) * 4; - struct pipe_winsys *ws = st->pipe->winsys; - struct pipe_constant_buffer *cbuf - = &st->state.constants[PIPE_SHADER_FRAGMENT]; + tgsi_mesa_compile_fp_program( &fp->Base, fp->tokens, ST_FP_MAX_TOKENS ); - if (!cbuf->buffer) - cbuf->buffer = ws->buffer_create(ws, 1); + fp->fs.inputs_read + = tgsi_mesa_translate_vertex_input_mask(fp->Base.Base.InputsRead); + fp->fs.outputs_written + = tgsi_mesa_translate_vertex_output_mask(fp->Base.Base.OutputsWritten); + fp->fs.tokens = &fp->tokens[0]; - /* load Mesa constants into the constant buffer */ - if (paramBytes) - ws->buffer_data(ws, cbuf->buffer, paramBytes, params->ParameterValues); - - cbuf->size = paramBytes; + if (TGSI_DEBUG) + tgsi_dump( fp->tokens, TGSI_DUMP_VERBOSE ); - st->pipe->set_constant_buffer(st->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf); + fp->dirty = 0; } + static void update_fs( struct st_context *st ) { - struct pipe_shader_state fs; struct st_fragment_program *fp = NULL; - struct gl_program_parameter_list *params = NULL; - /* find active shader and params */ + /* find active shader and params. Changes to this Mesa state + * should be covered by ST_NEW_FRAGMENT_PROGRAM, thanks to the + * logic in st_cb_program.c + */ if (st->ctx->Shader.CurrentProgram && st->ctx->Shader.CurrentProgram->LinkStatus && st->ctx->Shader.CurrentProgram->FragmentProgram) { struct gl_fragment_program *f = st->ctx->Shader.CurrentProgram->FragmentProgram; fp = st_fragment_program(f); - params = f->Base.Parameters; } - else if (st->ctx->FragmentProgram._Current) { + else { + assert(st->ctx->FragmentProgram._Current); fp = st_fragment_program(st->ctx->FragmentProgram._Current); - params = st->ctx->FragmentProgram._Current->Base.Parameters; - } - - /* update constants */ - if (fp && params) { - _mesa_load_state_parameters(st->ctx, params); - update_fs_constants(st, params); } /* translate shader to TGSI format */ - if (fp->dirty) - compile_fs( st, fp ); - - /* update pipe state */ - memset( &fs, 0, sizeof(fs) ); - fs.inputs_read - = tgsi_mesa_translate_fragment_input_mask(fp->Base.Base.InputsRead); - fs.outputs_written - = tgsi_mesa_translate_fragment_output_mask(fp->Base.Base.OutputsWritten); - fs.tokens = &fp->tokens[0]; - - if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 || - fp->dirty) - { - fp->dirty = 0; - st->state.fs = fs; - st->pipe->set_fs_state(st->pipe, &fs); + if (st->fp != fp || fp->dirty) { + st->fp = fp; + + if (fp->dirty) + compile_fs( st ); + + st->state.fs = fp->fs; + st->pipe->set_fs_state(st->pipe, &st->state.fs); } } const struct st_tracked_state st_update_fs = { .dirty = { - .mesa = _NEW_PROGRAM, + .mesa = 0, .st = ST_NEW_FRAGMENT_PROGRAM, }, .update = update_fs diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index b2d25fa993..ab7e2ae4be 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -45,108 +45,79 @@ #include "st_program.h" -#define TGSI_DEBUG 0 +#define TGSI_DEBUG 1 -static void compile_vs( struct st_context *st, - struct st_vertex_program *vs ) + + + +/* translate shader to TGSI format +*/ +static void compile_vs( struct st_context *st ) { + struct st_vertex_program *vp = st->vp; + /* XXX: fix static allocation of tokens: */ - tgsi_mesa_compile_vp_program( &vs->Base, vs->tokens, ST_FP_MAX_TOKENS ); + tgsi_mesa_compile_vp_program( &vp->Base, vp->tokens, ST_FP_MAX_TOKENS ); + + vp->vs.inputs_read + = tgsi_mesa_translate_vertex_input_mask(vp->Base.Base.InputsRead); + vp->vs.outputs_written + = tgsi_mesa_translate_vertex_output_mask(vp->Base.Base.OutputsWritten); + vp->vs.tokens = &vp->tokens[0]; if (TGSI_DEBUG) - tgsi_dump( vs->tokens, TGSI_DUMP_VERBOSE ); + tgsi_dump( vp->tokens, 0 ); #if defined(USE_X86_ASM) || defined(SLANG_X86) tgsi_emit_sse2( - vs->tokens, - &vs->sse2_program ); + vp->vs.tokens, + &vp->vs.sse2_program ); #endif -} - - -static void -update_vs_constants(struct st_context *st, - struct gl_program_parameter_list *params) - -{ - const uint paramBytes = params->NumParameters * sizeof(GLfloat) * 4; - struct pipe_winsys *ws = st->pipe->winsys; - struct pipe_constant_buffer *cbuf - = &st->state.constants[PIPE_SHADER_VERTEX]; - - if (!cbuf->buffer) - cbuf->buffer = ws->buffer_create(ws, 1); - - /* load Mesa constants into the constant buffer */ - if (paramBytes) - ws->buffer_data(ws, cbuf->buffer, paramBytes, params->ParameterValues); - - cbuf->size = paramBytes; - st->pipe->set_constant_buffer(st->pipe, PIPE_SHADER_VERTEX, 0, cbuf); + vp->dirty = 0; } + static void update_vs( struct st_context *st ) { - struct pipe_shader_state vs; - struct st_vertex_program *vp = NULL; - struct gl_program_parameter_list *params = NULL; + struct st_vertex_program *vp; - /* find active shader and params */ + /* find active shader and params -- Should be covered by + * ST_NEW_VERTEX_PROGRAM + */ if (st->ctx->Shader.CurrentProgram && st->ctx->Shader.CurrentProgram->LinkStatus && st->ctx->Shader.CurrentProgram->VertexProgram) { struct gl_vertex_program *f = st->ctx->Shader.CurrentProgram->VertexProgram; vp = st_vertex_program(f); - params = f->Base.Parameters; } - else if (st->ctx->VertexProgram._Current) { + else { + assert(st->ctx->VertexProgram._Current); vp = st_vertex_program(st->ctx->VertexProgram._Current); - params = st->ctx->VertexProgram._Current->Base.Parameters; } - /* update constants */ - if (vp && params) { - _mesa_load_state_parameters(st->ctx, params); - /*_mesa_print_parameter_list(params);*/ - update_vs_constants(st, params); - } + if (st->vp != vp || vp->dirty) { + st->vp = vp; - /* translate shader to TGSI format */ - if (vp->dirty) - compile_vs( st, vp ); - - /* update pipe state */ - memset( &vs, 0, sizeof(vs) ); - vs.inputs_read - = tgsi_mesa_translate_vertex_input_mask(vp->Base.Base.InputsRead); - vs.outputs_written - = tgsi_mesa_translate_vertex_output_mask(vp->Base.Base.OutputsWritten); - vs.tokens = &vp->tokens[0]; + if (vp->dirty) + compile_vs( st ); #if defined(USE_X86_ASM) || defined(SLANG_X86) - vs.executable = (void *) x86_get_func( &vp->sse2_program ); + vs.executable = (void *) x86_get_func( &vp->sse2_program ); #endif - if (memcmp(&vs, &st->state.vs, sizeof(vs)) != 0 || - vp->dirty) - { - vp->dirty = 0; - st->state.vs = vs; - st->pipe->set_vs_state(st->pipe, &vs); + st->state.vs = st->vp->vs; + st->pipe->set_vs_state(st->pipe, &st->state.vs); } } const struct st_tracked_state st_update_vs = { .dirty = { - .mesa = (_NEW_PROGRAM | - _NEW_MODELVIEW | - _NEW_PROJECTION | - _NEW_LIGHT), /*XXX MORE?*/ + .mesa = 0, .st = ST_NEW_VERTEX_PROGRAM, }, .update = update_vs @@ -155,28 +126,3 @@ const struct st_tracked_state st_update_vs = { - -/** - * When TnL state has changed, need to generate new vertex program. - * This should be done before updating the vertes shader (vs) state. - */ -static void update_tnl( struct st_context *st ) -{ - uint before = st->ctx->NewState; - if (st->ctx->VertexProgram._MaintainTnlProgram) - _tnl_UpdateFixedFunctionProgram( st->ctx ); - assert(before == st->ctx->NewState); -} - - -const struct st_tracked_state st_update_tnl = { - .dirty = { - .mesa = (_NEW_PROGRAM | - _NEW_LIGHT | - _NEW_TEXTURE | - _NEW_TRANSFORM | - _NEW_LIGHT), /* XXX more? */ - .st = 0 - }, - .update = update_tnl -}; diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index b84f552404..b9c19bdd3e 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -64,6 +64,17 @@ static void st_bind_program( GLcontext *ctx, } } +static void st_use_program( GLcontext *ctx, + GLuint program ) +{ + struct st_context *st = st_context(ctx); + + st->dirty.st |= ST_NEW_VERTEX_PROGRAM; + st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; +} + + + static struct gl_program *st_new_program( GLcontext *ctx, GLenum target, GLuint id ) @@ -132,6 +143,7 @@ static GLboolean st_is_program_native( GLcontext *ctx, return GL_TRUE; } + static void st_program_string_notify( GLcontext *ctx, GLenum target, struct gl_program *prog ) @@ -166,10 +178,8 @@ static void st_program_string_notify( GLcontext *ctx, void st_init_program_functions(struct dd_function_table *functions) { -#if 0 - assert(functions->ProgramStringNotify == _tnl_program_string); -#endif functions->BindProgram = st_bind_program; + functions->UseProgram = st_use_program; functions->NewProgram = st_new_program; functions->DeleteProgram = st_delete_program; functions->IsProgramNative = st_is_program_native; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 13ea28237c..9e8015d4c7 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -86,7 +86,7 @@ struct st_context } state; struct { - struct st_tracked_state tracked_state; + struct st_tracked_state tracked_state[2]; } constants; struct { @@ -109,6 +109,9 @@ struct st_context GLfloat polygon_offset_scale; /* ?? */ + struct st_vertex_program *vp; + struct st_fragment_program *fp; + struct pipe_buffer_handle *default_attrib_buffer; }; diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 883953399c..7a91983ce9 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -54,21 +54,7 @@ struct st_fragment_program struct tgsi_token tokens[ST_FP_MAX_TOKENS]; GLboolean dirty; -#if 0 - GLfloat (*cbuffer)[4]; - GLuint nr_constants; - - /* Translate all the parameters, etc, into a constant buffer which - * we update on state changes. - */ - struct - { - GLuint reg; /* Constant idx */ - const GLfloat *values; /* Pointer to tracked values */ - } *param; - GLuint nr_params; -#endif - + struct pipe_shader_state fs; GLuint param_state; }; @@ -89,9 +75,7 @@ struct st_vertex_program struct x86_function sse2_program; #endif -#if 0 - struct pipe_constant_buffer constants; -#endif + struct pipe_shader_state vs; GLuint param_state; }; diff --git a/src/mesa/tnl/t_vp_build.h b/src/mesa/tnl/t_vp_build.h index 4a98fff026..5e22fcf8c4 100644 --- a/src/mesa/tnl/t_vp_build.h +++ b/src/mesa/tnl/t_vp_build.h @@ -28,6 +28,13 @@ #include "mtypes.h" +#define TNL_FIXED_FUNCTION_STATE_FLAGS (_NEW_PROGRAM | \ + _NEW_LIGHT | \ + _NEW_TEXTURE | \ + _NEW_TRANSFORM | \ + _NEW_FOG | \ + _NEW_POINT) + extern void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx ); extern void _tnl_ProgramCacheInit( GLcontext *ctx ); -- cgit v1.2.3 From 4185da4681405f3cc4d0cc601d428f2f44d0dda8 Mon Sep 17 00:00:00 2001 From: keithw Date: Sat, 25 Aug 2007 22:00:36 +0100 Subject: add names to tracked state atoms to improve debug --- src/mesa/state_tracker/st_atom.c | 9 ++++++++- src/mesa/state_tracker/st_atom_alphatest.c | 1 + src/mesa/state_tracker/st_atom_blend.c | 1 + src/mesa/state_tracker/st_atom_clear_color.c | 1 + src/mesa/state_tracker/st_atom_clip.c | 1 + src/mesa/state_tracker/st_atom_depth.c | 1 + src/mesa/state_tracker/st_atom_framebuffer.c | 1 + src/mesa/state_tracker/st_atom_fs.c | 1 + src/mesa/state_tracker/st_atom_sampler.c | 1 + src/mesa/state_tracker/st_atom_scissor.c | 1 + src/mesa/state_tracker/st_atom_setup.c | 1 + src/mesa/state_tracker/st_atom_stencil.c | 1 + src/mesa/state_tracker/st_atom_stipple.c | 1 + src/mesa/state_tracker/st_atom_texture.c | 1 + src/mesa/state_tracker/st_atom_viewport.c | 1 + src/mesa/state_tracker/st_atom_vs.c | 1 + src/mesa/state_tracker/st_context.h | 1 + 17 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 99fcbdfda7..66ab5d7c3a 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -155,6 +155,8 @@ void st_validate_state( struct st_context *st ) if (state->st == 0) return; +// _mesa_printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st); + if (1) { /* Debug version which enforces various sanity checks on the * state flags which are generated and checked to help ensure @@ -168,14 +170,17 @@ void st_validate_state( struct st_context *st ) const struct st_tracked_state *atom = st->atoms[i]; struct st_state_flags generated; +// _mesa_printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st); + if (!(atom->dirty.mesa || atom->dirty.st) || !atom->update) { - _mesa_printf("malformed atom %d\n", i); + _mesa_printf("malformed atom %s\n", atom->name); assert(0); } if (check_state(state, &atom->dirty)) { st->atoms[i]->update( st ); +// _mesa_printf("after: %x\n", atom->dirty.mesa); } accumulate_state(&examined, &atom->dirty); @@ -188,6 +193,8 @@ void st_validate_state( struct st_context *st ) assert(!check_state(&examined, &generated)); prev = *state; } +// _mesa_printf("\n"); + } else { const GLuint nr = st->nr_atoms; diff --git a/src/mesa/state_tracker/st_atom_alphatest.c b/src/mesa/state_tracker/st_atom_alphatest.c index 1e2e449795..4378154053 100644 --- a/src/mesa/state_tracker/st_atom_alphatest.c +++ b/src/mesa/state_tracker/st_atom_alphatest.c @@ -81,6 +81,7 @@ update_alpha_test( struct st_context *st ) const struct st_tracked_state st_update_alpha_test = { + .name = "st_update_alpha_test", .dirty = { .mesa = (_NEW_COLOR), .st = 0, diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 256f13471a..afd21a6141 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -227,6 +227,7 @@ update_blend( struct st_context *st ) const struct st_tracked_state st_update_blend = { + .name = "st_update_blend", .dirty = { .mesa = (_NEW_COLOR), /* XXX _NEW_BLEND someday? */ .st = 0, diff --git a/src/mesa/state_tracker/st_atom_clear_color.c b/src/mesa/state_tracker/st_atom_clear_color.c index adf730cd8c..ce3431c5d3 100644 --- a/src/mesa/state_tracker/st_atom_clear_color.c +++ b/src/mesa/state_tracker/st_atom_clear_color.c @@ -54,6 +54,7 @@ update_clear_color_state( struct st_context *st ) const struct st_tracked_state st_update_clear_color = { + .name = "st_update_clear_color", .dirty = { .mesa = _NEW_COLOR, .st = 0, diff --git a/src/mesa/state_tracker/st_atom_clip.c b/src/mesa/state_tracker/st_atom_clip.c index 8ccad637d5..a6f0568660 100644 --- a/src/mesa/state_tracker/st_atom_clip.c +++ b/src/mesa/state_tracker/st_atom_clip.c @@ -62,6 +62,7 @@ static void update_clip( struct st_context *st ) const struct st_tracked_state st_update_clip = { + .name = "st_update_clip", .dirty = { .mesa = (_NEW_TRANSFORM), .st = 0, diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index 7fc51953dc..df05c79e36 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -84,6 +84,7 @@ update_depth( struct st_context *st ) const struct st_tracked_state st_update_depth = { + .name = "st_update_depth", .dirty = { .mesa = (_NEW_DEPTH), .st = 0, diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index f054eb8f21..3c4b37e7c5 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -82,6 +82,7 @@ update_framebuffer_state( struct st_context *st ) const struct st_tracked_state st_update_framebuffer = { + .name = "st_update_framebuffer", .dirty = { .mesa = _NEW_BUFFERS, .st = 0, diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index f706761198..767816bf23 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -99,6 +99,7 @@ static void update_fs( struct st_context *st ) const struct st_tracked_state st_update_fs = { + .name = "st_update_fs", .dirty = { .mesa = 0, .st = ST_NEW_FRAGMENT_PROGRAM, diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 7d568baf9e..d65565f991 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -152,6 +152,7 @@ update_samplers(struct st_context *st) const struct st_tracked_state st_update_sampler = { + .name = "st_update_sampler", .dirty = { .mesa = _NEW_TEXTURE, .st = 0, diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c index 2bf633828e..59601e91a1 100644 --- a/src/mesa/state_tracker/st_atom_scissor.c +++ b/src/mesa/state_tracker/st_atom_scissor.c @@ -83,6 +83,7 @@ update_scissor( struct st_context *st ) const struct st_tracked_state st_update_scissor = { + .name = "st_update_scissor", .dirty = { .mesa = (_NEW_SCISSOR | _NEW_BUFFERS), .st = 0, diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c index 3eac2588df..09d921560d 100644 --- a/src/mesa/state_tracker/st_atom_setup.c +++ b/src/mesa/state_tracker/st_atom_setup.c @@ -211,6 +211,7 @@ static void update_setup_state( struct st_context *st ) } const struct st_tracked_state st_update_setup = { + .name = "st_update_setup", .dirty = { .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), diff --git a/src/mesa/state_tracker/st_atom_stencil.c b/src/mesa/state_tracker/st_atom_stencil.c index d037335e9e..b8aec0b3b6 100644 --- a/src/mesa/state_tracker/st_atom_stencil.c +++ b/src/mesa/state_tracker/st_atom_stencil.c @@ -127,6 +127,7 @@ update_stencil( struct st_context *st ) const struct st_tracked_state st_update_stencil = { + .name = "st_update_stencil", .dirty = { .mesa = (_NEW_STENCIL), .st = 0, diff --git a/src/mesa/state_tracker/st_atom_stipple.c b/src/mesa/state_tracker/st_atom_stipple.c index dd04d2158c..c91214059a 100644 --- a/src/mesa/state_tracker/st_atom_stipple.c +++ b/src/mesa/state_tracker/st_atom_stipple.c @@ -54,6 +54,7 @@ update_stipple( struct st_context *st ) const struct st_tracked_state st_update_polygon_stipple = { + .name = "st_update_polygon_stipple", .dirty = { .mesa = (_NEW_POLYGONSTIPPLE), .st = 0, diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index bafd38695f..7970bcf2b8 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -72,6 +72,7 @@ update_textures(struct st_context *st) const struct st_tracked_state st_update_texture = { + .name = "st_update_texture", .dirty = { .mesa = _NEW_TEXTURE, .st = 0, diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index a70f4c7434..147aa3c51a 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -86,6 +86,7 @@ update_viewport( struct st_context *st ) const struct st_tracked_state st_update_viewport = { + .name = "st_update_viewport", .dirty = { .mesa = _NEW_BUFFERS | _NEW_VIEWPORT, .st = 0, diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index ab7e2ae4be..a1e6117bde 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -116,6 +116,7 @@ static void update_vs( struct st_context *st ) const struct st_tracked_state st_update_vs = { + .name = "st_update_vs", .dirty = { .mesa = 0, .st = ST_NEW_VERTEX_PROGRAM, diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 9e8015d4c7..cb34994d77 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -48,6 +48,7 @@ struct st_state_flags { }; struct st_tracked_state { + const char *name; struct st_state_flags dirty; void (*update)( struct st_context *st ); }; -- cgit v1.2.3 From d6ac959833a8e40a27907940969c622692f749b1 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 17 Sep 2007 11:55:18 -0400 Subject: Combing depth and stencil objects and making them immutable. Converting depth and stencil objects into a single state object (d3d10 like) and making it immutable. --- src/mesa/cso_cache/cso_cache.c | 6 + src/mesa/cso_cache/cso_cache.h | 4 +- src/mesa/pipe/failover/fo_context.h | 40 ++++--- src/mesa/pipe/failover/fo_state.c | 25 +---- src/mesa/pipe/failover/fo_state_emit.c | 7 +- src/mesa/pipe/i915simple/i915_context.h | 22 ++-- src/mesa/pipe/i915simple/i915_state.c | 44 +++++--- src/mesa/pipe/i915simple/i915_state_dynamic.c | 24 ++-- src/mesa/pipe/i915simple/i915_state_immediate.c | 22 ++-- src/mesa/pipe/p_context.h | 14 ++- src/mesa/pipe/p_state.h | 48 ++++---- src/mesa/pipe/softpipe/sp_context.c | 5 +- src/mesa/pipe/softpipe/sp_context.h | 26 ++--- src/mesa/pipe/softpipe/sp_quad.c | 8 +- src/mesa/pipe/softpipe/sp_quad_depth_test.c | 4 +- src/mesa/pipe/softpipe/sp_quad_fs.c | 2 +- src/mesa/pipe/softpipe/sp_quad_stencil.c | 32 +++--- src/mesa/pipe/softpipe/sp_state.h | 15 ++- src/mesa/pipe/softpipe/sp_state_blend.c | 34 +++--- src/mesa/pipe/softpipe/sp_state_derived.c | 7 +- src/mesa/sources | 1 - src/mesa/state_tracker/st_atom.c | 3 +- src/mesa/state_tracker/st_atom.h | 3 +- src/mesa/state_tracker/st_atom_depth.c | 108 +++++++++++++++--- src/mesa/state_tracker/st_atom_stencil.c | 141 ------------------------ src/mesa/state_tracker/st_cache.c | 17 +++ src/mesa/state_tracker/st_cache.h | 3 + src/mesa/state_tracker/st_cb_clear.c | 51 ++++----- src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_context.h | 3 +- 30 files changed, 337 insertions(+), 384 deletions(-) delete mode 100644 src/mesa/state_tracker/st_atom_stencil.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/cso_cache/cso_cache.c b/src/mesa/cso_cache/cso_cache.c index 61da590575..a4730394f8 100644 --- a/src/mesa/cso_cache/cso_cache.c +++ b/src/mesa/cso_cache/cso_cache.c @@ -76,6 +76,8 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ hash = sc->blend_hash; case CSO_SAMPLER: hash = sc->sampler_hash; + case CSO_DEPTH_STENCIL: + hash = sc->depth_stencil_hash; } return hash; @@ -88,6 +90,8 @@ static int _cso_size_for_type(enum cso_cache_type type) return sizeof(struct pipe_blend_state); case CSO_SAMPLER: return sizeof(struct pipe_sampler_state); + case CSO_DEPTH_STENCIL: + return sizeof(struct pipe_depth_stencil_state); } return 0; } @@ -138,6 +142,7 @@ struct cso_cache *cso_cache_create(void) sc->blend_hash = cso_hash_create(); sc->sampler_hash = cso_hash_create(); + sc->depth_stencil_hash = cso_hash_create(); return sc; } @@ -147,6 +152,7 @@ void cso_cache_delete(struct cso_cache *sc) assert(sc); cso_hash_delete(sc->blend_hash); cso_hash_delete(sc->sampler_hash); + cso_hash_delete(sc->depth_stencil_hash); free(sc); } diff --git a/src/mesa/cso_cache/cso_cache.h b/src/mesa/cso_cache/cso_cache.h index 05a4cfcbdd..c340cf7f67 100644 --- a/src/mesa/cso_cache/cso_cache.h +++ b/src/mesa/cso_cache/cso_cache.h @@ -42,11 +42,13 @@ struct cso_hash; struct cso_cache { struct cso_hash *blend_hash; struct cso_hash *sampler_hash; + struct cso_hash *depth_stencil_hash; }; enum cso_cache_type { CSO_BLEND, - CSO_SAMPLER + CSO_SAMPLER, + CSO_DEPTH_STENCIL }; unsigned cso_construct_key(void *item, int item_size); diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index fa336193a8..63ec7239ab 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -36,25 +36,24 @@ -#define FO_NEW_VIEWPORT 0x1 -#define FO_NEW_SETUP 0x2 -#define FO_NEW_FRAGMENT_SHADER 0x4 -#define FO_NEW_BLEND 0x8 -#define FO_NEW_CLIP 0x10 -#define FO_NEW_SCISSOR 0x20 -#define FO_NEW_STIPPLE 0x40 -#define FO_NEW_FRAMEBUFFER 0x80 -#define FO_NEW_ALPHA_TEST 0x100 -#define FO_NEW_DEPTH_TEST 0x200 -#define FO_NEW_SAMPLER 0x400 -#define FO_NEW_TEXTURE 0x800 -#define FO_NEW_STENCIL 0x1000 -#define FO_NEW_VERTEX 0x2000 -#define FO_NEW_VERTEX_SHADER 0x4000 -#define FO_NEW_BLEND_COLOR 0x8000 -#define FO_NEW_CLEAR_COLOR 0x10000 -#define FO_NEW_VERTEX_BUFFER 0x20000 -#define FO_NEW_VERTEX_ELEMENT 0x40000 +#define FO_NEW_VIEWPORT 0x1 +#define FO_NEW_SETUP 0x2 +#define FO_NEW_FRAGMENT_SHADER 0x4 +#define FO_NEW_BLEND 0x8 +#define FO_NEW_CLIP 0x10 +#define FO_NEW_SCISSOR 0x20 +#define FO_NEW_STIPPLE 0x40 +#define FO_NEW_FRAMEBUFFER 0x80 +#define FO_NEW_ALPHA_TEST 0x100 +#define FO_NEW_DEPTH_STENCIL 0x200 +#define FO_NEW_SAMPLER 0x400 +#define FO_NEW_TEXTURE 0x800 +#define FO_NEW_VERTEX 0x2000 +#define FO_NEW_VERTEX_SHADER 0x4000 +#define FO_NEW_BLEND_COLOR 0x8000 +#define FO_NEW_CLEAR_COLOR 0x10000 +#define FO_NEW_VERTEX_BUFFER 0x20000 +#define FO_NEW_VERTEX_ELEMENT 0x40000 @@ -69,19 +68,18 @@ struct failover_context { */ const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct pipe_depth_stencil_state *depth_stencil; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; - struct pipe_depth_state depth_test; struct pipe_framebuffer_state framebuffer; struct pipe_shader_state fragment_shader; struct pipe_shader_state vertex_shader; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct pipe_setup_state setup; - struct pipe_stencil_state stencil; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index f3a99e4198..43b9757b31 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -103,14 +103,14 @@ failover_set_clear_color_state( struct pipe_context *pipe, } static void -failover_set_depth_test_state(struct pipe_context *pipe, - const struct pipe_depth_state *depth) +failover_bind_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth_stencil) { struct failover_context *failover = failover_context(pipe); - failover->depth_test = *depth; - failover->dirty |= FO_NEW_DEPTH_TEST; - failover->hw->set_depth_state( failover->hw, depth ); + failover->depth_stencil = depth_stencil; + failover->dirty |= FO_NEW_DEPTH_STENCIL; + failover->hw->bind_depth_stencil_state( failover->hw, depth_stencil ); } static void @@ -183,18 +183,6 @@ failover_set_scissor_state( struct pipe_context *pipe, failover->hw->set_scissor_state( failover->hw, scissor ); } -static void -failover_set_stencil_state(struct pipe_context *pipe, - const struct pipe_stencil_state *stencil) -{ - struct failover_context *failover = failover_context(pipe); - - failover->stencil = *stencil; - failover->dirty |= FO_NEW_STENCIL; - failover->hw->set_stencil_state( failover->hw, stencil ); -} - - static void failover_bind_sampler_state(struct pipe_context *pipe, unsigned unit, @@ -268,19 +256,18 @@ failover_init_state_functions( struct failover_context *failover ) { failover->pipe.bind_blend_state = failover_bind_blend_state; failover->pipe.bind_sampler_state = failover_bind_sampler_state; + failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state; failover->pipe.set_alpha_test_state = failover_set_alpha_test_state; failover->pipe.set_blend_color = failover_set_blend_color; failover->pipe.set_clip_state = failover_set_clip_state; failover->pipe.set_clear_color_state = failover_set_clear_color_state; - failover->pipe.set_depth_state = failover_set_depth_test_state; failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; failover->pipe.set_fs_state = failover_set_fs_state; failover->pipe.set_vs_state = failover_set_vs_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; failover->pipe.set_scissor_state = failover_set_scissor_state; failover->pipe.set_setup_state = failover_set_setup_state; - failover->pipe.set_stencil_state = failover_set_stencil_state; failover->pipe.set_texture_state = failover_set_texture_state; failover->pipe.set_viewport_state = failover_set_viewport_state; failover->pipe.set_vertex_buffer = failover_set_vertex_buffer; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index 9d462678c5..3a1865d766 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -70,8 +70,8 @@ failover_state_emit( struct failover_context *failover ) if (failover->dirty & FO_NEW_CLEAR_COLOR) failover->sw->set_clear_color_state( failover->sw, &failover->clear_color ); - if (failover->dirty & FO_NEW_DEPTH_TEST) - failover->sw->set_depth_state( failover->sw, &failover->depth_test ); + if (failover->dirty & FO_NEW_DEPTH_STENCIL) + failover->sw->bind_depth_stencil_state( failover->sw, failover->depth_stencil ); if (failover->dirty & FO_NEW_FRAMEBUFFER) failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer ); @@ -91,9 +91,6 @@ failover_state_emit( struct failover_context *failover ) if (failover->dirty & FO_NEW_SCISSOR) failover->sw->set_scissor_state( failover->sw, &failover->scissor ); - if (failover->dirty & FO_NEW_STENCIL) - failover->sw->set_stencil_state( failover->sw, &failover->stencil ); - if (failover->dirty & FO_NEW_VIEWPORT) failover->sw->set_viewport_state( failover->sw, &failover->viewport ); diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 51baa281ec..518f780449 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -125,19 +125,18 @@ struct i915_context */ const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct pipe_depth_stencil_state *depth_stencil; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[PIPE_SHADER_TYPES]; - struct pipe_depth_state depth_test; struct pipe_framebuffer_state framebuffer; struct pipe_shader_state fs; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct pipe_setup_state setup; - struct pipe_stencil_state stencil; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; @@ -163,16 +162,15 @@ struct i915_context #define I915_NEW_SETUP 0x2 #define I915_NEW_FS 0x4 #define I915_NEW_BLEND 0x8 -#define I915_NEW_CLIP 0x10 -#define I915_NEW_SCISSOR 0x20 -#define I915_NEW_STIPPLE 0x40 -#define I915_NEW_FRAMEBUFFER 0x80 -#define I915_NEW_ALPHA_TEST 0x100 -#define I915_NEW_DEPTH_TEST 0x200 -#define I915_NEW_SAMPLER 0x400 -#define I915_NEW_TEXTURE 0x800 -#define I915_NEW_STENCIL 0x1000 -#define I915_NEW_CONSTANTS 0x2000 +#define I915_NEW_CLIP 0x10 +#define I915_NEW_SCISSOR 0x20 +#define I915_NEW_STIPPLE 0x40 +#define I915_NEW_FRAMEBUFFER 0x80 +#define I915_NEW_ALPHA_TEST 0x100 +#define I915_NEW_DEPTH_STENCIL 0x200 +#define I915_NEW_SAMPLER 0x400 +#define I915_NEW_TEXTURE 0x800 +#define I915_NEW_CONSTANTS 0x1000 /* Driver's internally generated state flags: diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 10060b45a4..5ac2e27d1a 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -107,38 +107,44 @@ static void i915_delete_sampler_state(struct pipe_context *pipe, /** XXX move someday? Or consolidate all these simple state setters * into one file. */ -static void i915_set_depth_test_state(struct pipe_context *pipe, - const struct pipe_depth_state *depth) -{ - struct i915_context *i915 = i915_context(pipe); - i915->depth_test = *depth; +static const struct pipe_depth_stencil_state * +i915_create_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth_stencil) +{ + struct pipe_depth_stencil_state *new_ds = + malloc(sizeof(struct pipe_depth_stencil_state)); + memcpy(new_ds, depth_stencil, sizeof(struct pipe_depth_stencil_state)); - i915->dirty |= I915_NEW_DEPTH_TEST; + return new_ds; } -static void i915_set_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha) +static void i915_bind_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth_stencil) { struct i915_context *i915 = i915_context(pipe); - i915->alpha_test = *alpha; + i915->depth_stencil = depth_stencil; - i915->dirty |= I915_NEW_ALPHA_TEST; + i915->dirty |= I915_NEW_DEPTH_STENCIL; } -static void i915_set_stencil_state(struct pipe_context *pipe, - const struct pipe_stencil_state *stencil) +static void i915_delete_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth_stencil) +{ + free((struct pipe_depth_stencil_state *)depth_stencil); +} + +static void i915_set_alpha_test_state(struct pipe_context *pipe, + const struct pipe_alpha_test_state *alpha) { struct i915_context *i915 = i915_context(pipe); - i915->stencil = *stencil; + i915->alpha_test = *alpha; - i915->dirty |= I915_NEW_STENCIL; + i915->dirty |= I915_NEW_ALPHA_TEST; } - - static void i915_set_scissor_state( struct pipe_context *pipe, const struct pipe_scissor_state *scissor ) { @@ -328,19 +334,21 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.bind_sampler_state = i915_bind_sampler_state; i915->pipe.delete_sampler_state = i915_delete_sampler_state; + i915->pipe.create_depth_stencil_state = i915_create_depth_stencil_state; + i915->pipe.bind_depth_stencil_state = i915_bind_depth_stencil_state; + i915->pipe.delete_depth_stencil_state = i915_delete_depth_stencil_state; + i915->pipe.set_alpha_test_state = i915_set_alpha_test_state; i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; i915->pipe.set_clear_color_state = i915_set_clear_color_state; i915->pipe.set_constant_buffer = i915_set_constant_buffer; - i915->pipe.set_depth_state = i915_set_depth_test_state; i915->pipe.set_framebuffer_state = i915_set_framebuffer_state; i915->pipe.set_fs_state = i915_set_fs_state; i915->pipe.set_vs_state = i915_set_vs_state; i915->pipe.set_polygon_stipple = i915_set_polygon_stipple; i915->pipe.set_scissor_state = i915_set_scissor_state; i915->pipe.set_setup_state = i915_set_setup_state; - i915->pipe.set_stencil_state = i915_set_stencil_state; i915->pipe.set_texture_state = i915_set_texture_state; i915->pipe.set_viewport_state = i915_set_viewport_state; i915->pipe.set_vertex_buffer = i915_set_vertex_buffer; diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c index 49a30fac11..9140eee7c2 100644 --- a/src/mesa/pipe/i915simple/i915_state_dynamic.c +++ b/src/mesa/pipe/i915simple/i915_state_dynamic.c @@ -68,8 +68,8 @@ static void upload_MODES4( struct i915_context *i915 ) /* I915_NEW_STENCIL */ { - int testmask = i915->stencil.value_mask[0] & 0xff; - int writemask = i915->stencil.write_mask[0] & 0xff; + int testmask = i915->depth_stencil->stencil.value_mask[0] & 0xff; + int writemask = i915->depth_stencil->stencil.write_mask[0] & 0xff; modes4 |= (_3DSTATE_MODES_4_CMD | ENABLE_STENCIL_TEST_MASK | @@ -94,7 +94,7 @@ static void upload_MODES4( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_MODES4 = { - .dirty = I915_NEW_BLEND | I915_NEW_STENCIL, + .dirty = I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL, .update = upload_MODES4 }; @@ -112,14 +112,14 @@ static void upload_BFO( struct i915_context *i915 ) /* _NEW_STENCIL */ - if (i915->stencil.back_enabled) { - int test = i915_translate_compare_func(i915->stencil.back_func); - int fop = i915_translate_stencil_op(i915->stencil.back_fail_op); - int dfop = i915_translate_stencil_op(i915->stencil.back_zfail_op); - int dpop = i915_translate_stencil_op(i915->stencil.back_zpass_op); - int ref = i915->stencil.ref_value[1] & 0xff; - int tmask = i915->stencil.value_mask[1] & 0xff; - int wmask = i915->stencil.write_mask[1] & 0xff; + if (i915->depth_stencil->stencil.back_enabled) { + int test = i915_translate_compare_func(i915->depth_stencil->stencil.back_func); + int fop = i915_translate_stencil_op(i915->depth_stencil->stencil.back_fail_op); + int dfop = i915_translate_stencil_op(i915->depth_stencil->stencil.back_zfail_op); + int dpop = i915_translate_stencil_op(i915->depth_stencil->stencil.back_zpass_op); + int ref = i915->depth_stencil->stencil.ref_value[1] & 0xff; + int tmask = i915->depth_stencil->stencil.value_mask[1] & 0xff; + int wmask = i915->depth_stencil->stencil.write_mask[1] & 0xff; bf[0] = (_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_FUNCS | @@ -157,7 +157,7 @@ static void upload_BFO( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_BFO = { - .dirty = I915_NEW_STENCIL, + .dirty = I915_NEW_DEPTH_STENCIL, .update = upload_BFO }; diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c index aaca534f5a..484913d308 100644 --- a/src/mesa/pipe/i915simple/i915_state_immediate.c +++ b/src/mesa/pipe/i915simple/i915_state_immediate.c @@ -128,12 +128,12 @@ static void upload_S5( struct i915_context *i915 ) unsigned LIS5 = 0; /* I915_NEW_STENCIL */ - if (i915->stencil.front_enabled) { - int test = i915_translate_compare_func(i915->stencil.front_func); - int fop = i915_translate_stencil_op(i915->stencil.front_fail_op); - int dfop = i915_translate_stencil_op(i915->stencil.front_zfail_op); - int dpop = i915_translate_stencil_op(i915->stencil.front_zpass_op); - int ref = i915->stencil.ref_value[0] & 0xff; + if (i915->depth_stencil->stencil.front_enabled) { + int test = i915_translate_compare_func(i915->depth_stencil->stencil.front_func); + int fop = i915_translate_stencil_op(i915->depth_stencil->stencil.front_fail_op); + int dfop = i915_translate_stencil_op(i915->depth_stencil->stencil.front_zfail_op); + int dpop = i915_translate_stencil_op(i915->depth_stencil->stencil.front_zpass_op); + int ref = i915->depth_stencil->stencil.ref_value[0] & 0xff; LIS5 |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE | @@ -179,7 +179,7 @@ static void upload_S5( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_S5 = { - .dirty = (I915_NEW_STENCIL | I915_NEW_BLEND | I915_NEW_SETUP), + .dirty = (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_SETUP), .update = upload_S5 }; @@ -219,13 +219,13 @@ static void upload_S6( struct i915_context *i915 ) /* I915_NEW_DEPTH */ - if (i915->depth_test.enabled) { - int func = i915_translate_compare_func(i915->depth_test.func); + if (i915->depth_stencil->depth.enabled) { + int func = i915_translate_compare_func(i915->depth_stencil->depth.func); LIS6 |= (S6_DEPTH_TEST_ENABLE | (func << S6_DEPTH_TEST_FUNC_SHIFT)); - if (i915->depth_test.writemask) + if (i915->depth_stencil->depth.writemask) LIS6 |= S6_DEPTH_WRITE_ENABLE; } @@ -236,7 +236,7 @@ static void upload_S6( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_S6 = { - .dirty = I915_NEW_ALPHA_TEST | I915_NEW_BLEND | I915_NEW_DEPTH_TEST, + .dirty = I915_NEW_ALPHA_TEST | I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL, .update = upload_S6 }; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 0913e49096..488f002531 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -101,6 +101,14 @@ struct pipe_context { void (*delete_sampler_state)(struct pipe_context *, const struct pipe_sampler_state *); + const struct pipe_depth_stencil_state * (*create_depth_stencil_state)( + struct pipe_context *, + const struct pipe_depth_stencil_state *); + void (*bind_depth_stencil_state)(struct pipe_context *, + const struct pipe_depth_stencil_state *); + void (*delete_depth_stencil_state)(struct pipe_context *, + const struct pipe_depth_stencil_state *); + void (*set_alpha_test_state)( struct pipe_context *, const struct pipe_alpha_test_state * ); @@ -116,9 +124,6 @@ struct pipe_context { void (*set_constant_buffer)( struct pipe_context *, uint shader, uint index, const struct pipe_constant_buffer *buf ); - - void (*set_depth_state)( struct pipe_context *, - const struct pipe_depth_state * ); void (*set_feedback_state)( struct pipe_context *, const struct pipe_feedback_state *); @@ -141,9 +146,6 @@ struct pipe_context { void (*set_scissor_state)( struct pipe_context *, const struct pipe_scissor_state * ); - void (*set_stencil_state)( struct pipe_context *, - const struct pipe_stencil_state * ); - void (*set_texture_state)( struct pipe_context *, unsigned unit, struct pipe_mipmap_tree * ); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index b994d17ea9..30e559b594 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -146,13 +146,31 @@ struct pipe_shader_state { void *executable; }; -struct pipe_depth_state +struct pipe_depth_stencil_state { - unsigned enabled:1; /**< depth test enabled? */ - unsigned writemask:1; /**< allow depth buffer writes? */ - unsigned func:3; /**< depth test func (PIPE_FUNC_x) */ - unsigned occlusion_count:1; /**< XXX move this elsewhere? */ - float clear; /**< Clear value in [0,1] (XXX correct place?) */ + struct { + unsigned enabled:1; /**< depth test enabled? */ + unsigned writemask:1; /**< allow depth buffer writes? */ + unsigned func:3; /**< depth test func (PIPE_FUNC_x) */ + unsigned occlusion_count:1; /**< XXX move this elsewhere? */ + float clear; /**< Clear value in [0,1] (XXX correct place?) */ + } depth; + struct { + unsigned front_enabled:1; + unsigned front_func:3; /**< PIPE_FUNC_x */ + unsigned front_fail_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned front_zpass_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned front_zfail_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned back_enabled:1; + unsigned back_func:3; /**< PIPE_FUNC_x */ + unsigned back_fail_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned back_zpass_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned back_zfail_op:3; /**< PIPE_STENCIL_OP_x */ + ubyte ref_value[2]; /**< [0] = front, [1] = back */ + ubyte value_mask[2]; + ubyte write_mask[2]; + ubyte clear_value; + } stencil; }; struct pipe_alpha_test_state { @@ -188,24 +206,6 @@ struct pipe_clear_color_state float color[4]; }; -struct pipe_stencil_state { - unsigned front_enabled:1; - unsigned front_func:3; /**< PIPE_FUNC_x */ - unsigned front_fail_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned front_zpass_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned front_zfail_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned back_enabled:1; - unsigned back_func:3; /**< PIPE_FUNC_x */ - unsigned back_fail_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned back_zpass_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned back_zfail_op:3; /**< PIPE_STENCIL_OP_x */ - ubyte ref_value[2]; /**< [0] = front, [1] = back */ - ubyte value_mask[2]; - ubyte write_mask[2]; - ubyte clear_value; -}; - - struct pipe_framebuffer_state { /** multiple colorbuffers for multiple render targets */ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index bab7985e8d..9a8b55bb0e 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -256,13 +256,15 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.create_sampler_state = softpipe_create_sampler_state; softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state; softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state; + softpipe->pipe.create_depth_stencil_state = softpipe_create_depth_stencil_state; + softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state; + softpipe->pipe.delete_depth_stencil_state = softpipe_delete_depth_stencil_state; softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_clip_state = softpipe_set_clip_state; softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state; softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer; - softpipe->pipe.set_depth_state = softpipe_set_depth_test_state; softpipe->pipe.set_feedback_state = softpipe_set_feedback_state; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_fs_state = softpipe_set_fs_state; @@ -270,7 +272,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; softpipe->pipe.set_scissor_state = softpipe_set_scissor_state; softpipe->pipe.set_setup_state = softpipe_set_setup_state; - softpipe->pipe.set_stencil_state = softpipe_set_stencil_state; softpipe->pipe.set_texture_state = softpipe_set_texture_state; softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 5cee1a3cf9..4cbb0f891e 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -50,18 +50,17 @@ struct draw_stage; #define SP_NEW_SETUP 0x2 #define SP_NEW_FS 0x4 #define SP_NEW_BLEND 0x8 -#define SP_NEW_CLIP 0x10 -#define SP_NEW_SCISSOR 0x20 -#define SP_NEW_STIPPLE 0x40 -#define SP_NEW_FRAMEBUFFER 0x80 -#define SP_NEW_ALPHA_TEST 0x100 -#define SP_NEW_DEPTH_TEST 0x200 -#define SP_NEW_SAMPLER 0x400 -#define SP_NEW_TEXTURE 0x800 -#define SP_NEW_STENCIL 0x1000 -#define SP_NEW_VERTEX 0x2000 -#define SP_NEW_VS 0x4000 -#define SP_NEW_CONSTANTS 0x8000 +#define SP_NEW_CLIP 0x10 +#define SP_NEW_SCISSOR 0x20 +#define SP_NEW_STIPPLE 0x40 +#define SP_NEW_FRAMEBUFFER 0x80 +#define SP_NEW_ALPHA_TEST 0x100 +#define SP_NEW_DEPTH_STENCIL 0x200 +#define SP_NEW_SAMPLER 0x400 +#define SP_NEW_TEXTURE 0x800 +#define SP_NEW_VERTEX 0x1000 +#define SP_NEW_VS 0x2000 +#define SP_NEW_CONSTANTS 0x4000 struct softpipe_context { @@ -73,13 +72,13 @@ struct softpipe_context { */ const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct pipe_depth_stencil_state *depth_stencil; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; - struct pipe_depth_state depth_test; struct pipe_feedback_state feedback; struct pipe_framebuffer_state framebuffer; struct pipe_shader_state fs; @@ -87,7 +86,6 @@ struct softpipe_context { struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct pipe_setup_state setup; - struct pipe_stencil_state stencil; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index 2fcbea1f22..1f45776d47 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -31,7 +31,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.bufloop; } - if (sp->depth_test.occlusion_count) { + if (sp->depth_stencil->depth.occlusion_count) { sp->quad.occlusion->next = sp->quad.first; sp->quad.first = sp->quad.occlusion; } @@ -43,12 +43,12 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.coverage; } - if ( sp->stencil.front_enabled - || sp->stencil.front_enabled) { + if ( sp->depth_stencil->stencil.front_enabled + || sp->depth_stencil->stencil.back_enabled) { sp->quad.stencil_test->next = sp->quad.first; sp->quad.first = sp->quad.stencil_test; } - else if (sp->depth_test.enabled && + else if (sp->depth_stencil->depth.enabled && sp->framebuffer.zbuf) { sp->quad.depth_test->next = sp->quad.first; sp->quad.first = sp->quad.depth_test; diff --git a/src/mesa/pipe/softpipe/sp_quad_depth_test.c b/src/mesa/pipe/softpipe/sp_quad_depth_test.c index 5d46e70393..ff1d84a02d 100644 --- a/src/mesa/pipe/softpipe/sp_quad_depth_test.c +++ b/src/mesa/pipe/softpipe/sp_quad_depth_test.c @@ -77,7 +77,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad) /* get zquad from zbuffer */ sps->read_quad_z(sps, quad->x0, quad->y0, bzzzz); - switch (softpipe->depth_test.func) { + switch (softpipe->depth_stencil->depth.func) { case PIPE_FUNC_NEVER: /* zmask = 0 */ break; @@ -129,7 +129,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad) quad->mask &= zmask; - if (softpipe->depth_test.writemask) { + if (softpipe->depth_stencil->depth.writemask) { /* This is also efficient with sse / spe instructions: */ diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index cb0b6d8a77..46ad08aaa1 100755 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -179,7 +179,7 @@ static void shade_begin(struct quad_stage *qs) unsigned i, entry; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - qss->samplers[i].state = &softpipe->sampler[i]; + qss->samplers[i].state = softpipe->sampler[i]; qss->samplers[i].texture = softpipe->texture[i]; qss->samplers[i].get_samples = sp_get_samples; qss->samplers[i].pipe = &softpipe->pipe; diff --git a/src/mesa/pipe/softpipe/sp_quad_stencil.c b/src/mesa/pipe/softpipe/sp_quad_stencil.c index 47b3b4f089..56cc6907b2 100644 --- a/src/mesa/pipe/softpipe/sp_quad_stencil.c +++ b/src/mesa/pipe/softpipe/sp_quad_stencil.c @@ -207,23 +207,23 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad) /* choose front or back face function, operator, etc */ /* XXX we could do these initializations once per primitive */ - if (softpipe->stencil.back_enabled && quad->facing) { - func = softpipe->stencil.back_func; - failOp = softpipe->stencil.back_fail_op; - zFailOp = softpipe->stencil.back_zfail_op; - zPassOp = softpipe->stencil.back_zpass_op; - ref = softpipe->stencil.ref_value[1]; - wrtMask = softpipe->stencil.write_mask[1]; - valMask = softpipe->stencil.value_mask[1]; + if (softpipe->depth_stencil->stencil.back_enabled && quad->facing) { + func = softpipe->depth_stencil->stencil.back_func; + failOp = softpipe->depth_stencil->stencil.back_fail_op; + zFailOp = softpipe->depth_stencil->stencil.back_zfail_op; + zPassOp = softpipe->depth_stencil->stencil.back_zpass_op; + ref = softpipe->depth_stencil->stencil.ref_value[1]; + wrtMask = softpipe->depth_stencil->stencil.write_mask[1]; + valMask = softpipe->depth_stencil->stencil.value_mask[1]; } else { - func = softpipe->stencil.front_func; - failOp = softpipe->stencil.front_fail_op; - zFailOp = softpipe->stencil.front_zfail_op; - zPassOp = softpipe->stencil.front_zpass_op; - ref = softpipe->stencil.ref_value[0]; - wrtMask = softpipe->stencil.write_mask[0]; - valMask = softpipe->stencil.value_mask[0]; + func = softpipe->depth_stencil->stencil.front_func; + failOp = softpipe->depth_stencil->stencil.front_fail_op; + zFailOp = softpipe->depth_stencil->stencil.front_zfail_op; + zPassOp = softpipe->depth_stencil->stencil.front_zpass_op; + ref = softpipe->depth_stencil->stencil.ref_value[0]; + wrtMask = softpipe->depth_stencil->stencil.write_mask[0]; + valMask = softpipe->depth_stencil->stencil.value_mask[0]; } assert(s_surf); /* shouldn't get here if there's no stencil buffer */ @@ -244,7 +244,7 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad) if (quad->mask) { /* now the pixels that passed the stencil test are depth tested */ - if (softpipe->depth_test.enabled) { + if (softpipe->depth_stencil->depth.enabled) { const unsigned origMask = quad->mask; sp_depth_test_quad(qs, quad); /* quad->mask is updated */ diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index c8c93709db..caec3b4519 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -50,6 +50,15 @@ void softpipe_bind_sampler_state(struct pipe_context *, void softpipe_delete_sampler_state(struct pipe_context *, const struct pipe_sampler_state *); + +const struct pipe_depth_stencil_state * +softpipe_create_depth_stencil_state(struct pipe_context *, + const struct pipe_depth_stencil_state *); +void softpipe_bind_depth_stencil_state(struct pipe_context *, + const struct pipe_depth_stencil_state *); +void softpipe_delete_depth_stencil_state(struct pipe_context *, + const struct pipe_depth_stencil_state *); + void softpipe_set_framebuffer_state( struct pipe_context *, const struct pipe_framebuffer_state * ); @@ -69,9 +78,6 @@ void softpipe_set_constant_buffer(struct pipe_context *, uint shader, uint index, const struct pipe_constant_buffer *buf); -void softpipe_set_depth_test_state( struct pipe_context *, - const struct pipe_depth_state * ); - void softpipe_set_feedback_state( struct pipe_context *, const struct pipe_feedback_state * ); @@ -90,9 +96,6 @@ void softpipe_set_scissor_state( struct pipe_context *, void softpipe_set_setup_state( struct pipe_context *, const struct pipe_setup_state * ); -void softpipe_set_stencil_state( struct pipe_context *, - const struct pipe_stencil_state * ); - void softpipe_set_texture_state( struct pipe_context *, unsigned unit, struct pipe_mipmap_tree * ); diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c index 34da613f9d..83f456ded5 100644 --- a/src/mesa/pipe/softpipe/sp_state_blend.c +++ b/src/mesa/pipe/softpipe/sp_state_blend.c @@ -71,16 +71,6 @@ void softpipe_set_blend_color( struct pipe_context *pipe, /** 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 |= SP_NEW_DEPTH_TEST; -} void softpipe_set_alpha_test_state(struct pipe_context *pipe, @@ -93,14 +83,30 @@ softpipe_set_alpha_test_state(struct pipe_context *pipe, softpipe->dirty |= SP_NEW_ALPHA_TEST; } +const struct pipe_depth_stencil_state * +softpipe_create_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth_stencil) +{ + struct pipe_depth_stencil_state *new_ds = malloc(sizeof(struct pipe_depth_stencil_state)); + memcpy(new_ds, depth_stencil, sizeof(struct pipe_depth_stencil_state)); + + return new_ds; +} + void -softpipe_set_stencil_state(struct pipe_context *pipe, - const struct pipe_stencil_state *stencil) +softpipe_bind_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth_stencil) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->stencil = *stencil; + softpipe->depth_stencil = depth_stencil; - softpipe->dirty |= SP_NEW_STENCIL; + softpipe->dirty |= SP_NEW_DEPTH_STENCIL; } +void +softpipe_delete_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth) +{ + free((struct pipe_depth_stencil_state*)depth); +} diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index e08ed50a70..47743e185c 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -55,7 +55,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) /* Need Z if depth test is enabled or the fragment program uses the * fragment position (XYZW). */ - if (softpipe->depth_test.enabled || + if (softpipe->depth_stencil->depth.enabled || (inputsRead & (1 << TGSI_ATTRIB_POS))) softpipe->need_z = TRUE; else @@ -186,15 +186,14 @@ void softpipe_update_derived( struct softpipe_context *softpipe ) calculate_vertex_layout( softpipe ); if (softpipe->dirty & (SP_NEW_SCISSOR | - SP_NEW_STENCIL | + SP_NEW_DEPTH_STENCIL | SP_NEW_FRAMEBUFFER)) compute_cliprect(softpipe); if (softpipe->dirty & (SP_NEW_BLEND | - SP_NEW_DEPTH_TEST | + SP_NEW_DEPTH_STENCIL | SP_NEW_ALPHA_TEST | SP_NEW_FRAMEBUFFER | - SP_NEW_STENCIL | SP_NEW_SETUP | SP_NEW_FS)) sp_build_quad_pipeline(softpipe); diff --git a/src/mesa/sources b/src/mesa/sources index 90fa5c65bf..22b592df09 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -204,7 +204,6 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_sampler.c \ state_tracker/st_atom_scissor.c \ state_tracker/st_atom_setup.c \ - state_tracker/st_atom_stencil.c \ state_tracker/st_atom_stipple.c \ state_tracker/st_atom_texture.c \ state_tracker/st_atom_viewport.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 66ab5d7c3a..99d0bcb90b 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -46,7 +46,7 @@ static const struct st_tracked_state *atoms[] = { &st_update_framebuffer, &st_update_clear_color, - &st_update_depth, + &st_update_depth_stencil, &st_update_clip, &st_update_tnl, @@ -58,7 +58,6 @@ static const struct st_tracked_state *atoms[] = &st_update_viewport, &st_update_scissor, &st_update_blend, - &st_update_stencil, &st_update_sampler, &st_update_texture, &st_update_vs_constants, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 447430bfef..0e362b1fbf 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -47,7 +47,7 @@ void st_validate_state( struct st_context *st ); const struct st_tracked_state st_update_framebuffer; const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_clear_color; -const struct st_tracked_state st_update_depth; +const struct st_tracked_state st_update_depth_stencil; const struct st_tracked_state st_update_tnl; const struct st_tracked_state st_update_fs; const struct st_tracked_state st_update_vs; @@ -56,7 +56,6 @@ const struct st_tracked_state st_update_polygon_stipple; const struct st_tracked_state st_update_viewport; const struct st_tracked_state st_update_scissor; const struct st_tracked_state st_update_blend; -const struct st_tracked_state st_update_stencil; const struct st_tracked_state st_update_sampler; const struct st_tracked_state st_update_texture; const struct st_tracked_state st_update_fs_constants; diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index df05c79e36..406773213d 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -29,15 +29,67 @@ * Authors: * Keith Whitwell * Brian Paul + * Zack Rusin */ #include "st_context.h" +#include "st_cache.h" #include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +/** + * Convert GLenum stencil func tokens to pipe tokens. + */ +static GLuint +gl_stencil_func_to_sp(GLenum func) +{ + /* Same values, just biased */ + assert(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER); + assert(PIPE_FUNC_LESS == GL_LESS - GL_NEVER); + assert(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER); + assert(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER); + assert(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER); + assert(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER); + assert(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER); + assert(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER); + assert(func >= GL_NEVER); + assert(func <= GL_ALWAYS); + return func - GL_NEVER; +} + + +/** + * Convert GLenum stencil op tokens to pipe tokens. + */ +static GLuint +gl_stencil_op_to_sp(GLenum func) +{ + switch (func) { + case GL_KEEP: + return PIPE_STENCIL_OP_KEEP; + case GL_ZERO: + return PIPE_STENCIL_OP_ZERO; + case GL_REPLACE: + return PIPE_STENCIL_OP_REPLACE; + case GL_INCR: + return PIPE_STENCIL_OP_INCR; + case GL_DECR: + return PIPE_STENCIL_OP_DECR; + case GL_INCR_WRAP: + return PIPE_STENCIL_OP_INCR_WRAP; + case GL_DECR_WRAP: + return PIPE_STENCIL_OP_DECR_WRAP; + case GL_INVERT: + return PIPE_STENCIL_OP_INVERT; + default: + assert("invalid GL token in gl_stencil_op_to_sp()" == NULL); + return 0; + } +} + /** * Convert GLenum depth func tokens to pipe tokens. */ @@ -59,35 +111,59 @@ gl_depth_func_to_sp(GLenum func) } -static void -update_depth( struct st_context *st ) +static void +update_depth_stencil(struct st_context *st) { - struct pipe_depth_state depth; + struct pipe_depth_stencil_state depth_stencil; - memset(&depth, 0, sizeof(depth)); + memset(&depth_stencil, 0, sizeof(depth_stencil)); - depth.enabled = st->ctx->Depth.Test; - depth.writemask = st->ctx->Depth.Mask; - depth.func = gl_depth_func_to_sp(st->ctx->Depth.Func); - depth.clear = st->ctx->Depth.Clear; + depth_stencil.depth.enabled = st->ctx->Depth.Test; + depth_stencil.depth.writemask = st->ctx->Depth.Mask; + depth_stencil.depth.func = gl_depth_func_to_sp(st->ctx->Depth.Func); + depth_stencil.depth.clear = st->ctx->Depth.Clear; if (st->ctx->Query.CurrentOcclusionObject && st->ctx->Query.CurrentOcclusionObject->Active) - depth.occlusion_count = 1; + depth_stencil.depth.occlusion_count = 1; + + if (st->ctx->Stencil.Enabled) { + depth_stencil.stencil.front_enabled = 1; + depth_stencil.stencil.front_func = gl_stencil_func_to_sp(st->ctx->Stencil.Function[0]); + depth_stencil.stencil.front_fail_op = gl_stencil_op_to_sp(st->ctx->Stencil.FailFunc[0]); + depth_stencil.stencil.front_zfail_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZFailFunc[0]); + depth_stencil.stencil.front_zpass_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZPassFunc[0]); + depth_stencil.stencil.ref_value[0] = st->ctx->Stencil.Ref[0] & 0xff; + depth_stencil.stencil.value_mask[0] = st->ctx->Stencil.ValueMask[0] & 0xff; + depth_stencil.stencil.write_mask[0] = st->ctx->Stencil.WriteMask[0] & 0xff; + if (st->ctx->Stencil.TestTwoSide) { + depth_stencil.stencil.back_enabled = 1; + depth_stencil.stencil.back_func = gl_stencil_func_to_sp(st->ctx->Stencil.Function[1]); + depth_stencil.stencil.back_fail_op = gl_stencil_op_to_sp(st->ctx->Stencil.FailFunc[1]); + depth_stencil.stencil.back_zfail_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZFailFunc[1]); + depth_stencil.stencil.back_zpass_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZPassFunc[1]); + depth_stencil.stencil.ref_value[1] = st->ctx->Stencil.Ref[1] & 0xff; + depth_stencil.stencil.value_mask[1] = st->ctx->Stencil.ValueMask[1] & 0xff; + depth_stencil.stencil.write_mask[1] = st->ctx->Stencil.WriteMask[1] & 0xff; + } + depth_stencil.stencil.clear_value = st->ctx->Stencil.Clear & 0xff; + } - if (memcmp(&depth, &st->state.depth, sizeof(depth)) != 0) { + struct pipe_depth_stencil_state *cached_state = + st_cached_depth_stencil_state(st, &depth_stencil); + if (st->state.depth_stencil != cached_state) { /* state has changed */ - st->state.depth = depth; /* struct copy */ - st->pipe->set_depth_state(st->pipe, &depth); /* set new state */ + st->state.depth_stencil = cached_state; + st->pipe->bind_depth_stencil_state(st->pipe, cached_state); /* set new state */ } } -const struct st_tracked_state st_update_depth = { - .name = "st_update_depth", +const struct st_tracked_state st_update_depth_stencil = { + .name = "st_update_depth_stencil", .dirty = { - .mesa = (_NEW_DEPTH), + .mesa = (_NEW_DEPTH|_NEW_STENCIL), .st = 0, }, - .update = update_depth + .update = update_depth_stencil }; diff --git a/src/mesa/state_tracker/st_atom_stencil.c b/src/mesa/state_tracker/st_atom_stencil.c deleted file mode 100644 index b8aec0b3b6..0000000000 --- a/src/mesa/state_tracker/st_atom_stencil.c +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - - /* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - -#include "st_context.h" -#include "st_atom.h" -#include "pipe/p_context.h" -#include "pipe/p_defines.h" - - -/** - * Convert GLenum stencil func tokens to pipe tokens. - */ -static GLuint -gl_stencil_func_to_sp(GLenum func) -{ - /* Same values, just biased */ - assert(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER); - assert(PIPE_FUNC_LESS == GL_LESS - GL_NEVER); - assert(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER); - assert(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER); - assert(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER); - assert(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER); - assert(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER); - assert(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER); - assert(func >= GL_NEVER); - assert(func <= GL_ALWAYS); - return func - GL_NEVER; -} - - -/** - * Convert GLenum stencil op tokens to pipe tokens. - */ -static GLuint -gl_stencil_op_to_sp(GLenum func) -{ - switch (func) { - case GL_KEEP: - return PIPE_STENCIL_OP_KEEP; - case GL_ZERO: - return PIPE_STENCIL_OP_ZERO; - case GL_REPLACE: - return PIPE_STENCIL_OP_REPLACE; - case GL_INCR: - return PIPE_STENCIL_OP_INCR; - case GL_DECR: - return PIPE_STENCIL_OP_DECR; - case GL_INCR_WRAP: - return PIPE_STENCIL_OP_INCR_WRAP; - case GL_DECR_WRAP: - return PIPE_STENCIL_OP_DECR_WRAP; - case GL_INVERT: - return PIPE_STENCIL_OP_INVERT; - default: - assert("invalid GL token in gl_stencil_op_to_sp()" == NULL); - return 0; - } -} - - -static void -update_stencil( struct st_context *st ) -{ - struct pipe_stencil_state stencil; - - memset(&stencil, 0, sizeof(stencil)); - - if (st->ctx->Stencil.Enabled) { - stencil.front_enabled = 1; - stencil.front_func = gl_stencil_func_to_sp(st->ctx->Stencil.Function[0]); - stencil.front_fail_op = gl_stencil_op_to_sp(st->ctx->Stencil.FailFunc[0]); - stencil.front_zfail_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZFailFunc[0]); - stencil.front_zpass_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZPassFunc[0]); - stencil.ref_value[0] = st->ctx->Stencil.Ref[0] & 0xff; - stencil.value_mask[0] = st->ctx->Stencil.ValueMask[0] & 0xff; - stencil.write_mask[0] = st->ctx->Stencil.WriteMask[0] & 0xff; - if (st->ctx->Stencil.TestTwoSide) { - stencil.back_enabled = 1; - stencil.back_func = gl_stencil_func_to_sp(st->ctx->Stencil.Function[1]); - stencil.back_fail_op = gl_stencil_op_to_sp(st->ctx->Stencil.FailFunc[1]); - stencil.back_zfail_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZFailFunc[1]); - stencil.back_zpass_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZPassFunc[1]); - stencil.ref_value[1] = st->ctx->Stencil.Ref[1] & 0xff; - stencil.value_mask[1] = st->ctx->Stencil.ValueMask[1] & 0xff; - stencil.write_mask[1] = st->ctx->Stencil.WriteMask[1] & 0xff; - } - stencil.clear_value = st->ctx->Stencil.Clear & 0xff; - } - - if (memcmp(&stencil, &st->state.stencil, sizeof(stencil)) != 0) { - /* state has changed */ - st->state.stencil = stencil; /* struct copy */ - st->pipe->set_stencil_state(st->pipe, &stencil); /* set new state */ - } -} - - -const struct st_tracked_state st_update_stencil = { - .name = "st_update_stencil", - .dirty = { - .mesa = (_NEW_STENCIL), - .st = 0, - }, - .update = update_stencil -}; - - - - - diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index 99fb45f00a..64c03be99d 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -76,3 +76,20 @@ struct pipe_sampler_state * st_cached_sampler_state( } return (struct pipe_sampler_state*)(cso_hash_iter_data(iter)); } + +struct pipe_depth_stencil_state * st_cached_depth_stencil_state( + struct st_context *st, + const struct pipe_depth_stencil_state *depth_stencil) +{ + unsigned hash_key = cso_construct_key((void*)depth_stencil, sizeof(struct pipe_depth_stencil_state)); + struct cso_hash_iter iter = cso_find_state_template(st->cache, + hash_key, CSO_DEPTH_STENCIL, + (void*)depth_stencil); + if (cso_hash_iter_is_null(iter)) { + const struct pipe_depth_stencil_state *created_state = st->pipe->create_depth_stencil_state( + st->pipe, depth_stencil); + iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL, + (void*)created_state); + } + return (struct pipe_depth_stencil_state*)(cso_hash_iter_data(iter)); +} diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index 927585141c..78cb2e774e 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -45,5 +45,8 @@ struct pipe_sampler_state * st_cached_sampler_state( struct st_context *st, const struct pipe_sampler_state *sampler); +struct pipe_depth_stencil_state *st_cached_depth_stencil_state( + struct st_context *st, + const struct pipe_depth_stencil_state *sampler); #endif diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 55e03f644e..e9aabd15b5 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -283,6 +283,7 @@ clear_with_quad(GLcontext *ctx, /* blend state: RGBA masking */ { struct pipe_blend_state blend; + const struct pipe_blend_state *state; memset(&blend, 0, sizeof(blend)); if (color) { if (ctx->Color.ColorMask[0]) @@ -296,20 +297,34 @@ clear_with_quad(GLcontext *ctx, if (st->ctx->Color.DitherFlag) blend.dither = 1; } - const struct pipe_blend_state *state = st_cached_blend_state(st, &blend); + state = st_cached_blend_state(st, &blend); pipe->bind_blend_state(pipe, state); } - /* depth state: always pass */ + /* depth_stencil state: always pass/set to ref value */ { - struct pipe_depth_state depth_test; - memset(&depth_test, 0, sizeof(depth_test)); + struct pipe_depth_stencil_state depth_stencil; + struct pipe_depth_stencil_state *cached; + memset(&depth_stencil, 0, sizeof(depth_stencil)); if (depth) { - depth_test.enabled = 1; - depth_test.writemask = 1; - depth_test.func = PIPE_FUNC_ALWAYS; + depth_stencil.depth.enabled = 1; + depth_stencil.depth.writemask = 1; + depth_stencil.depth.func = PIPE_FUNC_ALWAYS; } - pipe->set_depth_state(pipe, &depth_test); + + if (stencil) { + depth_stencil.stencil.front_enabled = 1; + depth_stencil.stencil.front_func = PIPE_FUNC_ALWAYS; + depth_stencil.stencil.front_fail_op = PIPE_STENCIL_OP_REPLACE; + depth_stencil.stencil.front_zpass_op = PIPE_STENCIL_OP_REPLACE; + depth_stencil.stencil.front_zfail_op = PIPE_STENCIL_OP_REPLACE; + depth_stencil.stencil.ref_value[0] = ctx->Stencil.Clear; + depth_stencil.stencil.value_mask[0] = 0xff; + depth_stencil.stencil.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff; + } + cached = + st_cached_depth_stencil_state(ctx->st, &depth_stencil); + pipe->bind_depth_stencil_state(pipe, cached); } /* setup state: nothing */ @@ -326,23 +341,6 @@ clear_with_quad(GLcontext *ctx, pipe->set_setup_state(pipe, &setup); } - /* stencil state: always set to ref value */ - { - struct pipe_stencil_state stencil_test; - memset(&stencil_test, 0, sizeof(stencil_test)); - if (stencil) { - stencil_test.front_enabled = 1; - stencil_test.front_func = PIPE_FUNC_ALWAYS; - stencil_test.front_fail_op = PIPE_STENCIL_OP_REPLACE; - stencil_test.front_zpass_op = PIPE_STENCIL_OP_REPLACE; - 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] & 0xff; - } - pipe->set_stencil_state(pipe, &stencil_test); - } - /* fragment shader state: color pass-through program */ { static struct st_fragment_program *stfp = NULL; @@ -393,11 +391,10 @@ clear_with_quad(GLcontext *ctx, /* Restore pipe state */ pipe->set_alpha_test_state(pipe, &st->state.alpha_test); pipe->bind_blend_state(pipe, st->state.blend); - pipe->set_depth_state(pipe, &st->state.depth); + pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil); pipe->set_fs_state(pipe, &st->state.fs); pipe->set_vs_state(pipe, &st->state.vs); pipe->set_setup_state(pipe, &st->state.setup); - pipe->set_stencil_state(pipe, &st->state.stencil); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); /* OR: st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 31a37e5cd4..a0012e3a8c 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -478,7 +478,7 @@ any_fragment_ops(const struct st_context *st) if (st->state.alpha_test.enabled || st->state.blend->blend_enable || st->state.blend->logicop_enable || - st->state.depth.enabled) + st->state.depth_stencil->depth.enabled) /* XXX more checks */ return GL_TRUE; else diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 13526ff9e7..7c887d0b55 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -76,13 +76,13 @@ struct st_context struct { const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct pipe_depth_stencil_state *depth_stencil; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; - struct pipe_depth_state depth; struct pipe_feedback_state feedback; struct pipe_framebuffer_state framebuffer; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; @@ -91,7 +91,6 @@ struct st_context struct pipe_setup_state setup; struct pipe_shader_state fs; struct pipe_shader_state vs; - struct pipe_stencil_state stencil; struct pipe_viewport_state viewport; } state; -- cgit v1.2.3 From 294401814d1d89cc731de1c22c25333aa5d59374 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 17 Sep 2007 12:59:50 -0400 Subject: converting the setup state to immutable object and renaming it to rasterizer state --- src/mesa/cso_cache/cso_cache.c | 6 ++ src/mesa/cso_cache/cso_cache.h | 4 +- src/mesa/pipe/draw/draw_context.c | 16 ++--- src/mesa/pipe/draw/draw_context.h | 2 +- src/mesa/pipe/draw/draw_cull.c | 2 +- src/mesa/pipe/draw/draw_offset.c | 4 +- src/mesa/pipe/draw/draw_private.h | 2 +- src/mesa/pipe/draw/draw_twoside.c | 2 +- src/mesa/pipe/draw/draw_unfilled.c | 4 +- src/mesa/pipe/failover/fo_context.h | 8 +-- src/mesa/pipe/failover/fo_state.c | 14 ++-- src/mesa/pipe/failover/fo_state_emit.c | 4 +- src/mesa/pipe/i915simple/i915_context.h | 4 +- src/mesa/pipe/i915simple/i915_state.c | 30 ++++++-- src/mesa/pipe/i915simple/i915_state_derived.c | 6 +- src/mesa/pipe/i915simple/i915_state_dynamic.c | 16 ++--- src/mesa/pipe/i915simple/i915_state_immediate.c | 30 ++++---- src/mesa/pipe/p_context.h | 11 ++- src/mesa/pipe/p_state.h | 4 +- src/mesa/pipe/softpipe/sp_context.c | 4 +- src/mesa/pipe/softpipe/sp_context.h | 4 +- src/mesa/pipe/softpipe/sp_prim_setup.c | 18 ++--- src/mesa/pipe/softpipe/sp_quad.c | 8 +-- src/mesa/pipe/softpipe/sp_quad_coverage.c | 6 +- src/mesa/pipe/softpipe/sp_state.h | 12 ++-- src/mesa/pipe/softpipe/sp_state_derived.c | 10 +-- src/mesa/pipe/softpipe/sp_state_setup.c | 26 +++++-- src/mesa/state_tracker/st_atom.c | 2 +- src/mesa/state_tracker/st_atom.h | 2 +- src/mesa/state_tracker/st_atom_setup.c | 95 +++++++++++++------------ src/mesa/state_tracker/st_cache.c | 18 +++++ src/mesa/state_tracker/st_cache.h | 6 +- src/mesa/state_tracker/st_cb_clear.c | 12 ++-- src/mesa/state_tracker/st_cb_drawpixels.c | 8 ++- src/mesa/state_tracker/st_context.h | 2 +- src/mesa/state_tracker/st_draw.c | 2 +- 36 files changed, 245 insertions(+), 159 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/cso_cache/cso_cache.c b/src/mesa/cso_cache/cso_cache.c index a4730394f8..4aaadf00e6 100644 --- a/src/mesa/cso_cache/cso_cache.c +++ b/src/mesa/cso_cache/cso_cache.c @@ -78,6 +78,8 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ hash = sc->sampler_hash; case CSO_DEPTH_STENCIL: hash = sc->depth_stencil_hash; + case CSO_RASTERIZER: + hash = sc->rasterizer_hash; } return hash; @@ -92,6 +94,8 @@ static int _cso_size_for_type(enum cso_cache_type type) return sizeof(struct pipe_sampler_state); case CSO_DEPTH_STENCIL: return sizeof(struct pipe_depth_stencil_state); + case CSO_RASTERIZER: + return sizeof(struct pipe_rasterizer_state); } return 0; } @@ -143,6 +147,7 @@ struct cso_cache *cso_cache_create(void) sc->blend_hash = cso_hash_create(); sc->sampler_hash = cso_hash_create(); sc->depth_stencil_hash = cso_hash_create(); + sc->rasterizer_hash = cso_hash_create(); return sc; } @@ -153,6 +158,7 @@ void cso_cache_delete(struct cso_cache *sc) cso_hash_delete(sc->blend_hash); cso_hash_delete(sc->sampler_hash); cso_hash_delete(sc->depth_stencil_hash); + cso_hash_delete(sc->rasterizer_hash); free(sc); } diff --git a/src/mesa/cso_cache/cso_cache.h b/src/mesa/cso_cache/cso_cache.h index c340cf7f67..23be9cd713 100644 --- a/src/mesa/cso_cache/cso_cache.h +++ b/src/mesa/cso_cache/cso_cache.h @@ -43,12 +43,14 @@ struct cso_cache { struct cso_hash *blend_hash; struct cso_hash *sampler_hash; struct cso_hash *depth_stencil_hash; + struct cso_hash *rasterizer_hash; }; enum cso_cache_type { CSO_BLEND, CSO_SAMPLER, - CSO_DEPTH_STENCIL + CSO_DEPTH_STENCIL, + CSO_RASTERIZER }; unsigned cso_construct_key(void *item, int item_size); diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index 4498293e92..f3236ad59e 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -98,19 +98,19 @@ static void validate_pipeline( struct draw_context *draw ) * shorter pipelines for lines & points. */ - if (draw->setup.fill_cw != PIPE_POLYGON_MODE_FILL || - draw->setup.fill_ccw != PIPE_POLYGON_MODE_FILL) { + if (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL || + draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) { draw->pipeline.unfilled->next = next; next = draw->pipeline.unfilled; } - if (draw->setup.offset_cw || - draw->setup.offset_ccw) { + if (draw->rasterizer->offset_cw || + draw->rasterizer->offset_ccw) { draw->pipeline.offset->next = next; next = draw->pipeline.offset; } - if (draw->setup.light_twoside) { + if (draw->rasterizer->light_twoside) { draw->pipeline.twoside->next = next; next = draw->pipeline.twoside; } @@ -134,7 +134,7 @@ static void validate_pipeline( struct draw_context *draw ) * this for clipped primitives, ie it is a part of the clip * routine. */ - if (draw->setup.flatshade) { + if (draw->rasterizer->flatshade) { draw->pipeline.flatshade->next = next; next = draw->pipeline.flatshade; } @@ -161,9 +161,9 @@ void draw_set_feedback_state( struct draw_context *draw, * This causes the drawing pipeline to be rebuilt. */ void draw_set_setup_state( struct draw_context *draw, - const struct pipe_setup_state *setup ) + const struct pipe_rasterizer_state *raster ) { - draw->setup = *setup; /* struct copy */ + draw->rasterizer = raster; validate_pipeline( draw ); } diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 2babc02f45..2714252fc5 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -87,7 +87,7 @@ void draw_set_feedback_state( struct draw_context *draw, const struct pipe_feedback_state * ); void draw_set_setup_state( struct draw_context *draw, - const struct pipe_setup_state *setup ); + const struct pipe_rasterizer_state *raster ); void draw_set_setup_stage( struct draw_context *draw, struct draw_stage *stage ); diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c index f3d56ad719..f898834ba5 100644 --- a/src/mesa/pipe/draw/draw_cull.c +++ b/src/mesa/pipe/draw/draw_cull.c @@ -54,7 +54,7 @@ static void cull_begin( struct draw_stage *stage ) { struct cull_stage *cull = cull_stage(stage); - cull->winding = stage->draw->setup.cull_mode; + cull->winding = stage->draw->rasterizer->cull_mode; stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c index 4f653e8c54..6acc7cbcd2 100644 --- a/src/mesa/pipe/draw/draw_offset.c +++ b/src/mesa/pipe/draw/draw_offset.c @@ -57,8 +57,8 @@ static void offset_begin( struct draw_stage *stage ) struct offset_stage *offset = offset_stage(stage); float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */ - offset->units = stage->draw->setup.offset_units * mrd; - offset->scale = stage->draw->setup.offset_scale; + offset->units = stage->draw->rasterizer->offset_units * mrd; + offset->scale = stage->draw->rasterizer->offset_scale; stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 8bcc3717c4..fb0aaff40d 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -137,7 +137,7 @@ struct draw_context } pipeline; /* pipe state that we need: */ - struct pipe_setup_state setup; + const struct pipe_rasterizer_state *rasterizer; struct pipe_feedback_state feedback; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index 98eb088035..3eb8cce637 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -55,7 +55,7 @@ static void twoside_begin( struct draw_stage *stage ) * if the triangle is back-facing (negative). * sign = -1 for CCW, +1 for CW */ - twoside->sign = (stage->draw->setup.front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f; + twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f; stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c index b0d6f3d065..2d374329d8 100644 --- a/src/mesa/pipe/draw/draw_unfilled.c +++ b/src/mesa/pipe/draw/draw_unfilled.c @@ -59,8 +59,8 @@ static void unfilled_begin( struct draw_stage *stage ) { struct unfilled_stage *unfilled = unfilled_stage(stage); - unfilled->mode[0] = stage->draw->setup.fill_ccw; /* front */ - unfilled->mode[1] = stage->draw->setup.fill_cw; /* back */ + unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */ + unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */ stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index 63ec7239ab..b05ceb88ad 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -37,7 +37,7 @@ #define FO_NEW_VIEWPORT 0x1 -#define FO_NEW_SETUP 0x2 +#define FO_NEW_RASTERIZER 0x2 #define FO_NEW_FRAGMENT_SHADER 0x4 #define FO_NEW_BLEND 0x8 #define FO_NEW_CLIP 0x10 @@ -66,9 +66,10 @@ struct failover_context { /* The most recent drawing state as set by the driver: */ - const struct pipe_blend_state *blend; - const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct pipe_blend_state *blend; + const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -79,7 +80,6 @@ struct failover_context { struct pipe_shader_state vertex_shader; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_setup_state setup; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index 43b9757b31..8e2b649590 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -160,15 +160,15 @@ failover_set_polygon_stipple( struct pipe_context *pipe, -static void -failover_set_setup_state( struct pipe_context *pipe, - const struct pipe_setup_state *setup ) +static void +failover_bind_rasterizer_state( struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup ) { struct failover_context *failover = failover_context(pipe); - failover->setup = *setup; - failover->dirty |= FO_NEW_SETUP; - failover->hw->set_setup_state( failover->hw, setup ); + failover->rasterizer = setup; + failover->dirty |= FO_NEW_RASTERIZER; + failover->hw->bind_rasterizer_state( failover->hw, setup ); } @@ -257,6 +257,7 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.bind_blend_state = failover_bind_blend_state; failover->pipe.bind_sampler_state = failover_bind_sampler_state; failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state; + failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state; failover->pipe.set_alpha_test_state = failover_set_alpha_test_state; failover->pipe.set_blend_color = failover_set_blend_color; @@ -267,7 +268,6 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_vs_state = failover_set_vs_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; failover->pipe.set_scissor_state = failover_set_scissor_state; - failover->pipe.set_setup_state = failover_set_setup_state; failover->pipe.set_texture_state = failover_set_texture_state; failover->pipe.set_viewport_state = failover_set_viewport_state; failover->pipe.set_vertex_buffer = failover_set_vertex_buffer; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index 3a1865d766..1c9573a7b0 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -85,8 +85,8 @@ failover_state_emit( struct failover_context *failover ) if (failover->dirty & FO_NEW_STIPPLE) failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple ); - if (failover->dirty & FO_NEW_SETUP) - failover->sw->set_setup_state( failover->sw, &failover->setup ); + if (failover->dirty & FO_NEW_RASTERIZER) + failover->sw->bind_rasterizer_state( failover->sw, failover->rasterizer ); if (failover->dirty & FO_NEW_SCISSOR) failover->sw->set_scissor_state( failover->sw, &failover->scissor ); diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 518f780449..3fab821fde 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -126,6 +126,7 @@ struct i915_context const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -136,7 +137,6 @@ struct i915_context struct pipe_shader_state fs; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_setup_state setup; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; @@ -159,7 +159,7 @@ struct i915_context /* A flag for each state_tracker state object: */ #define I915_NEW_VIEWPORT 0x1 -#define I915_NEW_SETUP 0x2 +#define I915_NEW_RASTERIZER 0x2 #define I915_NEW_FS 0x4 #define I915_NEW_BLEND 0x8 #define I915_NEW_CLIP 0x10 diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 5ac2e27d1a..00764902bc 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -288,19 +288,36 @@ static void i915_set_viewport_state( struct pipe_context *pipe, } -static void i915_set_setup_state( struct pipe_context *pipe, - const struct pipe_setup_state *setup ) + +static const struct pipe_rasterizer_state * +i915_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) +{ + struct pipe_rasterizer_state *raster = + malloc(sizeof(struct pipe_rasterizer_state)); + memcpy(raster, setup, sizeof(struct pipe_rasterizer_state)); + + return raster; +} + +static void i915_bind_rasterizer_state( struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup ) { struct i915_context *i915 = i915_context(pipe); - i915->setup = *setup; + i915->rasterizer = setup; /* pass-through to draw module */ draw_set_setup_state(i915->draw, setup); - i915->dirty |= I915_NEW_SETUP; + i915->dirty |= I915_NEW_RASTERIZER; } +static void i915_delete_rasterizer_state( struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup ) +{ + free((struct pipe_rasterizer_state*)setup); +} static void i915_set_vertex_buffer( struct pipe_context *pipe, unsigned index, @@ -338,6 +355,10 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.bind_depth_stencil_state = i915_bind_depth_stencil_state; i915->pipe.delete_depth_stencil_state = i915_delete_depth_stencil_state; + i915->pipe.create_rasterizer_state = i915_create_rasterizer_state; + i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state; + i915->pipe.delete_rasterizer_state = i915_delete_rasterizer_state; + i915->pipe.set_alpha_test_state = i915_set_alpha_test_state; i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; @@ -348,7 +369,6 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.set_vs_state = i915_set_vs_state; i915->pipe.set_polygon_stipple = i915_set_polygon_stipple; i915->pipe.set_scissor_state = i915_set_scissor_state; - i915->pipe.set_setup_state = i915_set_setup_state; i915->pipe.set_texture_state = i915_set_texture_state; i915->pipe.set_viewport_state = i915_set_viewport_state; i915->pipe.set_vertex_buffer = i915_set_vertex_buffer; diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 792bb93b17..504bc10a9e 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -44,7 +44,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) { const uint inputsRead = i915->fs.inputs_read; const interp_mode colorInterp - = i915->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR; + = i915->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &i915->current.vertex_info; uint front0 = 0, back0 = 0, front1 = 0, back1 = 0; boolean needW = 0; @@ -103,7 +103,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) * lighting. Edgeflag is dealt with specially by setting bits in * the vertex header. */ - if (i915->setup.light_twoside) { + if (i915->rasterizer->light_twoside) { if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT, colorInterp); @@ -142,7 +142,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) */ void i915_update_derived( struct i915_context *i915 ) { - if (i915->dirty & (I915_NEW_SETUP | I915_NEW_FS)) + if (i915->dirty & (I915_NEW_RASTERIZER | I915_NEW_FS)) calculate_vertex_layout( i915 ); if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_TEXTURE)) diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c index 9140eee7c2..a9791962e2 100644 --- a/src/mesa/pipe/i915simple/i915_state_dynamic.c +++ b/src/mesa/pipe/i915simple/i915_state_dynamic.c @@ -261,10 +261,10 @@ static void upload_DEPTHSCALE( struct i915_context *i915 ) memset( ds, 0, sizeof(ds) ); - /* I915_NEW_SETUP + /* I915_NEW_RASTERIZER */ ds[0].u = _3DSTATE_DEPTH_OFFSET_SCALE; - ds[1].f = i915->setup.offset_scale; + ds[1].f = i915->rasterizer->offset_scale; set_dynamic_indirect( i915, I915_DYNAMIC_DEPTHSCALE_0, @@ -273,7 +273,7 @@ static void upload_DEPTHSCALE( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_DEPTHSCALE = { - .dirty = I915_NEW_SETUP, + .dirty = I915_NEW_RASTERIZER, .update = upload_DEPTHSCALE }; @@ -298,9 +298,9 @@ static void upload_STIPPLE( struct i915_context *i915 ) st[0] = _3DSTATE_STIPPLE; st[1] = 0; - /* I915_NEW_SETUP + /* I915_NEW_RASTERIZER */ - if (i915->setup.poly_stipple_enable) { + if (i915->rasterizer->poly_stipple_enable) { st[1] |= ST1_ENABLE; } @@ -333,7 +333,7 @@ static void upload_STIPPLE( struct i915_context *i915 ) const struct i915_tracked_state i915_upload_STIPPLE = { - .dirty = I915_NEW_SETUP | I915_NEW_STIPPLE, + .dirty = I915_NEW_RASTERIZER | I915_NEW_STIPPLE, .update = upload_STIPPLE }; @@ -346,7 +346,7 @@ static void upload_SCISSOR_ENABLE( struct i915_context *i915 ) { unsigned sc[1]; - if (i915->setup.scissor) + if (i915->rasterizer->scissor) sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT; else sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT; @@ -358,7 +358,7 @@ static void upload_SCISSOR_ENABLE( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_SCISSOR_ENABLE = { - .dirty = I915_NEW_SETUP, + .dirty = I915_NEW_RASTERIZER, .update = upload_SCISSOR_ENABLE }; diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c index 484913d308..73508f557f 100644 --- a/src/mesa/pipe/i915simple/i915_state_immediate.c +++ b/src/mesa/pipe/i915simple/i915_state_immediate.c @@ -62,8 +62,8 @@ static void upload_S2S4(struct i915_context *i915) assert(LIS4); /* should never be zero? */ } - /* I915_NEW_SETUP */ - switch (i915->setup.cull_mode) { + /* I915_NEW_RASTERIZER */ + switch (i915->rasterizer->cull_mode) { case PIPE_WINDING_NONE: LIS4 |= S4_CULLMODE_NONE; break; @@ -78,25 +78,25 @@ static void upload_S2S4(struct i915_context *i915) break; } - /* I915_NEW_SETUP */ + /* I915_NEW_RASTERIZER */ { - int line_width = CLAMP((int)(i915->setup.line_width * 2), 1, 0xf); + int line_width = CLAMP((int)(i915->rasterizer->line_width * 2), 1, 0xf); LIS4 |= line_width << S4_LINE_WIDTH_SHIFT; - if (i915->setup.line_smooth) + if (i915->rasterizer->line_smooth) LIS4 |= S4_LINE_ANTIALIAS_ENABLE; } - /* I915_NEW_SETUP */ + /* I915_NEW_RASTERIZER */ { - int point_size = CLAMP((int) i915->setup.point_size, 1, 0xff); + int point_size = CLAMP((int) i915->rasterizer->point_size, 1, 0xff); LIS4 |= point_size << S4_POINT_WIDTH_SHIFT; } - /* I915_NEW_SETUP */ - if (i915->setup.flatshade) { + /* I915_NEW_RASTERIZER */ + if (i915->rasterizer->flatshade) { LIS4 |= (S4_FLATSHADE_ALPHA | S4_FLATSHADE_COLOR | S4_FLATSHADE_SPECULAR); @@ -114,7 +114,7 @@ static void upload_S2S4(struct i915_context *i915) const struct i915_tracked_state i915_upload_S2S4 = { - .dirty = I915_NEW_SETUP | I915_NEW_VERTEX_FORMAT, + .dirty = I915_NEW_RASTERIZER | I915_NEW_VERTEX_FORMAT, .update = upload_S2S4 }; @@ -165,7 +165,7 @@ static void upload_S5( struct i915_context *i915 ) #if 0 - /* I915_NEW_SETUP */ + /* I915_NEW_RASTERIZER */ if (i915->state.Polygon->OffsetFill) { LIS5 |= S5_GLOBAL_DEPTH_OFFSET_ENABLE; } @@ -179,7 +179,7 @@ static void upload_S5( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_S5 = { - .dirty = (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_SETUP), + .dirty = (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_RASTERIZER), .update = upload_S5 }; @@ -247,9 +247,9 @@ static void upload_S7( struct i915_context *i915 ) { float LIS7; - /* I915_NEW_SETUP + /* I915_NEW_RASTERIZER */ - LIS7 = i915->setup.offset_units; /* probably incorrect */ + LIS7 = i915->rasterizer->offset_units; /* probably incorrect */ if (LIS7 != i915->current.immediate[I915_IMMEDIATE_S7]) { i915->current.immediate[I915_IMMEDIATE_S7] = LIS7; @@ -258,7 +258,7 @@ static void upload_S7( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_S7 = { - .dirty = I915_NEW_SETUP, + .dirty = I915_NEW_RASTERIZER, .update = upload_S7 }; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 488f002531..dda758fe6a 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -101,6 +101,14 @@ struct pipe_context { void (*delete_sampler_state)(struct pipe_context *, const struct pipe_sampler_state *); + const struct pipe_rasterizer_state *(*create_rasterizer_state)( + struct pipe_context *, + const struct pipe_rasterizer_state *); + void (*bind_rasterizer_state)(struct pipe_context *, + const struct pipe_rasterizer_state *); + void (*delete_rasterizer_state)(struct pipe_context *, + const struct pipe_rasterizer_state *); + const struct pipe_depth_stencil_state * (*create_depth_stencil_state)( struct pipe_context *, const struct pipe_depth_stencil_state *); @@ -140,9 +148,6 @@ struct pipe_context { void (*set_polygon_stipple)( struct pipe_context *, const struct pipe_poly_stipple * ); - void (*set_setup_state)( struct pipe_context *, - const struct pipe_setup_state * ); - void (*set_scissor_state)( struct pipe_context *, const struct pipe_scissor_state * ); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 30e559b594..048feede3b 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -65,9 +65,9 @@ struct pipe_buffer_handle; /** - * Primitive (point/line/tri) setup info + * Primitive (point/line/tri) rasterization info */ -struct pipe_setup_state +struct pipe_rasterizer_state { unsigned flatshade:1; unsigned light_twoside:1; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 9a8b55bb0e..7753ce40d7 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -259,6 +259,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.create_depth_stencil_state = softpipe_create_depth_stencil_state; softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state; softpipe->pipe.delete_depth_stencil_state = softpipe_delete_depth_stencil_state; + softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state; + softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; + softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state; softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; @@ -271,7 +274,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.set_vs_state = softpipe_set_vs_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; softpipe->pipe.set_scissor_state = softpipe_set_scissor_state; - softpipe->pipe.set_setup_state = softpipe_set_setup_state; softpipe->pipe.set_texture_state = softpipe_set_texture_state; softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 4cbb0f891e..f1bb3d39a6 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -47,7 +47,7 @@ struct draw_stage; #define SP_NEW_VIEWPORT 0x1 -#define SP_NEW_SETUP 0x2 +#define SP_NEW_RASTERIZER 0x2 #define SP_NEW_FS 0x4 #define SP_NEW_BLEND 0x8 #define SP_NEW_CLIP 0x10 @@ -73,6 +73,7 @@ struct softpipe_context { const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -85,7 +86,6 @@ struct softpipe_context { struct pipe_shader_state vs; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_setup_state setup; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 83d317c36f..c64a4e9708 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -351,7 +351,7 @@ static boolean setup_sort_vertices( struct setup_stage *setup, * - the GLSL gl_FrontFacing fragment attribute (bool) * - two-sided stencil test */ - setup->quad.facing = (prim->det > 0.0) ^ (setup->softpipe->setup.front_winding == PIPE_WINDING_CW); + setup->quad.facing = (prim->det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW); return TRUE; } @@ -830,10 +830,10 @@ setup_line(struct draw_stage *stage, struct prim_header *prim) const int errorDec = error - dx; for (i = 0; i < dx; i++) { - if (!sp->setup.line_stipple_enable || + if (!sp->rasterizer->line_stipple_enable || stipple_test(sp->line_stipple_counter, - sp->setup.line_stipple_pattern, - sp->setup.line_stipple_factor + 1)) { + sp->rasterizer->line_stipple_pattern, + sp->rasterizer->line_stipple_factor + 1)) { plot(setup, x0, y0); } @@ -857,10 +857,10 @@ setup_line(struct draw_stage *stage, struct prim_header *prim) const int errorDec = error - dy; for (i = 0; i < dy; i++) { - if (!sp->setup.line_stipple_enable || + if (!sp->rasterizer->line_stipple_enable || stipple_test(sp->line_stipple_counter, - sp->setup.line_stipple_pattern, - sp->setup.line_stipple_factor + 1)) { + sp->rasterizer->line_stipple_pattern, + sp->rasterizer->line_stipple_factor + 1)) { plot(setup, x0, y0); } @@ -899,8 +899,8 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) const int sizeAttr = setup->lookup[TGSI_ATTRIB_POINTSIZE]; const float halfSize = sizeAttr ? (0.5f * v0->data[sizeAttr][0]) - : (0.5f * setup->softpipe->setup.point_size); - const boolean round = setup->softpipe->setup.point_smooth; + : (0.5f * setup->softpipe->rasterizer->point_size); + const boolean round = setup->softpipe->rasterizer->point_smooth; const float x = v0->data[TGSI_ATTRIB_POS][0]; const float y = v0->data[TGSI_ATTRIB_POS][1]; unsigned slot, j; diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index 1f45776d47..fc4f8328cf 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -36,9 +36,9 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.occlusion; } - if (sp->setup.poly_smooth || - sp->setup.line_smooth || - sp->setup.point_smooth) { + if (sp->rasterizer->poly_smooth || + sp->rasterizer->line_smooth || + sp->rasterizer->point_smooth) { sp->quad.coverage->next = sp->quad.first; sp->quad.first = sp->quad.coverage; } @@ -65,7 +65,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.shade; } - if (sp->setup.poly_stipple_enable) { + if (sp->rasterizer->poly_stipple_enable) { sp->quad.polygon_stipple->next = sp->quad.first; sp->quad.first = sp->quad.polygon_stipple; } diff --git a/src/mesa/pipe/softpipe/sp_quad_coverage.c b/src/mesa/pipe/softpipe/sp_quad_coverage.c index 8dfec59350..89f50bcca2 100644 --- a/src/mesa/pipe/softpipe/sp_quad_coverage.c +++ b/src/mesa/pipe/softpipe/sp_quad_coverage.c @@ -47,9 +47,9 @@ coverage_quad(struct quad_stage *qs, struct quad_header *quad) { struct softpipe_context *softpipe = qs->softpipe; - if ((softpipe->setup.poly_smooth && quad->prim == PRIM_TRI) || - (softpipe->setup.line_smooth && quad->prim == PRIM_LINE) || - (softpipe->setup.point_smooth && quad->prim == PRIM_POINT)) { + if ((softpipe->rasterizer->poly_smooth && quad->prim == PRIM_TRI) || + (softpipe->rasterizer->line_smooth && quad->prim == PRIM_LINE) || + (softpipe->rasterizer->point_smooth && quad->prim == PRIM_POINT)) { unsigned j; for (j = 0; j < QUAD_SIZE; j++) { assert(quad->coverage[j] >= 0.0); diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index caec3b4519..62bd26c4df 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -50,7 +50,6 @@ void softpipe_bind_sampler_state(struct pipe_context *, void softpipe_delete_sampler_state(struct pipe_context *, const struct pipe_sampler_state *); - const struct pipe_depth_stencil_state * softpipe_create_depth_stencil_state(struct pipe_context *, const struct pipe_depth_stencil_state *); @@ -59,6 +58,14 @@ void softpipe_bind_depth_stencil_state(struct pipe_context *, void softpipe_delete_depth_stencil_state(struct pipe_context *, const struct pipe_depth_stencil_state *); +const struct pipe_rasterizer_state * +softpipe_create_rasterizer_state(struct pipe_context *, + const struct pipe_rasterizer_state *); +void softpipe_bind_rasterizer_state(struct pipe_context *, + const struct pipe_rasterizer_state *); +void softpipe_delete_rasterizer_state(struct pipe_context *, + const struct pipe_rasterizer_state *); + void softpipe_set_framebuffer_state( struct pipe_context *, const struct pipe_framebuffer_state * ); @@ -93,9 +100,6 @@ void softpipe_set_polygon_stipple( struct pipe_context *, void softpipe_set_scissor_state( struct pipe_context *, const struct pipe_scissor_state * ); -void softpipe_set_setup_state( struct pipe_context *, - const struct pipe_setup_state * ); - void softpipe_set_texture_state( struct pipe_context *, unsigned unit, struct pipe_mipmap_tree * ); diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 47743e185c..8c6bacf65c 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -45,7 +45,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { const uint inputsRead = softpipe->fs.inputs_read; const interp_mode colorInterp - = softpipe->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR; + = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; uint front0 = 0, back0 = 0, front1 = 0, back1 = 0; uint i; @@ -112,7 +112,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) * lighting. Edgeflag is dealt with specially by setting bits in * the vertex header. */ - if (softpipe->setup.light_twoside) { + if (softpipe->rasterizer->light_twoside) { if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT, colorInterp); @@ -160,7 +160,7 @@ compute_cliprect(struct softpipe_context *sp) surfHeight = sp->scissor.maxy; } - if (sp->setup.scissor) { + if (sp->rasterizer->scissor) { /* clip to scissor rect */ sp->cliprect.minx = MAX2(sp->scissor.minx, 0); sp->cliprect.miny = MAX2(sp->scissor.miny, 0); @@ -182,7 +182,7 @@ compute_cliprect(struct softpipe_context *sp) */ void softpipe_update_derived( struct softpipe_context *softpipe ) { - if (softpipe->dirty & (SP_NEW_SETUP | SP_NEW_FS)) + if (softpipe->dirty & (SP_NEW_RASTERIZER | SP_NEW_FS)) calculate_vertex_layout( softpipe ); if (softpipe->dirty & (SP_NEW_SCISSOR | @@ -194,7 +194,7 @@ void softpipe_update_derived( struct softpipe_context *softpipe ) SP_NEW_DEPTH_STENCIL | SP_NEW_ALPHA_TEST | SP_NEW_FRAMEBUFFER | - SP_NEW_SETUP | + SP_NEW_RASTERIZER | SP_NEW_FS)) sp_build_quad_pipeline(softpipe); diff --git a/src/mesa/pipe/softpipe/sp_state_setup.c b/src/mesa/pipe/softpipe/sp_state_setup.c index 4715a26f55..6788396355 100644 --- a/src/mesa/pipe/softpipe/sp_state_setup.c +++ b/src/mesa/pipe/softpipe/sp_state_setup.c @@ -31,17 +31,35 @@ #include "pipe/draw/draw_context.h" -void softpipe_set_setup_state( struct pipe_context *pipe, - const struct pipe_setup_state *setup ) + +const struct pipe_rasterizer_state * +softpipe_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) +{ + struct pipe_rasterizer_state *raster = + malloc(sizeof(struct pipe_rasterizer_state)); + memcpy(raster, setup, sizeof(struct pipe_rasterizer_state)); + + return raster; +} + +void softpipe_bind_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) { struct softpipe_context *softpipe = softpipe_context(pipe); /* pass-through to draw module */ draw_set_setup_state(softpipe->draw, setup); - memcpy( &softpipe->setup, setup, sizeof(*setup) ); + softpipe->rasterizer = setup; + + softpipe->dirty |= SP_NEW_RASTERIZER; +} - softpipe->dirty |= SP_NEW_SETUP; +void softpipe_delete_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *rasterizer) +{ + free((struct pipe_rasterizer_state*)rasterizer); } diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 99d0bcb90b..a4af3aeb20 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -53,7 +53,7 @@ static const struct st_tracked_state *atoms[] = &st_update_vs, &st_update_fs, - &st_update_setup, + &st_update_rasterizer, &st_update_polygon_stipple, &st_update_viewport, &st_update_scissor, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 0e362b1fbf..26f6514698 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -51,7 +51,7 @@ const struct st_tracked_state st_update_depth_stencil; const struct st_tracked_state st_update_tnl; const struct st_tracked_state st_update_fs; const struct st_tracked_state st_update_vs; -const struct st_tracked_state st_update_setup; +const struct st_tracked_state st_update_rasterizer; const struct st_tracked_state st_update_polygon_stipple; const struct st_tracked_state st_update_viewport; const struct st_tracked_state st_update_scissor; diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c index 09d921560d..cab8ad5cd6 100644 --- a/src/mesa/state_tracker/st_atom_setup.c +++ b/src/mesa/state_tracker/st_atom_setup.c @@ -32,6 +32,7 @@ #include "st_context.h" +#include "st_cache.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "st_atom.h" @@ -68,20 +69,21 @@ static GLboolean get_offset_flag( GLuint fill_mode, } -static void update_setup_state( struct st_context *st ) +static void update_raster_state( struct st_context *st ) { GLcontext *ctx = st->ctx; - struct pipe_setup_state setup; + struct pipe_rasterizer_state raster; + const struct pipe_rasterizer_state *cached; - memset(&setup, 0, sizeof(setup)); + memset(&raster, 0, sizeof(raster)); /* _NEW_POLYGON, _NEW_BUFFERS */ { if (ctx->Polygon.FrontFace == GL_CCW) - setup.front_winding = PIPE_WINDING_CCW; + raster.front_winding = PIPE_WINDING_CCW; else - setup.front_winding = PIPE_WINDING_CW; + raster.front_winding = PIPE_WINDING_CW; /* XXX * I think the intention here is that user-created framebuffer objects @@ -90,13 +92,13 @@ static void update_setup_state( struct st_context *st ) * But this is an implementation/driver-specific artifact - remove... */ if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) - setup.front_winding ^= PIPE_WINDING_BOTH; + raster.front_winding ^= PIPE_WINDING_BOTH; } /* _NEW_LIGHT */ if (ctx->Light.ShadeModel == GL_FLAT) - setup.flatshade = 1; + raster.flatshade = 1; /* _NEW_LIGHT | _NEW_PROGRAM * @@ -105,23 +107,23 @@ static void update_setup_state( struct st_context *st ) * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. */ if (ctx->VertexProgram._Enabled) { - setup.light_twoside = ctx->VertexProgram.TwoSideEnabled; + raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; } else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { - setup.light_twoside = 1; + raster.light_twoside = 1; } /* _NEW_POLYGON */ if (ctx->Polygon.CullFlag) { if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - setup.cull_mode = PIPE_WINDING_BOTH; + raster.cull_mode = PIPE_WINDING_BOTH; } else if (ctx->Polygon.CullFaceMode == GL_FRONT) { - setup.cull_mode = setup.front_winding; + raster.cull_mode = raster.front_winding; } else { - setup.cull_mode = setup.front_winding ^ PIPE_WINDING_BOTH; + raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; } } @@ -131,23 +133,23 @@ static void update_setup_state( struct st_context *st ) GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); - if (setup.front_winding == PIPE_WINDING_CW) { - setup.fill_cw = fill_front; - setup.fill_ccw = fill_back; + if (raster.front_winding == PIPE_WINDING_CW) { + raster.fill_cw = fill_front; + raster.fill_ccw = fill_back; } else { - setup.fill_cw = fill_back; - setup.fill_ccw = fill_front; + raster.fill_cw = fill_back; + raster.fill_ccw = fill_front; } /* Simplify when culling is active: */ - if (setup.cull_mode & PIPE_WINDING_CW) { - setup.fill_cw = setup.fill_ccw; + if (raster.cull_mode & PIPE_WINDING_CW) { + raster.fill_cw = raster.fill_ccw; } - if (setup.cull_mode & PIPE_WINDING_CCW) { - setup.fill_ccw = setup.fill_cw; + if (raster.cull_mode & PIPE_WINDING_CCW) { + raster.fill_ccw = raster.fill_cw; } } @@ -155,67 +157,68 @@ static void update_setup_state( struct st_context *st ) */ if (ctx->Polygon.OffsetUnits != 0.0 || ctx->Polygon.OffsetFactor != 0.0) { - setup.offset_cw = get_offset_flag( setup.fill_cw, &ctx->Polygon ); - setup.offset_ccw = get_offset_flag( setup.fill_ccw, &ctx->Polygon ); - setup.offset_units = ctx->Polygon.OffsetUnits; - setup.offset_scale = ctx->Polygon.OffsetFactor; + raster.offset_cw = get_offset_flag( raster.fill_cw, &ctx->Polygon ); + raster.offset_ccw = get_offset_flag( raster.fill_ccw, &ctx->Polygon ); + raster.offset_units = ctx->Polygon.OffsetUnits; + raster.offset_scale = ctx->Polygon.OffsetFactor; } if (ctx->Polygon.SmoothFlag) - setup.poly_smooth = 1; + raster.poly_smooth = 1; if (ctx->Polygon.StippleFlag) - setup.poly_stipple_enable = 1; + raster.poly_stipple_enable = 1; /* _NEW_BUFFERS, _NEW_POLYGON */ - if (setup.fill_cw != PIPE_POLYGON_MODE_FILL || - setup.fill_ccw != PIPE_POLYGON_MODE_FILL) + if (raster.fill_cw != PIPE_POLYGON_MODE_FILL || + raster.fill_ccw != PIPE_POLYGON_MODE_FILL) { GLfloat mrd = (ctx->DrawBuffer ? ctx->DrawBuffer->_MRD : 1.0); - setup.offset_units = ctx->Polygon.OffsetFactor * mrd; - setup.offset_scale = (ctx->Polygon.OffsetUnits * mrd * + raster.offset_units = ctx->Polygon.OffsetFactor * mrd; + raster.offset_scale = (ctx->Polygon.OffsetUnits * mrd * st->polygon_offset_scale); } /* _NEW_POINT */ - setup.point_size = ctx->Point.Size; - setup.point_smooth = ctx->Point.SmoothFlag; + raster.point_size = ctx->Point.Size; + raster.point_smooth = ctx->Point.SmoothFlag; /* _NEW_LINE */ - setup.line_width = ctx->Line.Width; - setup.line_smooth = ctx->Line.SmoothFlag; - setup.line_stipple_enable = ctx->Line.StippleFlag; - setup.line_stipple_pattern = ctx->Line.StipplePattern; + raster.line_width = ctx->Line.Width; + raster.line_smooth = ctx->Line.SmoothFlag; + raster.line_stipple_enable = ctx->Line.StippleFlag; + raster.line_stipple_pattern = ctx->Line.StipplePattern; /* GL stipple factor is in [1,256], remap to [0, 255] here */ - setup.line_stipple_factor = ctx->Line.StippleFactor - 1; + raster.line_stipple_factor = ctx->Line.StippleFactor - 1; /* _NEW_MULTISAMPLE */ if (ctx->Multisample.Enabled) - setup.multisample = 1; + raster.multisample = 1; /* _NEW_SCISSOR */ if (ctx->Scissor.Enabled) - setup.scissor = 1; + raster.scissor = 1; - if (memcmp(&setup, &st->state.setup, sizeof(setup)) != 0) { - st->state.setup = setup; - st->pipe->set_setup_state( st->pipe, &setup ); + cached = st_cached_rasterizer_state(st, &raster); + if (st->state.rasterizer != cached) { + st->state.rasterizer = cached; + st->pipe->bind_rasterizer_state( st->pipe, cached ); } } -const struct st_tracked_state st_update_setup = { - .name = "st_update_setup", +const struct st_tracked_state st_update_rasterizer = { + .name = "st_update_rasterizer", .dirty = { .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), .st = 0, }, - .update = update_setup_state + .update = update_raster_state }; diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index 64c03be99d..a687c15587 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -93,3 +93,21 @@ struct pipe_depth_stencil_state * st_cached_depth_stencil_state( } return (struct pipe_depth_stencil_state*)(cso_hash_iter_data(iter)); } + +struct pipe_rasterizer_state * st_cached_rasterizer_state( + struct st_context *st, + const struct pipe_rasterizer_state *raster) +{ + unsigned hash_key = cso_construct_key((void*)raster, + sizeof(struct pipe_rasterizer_state)); + struct cso_hash_iter iter = cso_find_state_template(st->cache, + hash_key, CSO_RASTERIZER, + (void*)raster); + if (cso_hash_iter_is_null(iter)) { + const struct pipe_rasterizer_state *created_state = + st->pipe->create_rasterizer_state(st->pipe, raster); + iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER, + (void*)created_state); + } + return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter)); +} diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index 78cb2e774e..a06af31123 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -47,6 +47,10 @@ struct pipe_sampler_state * st_cached_sampler_state( struct pipe_depth_stencil_state *st_cached_depth_stencil_state( struct st_context *st, - const struct pipe_depth_stencil_state *sampler); + const struct pipe_depth_stencil_state *depth_stencil); + +struct pipe_rasterizer_state *st_cached_rasterizer_state( + struct st_context *st, + const struct pipe_rasterizer_state *raster); #endif diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index e9aabd15b5..584bc1cc2a 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -329,16 +329,18 @@ clear_with_quad(GLcontext *ctx, /* setup state: nothing */ { - struct pipe_setup_state setup; - memset(&setup, 0, sizeof(setup)); + struct pipe_rasterizer_state raster; + const struct pipe_rasterizer_state *cached; + memset(&raster, 0, sizeof(raster)); #if 0 /* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD * that matches the scissor bounds. */ if (ctx->Scissor.Enabled) - setup.scissor = 1; + raster.scissor = 1; #endif - pipe->set_setup_state(pipe, &setup); + cached = st_cached_rasterizer_state(ctx->st, &raster); + pipe->bind_rasterizer_state(pipe, cached); } /* fragment shader state: color pass-through program */ @@ -394,7 +396,7 @@ clear_with_quad(GLcontext *ctx, pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil); pipe->set_fs_state(pipe, &st->state.fs); pipe->set_vs_state(pipe, &st->state.vs); - pipe->set_setup_state(pipe, &st->state.setup); + pipe->bind_rasterizer_state(pipe, st->state.rasterizer); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); /* OR: st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index a0012e3a8c..78ede8e225 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -316,11 +316,13 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* setup state: just scissor */ { - struct pipe_setup_state setup; + struct pipe_rasterizer_state setup; + struct pipe_rasterizer_state *cached; memset(&setup, 0, sizeof(setup)); if (ctx->Scissor.Enabled) setup.scissor = 1; - pipe->set_setup_state(pipe, &setup); + cached = st_cached_rasterizer_state(ctx->st, &setup); + pipe->bind_rasterizer_state(pipe, cached); } /* fragment shader state: TEX lookup program */ @@ -400,7 +402,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, draw_quad(ctx, x0, y0, z, x1, y1); /* restore GL state */ - pipe->set_setup_state(pipe, &ctx->st->state.setup); + pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer); pipe->set_fs_state(pipe, &ctx->st->state.fs); pipe->set_vs_state(pipe, &ctx->st->state.vs); pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 7c887d0b55..516d319a6e 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -77,6 +77,7 @@ struct st_context const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -88,7 +89,6 @@ struct st_context struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_setup_state setup; struct pipe_shader_state fs; struct pipe_shader_state vs; struct pipe_viewport_state viewport; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 69f4b7fa5b..1ea7799021 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -394,7 +394,7 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(draw); draw_set_viewport_state(draw, &st->state.viewport); draw_set_clip_state(draw, &st->state.clip); - draw_set_setup_state(draw, &st->state.setup); + draw_set_setup_state(draw, st->state.rasterizer); draw_set_vertex_shader(draw, &st->state.vs); /* XXX need to set vertex info too */ -- cgit v1.2.3 From 6cb87cf26f904b891faa42268f373864fa33541d Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 21 Sep 2007 07:00:20 -0400 Subject: Make the alpha test state a cso. --- src/mesa/pipe/cso_cache/cso_cache.c | 7 ++++ src/mesa/pipe/cso_cache/cso_cache.h | 13 +++++-- src/mesa/pipe/failover/fo_context.h | 4 +-- src/mesa/pipe/failover/fo_state.c | 45 +++++++++++++++++++++---- src/mesa/pipe/failover/fo_state_emit.c | 3 +- src/mesa/pipe/i915simple/i915_context.h | 2 +- src/mesa/pipe/i915simple/i915_state.c | 24 ++++++++++--- src/mesa/pipe/i915simple/i915_state_immediate.c | 6 ++-- src/mesa/pipe/p_context.h | 32 ++++++++++-------- src/mesa/pipe/softpipe/sp_context.c | 4 ++- src/mesa/pipe/softpipe/sp_context.h | 2 +- src/mesa/pipe/softpipe/sp_quad.c | 2 +- src/mesa/pipe/softpipe/sp_quad_alpha_test.c | 4 +-- src/mesa/pipe/softpipe/sp_state.h | 12 +++++-- src/mesa/pipe/softpipe/sp_state_blend.c | 20 +++++++++-- src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom.h | 1 + src/mesa/state_tracker/st_atom_alphatest.c | 15 ++++----- src/mesa/state_tracker/st_cache.c | 20 +++++++++++ src/mesa/state_tracker/st_cache.h | 4 +++ src/mesa/state_tracker/st_cb_clear.c | 6 ++-- src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_context.h | 10 +++--- 23 files changed, 176 insertions(+), 63 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/cso_cache/cso_cache.c b/src/mesa/pipe/cso_cache/cso_cache.c index 71f0d08726..0bba5914dc 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.c +++ b/src/mesa/pipe/cso_cache/cso_cache.c @@ -90,6 +90,9 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ case CSO_VERTEX_SHADER: hash = sc->vs_hash; break; + case CSO_ALPHA_TEST: + hash = sc->alpha_hash; + break; } return hash; @@ -110,6 +113,8 @@ static int _cso_size_for_type(enum cso_cache_type type) return sizeof(struct pipe_shader_state); case CSO_VERTEX_SHADER: return sizeof(struct pipe_shader_state); + case CSO_ALPHA_TEST: + return sizeof(struct pipe_alpha_test_state); } return 0; } @@ -164,6 +169,7 @@ struct cso_cache *cso_cache_create(void) sc->rasterizer_hash = cso_hash_create(); sc->fs_hash = cso_hash_create(); sc->vs_hash = cso_hash_create(); + sc->alpha_hash = cso_hash_create(); return sc; } @@ -177,5 +183,6 @@ void cso_cache_delete(struct cso_cache *sc) cso_hash_delete(sc->rasterizer_hash); cso_hash_delete(sc->fs_hash); cso_hash_delete(sc->vs_hash); + cso_hash_delete(sc->alpha_hash); free(sc); } diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h index 2acb58c66b..cd36dd51e9 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.h +++ b/src/mesa/pipe/cso_cache/cso_cache.h @@ -40,12 +40,13 @@ struct cso_hash; struct cso_cache { + struct cso_hash *alpha_hash; struct cso_hash *blend_hash; - struct cso_hash *sampler_hash; struct cso_hash *depth_stencil_hash; - struct cso_hash *rasterizer_hash; struct cso_hash *fs_hash; struct cso_hash *vs_hash; + struct cso_hash *rasterizer_hash; + struct cso_hash *sampler_hash; }; struct cso_blend { @@ -78,13 +79,19 @@ struct cso_sampler { void *data; }; +struct cso_alpha_test { + struct pipe_alpha_test_state state; + void *data; +}; + enum cso_cache_type { CSO_BLEND, CSO_SAMPLER, CSO_DEPTH_STENCIL, CSO_RASTERIZER, CSO_FRAGMENT_SHADER, - CSO_VERTEX_SHADER + CSO_VERTEX_SHADER, + CSO_ALPHA_TEST }; unsigned cso_construct_key(void *item, int item_size); diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index 8a2fbe2be9..7a597013ab 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -64,12 +64,13 @@ struct fo_state { void *sw_state; void *hw_state; }; -struct failover_context { +struct failover_context { struct pipe_context pipe; /**< base class */ /* The most recent drawing state as set by the driver: */ + const struct fo_state *alpha_test; const struct fo_state *blend; const struct fo_state *sampler[PIPE_MAX_SAMPLERS]; const struct fo_state *depth_stencil; @@ -77,7 +78,6 @@ struct failover_context { const struct fo_state *fragment_shader; const struct fo_state *vertex_shader; - struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index ce3f0ca635..f63137f591 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -45,15 +45,44 @@ * lower overheads. */ +static void * +failover_create_alpha_test_state(struct pipe_context *pipe, + const struct pipe_alpha_test_state *templ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + + state->sw_state = failover->sw->create_alpha_test_state(pipe, templ); + state->hw_state = failover->hw->create_alpha_test_state(pipe, templ); + + return state; +} + static void -failover_set_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha) +failover_bind_alpha_test_state(struct pipe_context *pipe, + void *alpha) { struct failover_context *failover = failover_context(pipe); + struct fo_state *state = (struct fo_state *)alpha; - failover->alpha_test = *alpha; + failover->alpha_test = state; failover->dirty |= FO_NEW_ALPHA_TEST; - failover->hw->set_alpha_test_state( failover->hw, alpha ); + failover->hw->bind_alpha_test_state(failover->hw, + state->hw_state); +} + +static void +failover_delete_alpha_test_state(struct pipe_context *pipe, + void *alpha) +{ + struct fo_state *state = (struct fo_state*)alpha; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_alpha_test_state(pipe, state->sw_state); + failover->hw->delete_alpha_test_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); } @@ -95,7 +124,7 @@ failover_delete_blend_state( struct pipe_context *pipe, free(state); } -static void +static void failover_set_blend_color( struct pipe_context *pipe, const struct pipe_blend_color *blend_color ) { @@ -414,8 +443,11 @@ failover_set_vertex_element(struct pipe_context *pipe, void failover_init_state_functions( struct failover_context *failover ) { + failover->pipe.create_alpha_test_state = failover_create_alpha_test_state; + failover->pipe.bind_alpha_test_state = failover_bind_alpha_test_state; + failover->pipe.delete_alpha_test_state = failover_delete_alpha_test_state; failover->pipe.create_blend_state = failover_create_blend_state; - failover->pipe.bind_blend_state = failover_bind_blend_state; + failover->pipe.bind_blend_state = failover_bind_blend_state; failover->pipe.delete_blend_state = failover_delete_blend_state; failover->pipe.create_sampler_state = failover_create_sampler_state; failover->pipe.bind_sampler_state = failover_bind_sampler_state; @@ -433,7 +465,6 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.bind_vs_state = failover_bind_vs_state; failover->pipe.delete_vs_state = failover_delete_vs_state; - failover->pipe.set_alpha_test_state = failover_set_alpha_test_state; failover->pipe.set_blend_color = failover_set_blend_color; failover->pipe.set_clip_state = failover_set_clip_state; failover->pipe.set_clear_color_state = failover_set_clear_color_state; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index c0ea681024..a3aff8abd2 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -56,7 +56,8 @@ failover_state_emit( struct failover_context *failover ) unsigned i; if (failover->dirty & FO_NEW_ALPHA_TEST) - failover->sw->set_alpha_test_state( failover->sw, &failover->alpha_test ); + failover->sw->bind_alpha_test_state( failover->sw, + failover->alpha_test->sw_state ); if (failover->dirty & FO_NEW_BLEND) failover->sw->bind_blend_state( failover->sw, diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index f1e10f3433..9958a8592d 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -154,13 +154,13 @@ struct i915_context /* The most recent drawing state as set by the driver: */ + const struct pipe_alpha_test_state *alpha_test; const struct i915_blend_state *blend; const struct i915_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct i915_depth_stencil_state *depth_stencil; const struct i915_rasterizer_state *rasterizer; const struct pipe_shader_state *fs; - struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 525f8ce13a..8bfd2da3b5 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -394,16 +394,29 @@ static void i915_delete_depth_stencil_state(struct pipe_context *pipe, free(depth_stencil); } -static void i915_set_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha) + +static void * +i915_create_alpha_test_state(struct pipe_context *pipe, + const struct pipe_alpha_test_state *alpha) +{ + return 0; +} + +static void i915_bind_alpha_test_state(struct pipe_context *pipe, + void *alpha) { struct i915_context *i915 = i915_context(pipe); - i915->alpha_test = *alpha; + i915->alpha_test = (const struct pipe_alpha_test_state*)alpha; i915->dirty |= I915_NEW_ALPHA_TEST; } +static void i915_delete_alpha_test_state(struct pipe_context *pipe, + void *alpha) +{ +} + static void i915_set_scissor_state( struct pipe_context *pipe, const struct pipe_scissor_state *scissor ) { @@ -664,6 +677,10 @@ static void i915_set_vertex_element( struct pipe_context *pipe, void i915_init_state_functions( struct i915_context *i915 ) { + i915->pipe.create_alpha_test_state = i915_create_alpha_test_state; + i915->pipe.bind_alpha_test_state = i915_bind_alpha_test_state; + i915->pipe.delete_alpha_test_state = i915_delete_alpha_test_state; + i915->pipe.create_blend_state = i915_create_blend_state; i915->pipe.bind_blend_state = i915_bind_blend_state; i915->pipe.delete_blend_state = i915_delete_blend_state; @@ -686,7 +703,6 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.bind_vs_state = i915_bind_vs_state; i915->pipe.delete_vs_state = i915_delete_shader_state; - i915->pipe.set_alpha_test_state = i915_set_alpha_test_state; i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; i915->pipe.set_clear_color_state = i915_set_clear_color_state; diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c index 874c3819f2..014fddfdda 100644 --- a/src/mesa/pipe/i915simple/i915_state_immediate.c +++ b/src/mesa/pipe/i915simple/i915_state_immediate.c @@ -121,9 +121,9 @@ static void upload_S6( struct i915_context *i915 ) /* I915_NEW_ALPHA_TEST */ - if (i915->alpha_test.enabled) { - int test = i915_translate_compare_func(i915->alpha_test.func); - ubyte refByte = float_to_ubyte(i915->alpha_test.ref); + if (i915->alpha_test->enabled) { + int test = i915_translate_compare_func(i915->alpha_test->func); + ubyte refByte = float_to_ubyte(i915->alpha_test->ref); LIS6 |= (S6_ALPHA_TEST_ENABLE | diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 07ee019880..8ba1031efe 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -86,26 +86,30 @@ struct pipe_context { /* * State functions */ + void * (*create_alpha_test_state)(struct pipe_context *, + const struct pipe_alpha_test_state *); + void (*bind_alpha_test_state)(struct pipe_context *, void *); + void (*delete_alpha_test_state)(struct pipe_context *, void *); + void * (*create_blend_state)(struct pipe_context *, const struct pipe_blend_state *); - void (*bind_blend_state)(struct pipe_context *, void *); - void (*delete_blend_state)(struct pipe_context *, void *); + void (*bind_blend_state)(struct pipe_context *, void *); + void (*delete_blend_state)(struct pipe_context *, void *); void * (*create_sampler_state)(struct pipe_context *, const struct pipe_sampler_state *); - void (*bind_sampler_state)(struct pipe_context *, unsigned unit, - void *); - void (*delete_sampler_state)(struct pipe_context *, void *); + void (*bind_sampler_state)(struct pipe_context *, unsigned unit, void *); + void (*delete_sampler_state)(struct pipe_context *, void *); - void *(*create_rasterizer_state)(struct pipe_context *, - const struct pipe_rasterizer_state *); - void (*bind_rasterizer_state)(struct pipe_context *, void *); - void (*delete_rasterizer_state)(struct pipe_context *, void *); + void * (*create_rasterizer_state)(struct pipe_context *, + const struct pipe_rasterizer_state *); + void (*bind_rasterizer_state)(struct pipe_context *, void *); + void (*delete_rasterizer_state)(struct pipe_context *, void *); void * (*create_depth_stencil_state)(struct pipe_context *, const struct pipe_depth_stencil_state *); - void (*bind_depth_stencil_state)(struct pipe_context *, void *); - void (*delete_depth_stencil_state)(struct pipe_context *, void *); + void (*bind_depth_stencil_state)(struct pipe_context *, void *); + void (*delete_depth_stencil_state)(struct pipe_context *, void *); void * (*create_fs_state)(struct pipe_context *, const struct pipe_shader_state *); @@ -117,9 +121,9 @@ struct pipe_context { void (*bind_vs_state)(struct pipe_context *, void *); void (*delete_vs_state)(struct pipe_context *, void *); - void (*set_alpha_test_state)( struct pipe_context *, - const struct pipe_alpha_test_state * ); - + /* The following look more properties than states. + * maybe combine a few of them into states or pass them + * in the bind calls to the state */ void (*set_blend_color)( struct pipe_context *, const struct pipe_blend_color * ); diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index cac44606f7..a6ab45314c 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -260,6 +260,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.get_param = softpipe_get_param; /* state setters */ + softpipe->pipe.create_alpha_test_state = softpipe_create_alpha_test_state; + softpipe->pipe.bind_alpha_test_state = softpipe_bind_alpha_test_state; + softpipe->pipe.delete_alpha_test_state = softpipe_delete_alpha_test_state; softpipe->pipe.create_blend_state = softpipe_create_blend_state; softpipe->pipe.bind_blend_state = softpipe_bind_blend_state; softpipe->pipe.delete_blend_state = softpipe_delete_blend_state; @@ -279,7 +282,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.bind_vs_state = softpipe_bind_vs_state; softpipe->pipe.delete_vs_state = softpipe_delete_shader_state; - softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_clip_state = softpipe_set_clip_state; softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 95215eb640..7b1518cfac 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -70,6 +70,7 @@ struct softpipe_context { /* The most recent drawing state as set by the driver: */ + const struct pipe_alpha_test_state *alpha_test; const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; @@ -77,7 +78,6 @@ struct softpipe_context { const struct pipe_shader_state *fs; const struct pipe_shader_state *vs; - struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index fc4f8328cf..74a21dc54b 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -54,7 +54,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.depth_test; } - if (sp->alpha_test.enabled) { + if (sp->alpha_test->enabled) { sp->quad.alpha_test->next = sp->quad.first; sp->quad.first = sp->quad.alpha_test; } diff --git a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c index 64c1624bd0..4f28414b0e 100644 --- a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c +++ b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c @@ -14,10 +14,10 @@ static void alpha_test_quad(struct quad_stage *qs, struct quad_header *quad) { struct softpipe_context *softpipe = qs->softpipe; - const float ref = softpipe->alpha_test.ref; + const float ref = softpipe->alpha_test->ref; unsigned passMask = 0x0, j; - switch (softpipe->alpha_test.func) { + switch (softpipe->alpha_test->func) { case PIPE_FUNC_NEVER: quad->mask = 0x0; break; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 62323c41c3..f0e1461d25 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -33,6 +33,15 @@ #include "pipe/p_state.h" + +void * +softpipe_create_alpha_test_state(struct pipe_context *, + const struct pipe_alpha_test_state *); +void +softpipe_bind_alpha_test_state(struct pipe_context *, void *); +void +softpipe_delete_alpha_test_state(struct pipe_context *, void *); + void * softpipe_create_blend_state(struct pipe_context *, const struct pipe_blend_state *); @@ -62,9 +71,6 @@ void softpipe_delete_rasterizer_state(struct pipe_context *, void *); 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_color( struct pipe_context *pipe, const struct pipe_blend_color *blend_color ); diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c index cf47607955..cb0921f687 100644 --- a/src/mesa/pipe/softpipe/sp_state_blend.c +++ b/src/mesa/pipe/softpipe/sp_state_blend.c @@ -71,17 +71,31 @@ void softpipe_set_blend_color( struct pipe_context *pipe, * into one file. */ +void * +softpipe_create_alpha_test_state(struct pipe_context *pipe, + const struct pipe_alpha_test_state *alpha) +{ + return 0; +} + void -softpipe_set_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha) +softpipe_bind_alpha_test_state(struct pipe_context *pipe, + void *alpha) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->alpha_test = *alpha; + softpipe->alpha_test = (const struct pipe_alpha_test_state *)alpha; softpipe->dirty |= SP_NEW_ALPHA_TEST; } +void +softpipe_delete_alpha_test_state(struct pipe_context *pipe, + void *alpha) +{ + /* do nothing */ +} + void * softpipe_create_depth_stencil_state(struct pipe_context *pipe, const struct pipe_depth_stencil_state *depth_stencil) diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index a4af3aeb20..fc339b91ed 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -62,6 +62,7 @@ static const struct st_tracked_state *atoms[] = &st_update_texture, &st_update_vs_constants, &st_update_fs_constants, + &st_update_alpha_test }; diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 26f6514698..6710c1a269 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -60,6 +60,7 @@ const struct st_tracked_state st_update_sampler; const struct st_tracked_state st_update_texture; const struct st_tracked_state st_update_fs_constants; const struct st_tracked_state st_update_vs_constants; +const struct st_tracked_state st_update_alpha_test; #endif diff --git a/src/mesa/state_tracker/st_atom_alphatest.c b/src/mesa/state_tracker/st_atom_alphatest.c index 4378154053..873520ab02 100644 --- a/src/mesa/state_tracker/st_atom_alphatest.c +++ b/src/mesa/state_tracker/st_atom_alphatest.c @@ -33,6 +33,7 @@ #include "st_context.h" +#include "st_cache.h" #include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -63,6 +64,7 @@ static void update_alpha_test( struct st_context *st ) { struct pipe_alpha_test_state alpha; + const struct cso_alpha_test *cso; memset(&alpha, 0, sizeof(alpha)); @@ -71,11 +73,11 @@ update_alpha_test( struct st_context *st ) alpha.func = gl_alpha_func_to_sp(st->ctx->Color.AlphaFunc); alpha.ref = st->ctx->Color.AlphaRef; } - - if (memcmp(&alpha, &st->state.alpha_test, sizeof(alpha)) != 0) { + cso = st_cached_alpha_test_state(st, &alpha); + if (st->state.alpha_test != cso) { /* state has changed */ - st->state.alpha_test = alpha; /* struct copy */ - st->pipe->set_alpha_test_state(st->pipe, &alpha); /* set new state */ + st->state.alpha_test = cso; + st->pipe->bind_alpha_test_state(st->pipe, cso->data); /* bind new state */ } } @@ -88,8 +90,3 @@ const struct st_tracked_state st_update_alpha_test = { }, .update = update_alpha_test }; - - - - - diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index 01d1934232..1686721990 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -159,3 +159,23 @@ st_cached_vs_state(struct st_context *st, } return (struct cso_vertex_shader*)(cso_hash_iter_data(iter)); } + +const struct cso_alpha_test * +st_cached_alpha_test_state(struct st_context *st, + const struct pipe_alpha_test_state *templ) +{ + unsigned hash_key = cso_construct_key((void*)templ, + sizeof(struct pipe_alpha_test_state)); + struct cso_hash_iter iter = cso_find_state_template(st->cache, + hash_key, CSO_ALPHA_TEST, + (void*)templ); + if (cso_hash_iter_is_null(iter)) { + struct cso_alpha_test *cso = malloc(sizeof(struct cso_alpha_test)); + memcpy(&cso->state, templ, sizeof(struct pipe_alpha_test_state)); + cso->data = st->pipe->create_alpha_test_state(st->pipe, &cso->state); + if (!cso->data) + cso->data = &cso->state; + iter = cso_insert_state(st->cache, hash_key, CSO_ALPHA_TEST, cso); + } + return ((struct cso_alpha_test *)cso_hash_iter_data(iter)); +} diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index 483af6fdb4..422f668c56 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -39,6 +39,10 @@ struct pipe_blend_state; struct pipe_sampler_state; struct st_context; +const struct cso_alpha_test * +st_cached_alpha_test_state(struct st_context *st, + const struct pipe_alpha_test_state *alpha); + const struct cso_blend * st_cached_blend_state(struct st_context *st, const struct pipe_blend_state *blend); diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 5e63205088..c53446d588 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -275,8 +275,10 @@ clear_with_quad(GLcontext *ctx, /* alpha state: disabled */ { struct pipe_alpha_test_state alpha_test; + const struct cso_alpha_test *cso; memset(&alpha_test, 0, sizeof(alpha_test)); - pipe->set_alpha_test_state(pipe, &alpha_test); + cso = st_cached_alpha_test_state(st, &alpha_test); + pipe->bind_alpha_test_state(pipe, cso->data); } /* blend state: RGBA masking */ @@ -379,7 +381,7 @@ clear_with_quad(GLcontext *ctx, draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); /* Restore pipe state */ - pipe->set_alpha_test_state(pipe, &st->state.alpha_test); + pipe->bind_alpha_test_state(pipe, st->state.alpha_test->data); pipe->bind_blend_state(pipe, st->state.blend->data); pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil->data); pipe->bind_fs_state(pipe, st->state.fs->data); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index d814e34157..65c5465546 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -468,7 +468,7 @@ compatible_formats(GLenum format, GLenum type, GLuint pipeFormat) static GLboolean any_fragment_ops(const struct st_context *st) { - if (st->state.alpha_test.enabled || + if (st->state.alpha_test->state.enabled || st->state.blend->state.blend_enable || st->state.blend->state.logicop_enable || st->state.depth_stencil->state.depth.enabled) diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 55a857f46d..3713328eb1 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -75,14 +75,14 @@ struct st_context * though, we just shove random objects across the interface. */ struct { - const struct cso_blend *blend; - const struct cso_sampler *sampler[PIPE_MAX_SAMPLERS]; - const struct cso_depth_stencil *depth_stencil; - const struct cso_rasterizer *rasterizer; + const struct cso_alpha_test *alpha_test; + const struct cso_blend *blend; + const struct cso_sampler *sampler[PIPE_MAX_SAMPLERS]; + const struct cso_depth_stencil *depth_stencil; + const struct cso_rasterizer *rasterizer; const struct cso_fragment_shader *fs; const struct cso_vertex_shader *vs; - struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; -- cgit v1.2.3 From 40c543eb71368c646259afb87d5c76551f6b45b7 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 25 Sep 2007 14:29:11 -0600 Subject: Translate mesa vertex/fragment programs to TGSI programs at same time to do proper linking. Previously, programs were translated independently during validation. The problem is the translation to TGSI format, which packs shader input/outputs into continuous slots, depends on which vertex program is being paired with which fragment shader. Now, we look at the outputs of the vertex program in conjunction with the inputs of the fragment shader to be sure the attributes match up correctly. The new 'linked_program_pair' class keeps track of the associations between vertex and fragment shaders. It's also the place where the TGSI tokens are kept since they're no longer per-program state but per-linkage. Still a few loose ends, like implementing some kind of hash/lookup table for linked_program_pairs. --- src/mesa/pipe/draw/draw_feedback.c | 7 +- src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c | 4 + src/mesa/sources | 4 +- src/mesa/state_tracker/st_atom.c | 3 +- src/mesa/state_tracker/st_atom.h | 3 +- src/mesa/state_tracker/st_atom_fs.c | 96 +++++++++++------- src/mesa/state_tracker/st_atom_vs.c | 156 +++++++++++++++++++----------- src/mesa/state_tracker/st_cb_clear.c | 6 +- src/mesa/state_tracker/st_cb_drawpixels.c | 6 +- src/mesa/state_tracker/st_cb_feedback.c | 4 +- src/mesa/state_tracker/st_cb_program.c | 88 ++++++++++------- src/mesa/state_tracker/st_cb_rasterpos.c | 61 ++++++------ src/mesa/state_tracker/st_context.h | 6 +- src/mesa/state_tracker/st_program.h | 27 ++++-- 14 files changed, 287 insertions(+), 184 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/draw/draw_feedback.c b/src/mesa/pipe/draw/draw_feedback.c index 3b8400233e..ee54db0ad5 100644 --- a/src/mesa/pipe/draw/draw_feedback.c +++ b/src/mesa/pipe/draw/draw_feedback.c @@ -78,11 +78,9 @@ feedback_vertex(struct draw_stage *stage, const struct vertex_header *vertex) * we can either address output buffer 0 (for interleaving) or * output buffer i (for non-interleaved). */ -#if 0 for (i = 0; i < feedback->num_attribs; i++) { - const uint attr = feedback->attrib[i]; - const uint slot = stage->draw->vertex_info.attrib_to_slot[attr]; - const float *src = attr ? vertex->data[slot] : vertex->clip; + const uint slot = feedback->attrib[i]; + const float *src = slot ? vertex->data[slot] : vertex->clip; const uint size = feedback->size[i]; float *dest = fs->dest[i * select]; @@ -104,7 +102,6 @@ feedback_vertex(struct draw_stage *stage, const struct vertex_header *vertex) } fs->dest[i * select] += size; } -#endif fs->num_vert_emitted++; } diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index d0d97ab0f8..fa27fd3cd0 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -476,6 +476,8 @@ make_input_decl( { struct tgsi_full_declaration decl; + assert(semantic_name < TGSI_SEMANTIC_COUNT); + decl = tgsi_default_full_declaration(); decl.Declaration.File = TGSI_FILE_INPUT; decl.Declaration.Declare = TGSI_DECLARE_RANGE; @@ -500,6 +502,8 @@ make_output_decl( { struct tgsi_full_declaration decl; + assert(semantic_name < TGSI_SEMANTIC_COUNT); + decl = tgsi_default_full_declaration(); decl.Declaration.File = TGSI_FILE_OUTPUT; decl.Declaration.Declare = TGSI_DECLARE_RANGE; diff --git a/src/mesa/sources b/src/mesa/sources index 0d4fdc15f4..985bd2dce6 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -200,14 +200,13 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_depth.c \ state_tracker/st_atom_fixedfunction.c \ state_tracker/st_atom_framebuffer.c \ - state_tracker/st_atom_fs.c \ state_tracker/st_atom_sampler.c \ state_tracker/st_atom_scissor.c \ + state_tracker/st_atom_shader.c \ state_tracker/st_atom_rasterizer.c \ state_tracker/st_atom_stipple.c \ state_tracker/st_atom_texture.c \ state_tracker/st_atom_viewport.c \ - state_tracker/st_atom_vs.c \ state_tracker/st_cb_bufferobjects.c \ state_tracker/st_cb_clear.c \ state_tracker/st_cb_flush.c \ @@ -224,6 +223,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_context.c \ state_tracker/st_draw.c \ state_tracker/st_format.c \ + state_tracker/st_program.c \ state_tracker/st_mipmap_tree.c SHADER_SOURCES = \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index fc339b91ed..326042cb34 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -50,8 +50,7 @@ static const struct st_tracked_state *atoms[] = &st_update_clip, &st_update_tnl, - &st_update_vs, - &st_update_fs, + &st_update_shader, &st_update_rasterizer, &st_update_polygon_stipple, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 6710c1a269..94cb7bee7a 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -49,8 +49,7 @@ const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth_stencil; const struct st_tracked_state st_update_tnl; -const struct st_tracked_state st_update_fs; -const struct st_tracked_state st_update_vs; +const struct st_tracked_state st_update_shader; const struct st_tracked_state st_update_rasterizer; const struct st_tracked_state st_update_polygon_stipple; const struct st_tracked_state st_update_viewport; diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index dd4cdf0855..28019858f7 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -24,11 +24,12 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - /* - * Authors: - * Keith Whitwell - * Brian Paul - */ + +/* + * Authors: + * Keith Whitwell + * Brian Paul + */ #include "shader/prog_parameter.h" @@ -50,14 +51,20 @@ /** * Translate a Mesa fragment shader into a TGSI shader. + * \param inputMapping to map fragment program input registers to TGSI + * input slots + * \param tokensOut destination for TGSI tokens * \return pointer to cached pipe_shader object. */ const struct cso_fragment_shader * -st_translate_fragment_shader(struct st_context *st, - struct st_fragment_program *stfp) +st_translate_fragment_shader(const struct st_context *st, + struct st_fragment_program *stfp, + const GLuint inputMapping[], + struct tgsi_token *tokensOut, + GLuint maxTokens) { GLuint outputMapping[FRAG_RESULT_MAX]; - GLuint inputMapping[PIPE_MAX_SHADER_INPUTS]; + GLuint defaultInputMapping[FRAG_ATTRIB_MAX]; struct pipe_shader_state fs; const struct cso_fragment_shader *cso; GLuint interpMode[16]; /* XXX size? */ @@ -67,6 +74,7 @@ st_translate_fragment_shader(struct st_context *st, /* Check if all fragment programs need the fragment position (in order * to do perspective-corrected interpolation). */ + /* XXX temporary! */ if (st->pipe->get_param(st->pipe, PIPE_PARAM_FS_NEEDS_POS)) inputsRead |= FRAG_BIT_WPOS; @@ -77,28 +85,32 @@ st_translate_fragment_shader(struct st_context *st, */ for (attr = 0; attr < FRAG_ATTRIB_MAX; attr++) { if (inputsRead & (1 << attr)) { - inputMapping[attr] = fs.num_inputs; + const GLuint slot = fs.num_inputs; + + fs.num_inputs++; + + defaultInputMapping[attr] = slot; switch (attr) { case FRAG_ATTRIB_WPOS: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_POSITION; - fs.input_semantic_index[fs.num_inputs] = 0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_CONSTANT; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + fs.input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_CONSTANT; break; case FRAG_ATTRIB_COL0: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_COLOR; - fs.input_semantic_index[fs.num_inputs] = 0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + fs.input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_LINEAR; break; case FRAG_ATTRIB_COL1: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_COLOR; - fs.input_semantic_index[fs.num_inputs] = 1; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + fs.input_semantic_index[slot] = 1; + interpMode[slot] = TGSI_INTERPOLATE_LINEAR; break; case FRAG_ATTRIB_FOGC: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_FOG; - fs.input_semantic_index[fs.num_inputs] = 0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + fs.input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_TEX0: case FRAG_ATTRIB_TEX1: @@ -108,19 +120,17 @@ st_translate_fragment_shader(struct st_context *st, case FRAG_ATTRIB_TEX5: case FRAG_ATTRIB_TEX6: case FRAG_ATTRIB_TEX7: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_GENERIC; - fs.input_semantic_index[fs.num_inputs] = attr - FRAG_ATTRIB_TEX0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + fs.input_semantic_index[slot] = attr - FRAG_ATTRIB_TEX0; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_VAR0: /* fall-through */ default: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_GENERIC; - fs.input_semantic_index[fs.num_inputs] = attr - FRAG_ATTRIB_VAR0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + fs.input_semantic_index[slot] = attr - FRAG_ATTRIB_VAR0; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; } - - fs.num_inputs++; } } @@ -145,35 +155,40 @@ st_translate_fragment_shader(struct st_context *st, } } + if (!inputMapping) + inputMapping = defaultInputMapping; + /* XXX: fix static allocation of tokens: */ tgsi_mesa_compile_fp_program( &stfp->Base, + /* inputs */ fs.num_inputs, inputMapping, fs.input_semantic_name, fs.input_semantic_index, interpMode, + /* outputs */ outputMapping, - stfp->tokens, ST_FP_MAX_TOKENS ); + /* tokenized result */ + tokensOut, maxTokens); + - fs.tokens = &stfp->tokens[0]; + fs.tokens = tokensOut; cso = st_cached_fs_state(st, &fs); stfp->fs = cso; if (TGSI_DEBUG) - tgsi_dump( stfp->tokens, 0/*TGSI_DUMP_VERBOSE*/ ); + tgsi_dump( tokensOut, 0/*TGSI_DUMP_VERBOSE*/ ); #if defined(USE_X86_ASM) || defined(SLANG_X86) if (stfp->sse2_program.csr == stfp->sse2_program.store) - tgsi_emit_sse2_fs( stfp->tokens, &stfp->sse2_program ); + tgsi_emit_sse2_fs( tokensOut, &stfp->sse2_program ); if (!cso->state.executable) ((struct cso_fragment_shader*)cso)->state.executable = (void *) x86_get_func( &stfp->sse2_program ); #endif - stfp->dirty = 0; - return cso; } @@ -200,8 +215,9 @@ static void update_fs( struct st_context *st ) } /* if new binding, or shader has changed */ - if (st->fp != stfp || stfp->dirty) { + if (st->fp != stfp /**|| stfp->dirty**/) { +#if 0 if (stfp->dirty) (void) st_translate_fragment_shader( st, stfp ); @@ -210,10 +226,17 @@ static void update_fs( struct st_context *st ) st->state.fs = stfp->fs; st->pipe->bind_fs_state(st->pipe, st->state.fs->data); +#else + + /* NEW */ + st->dirty.st |= ST_NEW_LINKAGE; + +#endif } } +#if 0 const struct st_tracked_state st_update_fs = { .name = "st_update_fs", .dirty = { @@ -222,3 +245,4 @@ const struct st_tracked_state st_update_fs = { }, .update = update_fs }; +#endif diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index a6c0d159d4..0f07906a96 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -51,15 +51,22 @@ /** * Translate a Mesa vertex shader into a TGSI shader. + * \param outputMapping to map vertex program output registers to TGSI + * output slots + * \param tokensOut destination for TGSI tokens * \return pointer to cached pipe_shader object. */ const struct cso_vertex_shader * -st_translate_vertex_shader(struct st_context *st, - struct st_vertex_program *stvp) +st_translate_vertex_shader(const struct st_context *st, + struct st_vertex_program *stvp, + const GLuint outputMapping[], + struct tgsi_token *tokensOut, + GLuint maxTokens) { + GLuint defaultOutputMapping[VERT_RESULT_MAX]; struct pipe_shader_state vs; const struct cso_vertex_shader *cso; - GLuint attr; + GLuint attr, i; memset(&vs, 0, sizeof(vs)); @@ -69,31 +76,36 @@ st_translate_vertex_shader(struct st_context *st, */ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { if (stvp->Base.Base.InputsRead & (1 << attr)) { - stvp->input_to_index[attr] = vs.num_inputs; - stvp->index_to_input[vs.num_inputs] = attr; + const GLuint slot = vs.num_inputs; + + vs.num_inputs++; + + stvp->input_to_index[attr] = slot; + stvp->index_to_input[slot] = attr; + switch (attr) { case VERT_ATTRIB_POS: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_POSITION; - vs.input_semantic_index[vs.num_inputs] = 0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + vs.input_semantic_index[slot] = 0; break; case VERT_ATTRIB_WEIGHT: /* fall-through */ case VERT_ATTRIB_NORMAL: /* just label as a generic */ - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[vs.num_inputs] = 0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.input_semantic_index[slot] = 0; break; case VERT_ATTRIB_COLOR0: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; - vs.input_semantic_index[vs.num_inputs] = 0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs.input_semantic_index[slot] = 0; break; case VERT_ATTRIB_COLOR1: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; - vs.input_semantic_index[vs.num_inputs] = 1; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs.input_semantic_index[slot] = 1; break; case VERT_ATTRIB_FOG: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_FOG; - vs.input_semantic_index[vs.num_inputs] = 0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + vs.input_semantic_index[slot] = 0; break; case VERT_ATTRIB_TEX0: case VERT_ATTRIB_TEX1: @@ -103,8 +115,8 @@ st_translate_vertex_shader(struct st_context *st, case VERT_ATTRIB_TEX5: case VERT_ATTRIB_TEX6: case VERT_ATTRIB_TEX7: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[vs.num_inputs] = attr - VERT_ATTRIB_TEX0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.input_semantic_index[slot] = attr - VERT_ATTRIB_TEX0; break; case VERT_ATTRIB_GENERIC0: case VERT_ATTRIB_GENERIC1: @@ -115,53 +127,71 @@ st_translate_vertex_shader(struct st_context *st, case VERT_ATTRIB_GENERIC6: case VERT_ATTRIB_GENERIC7: assert(attr < VERT_ATTRIB_MAX); - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[vs.num_inputs] = attr - VERT_ATTRIB_GENERIC0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.input_semantic_index[slot] = attr - VERT_ATTRIB_GENERIC0; break; default: assert(0); } - vs.num_inputs++; } } + /* initialize output semantics to defaults */ + for (i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) { + vs.output_semantic_name[i] = TGSI_SEMANTIC_GENERIC; + vs.output_semantic_index[i] = 0; + } + /* - * Determine number of outputs, the register mapping and - * the semantic information for each vertex output/result. + * Determine number of outputs, the (default) output register + * mapping and the semantic information for each output. */ for (attr = 0; attr < VERT_RESULT_MAX; attr++) { if (stvp->Base.Base.OutputsWritten & (1 << attr)) { - /* put this attrib in the next available slot */ - st->vertex_attrib_to_slot[attr] = vs.num_outputs; + GLuint slot; + + if (outputMapping) { + slot = outputMapping[attr]; + assert(slot != ~0); + } + else { + slot = vs.num_outputs; + vs.num_outputs++; + defaultOutputMapping[attr] = slot; + } + + /* + printf("Output %u -> slot %u\n", attr, slot); + */ switch (attr) { case VERT_RESULT_HPOS: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_POSITION; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_COL0: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_COLOR; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_COL1: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_COLOR; - vs.output_semantic_index[vs.num_outputs] = 1; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs.output_semantic_index[slot] = 1; break; case VERT_RESULT_BFC0: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_BCOLOR; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_BFC1: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_BCOLOR; - vs.output_semantic_index[vs.num_outputs] = 1; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR; + vs.output_semantic_index[slot] = 1; break; case VERT_RESULT_FOGC: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_FOG; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_FOG; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_PSIZ: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_PSIZE; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_EDGE: assert(0); @@ -174,46 +204,59 @@ st_translate_vertex_shader(struct st_context *st, case VERT_RESULT_TEX5: case VERT_RESULT_TEX6: case VERT_RESULT_TEX7: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_GENERIC; - vs.output_semantic_index[vs.num_outputs] = attr - VERT_RESULT_TEX0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.output_semantic_index[slot] = attr - VERT_RESULT_TEX0; break; case VERT_RESULT_VAR0: /* fall-through */ default: assert(attr - VERT_RESULT_VAR0 < MAX_VARYING); - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_GENERIC; - vs.output_semantic_index[vs.num_outputs] = attr - VERT_RESULT_VAR0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.output_semantic_index[slot] = attr - VERT_RESULT_VAR0; } - - vs.num_outputs++; } } + if (outputMapping) { + /* find max output slot referenced to compute vs.num_outputs */ + GLuint maxSlot = 0; + for (attr = 0; attr < VERT_RESULT_MAX; attr++) { + if (outputMapping[attr] != ~0 && outputMapping[attr] > maxSlot) + maxSlot = outputMapping[attr]; + } + vs.num_outputs = maxSlot + 1; + } + else { + outputMapping = defaultOutputMapping; + } + /* XXX: fix static allocation of tokens: */ tgsi_mesa_compile_vp_program( &stvp->Base, + /* inputs */ vs.num_inputs, stvp->input_to_index, vs.input_semantic_name, vs.input_semantic_index, + /* outputs */ vs.num_outputs, - st->vertex_attrib_to_slot, + outputMapping, vs.output_semantic_name, vs.output_semantic_index, - stvp->tokens, ST_FP_MAX_TOKENS ); - - vs.tokens = &stvp->tokens[0]; + /* tokenized result */ + tokensOut, maxTokens); + vs.tokens = tokensOut; cso = st_cached_vs_state(st, &vs); stvp->vs = cso; if (TGSI_DEBUG) - tgsi_dump( stvp->tokens, 0 ); + tgsi_dump( tokensOut, 0 ); #if defined(USE_X86_ASM) || defined(SLANG_X86) if (stvp->sse2_program.csr == stvp->sse2_program.store) - tgsi_emit_sse2( stvp->tokens, &stvp->sse2_program ); + tgsi_emit_sse2( tokensOut, &stvp->sse2_program ); if (!cso->state.executable) ((struct cso_vertex_shader*)cso)->state.executable = (void *) x86_get_func( &stvp->sse2_program ); @@ -246,6 +289,7 @@ static void update_vs( struct st_context *st ) } if (st->vp != stvp || stvp->dirty) { +#if 0 if (stvp->dirty) (void) st_translate_vertex_shader( st, stvp ); @@ -260,10 +304,15 @@ static void update_vs( struct st_context *st ) tgsi_dump( stvp->tokens, 0 ); #endif st->pipe->bind_vs_state(st->pipe, st->state.vs->data); +#else + /* NEW */ + st->dirty.st |= ST_NEW_LINKAGE; + +#endif } } - +#if 0 const struct st_tracked_state st_update_vs = { .name = "st_update_vs", .dirty = { @@ -272,7 +321,4 @@ const struct st_tracked_state st_update_vs = { }, .update = update_vs }; - - - - +#endif diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 639e0ceb40..367ae06cf3 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -155,7 +155,8 @@ make_frag_shader(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR); stfp = (struct st_fragment_program *) p; - st_translate_fragment_shader(st, stfp); + st_translate_fragment_program(st, stfp, NULL, + stfp->tokens, ST_FP_MAX_TOKENS); return stfp; } @@ -203,7 +204,8 @@ make_vertex_shader(struct st_context *st) (1 << VERT_RESULT_HPOS)); stvp = (struct st_vertex_program *) p; - st_translate_vertex_shader(st, stvp); + st_translate_vertex_program(st, stvp, NULL, + stvp->tokens, ST_FP_MAX_TOKENS); assert(stvp->vs); return stvp; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 65c5465546..619c5d8ab7 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -92,7 +92,8 @@ make_fragment_shader(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR); stfp = (struct st_fragment_program *) p; - st_translate_fragment_shader(st, stfp); + st_translate_fragment_program(st, stfp, NULL, + stfp->tokens, ST_FP_MAX_TOKENS); return stfp; } @@ -141,7 +142,8 @@ make_vertex_shader(struct st_context *st) (1 << VERT_RESULT_HPOS)); stvp = (struct st_vertex_program *) p; - st_translate_vertex_shader(st, stvp); + st_translate_vertex_program(st, stvp, NULL, + stvp->tokens, ST_FP_MAX_TOKENS); return stvp; } diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 78cf4c2b4d..537a58f39d 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -102,13 +102,13 @@ feedback_vertex(GLcontext *ctx, const struct draw_context *draw, * color and texcoord attribs to use here. */ - slot = st->vertex_attrib_to_slot[VERT_RESULT_COL0]; + slot = st->vertex_result_to_slot[VERT_RESULT_COL0]; if (slot) color = v->data[slot]; else color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - slot = st->vertex_attrib_to_slot[VERT_RESULT_TEX0]; + slot = st->vertex_result_to_slot[VERT_RESULT_TEX0]; if (slot) texcoord = v->data[slot]; else diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 9f46f9e93f..aee316df6f 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -30,24 +30,26 @@ * Keith Whitwell */ +#include "main/glheader.h" +#include "main/macros.h" +#include "main/enums.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/program.h" +#include "shader/programopt.h" + #include "st_context.h" -#include "st_program.h" -#include "glheader.h" -#include "macros.h" -#include "enums.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "program.h" -#include "programopt.h" +#include "st_program.h" +#include "st_atom_shader.h" + #include "tnl/tnl.h" #include "pipe/tgsi/mesa/tgsi_mesa.h" -/* Counter to track program string changes: +/** + * Called via ctx->Driver.BindProgram() to bind an ARB vertex or + * fragment program. */ -static GLuint program_id = 0; - - static void st_bind_program( GLcontext *ctx, GLenum target, struct gl_program *prog ) @@ -62,8 +64,14 @@ static void st_bind_program( GLcontext *ctx, st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; break; } + st->dirty.st |= ST_NEW_LINKAGE; } + +/** + * Called via ctx->Driver.UseProgram() to bind a linked GLSL program + * (vertex shader + fragment shader). + */ static void st_use_program( GLcontext *ctx, GLuint program ) { @@ -71,6 +79,7 @@ static void st_use_program( GLcontext *ctx, st->dirty.st |= ST_NEW_VERTEX_PROGRAM; st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; + st->dirty.st |= ST_NEW_LINKAGE; } @@ -79,14 +88,13 @@ static struct gl_program *st_new_program( GLcontext *ctx, GLenum target, GLuint id ) { -// struct st_context *st = st_context(ctx); + struct st_context *st = st_context(ctx); switch (target) { case GL_VERTEX_PROGRAM_ARB: { struct st_vertex_program *prog = CALLOC_STRUCT(st_vertex_program); - prog->id = program_id++; - prog->dirty = 1; + prog->serialNo = 1; #if defined(USE_X86_ASM) || defined(SLANG_X86) x86_init_func( &prog->sse2_program ); @@ -102,8 +110,7 @@ static struct gl_program *st_new_program( GLcontext *ctx, case GL_FRAGMENT_PROGRAM_NV: { struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program); - prog->id = program_id++; - prog->dirty = 1; + prog->serialNo = 1; #if defined(USE_X86_ASM) || defined(SLANG_X86) x86_init_func( &prog->sse2_program ); @@ -118,29 +125,40 @@ static struct gl_program *st_new_program( GLcontext *ctx, default: return _mesa_new_program(ctx, target, id); } + + st->dirty.st |= ST_NEW_LINKAGE; } + static void st_delete_program( GLcontext *ctx, struct gl_program *prog ) { + struct st_context *st = st_context(ctx); + switch( prog->Target ) { - case GL_VERTEX_PROGRAM_ARB: { + case GL_VERTEX_PROGRAM_ARB: + { + struct st_vertex_program *stvp = (struct st_vertex_program *) prog; #if defined(USE_X86_ASM) || defined(SLANG_X86) - struct st_vertex_program *p = (struct st_vertex_program *) prog; - - x86_release_func( &p->sse2_program ); + x86_release_func( &stvp->sse2_program ); #endif + st_remove_vertex_program(st, stvp); + } break; - } - case GL_FRAGMENT_PROGRAM_ARB: { + case GL_FRAGMENT_PROGRAM_ARB: + { + struct st_fragment_program *stfp + = (struct st_fragment_program *) prog; #if defined(USE_X86_ASM) || defined(SLANG_X86) - struct st_fragment_program *p = (struct st_fragment_program *) prog; - - x86_release_func( &p->sse2_program ); + x86_release_func( &stfp->sse2_program ); #endif + st_remove_fragment_program(st, stfp); + } break; + default: + assert(0); /* problem */ } - } + _mesa_delete_program( ctx, prog ); } @@ -160,27 +178,31 @@ static void st_program_string_notify( GLcontext *ctx, struct st_context *st = st_context(ctx); if (target == GL_FRAGMENT_PROGRAM_ARB) { - struct st_fragment_program *p = (struct st_fragment_program *)prog; + struct st_fragment_program *stfp = (struct st_fragment_program *) prog; if (prog == &ctx->FragmentProgram._Current->Base) st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; - p->id = program_id++; - p->param_state = p->Base.Base.Parameters->StateFlags; + stfp->serialNo++; + + stfp->param_state = stfp->Base.Base.Parameters->StateFlags; } else if (target == GL_VERTEX_PROGRAM_ARB) { - struct st_vertex_program *p = (struct st_vertex_program *)prog; + struct st_vertex_program *stvp = (struct st_vertex_program *) prog; if (prog == &ctx->VertexProgram._Current->Base) st->dirty.st |= ST_NEW_VERTEX_PROGRAM; - p->id = program_id++; - p->param_state = p->Base.Base.Parameters->StateFlags; + stvp->serialNo++; + + stvp->param_state = stvp->Base.Base.Parameters->StateFlags; /* Also tell tnl about it: */ _tnl_program_string(ctx, target, prog); } + + st->dirty.st |= ST_NEW_LINKAGE; } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 2311bddc65..661d155e6d 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -53,9 +53,9 @@ static void setup_vertex_attribs(GLcontext *ctx) { struct pipe_context *pipe = ctx->st->pipe; -#if 0 - const uint inputAttrs = ctx->st->state.vs->inputs_read; - uint attr; + const struct cso_vertex_shader *vs = ctx->st->state.vs; + const struct st_vertex_program *stvp = ctx->st->vp; + uint slot; /* all attributes come from the default attribute buffer */ { @@ -67,20 +67,16 @@ setup_vertex_attribs(GLcontext *ctx) pipe->set_vertex_buffer(pipe, 0, &vbuffer); } - for (attr = 0; attr < 16; attr++) { + for (slot = 0; slot < vs->state.num_inputs; slot++) { struct pipe_vertex_element velement; + const GLuint attr = stvp->index_to_input[slot]; - if (inputAttrs & (1 << attr)) { - velement.src_offset = attr * 4 * sizeof(GLfloat); - velement.vertex_buffer_index = 0; - velement.dst_offset = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - pipe->set_vertex_element(pipe, attr, &velement); - } + velement.src_offset = attr * 4 * sizeof(GLfloat); + velement.vertex_buffer_index = 0; + velement.dst_offset = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + pipe->set_vertex_element(pipe, slot, &velement); } -#else - assert(0); -#endif } @@ -98,12 +94,11 @@ setup_feedback(GLcontext *ctx) feedback.discard = 1; feedback.num_attribs = 0; + /* feedback all results from vertex shader */ for (i = 0; i < vs->num_outputs; i++) { - if (1/***(1 << i) & outputAttrs***/) { - feedback.attrib[feedback.num_attribs] = i; - feedback.size[feedback.num_attribs] = 4; - feedback.num_attribs++; - } + feedback.attrib[feedback.num_attribs] = i; + feedback.size[feedback.num_attribs] = 4; + feedback.num_attribs++; } pipe->set_feedback_state(pipe, &feedback); @@ -261,13 +256,11 @@ update_rasterpos(GLcontext *ctx, static void st_RasterPos(GLcontext *ctx, const GLfloat v[4]) { - struct pipe_context *pipe = ctx->st->pipe; + const struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; float *buf_map; struct pipe_feedback_buffer fb_buf; - /** XXX TEMPORARILY DISABLE */ - return; - st_validate_state(ctx->st); /* setup vertex buffers */ @@ -277,7 +270,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) * Load the default attribute buffer with current attribs. */ { - struct pipe_buffer_handle *buf = ctx->st->default_attrib_buffer; + struct pipe_buffer_handle *buf = st->default_attrib_buffer; const unsigned size = sizeof(ctx->Current.Attrib); const void *data = ctx->Current.Attrib; /* colors, texcoords, etc */ @@ -313,17 +306,16 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) PIPE_BUFFER_FLAG_READ); /* extract values and update rasterpos state */ -#if 0 /* XXX update */ { - const uint outputAttrs = ctx->st->state.vs->outputs_written; + const GLuint *outputMapping = st->vertex_result_to_slot; const float *pos, *color0, *color1, *tex0; float *buf = buf_map; - assert(outputAttrs & (1 << TGSI_ATTRIB_POS)); + assert(outputMapping[VERT_RESULT_HPOS] != ~0); pos = buf; buf += 4; - if (outputAttrs & (1 << TGSI_ATTRIB_COLOR0)) { + if (outputMapping[VERT_RESULT_COL0] != ~0) { color0 = buf; buf += 4; } @@ -331,7 +323,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) color0 = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; } - if (outputAttrs & (1 << TGSI_ATTRIB_COLOR1)) { + if (outputMapping[VERT_RESULT_COL1] != ~0) { color1 = buf; buf += 4; } @@ -339,16 +331,23 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) color1 = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; } + if (outputMapping[VERT_RESULT_TEX0] != ~0) { + tex0 = buf; + buf += 4; + } + else { + tex0 = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + } + update_rasterpos(ctx, pos, color0, color1, tex0); } -#endif /* free vertex feedback buffer */ pipe->winsys->buffer_unmap(pipe->winsys, fb_buf.buffer); pipe->winsys->buffer_reference(pipe->winsys, &fb_buf.buffer, NULL); /* restore pipe state */ - pipe->set_feedback_state(pipe, &ctx->st->state.feedback); + pipe->set_feedback_state(pipe, &st->state.feedback); } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 3713328eb1..24f0ff9aaf 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -45,6 +45,8 @@ struct cso_blend; #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 #define ST_NEW_VERTEX_PROGRAM 0x4 +#define ST_NEW_LINKAGE 0x8 + struct st_state_flags { GLuint mesa; @@ -119,8 +121,8 @@ struct st_context GLfloat polygon_offset_scale; /* ?? */ - /** Mapping from VERT_ATTRIB_x to post-transformed vertex slot */ - GLuint vertex_attrib_to_slot[VERT_RESULT_MAX]; + /** Mapping from VERT_RESULT_x to post-transformed vertex slot */ + const GLuint *vertex_result_to_slot; struct st_vertex_program *vp; /**< Currently bound vertex program */ struct st_fragment_program *fp; /**< Currently bound fragment program */ diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 419afa4e78..355dee574b 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -47,11 +47,11 @@ struct st_fragment_program { struct gl_fragment_program Base; GLboolean error; /* If program is malformed for any reason. */ - GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ + + GLuint serialNo; /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; - GLboolean dirty; #if defined(USE_X86_ASM) || defined(SLANG_X86) struct x86_function sse2_program; @@ -68,7 +68,8 @@ struct st_vertex_program { struct gl_vertex_program Base; /**< The Mesa vertex program */ GLboolean error; /**< Set if program is malformed for any reason. */ - GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ + + GLuint serialNo; /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */ GLuint input_to_index[MAX_VERTEX_PROGRAM_ATTRIBS]; @@ -77,7 +78,6 @@ struct st_vertex_program /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; - GLboolean dirty; #if defined(USE_X86_ASM) || defined(SLANG_X86) struct x86_function sse2_program; @@ -90,7 +90,8 @@ struct st_vertex_program }; -extern void st_init_program_functions(struct dd_function_table *functions); +extern void +st_init_program_functions(struct dd_function_table *functions); static inline struct st_fragment_program * @@ -99,6 +100,7 @@ st_fragment_program( struct gl_fragment_program *fp ) return (struct st_fragment_program *)fp; } + static inline struct st_vertex_program * st_vertex_program( struct gl_vertex_program *vp ) { @@ -107,13 +109,18 @@ st_vertex_program( struct gl_vertex_program *vp ) extern const struct cso_fragment_shader * -st_translate_fragment_shader(struct st_context *st, - struct st_fragment_program *fp); +st_translate_fragment_program(struct st_context *st, + struct st_fragment_program *fp, + const GLuint inputMapping[], + struct tgsi_token *tokens, + GLuint maxTokens); extern const struct cso_vertex_shader * -st_translate_vertex_shader(struct st_context *st, - struct st_vertex_program *vp); - +st_translate_vertex_program(struct st_context *st, + struct st_vertex_program *vp, + const GLuint vert_output_to_slot[], + struct tgsi_token *tokens, + GLuint maxTokens); #endif -- cgit v1.2.3 From 088e80f6dbdaa8bdcac2d9a46e8d5f387c116371 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 30 Oct 2007 11:15:29 -0600 Subject: added st_update_pixel_transfer atom --- src/mesa/state_tracker/st_atom.c | 3 ++- src/mesa/state_tracker/st_atom.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 326042cb34..d967b9b978 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -61,7 +61,8 @@ static const struct st_tracked_state *atoms[] = &st_update_texture, &st_update_vs_constants, &st_update_fs_constants, - &st_update_alpha_test + &st_update_alpha_test, + &st_update_pixel_transfer }; diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 94cb7bee7a..a7caca5459 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -60,6 +60,7 @@ const struct st_tracked_state st_update_texture; const struct st_tracked_state st_update_fs_constants; const struct st_tracked_state st_update_vs_constants; const struct st_tracked_state st_update_alpha_test; +const struct st_tracked_state st_update_pixel_transfer; #endif -- cgit v1.2.3 From 8db4acc5547370761a9a489c947e9621adc8f945 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 31 Oct 2007 12:31:25 -0600 Subject: No longer need st_update_tnl atom --- src/mesa/state_tracker/st_atom.c | 1 - src/mesa/state_tracker/st_atom.h | 1 - 2 files changed, 2 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index d967b9b978..0797ea615e 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -49,7 +49,6 @@ static const struct st_tracked_state *atoms[] = &st_update_depth_stencil, &st_update_clip, - &st_update_tnl, &st_update_shader, &st_update_rasterizer, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index a7caca5459..63ce35958a 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -48,7 +48,6 @@ const struct st_tracked_state st_update_framebuffer; const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth_stencil; -const struct st_tracked_state st_update_tnl; const struct st_tracked_state st_update_shader; const struct st_tracked_state st_update_rasterizer; const struct st_tracked_state st_update_polygon_stipple; -- cgit v1.2.3 From 94cadef31f9d4ee9fce1bfa66fabb0a403a6f049 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 11 Dec 2007 13:19:33 +0000 Subject: gallium: remove redundant clear_color state. --- src/mesa/pipe/failover/fo_context.h | 1 - src/mesa/pipe/failover/fo_state.c | 11 ----- src/mesa/pipe/failover/fo_state_emit.c | 3 -- src/mesa/pipe/i915simple/i915_context.h | 1 - src/mesa/pipe/i915simple/i915_state.c | 11 ----- src/mesa/pipe/i965simple/brw_context.h | 1 - src/mesa/pipe/i965simple/brw_state.c | 9 ---- src/mesa/pipe/p_context.h | 3 -- src/mesa/pipe/p_state.h | 5 --- src/mesa/pipe/softpipe/sp_context.c | 1 - src/mesa/pipe/softpipe/sp_context.h | 1 - src/mesa/pipe/softpipe/sp_state.h | 3 -- src/mesa/pipe/softpipe/sp_state_surface.c | 8 ---- src/mesa/sources | 1 - src/mesa/state_tracker/st_atom.c | 1 - src/mesa/state_tracker/st_atom.h | 1 - src/mesa/state_tracker/st_atom_clear_color.c | 63 ---------------------------- src/mesa/state_tracker/st_context.h | 1 - 18 files changed, 125 deletions(-) delete mode 100644 src/mesa/state_tracker/st_atom_clear_color.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index 7cf18c9ec1..2423eb4556 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -79,7 +79,6 @@ struct failover_context { const struct fo_state *vertex_shader; struct pipe_blend_color blend_color; - struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index fd6137ba66..689d2fa3c7 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -146,16 +146,6 @@ failover_set_clip_state( struct pipe_context *pipe, failover->hw->set_clip_state( failover->hw, clip ); } -static void -failover_set_clear_color_state( struct pipe_context *pipe, - const struct pipe_clear_color_state *clear_color ) -{ - struct failover_context *failover = failover_context(pipe); - - failover->clear_color = *clear_color; - failover->dirty |= FO_NEW_CLEAR_COLOR; - failover->hw->set_clear_color_state( failover->hw, clear_color ); -} static void * failover_create_depth_stencil_state(struct pipe_context *pipe, @@ -480,7 +470,6 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_blend_color = failover_set_blend_color; failover->pipe.set_clip_state = failover_set_clip_state; - failover->pipe.set_clear_color_state = failover_set_clear_color_state; failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; failover->pipe.set_sampler_units = failover_set_sampler_units; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index a3aff8abd2..612b0a6ca3 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -69,9 +69,6 @@ failover_state_emit( struct failover_context *failover ) if (failover->dirty & FO_NEW_CLIP) failover->sw->set_clip_state( failover->sw, &failover->clip ); - if (failover->dirty & FO_NEW_CLEAR_COLOR) - failover->sw->set_clear_color_state( failover->sw, &failover->clear_color ); - if (failover->dirty & FO_NEW_DEPTH_STENCIL) failover->sw->bind_depth_stencil_state( failover->sw, failover->depth_stencil->sw_state ); diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index b9b67c4fcf..a239c8f72e 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -194,7 +194,6 @@ struct i915_context const struct pipe_shader_state *fs; struct pipe_blend_color blend_color; - struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[PIPE_SHADER_TYPES]; struct pipe_framebuffer_state framebuffer; diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index b9f257a007..a8c6565a54 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -548,16 +548,6 @@ static void i915_set_framebuffer_state(struct pipe_context *pipe, -static void i915_set_clear_color_state(struct pipe_context *pipe, - const struct pipe_clear_color_state *clear) -{ - struct i915_context *i915 = i915_context(pipe); - - i915->clear_color = *clear; /* struct copy */ -} - - - static void i915_set_clip_state( struct pipe_context *pipe, const struct pipe_clip_state *clip ) { @@ -720,7 +710,6 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; - i915->pipe.set_clear_color_state = i915_set_clear_color_state; i915->pipe.set_constant_buffer = i915_set_constant_buffer; i915->pipe.set_framebuffer_state = i915_set_framebuffer_state; diff --git a/src/mesa/pipe/i965simple/brw_context.h b/src/mesa/pipe/i965simple/brw_context.h index 00df46e704..53f66cd6a9 100644 --- a/src/mesa/pipe/i965simple/brw_context.h +++ b/src/mesa/pipe/i965simple/brw_context.h @@ -475,7 +475,6 @@ struct brw_context struct pipe_scissor_state Scissor; struct pipe_viewport_state Viewport; struct pipe_framebuffer_state FrameBuffer; - struct pipe_clear_color_state ClearColor; const struct pipe_constant_buffer *Constants[2]; const struct brw_texture *Texture[PIPE_MAX_SAMPLERS]; diff --git a/src/mesa/pipe/i965simple/brw_state.c b/src/mesa/pipe/i965simple/brw_state.c index b50f23c1a2..7731c2e01f 100644 --- a/src/mesa/pipe/i965simple/brw_state.c +++ b/src/mesa/pipe/i965simple/brw_state.c @@ -377,14 +377,6 @@ static void brw_set_framebuffer_state(struct pipe_context *pipe, -static void brw_set_clear_color_state(struct pipe_context *pipe, - const struct pipe_clear_color_state *clear) -{ - struct brw_context *brw = brw_context(pipe); - - brw->attribs.ClearColor = *clear; /* struct copy */ -} - /************************************************************************ * Rasterizer state */ @@ -449,7 +441,6 @@ brw_init_state_functions( struct brw_context *brw ) brw->pipe.set_blend_color = brw_set_blend_color; brw->pipe.set_clip_state = brw_set_clip_state; - brw->pipe.set_clear_color_state = brw_set_clear_color_state; brw->pipe.set_constant_buffer = brw_set_constant_buffer; brw->pipe.set_framebuffer_state = brw_set_framebuffer_state; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 7da4992841..6b97844445 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -132,9 +132,6 @@ struct pipe_context { void (*set_clip_state)( struct pipe_context *, const struct pipe_clip_state * ); - void (*set_clear_color_state)( struct pipe_context *, - const struct pipe_clear_color_state * ); - void (*set_constant_buffer)( struct pipe_context *, uint shader, uint index, const struct pipe_constant_buffer *buf ); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 50344bea78..56d4f96ed7 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -200,11 +200,6 @@ struct pipe_blend_color { float color[4]; }; -struct pipe_clear_color_state -{ - float color[4]; -}; - struct pipe_framebuffer_state { /** multiple colorbuffers for multiple render targets */ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 2eab3aaabb..43f23dc1e8 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -304,7 +304,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_clip_state = softpipe_set_clip_state; - softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state; softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 1c391dcd4d..45d15c720e 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -82,7 +82,6 @@ struct softpipe_context { const struct sp_vertex_shader_state *vs; struct pipe_blend_color blend_color; - struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; struct pipe_framebuffer_state framebuffer; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index f434567da5..80a1cba25a 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -92,9 +92,6 @@ void softpipe_set_framebuffer_state( struct pipe_context *, void softpipe_set_blend_color( struct pipe_context *pipe, const struct pipe_blend_color *blend_color ); -void softpipe_set_clear_color_state( struct pipe_context *, - const struct pipe_clear_color_state * ); - void softpipe_set_clip_state( struct pipe_context *, const struct pipe_clip_state * ); diff --git a/src/mesa/pipe/softpipe/sp_state_surface.c b/src/mesa/pipe/softpipe/sp_state_surface.c index 30bedc74bc..ee72aaf4c5 100644 --- a/src/mesa/pipe/softpipe/sp_state_surface.c +++ b/src/mesa/pipe/softpipe/sp_state_surface.c @@ -131,11 +131,3 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, -void -softpipe_set_clear_color_state(struct pipe_context *pipe, - const struct pipe_clear_color_state *clear) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - - softpipe->clear_color = *clear; /* struct copy */ -} diff --git a/src/mesa/sources b/src/mesa/sources index 4a5a97b47d..fb059498f9 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -200,7 +200,6 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom.c \ state_tracker/st_atom_alphatest.c \ state_tracker/st_atom_blend.c \ - state_tracker/st_atom_clear_color.c \ state_tracker/st_atom_clip.c \ state_tracker/st_atom_constbuf.c \ state_tracker/st_atom_depth.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 0797ea615e..bde81edd8c 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -45,7 +45,6 @@ static const struct st_tracked_state *atoms[] = { &st_update_framebuffer, - &st_update_clear_color, &st_update_depth_stencil, &st_update_clip, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 3c0db0db09..0114f42ba5 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -46,7 +46,6 @@ void st_validate_state( struct st_context *st ); const struct st_tracked_state st_update_framebuffer; const struct st_tracked_state st_update_clip; -const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth_stencil; const struct st_tracked_state st_update_shader; const struct st_tracked_state st_update_rasterizer; diff --git a/src/mesa/state_tracker/st_atom_clear_color.c b/src/mesa/state_tracker/st_atom_clear_color.c deleted file mode 100644 index ce3431c5d3..0000000000 --- a/src/mesa/state_tracker/st_atom_clear_color.c +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - - /* - * Authors: - * Keith Whitwell - * Brian Paul - */ - -#include "st_context.h" -#include "st_atom.h" -#include "pipe/p_context.h" - - -static void -update_clear_color_state( struct st_context *st ) -{ - struct pipe_clear_color_state clear; - - clear.color[0] = st->ctx->Color.ClearColor[0]; - clear.color[1] = st->ctx->Color.ClearColor[1]; - clear.color[2] = st->ctx->Color.ClearColor[2]; - clear.color[3] = st->ctx->Color.ClearColor[3]; - - if (memcmp(&clear, &st->state.clear_color, sizeof(clear)) != 0) { - st->state.clear_color = clear; - st->pipe->set_clear_color_state( st->pipe, &clear ); - } -} - - -const struct st_tracked_state st_update_clear_color = { - .name = "st_update_clear_color", - .dirty = { - .mesa = _NEW_COLOR, - .st = 0, - }, - .update = update_clear_color_state -}; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 33aacdb6d1..4855961d09 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -103,7 +103,6 @@ struct st_context const struct cso_vertex_shader *vs; struct pipe_blend_color blend_color; - struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; struct pipe_framebuffer_state framebuffer; -- cgit v1.2.3 From bfe79babf99e6b9435195178d1ea64687c60d161 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 17 Dec 2007 16:14:29 +0000 Subject: gallium: incorporate alpha state into depth_stencil state object. --- src/mesa/pipe/cell/ppu/cell_context.c | 4 -- src/mesa/pipe/cell/ppu/cell_context.h | 3 +- src/mesa/pipe/cell/ppu/cell_state.h | 9 +-- src/mesa/pipe/cell/ppu/cell_state_blend.c | 40 ++--------- src/mesa/pipe/cso_cache/cso_cache.c | 13 +--- src/mesa/pipe/cso_cache/cso_cache.h | 14 ++-- src/mesa/pipe/failover/fo_context.h | 1 - src/mesa/pipe/failover/fo_state.c | 60 +++------------- src/mesa/pipe/failover/fo_state_emit.c | 8 +-- src/mesa/pipe/i915simple/i915_context.h | 4 -- src/mesa/pipe/i915simple/i915_state.c | 86 ++++++++--------------- src/mesa/pipe/i915simple/i915_state_immediate.c | 6 +- src/mesa/pipe/i965simple/brw_cc.c | 49 ++++++------- src/mesa/pipe/i965simple/brw_context.h | 3 +- src/mesa/pipe/i965simple/brw_state.c | 42 ++--------- src/mesa/pipe/i965simple/brw_wm.c | 13 ++-- src/mesa/pipe/i965simple/brw_wm_state.c | 2 +- src/mesa/pipe/p_context.h | 13 ++-- src/mesa/pipe/p_state.h | 36 +++++----- src/mesa/pipe/softpipe/sp_context.c | 10 +-- src/mesa/pipe/softpipe/sp_context.h | 9 ++- src/mesa/pipe/softpipe/sp_quad.c | 8 +-- src/mesa/pipe/softpipe/sp_quad_alpha_test.c | 4 +- src/mesa/pipe/softpipe/sp_quad_stencil.c | 25 ++----- src/mesa/pipe/softpipe/sp_state.h | 9 +-- src/mesa/pipe/softpipe/sp_state_blend.c | 38 ++-------- src/mesa/pipe/softpipe/sp_state_derived.c | 8 +-- src/mesa/sources | 1 - src/mesa/state_tracker/st_atom.c | 3 +- src/mesa/state_tracker/st_atom.h | 3 +- src/mesa/state_tracker/st_atom_alphatest.c | 92 ------------------------- src/mesa/state_tracker/st_atom_depth.c | 55 ++++++++------- src/mesa/state_tracker/st_cache.c | 40 +++-------- src/mesa/state_tracker/st_cache.h | 9 +-- src/mesa/state_tracker/st_cb_clear.c | 35 ++++------ src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_context.h | 2 +- 37 files changed, 206 insertions(+), 553 deletions(-) delete mode 100644 src/mesa/state_tracker/st_atom_alphatest.c (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index eff33da969..b448a8aa8c 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -176,10 +176,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) /* state setters */ - cell->pipe.create_alpha_test_state = cell_create_alpha_test_state; - cell->pipe.bind_alpha_test_state = cell_bind_alpha_test_state; - cell->pipe.delete_alpha_test_state = cell_delete_alpha_test_state; - cell->pipe.create_blend_state = cell_create_blend_state; cell->pipe.bind_blend_state = cell_bind_blend_state; cell->pipe.delete_blend_state = cell_delete_blend_state; diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h index 96f000eef4..f8d6cc5d32 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.h +++ b/src/mesa/pipe/cell/ppu/cell_context.h @@ -40,10 +40,9 @@ struct cell_context struct cell_winsys *winsys; - const struct pipe_alpha_test_state *alpha_test; const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; - const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_depth_stencil_alpha_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; struct pipe_blend_color blend_color; diff --git a/src/mesa/pipe/cell/ppu/cell_state.h b/src/mesa/pipe/cell/ppu/cell_state.h index 4bad45950b..b01814202d 100644 --- a/src/mesa/pipe/cell/ppu/cell_state.h +++ b/src/mesa/pipe/cell/ppu/cell_state.h @@ -27,13 +27,6 @@ cell_set_framebuffer_state( struct pipe_context *, const struct pipe_framebuffer_state * ); -extern void * -cell_create_alpha_test_state(struct pipe_context *, - const struct pipe_alpha_test_state *); -extern void -cell_bind_alpha_test_state(struct pipe_context *, void *); -extern void -cell_delete_alpha_test_state(struct pipe_context *, void *); extern void * cell_create_blend_state(struct pipe_context *, const struct pipe_blend_state *); @@ -57,7 +50,7 @@ cell_delete_sampler_state(struct pipe_context *, void *); extern void * cell_create_depth_stencil_state(struct pipe_context *, - const struct pipe_depth_stencil_state *); + const struct pipe_depth_stencil_alpha_state *); extern void cell_bind_depth_stencil_state(struct pipe_context *, void *); diff --git a/src/mesa/pipe/cell/ppu/cell_state_blend.c b/src/mesa/pipe/cell/ppu/cell_state_blend.c index e807463d90..efcb9e38a4 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_blend.c +++ b/src/mesa/pipe/cell/ppu/cell_state_blend.c @@ -69,44 +69,14 @@ void cell_set_blend_color( struct pipe_context *pipe, } -/** XXX move someday? Or consolidate all these simple state setters - * into one file. - */ - -void * -cell_create_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha) -{ - struct pipe_alpha_test_state *state = MALLOC( sizeof(struct pipe_alpha_test_state) ); - memcpy(state, alpha, sizeof(struct pipe_alpha_test_state)); - return state; -} - -void -cell_bind_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - struct cell_context *cell = cell_context(pipe); - - cell->alpha_test = (const struct pipe_alpha_test_state *)alpha; - - cell->dirty |= CELL_NEW_ALPHA_TEST; -} - -void -cell_delete_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - FREE( alpha ); -} void * cell_create_depth_stencil_state(struct pipe_context *pipe, - const struct pipe_depth_stencil_state *depth_stencil) + const struct pipe_depth_stencil_alpha_state *depth_stencil) { - struct pipe_depth_stencil_state *state = - MALLOC( sizeof(struct pipe_depth_stencil_state) ); - memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_state)); + struct pipe_depth_stencil_alpha_state *state = + MALLOC( sizeof(struct pipe_depth_stencil_alpha_state) ); + memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_alpha_state)); return state; } @@ -116,7 +86,7 @@ cell_bind_depth_stencil_state(struct pipe_context *pipe, { struct cell_context *cell = cell_context(pipe); - cell->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil; + cell->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil; cell->dirty |= CELL_NEW_DEPTH_STENCIL; } diff --git a/src/mesa/pipe/cso_cache/cso_cache.c b/src/mesa/pipe/cso_cache/cso_cache.c index 0bba5914dc..9e77e0774d 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.c +++ b/src/mesa/pipe/cso_cache/cso_cache.c @@ -78,7 +78,7 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ case CSO_SAMPLER: hash = sc->sampler_hash; break; - case CSO_DEPTH_STENCIL: + case CSO_DEPTH_STENCIL_ALPHA: hash = sc->depth_stencil_hash; break; case CSO_RASTERIZER: @@ -90,9 +90,6 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ case CSO_VERTEX_SHADER: hash = sc->vs_hash; break; - case CSO_ALPHA_TEST: - hash = sc->alpha_hash; - break; } return hash; @@ -105,16 +102,14 @@ static int _cso_size_for_type(enum cso_cache_type type) return sizeof(struct pipe_blend_state); case CSO_SAMPLER: return sizeof(struct pipe_sampler_state); - case CSO_DEPTH_STENCIL: - return sizeof(struct pipe_depth_stencil_state); + case CSO_DEPTH_STENCIL_ALPHA: + return sizeof(struct pipe_depth_stencil_alpha_state); case CSO_RASTERIZER: return sizeof(struct pipe_rasterizer_state); case CSO_FRAGMENT_SHADER: return sizeof(struct pipe_shader_state); case CSO_VERTEX_SHADER: return sizeof(struct pipe_shader_state); - case CSO_ALPHA_TEST: - return sizeof(struct pipe_alpha_test_state); } return 0; } @@ -169,7 +164,6 @@ struct cso_cache *cso_cache_create(void) sc->rasterizer_hash = cso_hash_create(); sc->fs_hash = cso_hash_create(); sc->vs_hash = cso_hash_create(); - sc->alpha_hash = cso_hash_create(); return sc; } @@ -183,6 +177,5 @@ void cso_cache_delete(struct cso_cache *sc) cso_hash_delete(sc->rasterizer_hash); cso_hash_delete(sc->fs_hash); cso_hash_delete(sc->vs_hash); - cso_hash_delete(sc->alpha_hash); free(sc); } diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h index cd36dd51e9..116e2eaa2c 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.h +++ b/src/mesa/pipe/cso_cache/cso_cache.h @@ -40,7 +40,6 @@ struct cso_hash; struct cso_cache { - struct cso_hash *alpha_hash; struct cso_hash *blend_hash; struct cso_hash *depth_stencil_hash; struct cso_hash *fs_hash; @@ -54,8 +53,8 @@ struct cso_blend { void *data; }; -struct cso_depth_stencil { - struct pipe_depth_stencil_state state; +struct cso_depth_stencil_alpha { + struct pipe_depth_stencil_alpha_state state; void *data; }; @@ -79,19 +78,14 @@ struct cso_sampler { void *data; }; -struct cso_alpha_test { - struct pipe_alpha_test_state state; - void *data; -}; enum cso_cache_type { CSO_BLEND, CSO_SAMPLER, - CSO_DEPTH_STENCIL, + CSO_DEPTH_STENCIL_ALPHA, CSO_RASTERIZER, CSO_FRAGMENT_SHADER, - CSO_VERTEX_SHADER, - CSO_ALPHA_TEST + CSO_VERTEX_SHADER }; unsigned cso_construct_key(void *item, int item_size); diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index f5eaa0b5fa..1dc87291c9 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -70,7 +70,6 @@ struct failover_context { /* The most recent drawing state as set by the driver: */ - const struct fo_state *alpha_test; const struct fo_state *blend; const struct fo_state *sampler[PIPE_MAX_SAMPLERS]; const struct fo_state *depth_stencil; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index 6b4f1517ac..fa700b9674 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -45,45 +45,6 @@ * lower overheads. */ -static void * -failover_create_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *templ) -{ - struct fo_state *state = malloc(sizeof(struct fo_state)); - struct failover_context *failover = failover_context(pipe); - - state->sw_state = failover->sw->create_alpha_test_state(pipe, templ); - state->hw_state = failover->hw->create_alpha_test_state(pipe, templ); - - return state; -} - -static void -failover_bind_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - struct failover_context *failover = failover_context(pipe); - struct fo_state *state = (struct fo_state *)alpha; - - failover->alpha_test = state; - failover->dirty |= FO_NEW_ALPHA_TEST; - failover->hw->bind_alpha_test_state(failover->hw, - state->hw_state); -} - -static void -failover_delete_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - struct fo_state *state = (struct fo_state*)alpha; - struct failover_context *failover = failover_context(pipe); - - failover->sw->delete_alpha_test_state(pipe, state->sw_state); - failover->hw->delete_alpha_test_state(pipe, state->hw_state); - state->sw_state = 0; - state->hw_state = 0; - free(state); -} static void * @@ -149,13 +110,13 @@ failover_set_clip_state( struct pipe_context *pipe, static void * failover_create_depth_stencil_state(struct pipe_context *pipe, - const struct pipe_depth_stencil_state *templ) + const struct pipe_depth_stencil_alpha_state *templ) { struct fo_state *state = malloc(sizeof(struct fo_state)); struct failover_context *failover = failover_context(pipe); - state->sw_state = failover->sw->create_depth_stencil_state(pipe, templ); - state->hw_state = failover->hw->create_depth_stencil_state(pipe, templ); + state->sw_state = failover->sw->create_depth_stencil_alpha_state(pipe, templ); + state->hw_state = failover->hw->create_depth_stencil_alpha_state(pipe, templ); return state; } @@ -168,7 +129,7 @@ failover_bind_depth_stencil_state(struct pipe_context *pipe, struct fo_state *state = (struct fo_state *)depth_stencil; failover->depth_stencil = state; failover->dirty |= FO_NEW_DEPTH_STENCIL; - failover->hw->bind_depth_stencil_state(failover->hw, state->hw_state); + failover->hw->bind_depth_stencil_alpha_state(failover->hw, state->hw_state); } static void @@ -178,8 +139,8 @@ failover_delete_depth_stencil_state(struct pipe_context *pipe, struct fo_state *state = (struct fo_state*)ds; struct failover_context *failover = failover_context(pipe); - failover->sw->delete_depth_stencil_state(pipe, state->sw_state); - failover->hw->delete_depth_stencil_state(pipe, state->hw_state); + failover->sw->delete_depth_stencil_alpha_state(pipe, state->sw_state); + failover->hw->delete_depth_stencil_alpha_state(pipe, state->hw_state); state->sw_state = 0; state->hw_state = 0; free(state); @@ -434,18 +395,15 @@ failover_set_vertex_element(struct pipe_context *pipe, void failover_init_state_functions( struct failover_context *failover ) { - failover->pipe.create_alpha_test_state = failover_create_alpha_test_state; - failover->pipe.bind_alpha_test_state = failover_bind_alpha_test_state; - failover->pipe.delete_alpha_test_state = failover_delete_alpha_test_state; failover->pipe.create_blend_state = failover_create_blend_state; failover->pipe.bind_blend_state = failover_bind_blend_state; failover->pipe.delete_blend_state = failover_delete_blend_state; failover->pipe.create_sampler_state = failover_create_sampler_state; failover->pipe.bind_sampler_state = failover_bind_sampler_state; failover->pipe.delete_sampler_state = failover_delete_sampler_state; - failover->pipe.create_depth_stencil_state = failover_create_depth_stencil_state; - failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state; - failover->pipe.delete_depth_stencil_state = failover_delete_depth_stencil_state; + failover->pipe.create_depth_stencil_alpha_state = failover_create_depth_stencil_state; + failover->pipe.bind_depth_stencil_alpha_state = failover_bind_depth_stencil_state; + failover->pipe.delete_depth_stencil_alpha_state = failover_delete_depth_stencil_state; failover->pipe.create_rasterizer_state = failover_create_rasterizer_state; failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state; failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index c99ecd4f8d..c663dd4947 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -55,10 +55,6 @@ failover_state_emit( struct failover_context *failover ) { unsigned i; - if (failover->dirty & FO_NEW_ALPHA_TEST) - failover->sw->bind_alpha_test_state( failover->sw, - failover->alpha_test->sw_state ); - if (failover->dirty & FO_NEW_BLEND) failover->sw->bind_blend_state( failover->sw, failover->blend->sw_state ); @@ -70,8 +66,8 @@ failover_state_emit( struct failover_context *failover ) failover->sw->set_clip_state( failover->sw, &failover->clip ); if (failover->dirty & FO_NEW_DEPTH_STENCIL) - failover->sw->bind_depth_stencil_state( failover->sw, - failover->depth_stencil->sw_state ); + failover->sw->bind_depth_stencil_alpha_state( failover->sw, + failover->depth_stencil->sw_state ); if (failover->dirty & FO_NEW_FRAMEBUFFER) failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer ); diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 80df7f0fba..2f1f036993 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -146,9 +146,6 @@ struct i915_sampler_state { const struct pipe_sampler_state *templ; }; -struct i915_alpha_test_state { - unsigned LIS6; -}; struct i915_texture { struct pipe_texture base; @@ -186,7 +183,6 @@ struct i915_context /* The most recent drawing state as set by the driver: */ - const struct i915_alpha_test_state *alpha_test; const struct i915_blend_state *blend; const struct i915_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct i915_depth_stencil_state *depth_stencil; diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 2a9a587a37..f8332aab37 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -284,13 +284,13 @@ static void i915_delete_sampler_state(struct pipe_context *pipe, static void * i915_create_depth_stencil_state(struct pipe_context *pipe, - const struct pipe_depth_stencil_state *depth_stencil) + const struct pipe_depth_stencil_alpha_state *depth_stencil) { struct i915_depth_stencil_state *cso = CALLOC_STRUCT( i915_depth_stencil_state ); { - int testmask = depth_stencil->stencil.value_mask[0] & 0xff; - int writemask = depth_stencil->stencil.write_mask[0] & 0xff; + int testmask = depth_stencil->stencil[0].value_mask & 0xff; + int writemask = depth_stencil->stencil[0].write_mask & 0xff; cso->stencil_modes4 |= (_3DSTATE_MODES_4_CMD | ENABLE_STENCIL_TEST_MASK | @@ -299,12 +299,12 @@ i915_create_depth_stencil_state(struct pipe_context *pipe, STENCIL_WRITE_MASK(writemask)); } - if (depth_stencil->stencil.front_enabled) { - int test = i915_translate_compare_func(depth_stencil->stencil.front_func); - int fop = i915_translate_stencil_op(depth_stencil->stencil.front_fail_op); - int dfop = i915_translate_stencil_op(depth_stencil->stencil.front_zfail_op); - int dpop = i915_translate_stencil_op(depth_stencil->stencil.front_zpass_op); - int ref = depth_stencil->stencil.ref_value[0] & 0xff; + if (depth_stencil->stencil[0].enabled) { + int test = i915_translate_compare_func(depth_stencil->stencil[0].func); + int fop = i915_translate_stencil_op(depth_stencil->stencil[0].fail_op); + int dfop = i915_translate_stencil_op(depth_stencil->stencil[0].zfail_op); + int dpop = i915_translate_stencil_op(depth_stencil->stencil[0].zpass_op); + int ref = depth_stencil->stencil[0].ref_value & 0xff; cso->stencil_LIS5 |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE | @@ -315,14 +315,14 @@ i915_create_depth_stencil_state(struct pipe_context *pipe, (dpop << S5_STENCIL_PASS_Z_PASS_SHIFT)); } - if (depth_stencil->stencil.back_enabled) { - int test = i915_translate_compare_func(depth_stencil->stencil.back_func); - int fop = i915_translate_stencil_op(depth_stencil->stencil.back_fail_op); - int dfop = i915_translate_stencil_op(depth_stencil->stencil.back_zfail_op); - int dpop = i915_translate_stencil_op(depth_stencil->stencil.back_zpass_op); - int ref = depth_stencil->stencil.ref_value[1] & 0xff; - int tmask = depth_stencil->stencil.value_mask[1] & 0xff; - int wmask = depth_stencil->stencil.write_mask[1] & 0xff; + if (depth_stencil->stencil[1].enabled) { + int test = i915_translate_compare_func(depth_stencil->stencil[1].func); + int fop = i915_translate_stencil_op(depth_stencil->stencil[1].fail_op); + int dfop = i915_translate_stencil_op(depth_stencil->stencil[1].zfail_op); + int dpop = i915_translate_stencil_op(depth_stencil->stencil[1].zpass_op); + int ref = depth_stencil->stencil[1].ref_value & 0xff; + int tmask = depth_stencil->stencil[1].value_mask & 0xff; + int wmask = depth_stencil->stencil[1].write_mask & 0xff; cso->bfo[0] = (_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_FUNCS | @@ -363,6 +363,15 @@ i915_create_depth_stencil_state(struct pipe_context *pipe, cso->depth_LIS6 |= S6_DEPTH_WRITE_ENABLE; } + if (depth_stencil->alpha.enabled) { + int test = i915_translate_compare_func(depth_stencil->alpha.func); + ubyte refByte = float_to_ubyte(depth_stencil->alpha.ref); + + cso->depth_LIS6 |= (S6_ALPHA_TEST_ENABLE | + (test << S6_ALPHA_TEST_FUNC_SHIFT) | + (((unsigned) refByte) << S6_ALPHA_REF_SHIFT)); + } + return cso; } @@ -383,39 +392,6 @@ static void i915_delete_depth_stencil_state(struct pipe_context *pipe, } -static void * -i915_create_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha_test) -{ - struct i915_alpha_test_state *cso = CALLOC_STRUCT( i915_alpha_test_state ); - - if (alpha_test->enabled) { - int test = i915_translate_compare_func(alpha_test->func); - ubyte refByte = float_to_ubyte(alpha_test->ref); - - cso->LIS6 |= (S6_ALPHA_TEST_ENABLE | - (test << S6_ALPHA_TEST_FUNC_SHIFT) | - (((unsigned) refByte) << S6_ALPHA_REF_SHIFT)); - } - return cso; -} - -static void i915_bind_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - struct i915_context *i915 = i915_context(pipe); - - i915->alpha_test = (const struct i915_alpha_test_state*)alpha; - - i915->dirty |= I915_NEW_ALPHA_TEST; -} - -static void i915_delete_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - FREE(alpha); -} - static void i915_set_scissor_state( struct pipe_context *pipe, const struct pipe_scissor_state *scissor ) { @@ -674,10 +650,6 @@ static void i915_set_vertex_element( struct pipe_context *pipe, void i915_init_state_functions( struct i915_context *i915 ) { - i915->pipe.create_alpha_test_state = i915_create_alpha_test_state; - i915->pipe.bind_alpha_test_state = i915_bind_alpha_test_state; - i915->pipe.delete_alpha_test_state = i915_delete_alpha_test_state; - i915->pipe.create_blend_state = i915_create_blend_state; i915->pipe.bind_blend_state = i915_bind_blend_state; i915->pipe.delete_blend_state = i915_delete_blend_state; @@ -686,9 +658,9 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.bind_sampler_state = i915_bind_sampler_state; i915->pipe.delete_sampler_state = i915_delete_sampler_state; - i915->pipe.create_depth_stencil_state = i915_create_depth_stencil_state; - i915->pipe.bind_depth_stencil_state = i915_bind_depth_stencil_state; - i915->pipe.delete_depth_stencil_state = i915_delete_depth_stencil_state; + i915->pipe.create_depth_stencil_alpha_state = i915_create_depth_stencil_state; + i915->pipe.bind_depth_stencil_alpha_state = i915_bind_depth_stencil_state; + i915->pipe.delete_depth_stencil_alpha_state = i915_delete_depth_stencil_state; i915->pipe.create_rasterizer_state = i915_create_rasterizer_state; i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state; diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c index da2402c018..752d25f233 100644 --- a/src/mesa/pipe/i915simple/i915_state_immediate.c +++ b/src/mesa/pipe/i915simple/i915_state_immediate.c @@ -159,10 +159,6 @@ static void upload_S6( struct i915_context *i915 ) unsigned LIS6 = (S6_COLOR_WRITE_ENABLE | (2 << S6_TRISTRIP_PV_SHIFT)); - /* I915_NEW_ALPHA_TEST - */ - LIS6 |= i915->alpha_test->LIS6; - /* I915_NEW_BLEND */ LIS6 |= i915->blend->LIS6; @@ -178,7 +174,7 @@ static void upload_S6( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_S6 = { - I915_NEW_ALPHA_TEST | I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL, + I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL, upload_S6 }; diff --git a/src/mesa/pipe/i965simple/brw_cc.c b/src/mesa/pipe/i965simple/brw_cc.c index 6cc1505311..dcee731895 100644 --- a/src/mesa/pipe/i965simple/brw_cc.c +++ b/src/mesa/pipe/i965simple/brw_cc.c @@ -156,38 +156,37 @@ static void upload_cc_unit( struct brw_context *brw ) memset(&cc, 0, sizeof(cc)); /* BRW_NEW_DEPTH_STENCIL */ - if (brw->attribs.DepthStencil->stencil.front_enabled) { - cc.cc0.stencil_enable = brw->attribs.DepthStencil->stencil.front_enabled; - cc.cc0.stencil_func = brw_translate_compare_func(brw->attribs.DepthStencil->stencil.front_func); - cc.cc0.stencil_fail_op = brw_translate_stencil_op(brw->attribs.DepthStencil->stencil.front_fail_op); + if (brw->attribs.DepthStencil->stencil[0].enabled) { + cc.cc0.stencil_enable = brw->attribs.DepthStencil->stencil[0].enabled; + cc.cc0.stencil_func = brw_translate_compare_func(brw->attribs.DepthStencil->stencil[0].func); + cc.cc0.stencil_fail_op = brw_translate_stencil_op(brw->attribs.DepthStencil->stencil[0].fail_op); cc.cc0.stencil_pass_depth_fail_op = brw_translate_stencil_op( - brw->attribs.DepthStencil->stencil.front_zfail_op); + brw->attribs.DepthStencil->stencil[0].zfail_op); cc.cc0.stencil_pass_depth_pass_op = brw_translate_stencil_op( - brw->attribs.DepthStencil->stencil.front_zpass_op); - cc.cc1.stencil_ref = brw->attribs.DepthStencil->stencil.ref_value[0]; - cc.cc1.stencil_write_mask = brw->attribs.DepthStencil->stencil.write_mask[0]; - cc.cc1.stencil_test_mask = brw->attribs.DepthStencil->stencil.value_mask[0]; + brw->attribs.DepthStencil->stencil[0].zpass_op); + cc.cc1.stencil_ref = brw->attribs.DepthStencil->stencil[0].ref_value; + cc.cc1.stencil_write_mask = brw->attribs.DepthStencil->stencil[0].write_mask; + cc.cc1.stencil_test_mask = brw->attribs.DepthStencil->stencil[0].value_mask; - if (brw->attribs.DepthStencil->stencil.back_enabled) { - cc.cc0.bf_stencil_enable = brw->attribs.DepthStencil->stencil.back_enabled; + if (brw->attribs.DepthStencil->stencil[1].enabled) { + cc.cc0.bf_stencil_enable = brw->attribs.DepthStencil->stencil[1].enabled; cc.cc0.bf_stencil_func = brw_translate_compare_func( - brw->attribs.DepthStencil->stencil.back_func); + brw->attribs.DepthStencil->stencil[1].func); cc.cc0.bf_stencil_fail_op = brw_translate_stencil_op( - brw->attribs.DepthStencil->stencil.back_fail_op); + brw->attribs.DepthStencil->stencil[1].fail_op); cc.cc0.bf_stencil_pass_depth_fail_op = brw_translate_stencil_op( - brw->attribs.DepthStencil->stencil.back_zfail_op); + brw->attribs.DepthStencil->stencil[1].zfail_op); cc.cc0.bf_stencil_pass_depth_pass_op = brw_translate_stencil_op( - brw->attribs.DepthStencil->stencil.back_zpass_op); - cc.cc1.bf_stencil_ref = brw->attribs.DepthStencil->stencil.ref_value[1]; - cc.cc2.bf_stencil_write_mask = brw->attribs.DepthStencil->stencil.write_mask[1]; - cc.cc2.bf_stencil_test_mask = brw->attribs.DepthStencil->stencil.value_mask[1]; + brw->attribs.DepthStencil->stencil[1].zpass_op); + cc.cc1.bf_stencil_ref = brw->attribs.DepthStencil->stencil[1].ref_value; + cc.cc2.bf_stencil_write_mask = brw->attribs.DepthStencil->stencil[1].write_mask; + cc.cc2.bf_stencil_test_mask = brw->attribs.DepthStencil->stencil[1].value_mask; } /* Not really sure about this: */ - if (brw->attribs.DepthStencil->stencil.write_mask[0] || - (brw->attribs.DepthStencil->stencil.back_enabled && - brw->attribs.DepthStencil->stencil.write_mask[1])) + if (brw->attribs.DepthStencil->stencil[0].write_mask || + brw->attribs.DepthStencil->stencil[1].write_mask) cc.cc0.stencil_write_enable = 1; } @@ -228,11 +227,13 @@ static void upload_cc_unit( struct brw_context *brw ) /* BRW_NEW_ALPHATEST */ - if (brw->attribs.AlphaTest->enabled) { + if (brw->attribs.DepthStencil->alpha.enabled) { cc.cc3.alpha_test = 1; - cc.cc3.alpha_test_func = brw_translate_compare_func(brw->attribs.AlphaTest->func); + cc.cc3.alpha_test_func = + brw_translate_compare_func(brw->attribs.DepthStencil->alpha.func); - UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0], brw->attribs.AlphaTest->ref); + UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0], + brw->attribs.DepthStencil->alpha.ref); cc.cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8; } diff --git a/src/mesa/pipe/i965simple/brw_context.h b/src/mesa/pipe/i965simple/brw_context.h index 318c6a7049..11146570be 100644 --- a/src/mesa/pipe/i965simple/brw_context.h +++ b/src/mesa/pipe/i965simple/brw_context.h @@ -479,9 +479,8 @@ struct brw_context struct { - const struct pipe_alpha_test_state *AlphaTest; const struct pipe_blend_state *Blend; - const struct pipe_depth_stencil_state *DepthStencil; + const struct pipe_depth_stencil_alpha_state *DepthStencil; const struct pipe_poly_stipple *PolygonStipple; const struct pipe_rasterizer_state *Raster; const struct pipe_sampler_state *Samplers[PIPE_MAX_SAMPLERS]; diff --git a/src/mesa/pipe/i965simple/brw_state.c b/src/mesa/pipe/i965simple/brw_state.c index 26450ae597..e7f5a27a38 100644 --- a/src/mesa/pipe/i965simple/brw_state.c +++ b/src/mesa/pipe/i965simple/brw_state.c @@ -116,9 +116,9 @@ static void brw_delete_sampler_state(struct pipe_context *pipe, static void * brw_create_depth_stencil_state(struct pipe_context *pipe, - const struct pipe_depth_stencil_state *depth_stencil) + const struct pipe_depth_stencil_alpha_state *depth_stencil) { - DUP( pipe_depth_stencil_state, depth_stencil ); + DUP( pipe_depth_stencil_alpha_state, depth_stencil ); } static void brw_bind_depth_stencil_state(struct pipe_context *pipe, @@ -126,7 +126,7 @@ static void brw_bind_depth_stencil_state(struct pipe_context *pipe, { struct brw_context *brw = brw_context(pipe); - brw->attribs.DepthStencil = (const struct pipe_depth_stencil_state *)depth_stencil; + brw->attribs.DepthStencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil; brw->state.dirty.brw |= BRW_NEW_DEPTH_STENCIL; } @@ -137,32 +137,6 @@ static void brw_delete_depth_stencil_state(struct pipe_context *pipe, free(depth_stencil); } -/************************************************************************ - * Alpha test - */ -static void * -brw_create_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha_test) -{ - DUP(pipe_alpha_test_state, alpha_test); -} - -static void brw_bind_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - struct brw_context *brw = brw_context(pipe); - - brw->attribs.AlphaTest = (const struct pipe_alpha_test_state*)alpha; - - brw->state.dirty.brw |= BRW_NEW_ALPHA_TEST; -} - -static void brw_delete_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - free(alpha); -} - /************************************************************************ * Scissor */ @@ -415,10 +389,6 @@ static void brw_delete_rasterizer_state(struct pipe_context *pipe, void brw_init_state_functions( struct brw_context *brw ) { - brw->pipe.create_alpha_test_state = brw_create_alpha_test_state; - brw->pipe.bind_alpha_test_state = brw_bind_alpha_test_state; - brw->pipe.delete_alpha_test_state = brw_delete_alpha_test_state; - brw->pipe.create_blend_state = brw_create_blend_state; brw->pipe.bind_blend_state = brw_bind_blend_state; brw->pipe.delete_blend_state = brw_delete_blend_state; @@ -427,9 +397,9 @@ brw_init_state_functions( struct brw_context *brw ) brw->pipe.bind_sampler_state = brw_bind_sampler_state; brw->pipe.delete_sampler_state = brw_delete_sampler_state; - brw->pipe.create_depth_stencil_state = brw_create_depth_stencil_state; - brw->pipe.bind_depth_stencil_state = brw_bind_depth_stencil_state; - brw->pipe.delete_depth_stencil_state = brw_delete_depth_stencil_state; + brw->pipe.create_depth_stencil_alpha_state = brw_create_depth_stencil_state; + brw->pipe.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state; + brw->pipe.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state; brw->pipe.create_rasterizer_state = brw_create_rasterizer_state; brw->pipe.bind_rasterizer_state = brw_bind_rasterizer_state; diff --git a/src/mesa/pipe/i965simple/brw_wm.c b/src/mesa/pipe/i965simple/brw_wm.c index f0a38d384b..0ee0fbed51 100644 --- a/src/mesa/pipe/i965simple/brw_wm.c +++ b/src/mesa/pipe/i965simple/brw_wm.c @@ -93,15 +93,14 @@ static void brw_wm_populate_key( struct brw_context *brw, /* Build the index for table lookup */ - /* _NEW_COLOR */ + /* BRW_NEW_DEPTH_STENCIL */ if (fp->UsesKill || - brw->attribs.AlphaTest->enabled) + brw->attribs.DepthStencil->alpha.enabled) lookup |= IZ_PS_KILL_ALPHATEST_BIT; if (fp->ComputesDepth) lookup |= IZ_PS_COMPUTES_DEPTH_BIT; - /* _NEW_DEPTH */ if (brw->attribs.DepthStencil->depth.enabled) lookup |= IZ_DEPTH_TEST_ENABLE_BIT; @@ -109,13 +108,11 @@ static void brw_wm_populate_key( struct brw_context *brw, brw->attribs.DepthStencil->depth.writemask) /* ?? */ lookup |= IZ_DEPTH_WRITE_ENABLE_BIT; - /* _NEW_STENCIL */ - if (brw->attribs.DepthStencil->stencil.front_enabled) { + if (brw->attribs.DepthStencil->stencil[0].enabled) { lookup |= IZ_STENCIL_TEST_ENABLE_BIT; - if (brw->attribs.DepthStencil->stencil.write_mask[0] || - (brw->attribs.DepthStencil->stencil.back_enabled && - brw->attribs.DepthStencil->stencil.write_mask[1])) + if (brw->attribs.DepthStencil->stencil[0].write_mask || + brw->attribs.DepthStencil->stencil[1].write_mask) lookup |= IZ_STENCIL_WRITE_ENABLE_BIT; } diff --git a/src/mesa/pipe/i965simple/brw_wm_state.c b/src/mesa/pipe/i965simple/brw_wm_state.c index 52d2c85423..5ccd488842 100644 --- a/src/mesa/pipe/i965simple/brw_wm_state.c +++ b/src/mesa/pipe/i965simple/brw_wm_state.c @@ -122,7 +122,7 @@ static void upload_wm_unit(struct brw_context *brw ) /* BRW_NEW_ALPHA_TEST */ if (fp->UsesKill || - brw->attribs.AlphaTest->enabled) + brw->attribs.DepthStencil->alpha.enabled) wm.wm5.program_uses_killpixel = 1; wm.wm5.enable_8_pix = 1; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 92ca7dd8e3..1afb38a868 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -102,11 +102,6 @@ struct pipe_context { /* * State functions */ - void * (*create_alpha_test_state)(struct pipe_context *, - const struct pipe_alpha_test_state *); - void (*bind_alpha_test_state)(struct pipe_context *, void *); - void (*delete_alpha_test_state)(struct pipe_context *, void *); - void * (*create_blend_state)(struct pipe_context *, const struct pipe_blend_state *); void (*bind_blend_state)(struct pipe_context *, void *); @@ -122,10 +117,10 @@ struct pipe_context { void (*bind_rasterizer_state)(struct pipe_context *, void *); void (*delete_rasterizer_state)(struct pipe_context *, void *); - void * (*create_depth_stencil_state)(struct pipe_context *, - const struct pipe_depth_stencil_state *); - void (*bind_depth_stencil_state)(struct pipe_context *, void *); - void (*delete_depth_stencil_state)(struct pipe_context *, void *); + void * (*create_depth_stencil_alpha_state)(struct pipe_context *, + const struct pipe_depth_stencil_alpha_state *); + void (*bind_depth_stencil_alpha_state)(struct pipe_context *, void *); + void (*delete_depth_stencil_alpha_state)(struct pipe_context *, void *); void * (*create_fs_state)(struct pipe_context *, const struct pipe_shader_state *); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index af65d365bf..b7793c6d31 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -147,7 +147,7 @@ struct pipe_shader_state { ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; }; -struct pipe_depth_stencil_state +struct pipe_depth_stencil_alpha_state { struct { unsigned enabled:1; /**< depth test enabled? */ @@ -156,28 +156,24 @@ struct pipe_depth_stencil_state unsigned occlusion_count:1; /**< XXX move this elsewhere? */ } depth; struct { - unsigned front_enabled:1; - unsigned front_func:3; /**< PIPE_FUNC_x */ - unsigned front_fail_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned front_zpass_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned front_zfail_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned back_enabled:1; - unsigned back_func:3; /**< PIPE_FUNC_x */ - unsigned back_fail_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned back_zpass_op:3; /**< PIPE_STENCIL_OP_x */ - unsigned back_zfail_op:3; /**< PIPE_STENCIL_OP_x */ - ubyte ref_value[2]; /**< [0] = front, [1] = back */ - ubyte value_mask[2]; - ubyte write_mask[2]; - } stencil; -}; + unsigned enabled:1; + unsigned func:3; /**< PIPE_FUNC_x */ + unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */ + ubyte ref_value; + ubyte value_mask; + ubyte write_mask; + } stencil[2]; /**< [0] = front, [1] = back */ -struct pipe_alpha_test_state { - unsigned enabled:1; - unsigned func:3; /**< PIPE_FUNC_x */ - float ref; /**< reference value */ + struct { + unsigned enabled:1; + unsigned func:3; /**< PIPE_FUNC_x */ + float ref; /**< reference value */ + } alpha; }; + struct pipe_blend_state { unsigned blend_enable:1; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index b62e691e87..b6995b8a6c 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -240,10 +240,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.get_paramf = softpipe_get_paramf; /* state setters */ - softpipe->pipe.create_alpha_test_state = softpipe_create_alpha_test_state; - softpipe->pipe.bind_alpha_test_state = softpipe_bind_alpha_test_state; - softpipe->pipe.delete_alpha_test_state = softpipe_delete_alpha_test_state; - softpipe->pipe.create_blend_state = softpipe_create_blend_state; softpipe->pipe.bind_blend_state = softpipe_bind_blend_state; softpipe->pipe.delete_blend_state = softpipe_delete_blend_state; @@ -252,9 +248,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state; softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state; - softpipe->pipe.create_depth_stencil_state = softpipe_create_depth_stencil_state; - softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state; - softpipe->pipe.delete_depth_stencil_state = softpipe_delete_depth_stencil_state; + softpipe->pipe.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state; + softpipe->pipe.bind_depth_stencil_alpha_state = softpipe_bind_depth_stencil_state; + softpipe->pipe.delete_depth_stencil_alpha_state = softpipe_delete_depth_stencil_state; softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state; softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 8fd44933f2..8f14dd11d1 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -53,13 +53,13 @@ struct softpipe_tile_cache; #define SP_NEW_SCISSOR 0x20 #define SP_NEW_STIPPLE 0x40 #define SP_NEW_FRAMEBUFFER 0x80 -#define SP_NEW_ALPHA_TEST 0x100 -#define SP_NEW_DEPTH_STENCIL 0x200 +#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100 +#define SP_NEW_CONSTANTS 0x200 #define SP_NEW_SAMPLER 0x400 #define SP_NEW_TEXTURE 0x800 #define SP_NEW_VERTEX 0x1000 #define SP_NEW_VS 0x2000 -#define SP_NEW_CONSTANTS 0x4000 +#define SP_NEW_QUERY 0x4000 struct sp_vertex_shader_state { struct pipe_shader_state *state; @@ -73,10 +73,9 @@ struct softpipe_context { /* The most recent drawing state as set by the driver: */ - const struct pipe_alpha_test_state *alpha_test; const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; - const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_depth_stencil_alpha_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; const struct sp_fragment_shader_state *fs; const struct sp_vertex_shader_state *vs; diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index 6330465a8b..a10c9c3e02 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -43,8 +43,8 @@ static void sp_build_depth_stencil( struct softpipe_context *sp ) { - if (sp->depth_stencil->stencil.front_enabled || - sp->depth_stencil->stencil.back_enabled) { + if (sp->depth_stencil->stencil[0].enabled || + sp->depth_stencil->stencil[1].enabled) { sp_push_quad_first( sp, sp->quad.stencil_test ); } else if (sp->depth_stencil->depth.enabled && @@ -59,7 +59,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp) boolean early_depth_test = sp->depth_stencil->depth.enabled && sp->framebuffer.zbuf && - !sp->alpha_test->enabled && + !sp->depth_stencil->alpha.enabled && sp->fs->shader.output_semantic_name[0] != TGSI_SEMANTIC_POSITION; /* build up the pipeline in reverse order... */ @@ -98,7 +98,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp_build_depth_stencil( sp ); } - if (sp->alpha_test->enabled) { + if (sp->depth_stencil->alpha.enabled) { sp_push_quad_first( sp, sp->quad.alpha_test ); } diff --git a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c index d056abe98d..4ffeac35e1 100644 --- a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c +++ b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c @@ -14,11 +14,11 @@ static void alpha_test_quad(struct quad_stage *qs, struct quad_header *quad) { struct softpipe_context *softpipe = qs->softpipe; - const float ref = softpipe->alpha_test->ref; + const float ref = softpipe->depth_stencil->alpha.ref; unsigned passMask = 0x0, j; const float *aaaa = quad->outputs.color[3]; - switch (softpipe->alpha_test->func) { + switch (softpipe->depth_stencil->alpha.func) { case PIPE_FUNC_NEVER: quad->mask = 0x0; break; diff --git a/src/mesa/pipe/softpipe/sp_quad_stencil.c b/src/mesa/pipe/softpipe/sp_quad_stencil.c index 3f3eca078b..a688a06c74 100644 --- a/src/mesa/pipe/softpipe/sp_quad_stencil.c +++ b/src/mesa/pipe/softpipe/sp_quad_stencil.c @@ -211,24 +211,13 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad) /* choose front or back face function, operator, etc */ /* XXX we could do these initializations once per primitive */ - if (softpipe->depth_stencil->stencil.back_enabled && quad->facing) { - func = softpipe->depth_stencil->stencil.back_func; - failOp = softpipe->depth_stencil->stencil.back_fail_op; - zFailOp = softpipe->depth_stencil->stencil.back_zfail_op; - zPassOp = softpipe->depth_stencil->stencil.back_zpass_op; - ref = softpipe->depth_stencil->stencil.ref_value[1]; - wrtMask = softpipe->depth_stencil->stencil.write_mask[1]; - valMask = softpipe->depth_stencil->stencil.value_mask[1]; - } - else { - func = softpipe->depth_stencil->stencil.front_func; - failOp = softpipe->depth_stencil->stencil.front_fail_op; - zFailOp = softpipe->depth_stencil->stencil.front_zfail_op; - zPassOp = softpipe->depth_stencil->stencil.front_zpass_op; - ref = softpipe->depth_stencil->stencil.ref_value[0]; - wrtMask = softpipe->depth_stencil->stencil.write_mask[0]; - valMask = softpipe->depth_stencil->stencil.value_mask[0]; - } + func = softpipe->depth_stencil->stencil[quad->facing].func; + failOp = softpipe->depth_stencil->stencil[quad->facing].fail_op; + zFailOp = softpipe->depth_stencil->stencil[quad->facing].zfail_op; + zPassOp = softpipe->depth_stencil->stencil[quad->facing].zpass_op; + ref = softpipe->depth_stencil->stencil[quad->facing].ref_value; + wrtMask = softpipe->depth_stencil->stencil[quad->facing].write_mask; + valMask = softpipe->depth_stencil->stencil[quad->facing].value_mask; assert(ps); /* shouldn't get here if there's no stencil buffer */ diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index a3bd078a71..76b79b5280 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -52,13 +52,6 @@ struct sp_fragment_shader_state { #endif }; -void * -softpipe_create_alpha_test_state(struct pipe_context *, - const struct pipe_alpha_test_state *); -void -softpipe_bind_alpha_test_state(struct pipe_context *, void *); -void -softpipe_delete_alpha_test_state(struct pipe_context *, void *); void * softpipe_create_blend_state(struct pipe_context *, @@ -76,7 +69,7 @@ void softpipe_delete_sampler_state(struct pipe_context *, void *); void * softpipe_create_depth_stencil_state(struct pipe_context *, - const struct pipe_depth_stencil_state *); + const struct pipe_depth_stencil_alpha_state *); void softpipe_bind_depth_stencil_state(struct pipe_context *, void *); void softpipe_delete_depth_stencil_state(struct pipe_context *, void *); diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c index 5ceec2513f..160ca5cbc0 100644 --- a/src/mesa/pipe/softpipe/sp_state_blend.c +++ b/src/mesa/pipe/softpipe/sp_state_blend.c @@ -73,40 +73,14 @@ void softpipe_set_blend_color( struct pipe_context *pipe, * into one file. */ -void * -softpipe_create_alpha_test_state(struct pipe_context *pipe, - const struct pipe_alpha_test_state *alpha) -{ - struct pipe_alpha_test_state *state = MALLOC( sizeof(struct pipe_alpha_test_state) ); - memcpy(state, alpha, sizeof(struct pipe_alpha_test_state)); - return state; -} - -void -softpipe_bind_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - - softpipe->alpha_test = (const struct pipe_alpha_test_state *)alpha; - - softpipe->dirty |= SP_NEW_ALPHA_TEST; -} - -void -softpipe_delete_alpha_test_state(struct pipe_context *pipe, - void *alpha) -{ - FREE( alpha ); -} void * softpipe_create_depth_stencil_state(struct pipe_context *pipe, - const struct pipe_depth_stencil_state *depth_stencil) + const struct pipe_depth_stencil_alpha_state *depth_stencil) { - struct pipe_depth_stencil_state *state = - MALLOC( sizeof(struct pipe_depth_stencil_state) ); - memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_state)); + struct pipe_depth_stencil_alpha_state *state = + MALLOC( sizeof(struct pipe_depth_stencil_alpha_state) ); + memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_alpha_state)); return state; } @@ -116,9 +90,9 @@ softpipe_bind_depth_stencil_state(struct pipe_context *pipe, { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil; + softpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil; - softpipe->dirty |= SP_NEW_DEPTH_STENCIL; + softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA; } void diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 736ac1c33b..94072a2d30 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -201,16 +201,16 @@ void softpipe_update_derived( struct softpipe_context *softpipe ) calculate_vertex_layout( softpipe ); if (softpipe->dirty & (SP_NEW_SCISSOR | - SP_NEW_DEPTH_STENCIL | + SP_NEW_DEPTH_STENCIL_ALPHA | SP_NEW_FRAMEBUFFER)) compute_cliprect(softpipe); if (softpipe->dirty & (SP_NEW_BLEND | - SP_NEW_DEPTH_STENCIL | - SP_NEW_ALPHA_TEST | + SP_NEW_DEPTH_STENCIL_ALPHA | SP_NEW_FRAMEBUFFER | SP_NEW_RASTERIZER | - SP_NEW_FS)) + SP_NEW_FS | + SP_NEW_QUERY)) sp_build_quad_pipeline(softpipe); softpipe->dirty = 0; diff --git a/src/mesa/sources b/src/mesa/sources index 5d29d20aed..56ea6dbce2 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -201,7 +201,6 @@ PIPEUTIL_SOURCES = \ STATETRACKER_SOURCES = \ state_tracker/st_atom.c \ - state_tracker/st_atom_alphatest.c \ state_tracker/st_atom_blend.c \ state_tracker/st_atom_clip.c \ state_tracker/st_atom_constbuf.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index bde81edd8c..0e22a2fa6e 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -45,7 +45,7 @@ static const struct st_tracked_state *atoms[] = { &st_update_framebuffer, - &st_update_depth_stencil, + &st_update_depth_stencil_alpha, &st_update_clip, &st_update_shader, @@ -59,7 +59,6 @@ static const struct st_tracked_state *atoms[] = &st_update_texture, &st_update_vs_constants, &st_update_fs_constants, - &st_update_alpha_test, &st_update_pixel_transfer }; diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 0114f42ba5..3a63e2dec0 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -46,7 +46,7 @@ void st_validate_state( struct st_context *st ); const struct st_tracked_state st_update_framebuffer; const struct st_tracked_state st_update_clip; -const struct st_tracked_state st_update_depth_stencil; +const struct st_tracked_state st_update_depth_stencil_alpha; const struct st_tracked_state st_update_shader; const struct st_tracked_state st_update_rasterizer; const struct st_tracked_state st_update_polygon_stipple; @@ -57,7 +57,6 @@ const struct st_tracked_state st_update_sampler; const struct st_tracked_state st_update_texture; const struct st_tracked_state st_update_fs_constants; const struct st_tracked_state st_update_vs_constants; -const struct st_tracked_state st_update_alpha_test; const struct st_tracked_state st_update_pixel_transfer; diff --git a/src/mesa/state_tracker/st_atom_alphatest.c b/src/mesa/state_tracker/st_atom_alphatest.c deleted file mode 100644 index 873520ab02..0000000000 --- a/src/mesa/state_tracker/st_atom_alphatest.c +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - - /* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - -#include "st_context.h" -#include "st_cache.h" -#include "st_atom.h" -#include "pipe/p_context.h" -#include "pipe/p_defines.h" - - -/** - * Convert GLenum stencil func tokens to pipe tokens. - */ -static GLuint -gl_alpha_func_to_sp(GLenum func) -{ - /* Same values, just biased */ - assert(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER); - assert(PIPE_FUNC_LESS == GL_LESS - GL_NEVER); - assert(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER); - assert(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER); - assert(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER); - assert(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER); - assert(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER); - assert(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER); - assert(func >= GL_NEVER); - assert(func <= GL_ALWAYS); - return func - GL_NEVER; -} - - -static void -update_alpha_test( struct st_context *st ) -{ - struct pipe_alpha_test_state alpha; - const struct cso_alpha_test *cso; - - memset(&alpha, 0, sizeof(alpha)); - - if (st->ctx->Color.AlphaEnabled) { - alpha.enabled = 1; - alpha.func = gl_alpha_func_to_sp(st->ctx->Color.AlphaFunc); - alpha.ref = st->ctx->Color.AlphaRef; - } - cso = st_cached_alpha_test_state(st, &alpha); - if (st->state.alpha_test != cso) { - /* state has changed */ - st->state.alpha_test = cso; - st->pipe->bind_alpha_test_state(st->pipe, cso->data); /* bind new state */ - } -} - - -const struct st_tracked_state st_update_alpha_test = { - .name = "st_update_alpha_test", - .dirty = { - .mesa = (_NEW_COLOR), - .st = 0, - }, - .update = update_alpha_test -}; diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index e785434cec..7aecdbfbcc 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -91,10 +91,10 @@ gl_stencil_op_to_pipe(GLenum func) } static void -update_depth_stencil(struct st_context *st) +update_depth_stencil_alpha(struct st_context *st) { - struct pipe_depth_stencil_state depth_stencil; - const struct cso_depth_stencil *cso; + struct pipe_depth_stencil_alpha_state depth_stencil; + const struct cso_depth_stencil_alpha *cso; memset(&depth_stencil, 0, sizeof(depth_stencil)); @@ -107,40 +107,47 @@ update_depth_stencil(struct st_context *st) depth_stencil.depth.occlusion_count = 1; if (st->ctx->Stencil.Enabled) { - depth_stencil.stencil.front_enabled = 1; - depth_stencil.stencil.front_func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]); - depth_stencil.stencil.front_fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]); - depth_stencil.stencil.front_zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]); - depth_stencil.stencil.front_zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]); - depth_stencil.stencil.ref_value[0] = st->ctx->Stencil.Ref[0] & 0xff; - depth_stencil.stencil.value_mask[0] = st->ctx->Stencil.ValueMask[0] & 0xff; - depth_stencil.stencil.write_mask[0] = st->ctx->Stencil.WriteMask[0] & 0xff; + depth_stencil.stencil[0].enabled = 1; + depth_stencil.stencil[0].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]); + depth_stencil.stencil[0].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]); + depth_stencil.stencil[0].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]); + depth_stencil.stencil[0].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]); + depth_stencil.stencil[0].ref_value = st->ctx->Stencil.Ref[0] & 0xff; + depth_stencil.stencil[0].value_mask = st->ctx->Stencil.ValueMask[0] & 0xff; + depth_stencil.stencil[0].write_mask = st->ctx->Stencil.WriteMask[0] & 0xff; + if (st->ctx->Stencil.TestTwoSide) { - depth_stencil.stencil.back_enabled = 1; - depth_stencil.stencil.back_func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]); - depth_stencil.stencil.back_fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]); - depth_stencil.stencil.back_zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]); - depth_stencil.stencil.back_zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]); - depth_stencil.stencil.ref_value[1] = st->ctx->Stencil.Ref[1] & 0xff; - depth_stencil.stencil.value_mask[1] = st->ctx->Stencil.ValueMask[1] & 0xff; - depth_stencil.stencil.write_mask[1] = st->ctx->Stencil.WriteMask[1] & 0xff; + depth_stencil.stencil[1].enabled = 1; + depth_stencil.stencil[1].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]); + depth_stencil.stencil[1].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]); + depth_stencil.stencil[1].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]); + depth_stencil.stencil[1].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]); + depth_stencil.stencil[1].ref_value = st->ctx->Stencil.Ref[1] & 0xff; + depth_stencil.stencil[1].value_mask = st->ctx->Stencil.ValueMask[1] & 0xff; + depth_stencil.stencil[1].write_mask = st->ctx->Stencil.WriteMask[1] & 0xff; } } - cso = st_cached_depth_stencil_state(st, &depth_stencil); + if (st->ctx->Color.AlphaEnabled) { + depth_stencil.alpha.enabled = 1; + depth_stencil.alpha.func = st_compare_func_to_pipe(st->ctx->Color.AlphaFunc); + depth_stencil.alpha.ref = st->ctx->Color.AlphaRef; + } + + cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil); if (st->state.depth_stencil != cso) { /* state has changed */ st->state.depth_stencil = cso; - st->pipe->bind_depth_stencil_state(st->pipe, cso->data); /* bind new state */ + st->pipe->bind_depth_stencil_alpha_state(st->pipe, cso->data); /* bind new state */ } } -const struct st_tracked_state st_update_depth_stencil = { +const struct st_tracked_state st_update_depth_stencil_alpha = { .name = "st_update_depth_stencil", .dirty = { - .mesa = (_NEW_DEPTH|_NEW_STENCIL), + .mesa = (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR), .st = 0, }, - .update = update_depth_stencil + .update = update_depth_stencil_alpha }; diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index c0f712ba1d..e0965b217a 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -87,24 +87,25 @@ st_cached_sampler_state(struct st_context *st, return (struct cso_sampler*)(cso_hash_iter_data(iter)); } -const struct cso_depth_stencil * -st_cached_depth_stencil_state(struct st_context *st, - const struct pipe_depth_stencil_state *templ) +const struct cso_depth_stencil_alpha * +st_cached_depth_stencil_alpha_state(struct st_context *st, + const struct pipe_depth_stencil_alpha_state *templ) { unsigned hash_key = cso_construct_key((void*)templ, - sizeof(struct pipe_depth_stencil_state)); + sizeof(struct pipe_depth_stencil_alpha_state)); struct cso_hash_iter iter = cso_find_state_template(st->cache, - hash_key, CSO_DEPTH_STENCIL, + hash_key, + CSO_DEPTH_STENCIL_ALPHA, (void*)templ); if (cso_hash_iter_is_null(iter)) { - struct cso_depth_stencil *cso = malloc(sizeof(struct cso_depth_stencil)); - memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_state)); - cso->data = st->pipe->create_depth_stencil_state(st->pipe, &cso->state); + struct cso_depth_stencil_alpha *cso = malloc(sizeof(struct cso_depth_stencil_alpha)); + memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_alpha_state)); + cso->data = st->pipe->create_depth_stencil_alpha_state(st->pipe, &cso->state); if (!cso->data) cso->data = &cso->state; - iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL, cso); + iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL_ALPHA, cso); } - return (struct cso_depth_stencil*)(cso_hash_iter_data(iter)); + return (struct cso_depth_stencil_alpha*)(cso_hash_iter_data(iter)); } const struct cso_rasterizer* st_cached_rasterizer_state( @@ -167,22 +168,3 @@ st_cached_vs_state(struct st_context *st, return (struct cso_vertex_shader*)(cso_hash_iter_data(iter)); } -const struct cso_alpha_test * -st_cached_alpha_test_state(struct st_context *st, - const struct pipe_alpha_test_state *templ) -{ - unsigned hash_key = cso_construct_key((void*)templ, - sizeof(struct pipe_alpha_test_state)); - struct cso_hash_iter iter = cso_find_state_template(st->cache, - hash_key, CSO_ALPHA_TEST, - (void*)templ); - if (cso_hash_iter_is_null(iter)) { - struct cso_alpha_test *cso = malloc(sizeof(struct cso_alpha_test)); - memcpy(&cso->state, templ, sizeof(struct pipe_alpha_test_state)); - cso->data = st->pipe->create_alpha_test_state(st->pipe, &cso->state); - if (!cso->data) - cso->data = &cso->state; - iter = cso_insert_state(st->cache, hash_key, CSO_ALPHA_TEST, cso); - } - return ((struct cso_alpha_test *)cso_hash_iter_data(iter)); -} diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index 422f668c56..e0c176b0ff 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -39,9 +39,6 @@ struct pipe_blend_state; struct pipe_sampler_state; struct st_context; -const struct cso_alpha_test * -st_cached_alpha_test_state(struct st_context *st, - const struct pipe_alpha_test_state *alpha); const struct cso_blend * st_cached_blend_state(struct st_context *st, @@ -51,9 +48,9 @@ const struct cso_sampler * st_cached_sampler_state(struct st_context *st, const struct pipe_sampler_state *sampler); -const struct cso_depth_stencil * -st_cached_depth_stencil_state(struct st_context *st, - const struct pipe_depth_stencil_state *depth_stencil); +const struct cso_depth_stencil_alpha * +st_cached_depth_stencil_alpha_state(struct st_context *st, + const struct pipe_depth_stencil_alpha_state *depth_stencil); const struct cso_rasterizer * st_cached_rasterizer_state(struct st_context *st, diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index b4b2429a2a..40319f4b4b 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -272,14 +272,6 @@ clear_with_quad(GLcontext *ctx, const GLfloat x1 = ctx->DrawBuffer->_Xmax; const GLfloat y1 = ctx->DrawBuffer->_Ymax; - /* alpha state: disabled */ - { - struct pipe_alpha_test_state alpha_test; - const struct cso_alpha_test *cso; - memset(&alpha_test, 0, sizeof(alpha_test)); - cso = st_cached_alpha_test_state(st, &alpha_test); - pipe->bind_alpha_test_state(pipe, cso->data); - } /* blend state: RGBA masking */ { @@ -304,8 +296,8 @@ clear_with_quad(GLcontext *ctx, /* depth_stencil state: always pass/set to ref value */ { - struct pipe_depth_stencil_state depth_stencil; - const struct cso_depth_stencil *cso; + struct pipe_depth_stencil_alpha_state depth_stencil; + const struct cso_depth_stencil_alpha *cso; memset(&depth_stencil, 0, sizeof(depth_stencil)); if (depth) { depth_stencil.depth.enabled = 1; @@ -314,17 +306,17 @@ clear_with_quad(GLcontext *ctx, } if (stencil) { - depth_stencil.stencil.front_enabled = 1; - depth_stencil.stencil.front_func = PIPE_FUNC_ALWAYS; - depth_stencil.stencil.front_fail_op = PIPE_STENCIL_OP_REPLACE; - depth_stencil.stencil.front_zpass_op = PIPE_STENCIL_OP_REPLACE; - depth_stencil.stencil.front_zfail_op = PIPE_STENCIL_OP_REPLACE; - depth_stencil.stencil.ref_value[0] = ctx->Stencil.Clear; - depth_stencil.stencil.value_mask[0] = 0xff; - depth_stencil.stencil.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff; + depth_stencil.stencil[0].enabled = 1; + depth_stencil.stencil[0].func = PIPE_FUNC_ALWAYS; + depth_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE; + depth_stencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE; + depth_stencil.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE; + depth_stencil.stencil[0].ref_value = ctx->Stencil.Clear; + depth_stencil.stencil[0].value_mask = 0xff; + depth_stencil.stencil[0].write_mask = ctx->Stencil.WriteMask[0] & 0xff; } - cso = st_cached_depth_stencil_state(st, &depth_stencil); - pipe->bind_depth_stencil_state(pipe, cso->data); + cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil); + pipe->bind_depth_stencil_alpha_state(pipe, cso->data); } /* rasterizer state: nothing */ @@ -381,9 +373,8 @@ clear_with_quad(GLcontext *ctx, draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); /* Restore pipe state */ - pipe->bind_alpha_test_state(pipe, st->state.alpha_test->data); pipe->bind_blend_state(pipe, st->state.blend->data); - pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil->data); + pipe->bind_depth_stencil_alpha_state(pipe, st->state.depth_stencil->data); pipe->bind_fs_state(pipe, st->state.fs->data); pipe->bind_vs_state(pipe, st->state.vs->data); pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 0bc48b7039..e70a5b49e1 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -789,7 +789,7 @@ compatible_formats(GLenum format, GLenum type, enum pipe_format pipeFormat) static GLboolean any_fragment_ops(const struct st_context *st) { - if (st->state.alpha_test->state.enabled || + if (st->state.depth_stencil->state.alpha.enabled || st->state.blend->state.blend_enable || st->state.blend->state.logicop_enable || st->state.depth_stencil->state.depth.enabled) diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 87646b3c71..c3919d474c 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -97,7 +97,7 @@ struct st_context const struct cso_alpha_test *alpha_test; const struct cso_blend *blend; const struct cso_sampler *sampler[PIPE_MAX_SAMPLERS]; - const struct cso_depth_stencil *depth_stencil; + const struct cso_depth_stencil_alpha *depth_stencil; const struct cso_rasterizer *rasterizer; const struct cso_fragment_shader *fs; const struct cso_vertex_shader *vs; -- cgit v1.2.3 From c62b197b528293abb56b099503344e3cdd7d6c40 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 28 Mar 2008 14:53:47 -0600 Subject: gallium: implement a glBitmap cache The bitmap cache attempts to accumulate a series of glBitmap calls in a buffer to effectively render a whole bunch of bitmaps at once. The cache can be disabled, if needed, by setting UseBitmapCache=GL_FALSE. --- src/mesa/state_tracker/st_atom.c | 3 + src/mesa/state_tracker/st_cb_bitmap.c | 234 ++++++++++++++++++++++++++++++++-- src/mesa/state_tracker/st_cb_bitmap.h | 5 + src/mesa/state_tracker/st_cb_flush.c | 3 + src/mesa/state_tracker/st_context.c | 1 + src/mesa/state_tracker/st_context.h | 2 + 6 files changed, 236 insertions(+), 12 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 0e22a2fa6e..40e4142631 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -32,6 +32,7 @@ #include "pipe/p_defines.h" #include "st_context.h" #include "st_atom.h" +#include "st_cb_bitmap.h" #include "st_program.h" @@ -147,6 +148,8 @@ void st_validate_state( struct st_context *st ) struct st_state_flags *state = &st->dirty; GLuint i; + st_flush_bitmap_cache(st); + check_program_state( st ); if (state->st == 0) diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 64b1882424..e46dcbf661 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -59,6 +59,31 @@ +/** + * The bitmap cache attempts to accumulate multiple glBitmap calls in a + * buffer which is then rendered en mass upon a flush, state change, etc. + * A wide, short buffer is used to target the common case of a series + * of glBitmap calls being used to draw text. + */ +static GLboolean UseBitmapCache = 0*GL_TRUE; + + +#define BITMAP_CACHE_WIDTH 512 +#define BITMAP_CACHE_HEIGHT 32 + +struct bitmap_cache +{ + /** An I8 texture image: */ + GLubyte buffer[BITMAP_CACHE_HEIGHT][BITMAP_CACHE_WIDTH]; + GLboolean empty; + /** Window pos to render the cached image */ + GLint xpos, ypos; + struct pipe_texture *texture; +}; + + + + /** * Make fragment program for glBitmap: * Sample the texture and kill the fragment if the bit is 0. @@ -390,16 +415,18 @@ setup_bitmap_vertex_data(struct st_context *st, static void draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, GLsizei width, GLsizei height, - struct pipe_texture *pt, - struct st_fragment_program *stfp) + struct pipe_texture *pt) { struct st_context *st = ctx->st; struct pipe_context *pipe = ctx->st->pipe; struct cso_context *cso = ctx->st->cso_context; + struct st_fragment_program *stfp; GLuint maxSize; + stfp = combined_bitmap_fragment_program(ctx); + /* limit checks */ - /* XXX if DrawPixels image is larger than max texture size, break + /* XXX if the bitmap is larger than the max texture size, break * it up into chunks. */ maxSize = 1 << (pipe->screen->get_param(pipe->screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1); @@ -467,18 +494,185 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, +static void +init_bitmap_cache(struct st_context *st) +{ + struct pipe_context *pipe = st->pipe; + struct pipe_screen *screen = pipe->screen; + enum pipe_format format; + + st->bitmap.cache = CALLOC_STRUCT(bitmap_cache); + if (!st->bitmap.cache) + return; + + /* find a usable texture format */ + if (screen->is_format_supported(screen, PIPE_FORMAT_U_I8, PIPE_TEXTURE)) { + format = PIPE_FORMAT_U_I8; + } + else { + /* XXX support more formats */ + assert(0); + } + + st->bitmap.cache->texture + = st_texture_create(st, PIPE_TEXTURE_2D, format, 0, + BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, 1, 0); + if (!st->bitmap.cache->texture) { + FREE(st->bitmap.cache); + st->bitmap.cache = NULL; + return; + } + + st->bitmap.cache->empty = GL_TRUE; +} + + +/** + * If there's anything in the bitmap cache, draw/flush it now. + */ +void +st_flush_bitmap_cache(struct st_context *st) +{ + if (!st->bitmap.cache->empty) { + struct pipe_context *pipe = st->pipe; + struct pipe_screen *screen = pipe->screen; + struct pipe_surface *surf; + void *dest; + + /* update the texture map image */ + surf = screen->get_tex_surface(screen, st->bitmap.cache->texture, 0, 0, 0); + dest = pipe_surface_map(surf); + memcpy(dest, st->bitmap.cache->buffer, sizeof(st->bitmap.cache->buffer)); + pipe_surface_unmap(surf); + pipe_surface_reference(&surf, NULL); + + pipe->texture_update(pipe, st->bitmap.cache->texture, 0, 0x1); + + draw_bitmap_quad(st->ctx, + st->bitmap.cache->xpos, + st->bitmap.cache->ypos, + st->ctx->Current.RasterPos[2], + BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, + st->bitmap.cache->texture); + + memset(st->bitmap.cache->buffer, 0, sizeof(st->bitmap.cache->buffer)); + st->bitmap.cache->empty = GL_TRUE; + } +} + + +/** + * Try to accumulate this glBitmap call in the bitmap cache. + * \return GL_TRUE for success, GL_FALSE if bitmap is too large, etc. + */ +static GLboolean +accum_bitmap(struct st_context *st, + GLint x, GLint y, GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap ) +{ + int row, col; + int px = -999, py; + + if (width > BITMAP_CACHE_WIDTH || + height > BITMAP_CACHE_HEIGHT) + return GL_FALSE; /* too big to cache */ + + if (!st->bitmap.cache->empty) { + px = x - st->bitmap.cache->xpos; /* pos in buffer */ + py = y - st->bitmap.cache->ypos; + if (px < 0 || px + width > BITMAP_CACHE_WIDTH || + py < 0 || py + height > BITMAP_CACHE_HEIGHT) { + /* This bitmap would extend beyond cache bounds, + * so flush and continue. + */ + st_flush_bitmap_cache(st); + } + } + + if (st->bitmap.cache->empty) { + /* Initialize. Center bitmap vertically in the buffer. */ + px = 0; + py = (BITMAP_CACHE_HEIGHT - height) / 2; + st->bitmap.cache->xpos = x; + st->bitmap.cache->ypos = y - py; + st->bitmap.cache->empty = GL_FALSE; + } + + assert(px != -999); + + /* XXX try to combine this code with code in make_bitmap_texture() */ +#define SET_PIXEL(COL, ROW) \ + st->bitmap.cache->buffer[py + (ROW)][px + (COL)] = 0xff; + + for (row = 0; row < height; row++) { + const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack, + bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); + + if (unpack->LsbFirst) { + /* Lsb first */ + GLubyte mask = 1U << (unpack->SkipPixels & 0x7); + for (col = 0; col < width; col++) { + + if (*src & mask) { + SET_PIXEL(col, row); + } + + if (mask == 128U) { + src++; + mask = 1U; + } + else { + mask = mask << 1; + } + } + + /* get ready for next row */ + if (mask != 1) + src++; + } + else { + /* Msb first */ + GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); + for (col = 0; col < width; col++) { + + if (*src & mask) { + SET_PIXEL(col, row); + } + + if (mask == 1U) { + src++; + mask = 128U; + } + else { + mask = mask >> 1; + } + } + + /* get ready for next row */ + if (mask != 128) + src++; + } + + } /* row */ + + return GL_TRUE; /* accumulated */ +} + + + +/** + * Called via ctx->Driver.Bitmap() + */ static void st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { - struct st_fragment_program *stfp; struct st_context *st = ctx->st; struct pipe_texture *pt; st_validate_state(st); - stfp = combined_bitmap_fragment_program(ctx); - if (!st->bitmap.vs) { /* create pass-through vertex shader now */ const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, @@ -491,26 +685,36 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, &st->bitmap.vert_shader); } - st_validate_state(st); + if (UseBitmapCache && accum_bitmap(st, x, y, width, height, unpack, bitmap)) + return; pt = make_bitmap_texture(ctx, width, height, unpack, bitmap); if (pt) { assert(pt->target == PIPE_TEXTURE_2D); draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2], - width, height, - pt, stfp); + width, height, pt); pipe_texture_reference(&pt, NULL); } } - -void st_init_bitmap_functions(struct dd_function_table *functions) +/** Per-context init */ +void +st_init_bitmap_functions(struct dd_function_table *functions) { functions->Bitmap = st_Bitmap; } +/** Per-context init */ +void +st_init_bitmap(struct st_context *st) +{ + init_bitmap_cache(st); +} + + +/** Per-context tear-down */ void st_destroy_bitmap(struct st_context *st) { @@ -528,9 +732,15 @@ st_destroy_bitmap(struct st_context *st) pipe->delete_vs_state(pipe, st->bitmap.vs); st->bitmap.vs = NULL; } + if (st->bitmap.vbuf) { pipe->winsys->buffer_destroy(pipe->winsys, st->bitmap.vbuf); st->bitmap.vbuf = NULL; } -} + if (st->bitmap.cache) { + pipe_texture_release(&st->bitmap.cache->texture); + FREE(st->bitmap.cache); + st->bitmap.cache = NULL; + } +} diff --git a/src/mesa/state_tracker/st_cb_bitmap.h b/src/mesa/state_tracker/st_cb_bitmap.h index ac19e0ebb1..aae11d34c9 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.h +++ b/src/mesa/state_tracker/st_cb_bitmap.h @@ -33,9 +33,14 @@ extern void st_init_bitmap_functions(struct dd_function_table *functions); +extern void +st_init_bitmap(struct st_context *st); extern void st_destroy_bitmap(struct st_context *st); +extern void +st_flush_bitmap_cache(struct st_context *st); + #endif /* ST_CB_BITMAP_H */ diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index a536a059bd..e321b401e2 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -35,6 +35,7 @@ #include "main/macros.h" #include "main/context.h" #include "st_context.h" +#include "st_cb_bitmap.h" #include "st_cb_flush.h" #include "st_cb_fbo.h" #include "st_public.h" @@ -48,6 +49,8 @@ void st_flush( struct st_context *st, uint pipeFlushFlags, { FLUSH_VERTICES(st->ctx, 0); + st_flush_bitmap_cache(st); + st->pipe->flush( st->pipe, pipeFlushFlags, fence ); } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 726e06d7c2..a20195f2de 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -109,6 +109,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st->cso_context = cso_create_context(pipe); st_init_atoms( st ); + st_init_bitmap(st); st_init_draw( st ); st_init_generate_mipmap(st); st_init_blit(st); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index f235c194b7..85e3d47e1a 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -42,6 +42,7 @@ struct cso_cache; struct cso_blend; struct gen_mipmap_state; struct blit_state; +struct bitmap_cache; #define ST_NEW_MESA 0x1 /* Mesa state has changed */ @@ -151,6 +152,7 @@ struct st_context void *vs; float vertices[4][3][4]; /**< vertex pos + color + texcoord */ struct pipe_buffer *vbuf; + struct bitmap_cache *cache; } bitmap; /** for glClear */ -- cgit v1.2.3 From 5a460c7391ef35b1dcf6ad7f5494fb23279b2e45 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 28 Mar 2008 15:17:50 -0600 Subject: gallium: don't call st_flush_bitmap_cache() if the only change is _NEW_PACKUNPACK state --- src/mesa/state_tracker/st_atom.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 40e4142631..18063adc79 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -148,7 +148,12 @@ void st_validate_state( struct st_context *st ) struct st_state_flags *state = &st->dirty; GLuint i; - st_flush_bitmap_cache(st); + /* The bitmap cache is immune to pixel unpack changes. + * Note that GLUT makes several calls to glPixelStore for each + * bitmap char it draws so this is an important check. + */ + if (state->mesa & ~_NEW_PACKUNPACK) + st_flush_bitmap_cache(st); check_program_state( st ); -- cgit v1.2.3 From 1a82d9648b3db780e58e4966924157542d148c58 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 May 2008 16:44:33 -0600 Subject: gallium: fix some render to texture bugs Before, we were sometimes rendering into a stale texture because st_finalize_texture() would discard the old texture and create a new one. Moved st_update_framebuffer atom after texture validation so that we can create a new renderbuffer surface if the texture changes. Also, split texture validation into two parts: finalize_textures and update_textures. Do finalize_textures first to avoid getting into the situtation where we're doing a pipe->surface_copy() mid-way through state validation. Some debug code still in place, but disabled... --- src/mesa/state_tracker/st_atom.c | 3 +- src/mesa/state_tracker/st_atom.h | 1 + src/mesa/state_tracker/st_atom_framebuffer.c | 60 ++++++++++++++++++++- src/mesa/state_tracker/st_atom_shader.c | 26 ++++++++- src/mesa/state_tracker/st_atom_texture.c | 80 +++++++++++++++++----------- src/mesa/state_tracker/st_cb_fbo.c | 34 +++++++++--- src/mesa/state_tracker/st_cb_fbo.h | 3 ++ src/mesa/state_tracker/st_cb_readpixels.c | 2 + src/mesa/state_tracker/st_cb_texture.c | 1 + src/mesa/state_tracker/st_context.h | 3 ++ src/mesa/state_tracker/st_texture.c | 16 ++++++ 11 files changed, 189 insertions(+), 40 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 18063adc79..ecfd117918 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -45,10 +45,10 @@ */ static const struct st_tracked_state *atoms[] = { - &st_update_framebuffer, &st_update_depth_stencil_alpha, &st_update_clip, + &st_finalize_textures, &st_update_shader, &st_update_rasterizer, @@ -58,6 +58,7 @@ static const struct st_tracked_state *atoms[] = &st_update_blend, &st_update_sampler, &st_update_texture, + &st_update_framebuffer, &st_update_vs_constants, &st_update_fs_constants, &st_update_pixel_transfer diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index c6c6eba812..c7cffd85c8 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -55,6 +55,7 @@ extern const struct st_tracked_state st_update_scissor; extern const struct st_tracked_state st_update_blend; extern const struct st_tracked_state st_update_sampler; extern const struct st_tracked_state st_update_texture; +extern const struct st_tracked_state st_finalize_textures; extern const struct st_tracked_state st_update_fs_constants; extern const struct st_tracked_state st_update_vs_constants; extern const struct st_tracked_state st_update_pixel_transfer; diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 0a6974d8a7..c9a30e44b2 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -34,13 +34,60 @@ #include "st_context.h" #include "st_atom.h" #include "st_cb_fbo.h" +#include "st_texture.h" #include "pipe/p_context.h" +#include "pipe/p_inlines.h" #include "cso_cache/cso_context.h" + +/** + * When doing GL render to texture, we have to be sure that finalize_texture() + * didn't yank out the pipe_texture that we earlier created a surface for. + * Check for that here and create a new surface if needed. + */ +static void +update_renderbuffer_surface(struct st_context *st, + struct st_renderbuffer *strb) +{ + struct pipe_screen *screen = st->pipe->screen; + struct pipe_texture *texture = strb->rtt->pt; + int rtt_width = strb->Base.Width; + int rtt_height = strb->Base.Height; + + if (!strb->surface || + strb->surface->texture != texture || + strb->surface->width != rtt_width || + strb->surface->height != rtt_height) { + int level; + /* find matching mipmap level size */ + for (level = 0; level <= texture->last_level; level++) { + if (texture->width[level] == rtt_width && + texture->height[level] == rtt_height) { + + pipe_surface_reference(&strb->surface, NULL); + + strb->surface = screen->get_tex_surface(screen, + texture, + strb->rtt_face, + level, + strb->rtt_slice, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); +#if 0 + printf("-- alloc new surface %d x %d into tex %p\n", + strb->surface->width, strb->surface->height, + texture); +#endif + break; + } + } + } +} + + /** * Update framebuffer state (color, depth, stencil, etc. buffers) - * XXX someday: separate draw/read buffers. */ static void update_framebuffer_state( struct st_context *st ) @@ -55,6 +102,8 @@ update_framebuffer_state( struct st_context *st ) framebuffer->width = fb->Width; framebuffer->height = fb->Height; + /*printf("------ fb size %d x %d\n", fb->Width, fb->Height);*/ + /* Examine Mesa's ctx->DrawBuffer->_ColorDrawBuffers state * to determine which surfaces to draw to */ @@ -62,6 +111,13 @@ update_framebuffer_state( struct st_context *st ) for (j = 0; j < MAX_DRAW_BUFFERS; j++) { for (i = 0; i < fb->_NumColorDrawBuffers[j]; i++) { strb = st_renderbuffer(fb->_ColorDrawBuffers[j][i]); + + /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/ + if (strb->rtt) { + /* rendering to a GL texture, may have to update surface */ + update_renderbuffer_surface(st, strb); + } + assert(strb->surface); framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface; framebuffer->num_cbufs++; @@ -99,7 +155,7 @@ const struct st_tracked_state st_update_framebuffer = { "st_update_framebuffer", /* name */ { /* dirty */ _NEW_BUFFERS, /* mesa */ - 0, /* st */ + ST_NEW_FRAMEBUFFER, /* st */ }, update_framebuffer_state /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 7745591afb..8839ab380f 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -44,6 +44,8 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" +#include "util/u_simple_shaders.h" + #include "cso_cache/cso_context.h" #include "st_context.h" @@ -252,6 +254,20 @@ st_free_translated_vertex_programs(struct st_context *st, } +static void * +get_passthrough_fs(struct st_context *st) +{ + struct pipe_shader_state shader; + + if (!st->passthrough_fs) { + st->passthrough_fs = + util_make_fragment_passthrough_shader(st->pipe, &shader); + free((void *) shader.tokens); + } + + return st->passthrough_fs; +} + static void update_linkage( struct st_context *st ) @@ -277,7 +293,15 @@ update_linkage( struct st_context *st ) st_reference_fragprog(st, &st->fp, stfp); cso_set_vertex_shader_handle(st->cso_context, stvp->driver_shader); - cso_set_fragment_shader_handle(st->cso_context, stfp->driver_shader); + + if (st->missing_textures) { + /* use a pass-through frag shader that uses no textures */ + void *fs = get_passthrough_fs(st); + cso_set_fragment_shader_handle(st->cso_context, fs); + } + else { + cso_set_fragment_shader_handle(st->cso_context, stfp->driver_shader); + } st->vertex_result_to_slot = xvp->output_to_slot; } diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index 767654f3d0..1ec671ed48 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -39,34 +39,13 @@ #include "pipe/p_context.h" #include "pipe/p_inlines.h" #include "cso_cache/cso_context.h" -#include "util/u_simple_shaders.h" -static void * -get_passthrough_fs(struct st_context *st) -{ - struct pipe_shader_state shader; - - if (!st->passthrough_fs) { - st->passthrough_fs = - util_make_fragment_passthrough_shader(st->pipe, &shader); - free((void *) shader.tokens); - } - - return st->passthrough_fs; -} - - -/** - * XXX This needs some work yet.... - * Need to "upload" texture images at appropriate times. - */ static void update_textures(struct st_context *st) { struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current; GLuint su; - GLboolean missing_textures = GL_FALSE; st->state.num_textures = 0; @@ -85,13 +64,11 @@ update_textures(struct st_context *st) retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush); if (!retval) { /* out of mem */ - missing_textures = GL_TRUE; + /* missing texture */ continue; } st->state.num_textures = su + 1; - - stObj->teximage_realloc = TRUE; } pt = st_get_stobj_texture(stObj); @@ -103,12 +80,6 @@ update_textures(struct st_context *st) cso_set_sampler_textures(st->cso_context, st->state.num_textures, st->state.sampler_texture); - - if (missing_textures) { - /* use a pass-through frag shader that uses no textures */ - void *fs = get_passthrough_fs(st); - cso_set_fragment_shader_handle(st->cso_context, fs); - } } @@ -120,3 +91,52 @@ const struct st_tracked_state st_update_texture = { }, update_textures /* update */ }; + + + + +static void +finalize_textures(struct st_context *st) +{ + struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current; + const GLboolean prev_missing_textures = st->missing_textures; + GLuint su; + + st->missing_textures = GL_FALSE; + + for (su = 0; su < st->ctx->Const.MaxTextureCoordUnits; su++) { + if (fprog->Base.SamplersUsed & (1 << su)) { + const GLuint texUnit = fprog->Base.SamplerUnits[su]; + struct gl_texture_object *texObj + = st->ctx->Texture.Unit[texUnit]._Current; + struct st_texture_object *stObj = st_texture_object(texObj); + + if (texObj) { + GLboolean flush, retval; + + retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush); + if (!retval) { + /* out of mem */ + st->missing_textures = GL_TRUE; + continue; + } + + stObj->teximage_realloc = TRUE; + } + } + } + + if (prev_missing_textures != st->missing_textures) + st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; +} + + + +const struct st_tracked_state st_finalize_textures = { + "st_finalize_textures", /* name */ + { /* dirty */ + _NEW_TEXTURE, /* mesa */ + 0, /* st */ + }, + finalize_textures /* update */ +}; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 747d4905e6..2368c31f4b 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -358,6 +358,10 @@ st_render_texture(GLcontext *ctx, struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_texture *pt; + struct st_texture_object *stObj; + const struct gl_texture_image *texImage = + att->Texture->Image[att->CubeMapFace][att->TextureLevel]; + assert(!att->Renderbuffer); @@ -374,27 +378,42 @@ st_render_texture(GLcontext *ctx, strb = st_renderbuffer(rb); /* get the texture for the texture object */ + stObj = st_texture_object(att->Texture); + + /* point renderbuffer at texobject */ + strb->rtt = stObj; + strb->rtt_level = att->TextureLevel; + strb->rtt_face = att->CubeMapFace; + strb->rtt_slice = att->Zoffset; + + rb->Width = texImage->Width2; + rb->Height = texImage->Height2; + /*printf("***** render to texture level %d: %d x %d\n", att->TextureLevel, rb->Width, rb->Height);*/ + pt = st_get_texobj_texture(att->Texture); assert(pt); - assert(pt->width[att->TextureLevel]); - - rb->Width = pt->width[att->TextureLevel]; - rb->Height = pt->height[att->TextureLevel]; + /*printf("***** pipe texture %d x %d\n", pt->width[0], pt->height[0]);*/ pipe_texture_reference( &strb->texture, pt ); + pipe_surface_reference(&strb->surface, NULL); + +#if 0 /* the renderbuffer's surface is inside the texture */ strb->surface = screen->get_tex_surface(screen, pt, att->CubeMapFace, - att->TextureLevel, + att->TextureLevel /*- att->Texture->BaseLevel*/, att->Zoffset, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE); + printf("***** surface size: %d x %d\n", strb->surface->width, strb->surface->height); + assert(strb->surface); assert(screen->is_format_supported(screen, strb->surface->format, PIPE_TEXTURE)); assert(screen->is_format_supported(screen, strb->surface->format, PIPE_SURFACE)); init_renderbuffer_bits(strb, pt->format); +#endif /* printf("RENDER TO TEXTURE obj=%p pt=%p surf=%p %d x %d\n", @@ -424,7 +443,10 @@ st_finish_render_texture(GLcontext *ctx, ctx->st->pipe->flush(ctx->st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - screen->tex_surface_release( screen, &strb->surface ); + if (strb->surface) + screen->tex_surface_release( screen, &strb->surface ); + + strb->rtt = NULL; /* printf("FINISH RENDER TO TEXTURE surf=%p\n", strb->surface); diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h index f9cec91314..87b0734a0c 100644 --- a/src/mesa/state_tracker/st_cb_fbo.h +++ b/src/mesa/state_tracker/st_cb_fbo.h @@ -44,6 +44,9 @@ struct st_renderbuffer struct pipe_texture *texture; struct pipe_surface *surface; /* temporary view into texture */ enum pipe_format format; /** preferred format, or PIPE_FORMAT_NONE */ + + struct st_texture_object *rtt; /**< GL render to texture's texture */ + int rtt_level, rtt_face, rtt_slice; }; diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 0b2b9d544d..3615fafc0a 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -183,6 +183,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, struct gl_pixelstore_attrib clippedPacking = *pack; struct pipe_surface *surf; + assert(ctx->ReadBuffer->Width > 0); + /* XXX convolution not done yet */ assert((transferOps & IMAGE_CONVOLUTION_BIT) == 0); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 3206215b2e..3468b5f2a1 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1496,6 +1496,7 @@ st_finalize_texture(GLcontext *ctx, stObj->pt->cpp != cpp || stObj->pt->compressed != firstImage->base.IsCompressed) { pipe_texture_release(&stObj->pt); + ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER; } } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 1ca779d0a9..69be4ebdd0 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -53,6 +53,7 @@ struct bitmap_cache; #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 #define ST_NEW_VERTEX_PROGRAM 0x4 +#define ST_NEW_FRAMEBUFFER 0x8 struct st_state_flags { @@ -121,6 +122,8 @@ struct st_context struct st_state_flags dirty; + GLboolean missing_textures; + GLfloat polygon_offset_scale; /* ?? */ /** Mapping from VERT_RESULT_x to post-transformed vertex slot */ diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 2b3742d4e5..d0f56c9717 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -315,6 +315,22 @@ st_texture_image_copy(struct pipe_context *pipe, assert(src->width[srcLevel] == width); assert(src->height[srcLevel] == height); +#if 0 + { + src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, + PIPE_BUFFER_USAGE_CPU_READ); + ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ); + map += src_surface->width * src_surface->height * 4 / 2; + printf("%s center pixel: %d %d %d %d (pt %p[%d] -> %p[%d])\n", + __FUNCTION__, + map[0], map[1], map[2], map[3], + src, srcLevel, dst, dstLevel); + + screen->surface_unmap(screen, src_surface); + pipe_surface_reference(&src_surface, NULL); + } +#endif + dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i, PIPE_BUFFER_USAGE_GPU_WRITE); -- cgit v1.2.3 From 101d1a658a614d1e2ec02b1e697f6161291af653 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 23 Jul 2008 21:06:01 +0900 Subject: mesa: Prefix main includes with dir to avoid conflicts. Some of the headers in src/mesa/main have pretty common names which easily conflict with third-party code, e.g. config.h --- src/mesa/SConscript | 1 - src/mesa/glapi/glapi.c | 2 +- src/mesa/glapi/glapi_getproc.c | 2 +- src/mesa/glapi/glthread.c | 2 +- src/mesa/math/m_debug_clip.c | 8 ++++---- src/mesa/math/m_debug_norm.c | 8 ++++---- src/mesa/math/m_debug_xform.c | 8 ++++---- src/mesa/math/m_matrix.c | 8 ++++---- src/mesa/math/m_translate.c | 6 +++--- src/mesa/math/m_vector.c | 8 ++++---- src/mesa/math/m_xform.h | 4 ++-- src/mesa/shader/arbprogparse.c | 6 +++--- src/mesa/shader/arbprogparse.h | 2 +- src/mesa/shader/arbprogram.c | 12 ++++++------ src/mesa/shader/atifragshader.c | 14 +++++++------- src/mesa/shader/grammar/grammar_mesa.h | 2 +- src/mesa/shader/nvfragparse.c | 8 ++++---- src/mesa/shader/nvprogram.c | 10 +++++----- src/mesa/shader/nvvertparse.c | 8 ++++---- src/mesa/shader/prog_debug.c | 6 +++--- src/mesa/shader/prog_execute.c | 6 +++--- src/mesa/shader/prog_instruction.c | 6 +++--- src/mesa/shader/prog_parameter.c | 6 +++--- src/mesa/shader/prog_parameter.h | 2 +- src/mesa/shader/prog_print.c | 6 +++--- src/mesa/shader/prog_statevars.c | 12 ++++++------ src/mesa/shader/prog_statevars.h | 2 +- src/mesa/shader/program.c | 6 +++--- src/mesa/shader/program.h | 2 +- src/mesa/shader/programopt.c | 4 ++-- src/mesa/shader/shader_api.c | 8 ++++---- src/mesa/shader/shader_api.h | 4 ++-- src/mesa/shader/slang/slang_codegen.h | 2 +- src/mesa/shader/slang/slang_compile.h | 4 ++-- src/mesa/shader/slang/slang_compile_function.c | 2 +- src/mesa/shader/slang/slang_compile_operation.c | 2 +- src/mesa/shader/slang/slang_compile_struct.c | 2 +- src/mesa/shader/slang/slang_compile_variable.c | 2 +- src/mesa/shader/slang/slang_emit.h | 4 ++-- src/mesa/shader/slang/slang_ir.c | 4 ++-- src/mesa/shader/slang/slang_ir.h | 4 ++-- src/mesa/shader/slang/slang_library_noise.c | 2 +- src/mesa/shader/slang/slang_log.c | 2 +- src/mesa/shader/slang/slang_mem.c | 4 ++-- src/mesa/shader/slang/slang_mem.h | 2 +- src/mesa/shader/slang/slang_preprocess.c | 2 +- src/mesa/shader/slang/slang_print.c | 2 +- src/mesa/shader/slang/slang_simplify.c | 6 +++--- src/mesa/shader/slang/slang_storage.c | 2 +- src/mesa/shader/slang/slang_typeinfo.h | 4 ++-- src/mesa/shader/slang/slang_utility.c | 2 +- src/mesa/sources | 1 - src/mesa/sparc/sparc.c | 2 +- src/mesa/state_tracker/st_atom.c | 4 ++-- src/mesa/state_tracker/st_atom_viewport.c | 4 ++-- src/mesa/state_tracker/st_mesa_to_tgsi.h | 2 +- src/mesa/state_tracker/st_texture.c | 2 +- src/mesa/swrast/s_aaline.c | 8 ++++---- src/mesa/swrast/s_aaline.h | 2 +- src/mesa/swrast/s_aatriangle.c | 12 ++++++------ src/mesa/swrast/s_aatriangle.h | 2 +- src/mesa/swrast/s_accum.c | 8 ++++---- src/mesa/swrast/s_accum.h | 2 +- src/mesa/swrast/s_alpha.c | 8 ++++---- src/mesa/swrast/s_alpha.h | 2 +- src/mesa/swrast/s_atifragshader.c | 8 ++++---- src/mesa/swrast/s_bitmap.c | 4 ++-- src/mesa/swrast/s_blend.c | 8 ++++---- src/mesa/swrast/s_blend.h | 2 +- src/mesa/swrast/s_blit.c | 4 ++-- src/mesa/swrast/s_buffers.c | 10 +++++----- src/mesa/swrast/s_context.c | 8 ++++---- src/mesa/swrast/s_copypix.c | 10 +++++----- src/mesa/swrast/s_depth.c | 8 ++++---- src/mesa/swrast/s_depth.h | 2 +- src/mesa/swrast/s_drawpix.c | 8 ++++---- src/mesa/swrast/s_drawpix.h | 2 +- src/mesa/swrast/s_feedback.c | 10 +++++----- src/mesa/swrast/s_feedback.h | 2 +- src/mesa/swrast/s_fog.c | 8 ++++---- src/mesa/swrast/s_fog.h | 2 +- src/mesa/swrast/s_lines.c | 8 ++++---- src/mesa/swrast/s_lines.h | 2 +- src/mesa/swrast/s_logic.c | 8 ++++---- src/mesa/swrast/s_logic.h | 2 +- src/mesa/swrast/s_masking.c | 4 ++-- src/mesa/swrast/s_masking.h | 2 +- src/mesa/swrast/s_points.c | 8 ++++---- src/mesa/swrast/s_points.h | 2 +- src/mesa/swrast/s_readpix.c | 10 +++++----- src/mesa/swrast/s_span.c | 10 +++++----- src/mesa/swrast/s_span.h | 2 +- src/mesa/swrast/s_spantemp.h | 2 +- src/mesa/swrast/s_stencil.c | 6 +++--- src/mesa/swrast/s_stencil.h | 2 +- src/mesa/swrast/s_texcombine.c | 10 +++++----- src/mesa/swrast/s_texcombine.h | 2 +- src/mesa/swrast/s_texfilter.c | 8 ++++---- src/mesa/swrast/s_texfilter.h | 2 +- src/mesa/swrast/s_texstore.c | 10 +++++----- src/mesa/swrast/s_triangle.c | 10 +++++----- src/mesa/swrast/s_triangle.h | 2 +- src/mesa/swrast/s_zoom.c | 8 ++++---- src/mesa/swrast/s_zoom.h | 2 +- src/mesa/swrast_setup/ss_context.c | 6 +++--- src/mesa/swrast_setup/ss_context.h | 2 +- src/mesa/swrast_setup/ss_triangle.c | 8 ++++---- src/mesa/swrast_setup/ss_triangle.h | 2 +- src/mesa/swrast_setup/ss_vb.h | 2 +- src/mesa/tnl/t_draw.c | 12 ++++++------ src/mesa/tnl/t_pipeline.h | 2 +- src/mesa/tnl/t_rasterpos.c | 10 +++++----- src/mesa/tnl/t_vb_cull.c | 12 ++++++------ src/mesa/tnl/t_vb_fog.c | 12 ++++++------ src/mesa/tnl/t_vb_light.c | 10 +++++----- src/mesa/tnl/t_vb_normals.c | 12 ++++++------ src/mesa/tnl/t_vb_points.c | 4 ++-- src/mesa/tnl/t_vb_program.c | 10 +++++----- src/mesa/tnl/t_vb_render.c | 12 ++++++------ src/mesa/tnl/t_vb_texgen.c | 12 ++++++------ src/mesa/tnl/t_vb_texmat.c | 12 ++++++------ src/mesa/tnl/t_vb_vertex.c | 12 ++++++------ src/mesa/tnl/t_vertex.c | 6 +++--- src/mesa/tnl/t_vertex.h | 2 +- src/mesa/tnl/t_vertex_generic.c | 6 +++--- src/mesa/tnl/t_vertex_sse.c | 8 ++++---- src/mesa/tnl/t_vp_build.c | 2 +- src/mesa/tnl/t_vp_build.h | 2 +- src/mesa/vf/vf.c | 6 +++--- src/mesa/vf/vf_generic.c | 8 ++++---- src/mesa/vf/vf_sse.c | 8 ++++---- src/mesa/x86-64/x86-64.c | 4 ++-- src/mesa/x86/3dnow.c | 4 ++-- src/mesa/x86/common_x86.c | 2 +- src/mesa/x86/rtasm/x86sse.c | 2 +- src/mesa/x86/sse.c | 4 ++-- src/mesa/x86/x86.c | 4 ++-- 137 files changed, 369 insertions(+), 371 deletions(-) (limited to 'src/mesa/state_tracker/st_atom.c') diff --git a/src/mesa/SConscript b/src/mesa/SConscript index d2de189f69..2c74dc7dd0 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -10,7 +10,6 @@ if env['platform'] != 'winddk': env.Append(CPPPATH = [ '#/src/mesa', - '#/src/mesa/main', ]) if gcc: diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index c236656d9a..53efd7eef4 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -50,7 +50,7 @@ -#include "glheader.h" +#include "main/glheader.h" #include "glapi.h" #include "glapioffsets.h" #include "glapitable.h" diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index 3634444c85..6d40b495c7 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -32,7 +32,7 @@ #include #include -#include "glheader.h" +#include "main/glheader.h" #include "glapi.h" #include "glapioffsets.h" #include "glapitable.h" diff --git a/src/mesa/glapi/glthread.c b/src/mesa/glapi/glthread.c index 4513853f5a..09cc8cfcde 100644 --- a/src/mesa/glapi/glthread.c +++ b/src/mesa/glapi/glthread.c @@ -29,7 +29,7 @@ */ -#include "glheader.h" +#include "main/glheader.h" #include "glthread.h" diff --git a/src/mesa/math/m_debug_clip.c b/src/mesa/math/m_debug_clip.c index ab28818359..460fed4a75 100644 --- a/src/mesa/math/m_debug_clip.c +++ b/src/mesa/math/m_debug_clip.c @@ -25,10 +25,10 @@ * Gareth Hughes */ -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "m_matrix.h" #include "m_xform.h" diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c index 11cae6bba7..89c632e7d5 100644 --- a/src/mesa/math/m_debug_norm.c +++ b/src/mesa/math/m_debug_norm.c @@ -26,10 +26,10 @@ * Gareth Hughes */ -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "m_matrix.h" #include "m_xform.h" diff --git a/src/mesa/math/m_debug_xform.c b/src/mesa/math/m_debug_xform.c index 0b07b4fd68..df8cc066b6 100644 --- a/src/mesa/math/m_debug_xform.c +++ b/src/mesa/math/m_debug_xform.c @@ -26,10 +26,10 @@ * Updated for P6 architecture by Gareth Hughes. */ -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "m_matrix.h" #include "m_xform.h" diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c index b4ba1bc2a0..84b4cae4ad 100644 --- a/src/mesa/math/m_matrix.c +++ b/src/mesa/math/m_matrix.c @@ -34,10 +34,10 @@ */ -#include "glheader.h" -#include "imports.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/imports.h" #include "m_matrix.h" diff --git a/src/mesa/math/m_translate.c b/src/mesa/math/m_translate.c index c7423e9d9d..4a20f45ee4 100644 --- a/src/mesa/math/m_translate.c +++ b/src/mesa/math/m_translate.c @@ -28,9 +28,9 @@ */ -#include "glheader.h" -#include "mtypes.h" /* GLchan hack */ -#include "colormac.h" +#include "main/glheader.h" +#include "main/mtypes.h" /* GLchan hack */ +#include "main/colormac.h" #include "m_translate.h" diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c index 3ad81d468b..c5e2fd1de1 100644 --- a/src/mesa/math/m_vector.c +++ b/src/mesa/math/m_vector.c @@ -28,10 +28,10 @@ */ -#include "glheader.h" -#include "imports.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/imports.h" #include "m_vector.h" diff --git a/src/mesa/math/m_xform.h b/src/mesa/math/m_xform.h index 99b071a46b..d1b974f043 100644 --- a/src/mesa/math/m_xform.h +++ b/src/mesa/math/m_xform.h @@ -27,8 +27,8 @@ #define _M_XFORM_H -#include "glheader.h" -#include "config.h" +#include "main/glheader.h" +#include "main/config.h" #include "math/m_vector.h" #include "math/m_matrix.h" diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index ff583352ce..78cc6aa9cc 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -38,9 +38,9 @@ #include "programopt.h" #include "prog_parameter.h" #include "prog_statevars.h" -#include "context.h" -#include "macros.h" -#include "mtypes.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/mtypes.h" #include "prog_instruction.h" diff --git a/src/mesa/shader/arbprogparse.h b/src/mesa/shader/arbprogparse.h index 4574e5cd55..980d39fb9f 100644 --- a/src/mesa/shader/arbprogparse.h +++ b/src/mesa/shader/arbprogparse.h @@ -26,7 +26,7 @@ #ifndef ARBPROGPARSE_H #define ARBPROGPARSE_H -#include "mtypes.h" +#include "main/mtypes.h" extern void _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target, diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index 81c20a0150..beb5deea50 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -29,14 +29,14 @@ */ -#include "glheader.h" +#include "main/glheader.h" #include "arbprogram.h" #include "arbprogparse.h" -#include "context.h" -#include "hash.h" -#include "imports.h" -#include "macros.h" -#include "mtypes.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/mtypes.h" #include "program.h" diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c index 854c911874..ac087d415c 100644 --- a/src/mesa/shader/atifragshader.c +++ b/src/mesa/shader/atifragshader.c @@ -21,13 +21,13 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "glheader.h" -#include "context.h" -#include "hash.h" -#include "imports.h" -#include "macros.h" -#include "enums.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/enums.h" +#include "main/mtypes.h" #include "atifragshader.h" #define MESA_DEBUG_ATI_FS 0 diff --git a/src/mesa/shader/grammar/grammar_mesa.h b/src/mesa/shader/grammar/grammar_mesa.h index c14033a9d4..6c92c5812d 100644 --- a/src/mesa/shader/grammar/grammar_mesa.h +++ b/src/mesa/shader/grammar/grammar_mesa.h @@ -26,7 +26,7 @@ #define GRAMMAR_MESA_H -#include "imports.h" +#include "main/imports.h" /* NOTE: include Mesa 3-D specific headers here */ diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index 0f1a1eade4..a2a7a5f3f4 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -37,10 +37,10 @@ * including any use thereof or modifications thereto. */ -#include "glheader.h" -#include "context.h" -#include "imports.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" +#include "main/macros.h" #include "prog_parameter.h" #include "prog_instruction.h" #include "nvfragparse.h" diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c index 409c61cdc1..d656d4b28b 100644 --- a/src/mesa/shader/nvprogram.c +++ b/src/mesa/shader/nvprogram.c @@ -37,11 +37,11 @@ * including any use thereof or modifications thereto. */ -#include "glheader.h" -#include "context.h" -#include "hash.h" -#include "imports.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/imports.h" +#include "main/macros.h" #include "prog_parameter.h" #include "prog_instruction.h" #include "nvfragparse.h" diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index ac96d4a60e..08538c0ee4 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -37,10 +37,10 @@ * including any use thereof or modifications thereto. */ -#include "glheader.h" -#include "context.h" -#include "imports.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" +#include "main/macros.h" #include "nvprogram.h" #include "nvvertparse.h" #include "prog_instruction.h" diff --git a/src/mesa/shader/prog_debug.c b/src/mesa/shader/prog_debug.c index 57929fcbca..7bcb2ef734 100644 --- a/src/mesa/shader/prog_debug.c +++ b/src/mesa/shader/prog_debug.c @@ -23,9 +23,9 @@ */ -#include "glheader.h" -#include "context.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" #include "nvfragparse.h" #include "nvvertparse.h" #include "program.h" diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 4745211c65..5afd9eb153 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -35,9 +35,9 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" #include "program.h" #include "prog_execute.h" #include "prog_instruction.h" diff --git a/src/mesa/shader/prog_instruction.c b/src/mesa/shader/prog_instruction.c index bea5d0551e..1033496d97 100644 --- a/src/mesa/shader/prog_instruction.c +++ b/src/mesa/shader/prog_instruction.c @@ -23,9 +23,9 @@ */ -#include "glheader.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "prog_instruction.h" diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index d87e8f6e15..e0d2096b30 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -29,9 +29,9 @@ */ -#include "glheader.h" -#include "imports.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/macros.h" #include "prog_instruction.h" #include "prog_parameter.h" #include "prog_statevars.h" diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h index dfb8c39ca4..ac5c629fab 100644 --- a/src/mesa/shader/prog_parameter.h +++ b/src/mesa/shader/prog_parameter.h @@ -31,7 +31,7 @@ #ifndef PROG_PARAMETER_H #define PROG_PARAMETER_H -#include "mtypes.h" +#include "main/mtypes.h" #include "prog_statevars.h" diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index 5368ab2187..10c5afec18 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -28,9 +28,9 @@ * \author Brian Paul */ -#include "glheader.h" -#include "context.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" #include "prog_instruction.h" #include "prog_parameter.h" #include "prog_print.h" diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 81bb4122f2..819db25a00 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -29,12 +29,12 @@ */ -#include "glheader.h" -#include "context.h" -#include "hash.h" -#include "imports.h" -#include "macros.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/mtypes.h" #include "prog_statevars.h" #include "prog_parameter.h" diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h index a515fda3aa..0a1c235828 100644 --- a/src/mesa/shader/prog_statevars.h +++ b/src/mesa/shader/prog_statevars.h @@ -25,7 +25,7 @@ #ifndef PROG_STATEVARS_H #define PROG_STATEVARS_H -#include "mtypes.h" +#include "main/mtypes.h" /** diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 13d6df1ce6..02e23aaa3a 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -29,9 +29,9 @@ */ -#include "glheader.h" -#include "context.h" -#include "hash.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/hash.h" #include "program.h" #include "prog_cache.h" #include "prog_parameter.h" diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index 7484961364..f8bd63233e 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -40,7 +40,7 @@ #ifndef PROGRAM_H #define PROGRAM_H -#include "mtypes.h" +#include "main/mtypes.h" extern struct gl_program _mesa_DummyProgram; diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c index f3511ba00e..d6a3231055 100644 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@ -31,8 +31,8 @@ */ -#include "glheader.h" -#include "context.h" +#include "main/glheader.h" +#include "main/context.h" #include "prog_parameter.h" #include "prog_statevars.h" #include "program.h" diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index bd3745cfe6..b33dfd6663 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -35,10 +35,10 @@ */ -#include "glheader.h" -#include "context.h" -#include "hash.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/macros.h" #include "program.h" #include "prog_parameter.h" #include "prog_print.h" diff --git a/src/mesa/shader/shader_api.h b/src/mesa/shader/shader_api.h index 5521c585b5..e7f1266915 100644 --- a/src/mesa/shader/shader_api.h +++ b/src/mesa/shader/shader_api.h @@ -27,8 +27,8 @@ #define SHADER_API_H -#include "glheader.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/mtypes.h" /** diff --git a/src/mesa/shader/slang/slang_codegen.h b/src/mesa/shader/slang/slang_codegen.h index 821d396162..ba7ca4c142 100644 --- a/src/mesa/shader/slang/slang_codegen.h +++ b/src/mesa/shader/slang/slang_codegen.h @@ -27,7 +27,7 @@ #define SLANG_CODEGEN_H -#include "imports.h" +#include "main/imports.h" #include "slang_compile.h" diff --git a/src/mesa/shader/slang/slang_compile.h b/src/mesa/shader/slang/slang_compile.h index 0f1f820d2e..35e468b44e 100644 --- a/src/mesa/shader/slang/slang_compile.h +++ b/src/mesa/shader/slang/slang_compile.h @@ -25,8 +25,8 @@ #if !defined SLANG_COMPILE_H #define SLANG_COMPILE_H -#include "imports.h" -#include "mtypes.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "slang_typeinfo.h" #include "slang_compile_variable.h" #include "slang_compile_struct.h" diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c index 80769b33ae..8405d7f778 100644 --- a/src/mesa/shader/slang/slang_compile_function.c +++ b/src/mesa/shader/slang/slang_compile_function.c @@ -28,7 +28,7 @@ * \author Michal Krol */ -#include "imports.h" +#include "main/imports.h" #include "slang_compile.h" #include "slang_mem.h" diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c index 4d2fd5b666..c0d469c829 100644 --- a/src/mesa/shader/slang/slang_compile_operation.c +++ b/src/mesa/shader/slang/slang_compile_operation.c @@ -28,7 +28,7 @@ * \author Michal Krol */ -#include "imports.h" +#include "main/imports.h" #include "slang_compile.h" #include "slang_mem.h" diff --git a/src/mesa/shader/slang/slang_compile_struct.c b/src/mesa/shader/slang/slang_compile_struct.c index 96bdb1f491..e6c38730d7 100644 --- a/src/mesa/shader/slang/slang_compile_struct.c +++ b/src/mesa/shader/slang/slang_compile_struct.c @@ -28,7 +28,7 @@ * \author Michal Krol */ -#include "imports.h" +#include "main/imports.h" #include "slang_mem.h" #include "slang_compile.h" diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c index d53255075f..b26c18e38d 100644 --- a/src/mesa/shader/slang/slang_compile_variable.c +++ b/src/mesa/shader/slang/slang_compile_variable.c @@ -28,7 +28,7 @@ * \author Michal Krol */ -#include "imports.h" +#include "main/imports.h" #include "slang_compile.h" #include "slang_mem.h" diff --git a/src/mesa/shader/slang/slang_emit.h b/src/mesa/shader/slang/slang_emit.h index 153e872d74..4db4bbe562 100644 --- a/src/mesa/shader/slang/slang_emit.h +++ b/src/mesa/shader/slang/slang_emit.h @@ -26,10 +26,10 @@ #define SLANG_EMIT_H -#include "imports.h" +#include "main/imports.h" #include "slang_compile.h" #include "slang_ir.h" -#include "mtypes.h" +#include "main/mtypes.h" extern void diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c index a414036a36..23d554234e 100644 --- a/src/mesa/shader/slang/slang_ir.c +++ b/src/mesa/shader/slang/slang_ir.c @@ -23,8 +23,8 @@ */ -#include "imports.h" -#include "context.h" +#include "main/imports.h" +#include "main/context.h" #include "slang_ir.h" #include "slang_mem.h" #include "shader/prog_print.h" diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h index 61ff649e5c..e4697ba3b4 100644 --- a/src/mesa/shader/slang/slang_ir.h +++ b/src/mesa/shader/slang/slang_ir.h @@ -33,10 +33,10 @@ #define SLANG_IR_H -#include "imports.h" +#include "main/imports.h" #include "slang_compile.h" #include "slang_label.h" -#include "mtypes.h" +#include "main/mtypes.h" /** diff --git a/src/mesa/shader/slang/slang_library_noise.c b/src/mesa/shader/slang/slang_library_noise.c index 46075c492c..25a05657cc 100644 --- a/src/mesa/shader/slang/slang_library_noise.c +++ b/src/mesa/shader/slang/slang_library_noise.c @@ -49,7 +49,7 @@ */ -#include "imports.h" +#include "main/imports.h" #include "slang_library_noise.h" #define FASTFLOOR(x) ( ((x)>0) ? ((int)x) : (((int)x)-1) ) diff --git a/src/mesa/shader/slang/slang_log.c b/src/mesa/shader/slang/slang_log.c index c963914fe3..01591ceba5 100644 --- a/src/mesa/shader/slang/slang_log.c +++ b/src/mesa/shader/slang/slang_log.c @@ -22,7 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "imports.h" +#include "main/imports.h" #include "slang_log.h" #include "slang_utility.h" diff --git a/src/mesa/shader/slang/slang_mem.c b/src/mesa/shader/slang/slang_mem.c index e1d1e6ba14..21d6bfce88 100644 --- a/src/mesa/shader/slang/slang_mem.c +++ b/src/mesa/shader/slang/slang_mem.c @@ -32,8 +32,8 @@ * \author Brian Paul */ -#include "context.h" -#include "macros.h" +#include "main/context.h" +#include "main/macros.h" #include "slang_mem.h" diff --git a/src/mesa/shader/slang/slang_mem.h b/src/mesa/shader/slang/slang_mem.h index 49885b6c98..b5bfae2479 100644 --- a/src/mesa/shader/slang/slang_mem.h +++ b/src/mesa/shader/slang/slang_mem.h @@ -27,7 +27,7 @@ #define SLANG_MEM_H -#include "imports.h" +#include "main/imports.h" typedef struct slang_mempool_ slang_mempool; diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index d3f412c211..bfe29b6bc9 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -28,7 +28,7 @@ * \author Michal Krol */ -#include "imports.h" +#include "main/imports.h" #include "shader/grammar/grammar_mesa.h" #include "slang_preprocess.h" diff --git a/src/mesa/shader/slang/slang_print.c b/src/mesa/shader/slang/slang_print.c index f48762fb11..4422f70159 100644 --- a/src/mesa/shader/slang/slang_print.c +++ b/src/mesa/shader/slang/slang_print.c @@ -4,7 +4,7 @@ */ -#include "imports.h" +#include "main/imports.h" #include "slang_compile.h" #include "slang_print.h" diff --git a/src/mesa/shader/slang/slang_simplify.c b/src/mesa/shader/slang/slang_simplify.c index 9a4b6a88d1..d5997283a8 100644 --- a/src/mesa/shader/slang/slang_simplify.c +++ b/src/mesa/shader/slang/slang_simplify.c @@ -28,9 +28,9 @@ * \author Michal Krol */ -#include "imports.h" -#include "macros.h" -#include "get.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/get.h" #include "slang_compile.h" #include "slang_codegen.h" #include "slang_simplify.h" diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c index bc32aa4b02..e8b0fb7747 100644 --- a/src/mesa/shader/slang/slang_storage.c +++ b/src/mesa/shader/slang/slang_storage.c @@ -28,7 +28,7 @@ * \author Michal Krol */ -#include "imports.h" +#include "main/imports.h" #include "slang_storage.h" #include "slang_mem.h" diff --git a/src/mesa/shader/slang/slang_typeinfo.h b/src/mesa/shader/slang/slang_typeinfo.h index 587331e8b1..8a36fc3422 100644 --- a/src/mesa/shader/slang/slang_typeinfo.h +++ b/src/mesa/shader/slang/slang_typeinfo.h @@ -25,8 +25,8 @@ #ifndef SLANG_TYPEINFO_H #define SLANG_TYPEINFO_H 1 -#include "imports.h" -#include "mtypes.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "slang_log.h" #include "slang_utility.h" #include "slang_vartable.h" diff --git a/src/mesa/shader/slang/slang_utility.c b/src/mesa/shader/slang/slang_utility.c index 2a2dc8e54f..3631e32b3c 100644 --- a/src/mesa/shader/slang/slang_utility.c +++ b/src/mesa/shader/slang/slang_utility.c @@ -28,7 +28,7 @@ * \author Michal Krol */ -#include "imports.h" +#include "main/imports.h" #include "slang_utility.h" #include "slang_mem.h" diff --git a/src/mesa/sources b/src/mesa/sources index e6b050c3f2..0e0e10979b 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -342,7 +342,6 @@ COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o) INCLUDE_DIRS = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/gallium/auxiliary diff --git a/src/mesa/sparc/sparc.c b/src/mesa/sparc/sparc.c index 1b77b0bb7b..84e8ac6723 100644 --- a/src/mesa/sparc/sparc.c +++ b/src/mesa/sparc/sparc.c @@ -31,7 +31,7 @@ #ifdef USE_SPARC_ASM -#include "context.h" +#include "main/context.h" #include "math/m_xform.h" #include "tnl/t_context.h" diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index ecfd117918..fc8587f459 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -26,8 +26,8 @@ **************************************************************************/ -#include "glheader.h" -#include "context.h" +#include "main/glheader.h" +#include "main/context.h" #include "pipe/p_defines.h" #include "st_context.h" diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index 8b9f1abda4..27ec2eb033 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -26,8 +26,8 @@ **************************************************************************/ -#include "context.h" -#include "colormac.h" +#include "main/context.h" +#include "main/colormac.h" #include "st_context.h" #include "st_atom.h" #include "pipe/p_context.h" diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index 63fc855b53..f17f2eac96 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -29,7 +29,7 @@ #ifndef ST_MESA_TO_TGSI_H #define ST_MESA_TO_TGSI_H -#include "mtypes.h" +#include "main/mtypes.h" #if defined __cplusplus diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 3e5054ecd2..289b78b38b 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -28,7 +28,7 @@ #include "st_context.h" #include "st_format.h" #include "st_texture.h" -#include "enums.h" +#include "main/enums.h" #undef Elements /* fix re-defined macro warning */ diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c index d6a9afb421..ee65a71d7e 100644 --- a/src/mesa/swrast/s_aaline.c +++ b/src/mesa/swrast/s_aaline.c @@ -23,14 +23,14 @@ */ -#include "glheader.h" -#include "imports.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/macros.h" #include "swrast/s_aaline.h" #include "swrast/s_context.h" #include "swrast/s_span.h" #include "swrast/swrast.h" -#include "mtypes.h" +#include "main/mtypes.h" #define SUB_PIXEL 4 diff --git a/src/mesa/swrast/s_aaline.h b/src/mesa/swrast/s_aaline.h index 41e7e5fd4d..9fb4959f91 100644 --- a/src/mesa/swrast/s_aaline.h +++ b/src/mesa/swrast/s_aaline.h @@ -28,7 +28,7 @@ #define S_AALINE_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c index 66891f9fec..078f16aea0 100644 --- a/src/mesa/swrast/s_aatriangle.c +++ b/src/mesa/swrast/s_aatriangle.c @@ -28,12 +28,12 @@ */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "s_aatriangle.h" #include "s_context.h" #include "s_span.h" diff --git a/src/mesa/swrast/s_aatriangle.h b/src/mesa/swrast/s_aatriangle.h index ebb828eb19..734d420b62 100644 --- a/src/mesa/swrast/s_aatriangle.h +++ b/src/mesa/swrast/s_aatriangle.h @@ -28,7 +28,7 @@ #define S_AATRIANGLE_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index 3c45dee399..13a42fdf53 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -23,10 +23,10 @@ */ -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "fbobject.h" #include "s_accum.h" diff --git a/src/mesa/swrast/s_accum.h b/src/mesa/swrast/s_accum.h index 97d2bef4c3..42e38cf02b 100644 --- a/src/mesa/swrast/s_accum.h +++ b/src/mesa/swrast/s_accum.h @@ -27,7 +27,7 @@ #define S_ACCUM_H -#include "mtypes.h" +#include "main/mtypes.h" extern void diff --git a/src/mesa/swrast/s_alpha.c b/src/mesa/swrast/s_alpha.c index 3c55d3e9e3..5761bb00b4 100644 --- a/src/mesa/swrast/s_alpha.c +++ b/src/mesa/swrast/s_alpha.c @@ -27,10 +27,10 @@ * \brief Functions to apply alpha test. */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/macros.h" #include "s_alpha.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_alpha.h b/src/mesa/swrast/s_alpha.h index a85ef8a83a..92cb01b18a 100644 --- a/src/mesa/swrast/s_alpha.h +++ b/src/mesa/swrast/s_alpha.h @@ -28,7 +28,7 @@ #define S_ALPHA_H -#include "mtypes.h" +#include "main/mtypes.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_atifragshader.c b/src/mesa/swrast/s_atifragshader.c index 55ec757ee0..9fa352c36b 100644 --- a/src/mesa/swrast/s_atifragshader.c +++ b/src/mesa/swrast/s_atifragshader.c @@ -20,10 +20,10 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" #include "shader/program.h" #include "shader/atifragshader.h" #include "swrast/s_atifragshader.h" diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index f3dda12e25..2308acae1c 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -28,10 +28,10 @@ * \author Brian Paul */ -#include "glheader.h" +#include "main/glheader.h" #include "bufferobj.h" #include "image.h" -#include "macros.h" +#include "main/macros.h" #include "pixel.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_blend.c b/src/mesa/swrast/s_blend.c index 82c5e84294..7fd8945354 100644 --- a/src/mesa/swrast/s_blend.c +++ b/src/mesa/swrast/s_blend.c @@ -35,10 +35,10 @@ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/macros.h" #include "s_blend.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_blend.h b/src/mesa/swrast/s_blend.h index 0b8cbed1a0..c8abecc099 100644 --- a/src/mesa/swrast/s_blend.h +++ b/src/mesa/swrast/s_blend.h @@ -27,7 +27,7 @@ #define S_BLEND_H -#include "mtypes.h" +#include "main/mtypes.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c index 5aec4aad03..0e12dfa1da 100644 --- a/src/mesa/swrast/s_blit.c +++ b/src/mesa/swrast/s_blit.c @@ -23,8 +23,8 @@ */ -#include "glheader.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/macros.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c index 90a56284c5..a70f474587 100644 --- a/src/mesa/swrast/s_buffers.c +++ b/src/mesa/swrast/s_buffers.c @@ -24,11 +24,11 @@ /** XXX This file should be named s_clear.c */ -#include "glheader.h" -#include "colormac.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "s_accum.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index f43fa61f8a..4d9b956f85 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -26,11 +26,11 @@ * Brian Paul */ -#include "imports.h" +#include "main/imports.h" #include "bufferobj.h" -#include "context.h" -#include "colormac.h" -#include "mtypes.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/mtypes.h" #include "teximage.h" #include "swrast.h" #include "shader/prog_statevars.h" diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index bbe1081860..7385a9942c 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -23,14 +23,14 @@ */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" #include "convolve.h" #include "histogram.h" #include "image.h" -#include "macros.h" -#include "imports.h" +#include "main/macros.h" +#include "main/imports.h" #include "pixel.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 408174c990..a9d3e9d98e 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -23,10 +23,10 @@ */ -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "fbobject.h" #include "s_depth.h" diff --git a/src/mesa/swrast/s_depth.h b/src/mesa/swrast/s_depth.h index d1ed050efd..484cc73f49 100644 --- a/src/mesa/swrast/s_depth.h +++ b/src/mesa/swrast/s_depth.h @@ -27,7 +27,7 @@ #define S_DEPTH_H -#include "mtypes.h" +#include "main/mtypes.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index cbf6617058..d1120d2cee 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -23,13 +23,13 @@ */ -#include "glheader.h" +#include "main/glheader.h" #include "bufferobj.h" -#include "context.h" +#include "main/context.h" #include "convolve.h" #include "image.h" -#include "macros.h" -#include "imports.h" +#include "main/macros.h" +#include "main/imports.h" #include "pixel.h" #include "state.h" diff --git a/src/mesa/swrast/s_drawpix.h b/src/mesa/swrast/s_drawpix.h index 66067115dd..7882a79966 100644 --- a/src/mesa/swrast/s_drawpix.h +++ b/src/mesa/swrast/s_drawpix.h @@ -28,7 +28,7 @@ #define S_DRAWPIXELS_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" /* XXX kill this header? */ diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c index 07b7409ab5..31cea8e41f 100644 --- a/src/mesa/swrast/s_feedback.c +++ b/src/mesa/swrast/s_feedback.c @@ -22,12 +22,12 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "enums.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/enums.h" #include "feedback.h" -#include "macros.h" +#include "main/macros.h" #include "s_context.h" #include "s_feedback.h" diff --git a/src/mesa/swrast/s_feedback.h b/src/mesa/swrast/s_feedback.h index 73f45c10be..6484f1dc75 100644 --- a/src/mesa/swrast/s_feedback.h +++ b/src/mesa/swrast/s_feedback.h @@ -28,7 +28,7 @@ #define S_FEEDBACK_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c index 7b143f6e5b..b9ba265db6 100644 --- a/src/mesa/swrast/s_fog.c +++ b/src/mesa/swrast/s_fog.c @@ -23,10 +23,10 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" #include "s_context.h" #include "s_fog.h" diff --git a/src/mesa/swrast/s_fog.h b/src/mesa/swrast/s_fog.h index 9639bee2cc..2346dd1734 100644 --- a/src/mesa/swrast/s_fog.h +++ b/src/mesa/swrast/s_fog.h @@ -28,7 +28,7 @@ #define S_FOG_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 3de438760b..23cb9b57ef 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -23,10 +23,10 @@ */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/macros.h" #include "s_aaline.h" #include "s_context.h" #include "s_depth.h" diff --git a/src/mesa/swrast/s_lines.h b/src/mesa/swrast/s_lines.h index 5372b99b91..6c629ca2d4 100644 --- a/src/mesa/swrast/s_lines.h +++ b/src/mesa/swrast/s_lines.h @@ -27,7 +27,7 @@ #ifndef S_LINES_H #define S_LINES_H -#include "mtypes.h" +#include "main/mtypes.h" void _swrast_choose_line( GLcontext *ctx ); diff --git a/src/mesa/swrast/s_logic.c b/src/mesa/swrast/s_logic.c index 0af9063968..f0274b4c0b 100644 --- a/src/mesa/swrast/s_logic.c +++ b/src/mesa/swrast/s_logic.c @@ -23,10 +23,10 @@ */ -#include "glheader.h" -#include "context.h" -#include "imports.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" +#include "main/macros.h" #include "s_context.h" #include "s_logic.h" diff --git a/src/mesa/swrast/s_logic.h b/src/mesa/swrast/s_logic.h index 0bc2c3f8a8..04ef00bb99 100644 --- a/src/mesa/swrast/s_logic.h +++ b/src/mesa/swrast/s_logic.h @@ -27,7 +27,7 @@ #define S_LOGIC_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_masking.c b/src/mesa/swrast/s_masking.c index a69720e83a..df779b0739 100644 --- a/src/mesa/swrast/s_masking.c +++ b/src/mesa/swrast/s_masking.c @@ -28,8 +28,8 @@ */ -#include "glheader.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/macros.h" #include "s_context.h" #include "s_masking.h" diff --git a/src/mesa/swrast/s_masking.h b/src/mesa/swrast/s_masking.h index 0596cb3f45..688c07c7ae 100644 --- a/src/mesa/swrast/s_masking.h +++ b/src/mesa/swrast/s_masking.h @@ -27,7 +27,7 @@ #define S_MASKING_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index f4b3650210..9f52da980c 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -23,10 +23,10 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" #include "texstate.h" #include "s_context.h" #include "s_feedback.h" diff --git a/src/mesa/swrast/s_points.h b/src/mesa/swrast/s_points.h index 40b442e951..3fda115c0d 100644 --- a/src/mesa/swrast/s_points.h +++ b/src/mesa/swrast/s_points.h @@ -27,7 +27,7 @@ #ifndef S_POINTS_H #define S_POINTS_H -#include "mtypes.h" +#include "main/mtypes.h" extern void _swrast_choose_point( GLcontext *ctx ); diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 2f155d0b70..6186f92899 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -23,15 +23,15 @@ */ -#include "glheader.h" +#include "main/glheader.h" #include "bufferobj.h" -#include "colormac.h" +#include "main/colormac.h" #include "convolve.h" -#include "context.h" +#include "main/context.h" #include "feedback.h" #include "image.h" -#include "macros.h" -#include "imports.h" +#include "main/macros.h" +#include "main/imports.h" #include "pixel.h" #include "state.h" diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index d9c1d1bec7..457dc4a6ce 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -30,11 +30,11 @@ * \author Brian Paul */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "image.h" #include "s_atifragshader.h" diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index 512134db0f..6b814fc8fb 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -27,7 +27,7 @@ #define S_SPAN_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_spantemp.h b/src/mesa/swrast/s_spantemp.h index 1eef81eb91..bab2ca7378 100644 --- a/src/mesa/swrast/s_spantemp.h +++ b/src/mesa/swrast/s_spantemp.h @@ -43,7 +43,7 @@ * ignored otherwise. */ -#include "macros.h" +#include "main/macros.h" #ifdef CI_MODE diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index d0cbdd6917..cdb7e4669c 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -23,9 +23,9 @@ */ -#include "glheader.h" -#include "context.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" #include "s_context.h" #include "s_depth.h" diff --git a/src/mesa/swrast/s_stencil.h b/src/mesa/swrast/s_stencil.h index 1fcb538fec..742f8d4c94 100644 --- a/src/mesa/swrast/s_stencil.h +++ b/src/mesa/swrast/s_stencil.h @@ -27,7 +27,7 @@ #define S_STENCIL_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index 4c5e22618e..b7724f7b20 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -23,11 +23,11 @@ */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "imports.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/imports.h" +#include "main/macros.h" #include "image.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_texcombine.h b/src/mesa/swrast/s_texcombine.h index 3bf70e0b86..20cd2bd8ad 100644 --- a/src/mesa/swrast/s_texcombine.h +++ b/src/mesa/swrast/s_texcombine.h @@ -27,7 +27,7 @@ #define S_TEXCOMBINE_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" extern void diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index c2a7512388..bb0fc823e7 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -23,10 +23,10 @@ */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/imports.h" #include "texformat.h" #include "s_context.h" diff --git a/src/mesa/swrast/s_texfilter.h b/src/mesa/swrast/s_texfilter.h index e4445e79a0..6267ad17eb 100644 --- a/src/mesa/swrast/s_texfilter.h +++ b/src/mesa/swrast/s_texfilter.h @@ -27,7 +27,7 @@ #define S_TEXFILTER_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c index 3f49b40d9c..f5d081d7a3 100644 --- a/src/mesa/swrast/s_texstore.c +++ b/src/mesa/swrast/s_texstore.c @@ -36,13 +36,13 @@ -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "context.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/colormac.h" +#include "main/context.h" #include "convolve.h" #include "image.h" -#include "macros.h" +#include "main/macros.h" #include "mipmap.h" #include "texformat.h" #include "teximage.h" diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index c255545217..00cff6635f 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -29,11 +29,11 @@ * functions to draw triangles. */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "imports.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/imports.h" +#include "main/macros.h" #include "texformat.h" #include "s_aatriangle.h" diff --git a/src/mesa/swrast/s_triangle.h b/src/mesa/swrast/s_triangle.h index 0de812500c..c3cadae2d4 100644 --- a/src/mesa/swrast/s_triangle.h +++ b/src/mesa/swrast/s_triangle.h @@ -28,7 +28,7 @@ #define S_TRIANGLES_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index 9f1a4c6f0a..48b4d1e240 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -22,10 +22,10 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "glheader.h" -#include "macros.h" -#include "imports.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/colormac.h" #include "s_context.h" #include "s_span.h" diff --git a/src/mesa/swrast/s_zoom.h b/src/mesa/swrast/s_zoom.h index 6ca11ac211..7701515476 100644 --- a/src/mesa/swrast/s_zoom.h +++ b/src/mesa/swrast/s_zoom.h @@ -25,7 +25,7 @@ #ifndef S_ZOOM_H #define S_ZOOM_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast.h" diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index a9c7d941e5..fd6935e7be 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -25,9 +25,9 @@ * Keith Whitwell */ -#include "glheader.h" -#include "imports.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/colormac.h" #include "ss_context.h" #include "ss_triangle.h" #include "swrast_setup.h" diff --git a/src/mesa/swrast_setup/ss_context.h b/src/mesa/swrast_setup/ss_context.h index 11f9ded3ff..1ec293fade 100644 --- a/src/mesa/swrast_setup/ss_context.h +++ b/src/mesa/swrast_setup/ss_context.h @@ -28,7 +28,7 @@ #ifndef SS_CONTEXT_H #define SS_CONTEXT_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast/swrast.h" #include "swrast_setup.h" #include "tnl/t_context.h" diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c index b4207f2c64..9fef7a52ec 100644 --- a/src/mesa/swrast_setup/ss_triangle.c +++ b/src/mesa/swrast_setup/ss_triangle.c @@ -25,10 +25,10 @@ * Keith Whitwell */ -#include "glheader.h" -#include "colormac.h" -#include "macros.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/macros.h" +#include "main/mtypes.h" #include "tnl/t_context.h" diff --git a/src/mesa/swrast_setup/ss_triangle.h b/src/mesa/swrast_setup/ss_triangle.h index 78833269e6..863e744607 100644 --- a/src/mesa/swrast_setup/ss_triangle.h +++ b/src/mesa/swrast_setup/ss_triangle.h @@ -29,7 +29,7 @@ #ifndef SS_TRIANGLE_H #define SS_TRIANGLE_H -#include "mtypes.h" +#include "main/mtypes.h" #include "ss_context.h" diff --git a/src/mesa/swrast_setup/ss_vb.h b/src/mesa/swrast_setup/ss_vb.h index 6ea0cb1a70..2ad1f56f39 100644 --- a/src/mesa/swrast_setup/ss_vb.h +++ b/src/mesa/swrast_setup/ss_vb.h @@ -29,7 +29,7 @@ #ifndef SS_VB_H #define SS_VB_H -#include "mtypes.h" +#include "main/mtypes.h" #include "swrast_setup.h" void _swsetup_vb_init( GLcontext *ctx ); diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index 5b2b2ae549..a1a46f6b82 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -26,13 +26,13 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" #include "state.h" -#include "mtypes.h" -#include "macros.h" -#include "enums.h" +#include "main/mtypes.h" +#include "main/macros.h" +#include "main/enums.h" #include "t_context.h" #include "t_pipeline.h" diff --git a/src/mesa/tnl/t_pipeline.h b/src/mesa/tnl/t_pipeline.h index 0952854b85..d110010f04 100644 --- a/src/mesa/tnl/t_pipeline.h +++ b/src/mesa/tnl/t_pipeline.h @@ -30,7 +30,7 @@ #ifndef _T_PIPELINE_H_ #define _T_PIPELINE_H_ -#include "mtypes.h" +#include "main/mtypes.h" #include "t_context.h" extern void _tnl_run_pipeline( GLcontext *ctx ); diff --git a/src/mesa/tnl/t_rasterpos.c b/src/mesa/tnl/t_rasterpos.c index be963867c0..dfbe0f1806 100644 --- a/src/mesa/tnl/t_rasterpos.c +++ b/src/mesa/tnl/t_rasterpos.c @@ -23,15 +23,15 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" #include "feedback.h" #include "light.h" -#include "macros.h" +#include "main/macros.h" #include "rastpos.h" #include "simple_list.h" -#include "mtypes.h" +#include "main/mtypes.h" #include "math/m_matrix.h" #include "tnl/tnl.h" diff --git a/src/mesa/tnl/t_vb_cull.c b/src/mesa/tnl/t_vb_cull.c index 21a32e5b1d..712901acf3 100644 --- a/src/mesa/tnl/t_vb_cull.c +++ b/src/mesa/tnl/t_vb_cull.c @@ -26,12 +26,12 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "math/m_xform.h" diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c index f6518500d8..00c0979f3f 100644 --- a/src/mesa/tnl/t_vb_fog.c +++ b/src/mesa/tnl/t_vb_fog.c @@ -26,12 +26,12 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "math/m_xform.h" diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index 12f2cc7735..ebd3412d20 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -24,13 +24,13 @@ -#include "glheader.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/colormac.h" #include "light.h" -#include "macros.h" -#include "imports.h" +#include "main/macros.h" +#include "main/imports.h" #include "simple_list.h" -#include "mtypes.h" +#include "main/mtypes.h" #include "math/m_translate.h" diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index 01fad0cee2..a4821cc1cc 100644 --- a/src/mesa/tnl/t_vb_normals.c +++ b/src/mesa/tnl/t_vb_normals.c @@ -26,12 +26,12 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "math/m_xform.h" diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index 1ac14fedf9..01d055c1dd 100644 --- a/src/mesa/tnl/t_vb_points.c +++ b/src/mesa/tnl/t_vb_points.c @@ -25,8 +25,8 @@ * Brian Paul */ -#include "mtypes.h" -#include "imports.h" +#include "main/mtypes.h" +#include "main/imports.h" #include "t_context.h" #include "t_pipeline.h" diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index f8e561ac57..c778f5d248 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -30,11 +30,11 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "shader/prog_instruction.h" #include "shader/prog_statevars.h" #include "shader/prog_execute.h" diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index c38f0745e1..c1bebc9942 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -38,12 +38,12 @@ */ -#include "glheader.h" -#include "context.h" -#include "enums.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/enums.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "t_pipeline.h" diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c index e98ab743c5..14d3876e54 100644 --- a/src/mesa/tnl/t_vb_texgen.c +++ b/src/mesa/tnl/t_vb_texgen.c @@ -35,12 +35,12 @@ * including any use thereof or modifications thereto. */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "math/m_xform.h" diff --git a/src/mesa/tnl/t_vb_texmat.c b/src/mesa/tnl/t_vb_texmat.c index 674d36f8cb..0abe8cc35d 100644 --- a/src/mesa/tnl/t_vb_texmat.c +++ b/src/mesa/tnl/t_vb_texmat.c @@ -26,12 +26,12 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "math/m_xform.h" diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index 276305b5e6..30aa7c4086 100644 --- a/src/mesa/tnl/t_vb_vertex.c +++ b/src/mesa/tnl/t_vb_vertex.c @@ -26,12 +26,12 @@ */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "math/m_xform.h" diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index a6728c318f..b661524c87 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -25,9 +25,9 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" #include "t_context.h" #include "t_vertex.h" diff --git a/src/mesa/tnl/t_vertex.h b/src/mesa/tnl/t_vertex.h index fda8f151d3..712311a146 100644 --- a/src/mesa/tnl/t_vertex.h +++ b/src/mesa/tnl/t_vertex.h @@ -28,7 +28,7 @@ #ifndef _TNL_VERTEX_H #define _TNL_VERTEX_H -#include "mtypes.h" +#include "main/mtypes.h" #include "t_context.h" /* New mechanism to specify hardware vertices so that tnl can build diff --git a/src/mesa/tnl/t_vertex_generic.c b/src/mesa/tnl/t_vertex_generic.c index 236a5bedc8..c399423b9e 100644 --- a/src/mesa/tnl/t_vertex_generic.c +++ b/src/mesa/tnl/t_vertex_generic.c @@ -26,9 +26,9 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" #include "t_context.h" #include "t_vertex.h" #include "simple_list.h" diff --git a/src/mesa/tnl/t_vertex_sse.c b/src/mesa/tnl/t_vertex_sse.c index a180441a5a..96def25206 100644 --- a/src/mesa/tnl/t_vertex_sse.c +++ b/src/mesa/tnl/t_vertex_sse.c @@ -25,13 +25,13 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" #include "t_context.h" #include "t_vertex.h" #include "simple_list.h" -#include "enums.h" +#include "main/enums.h" #if defined(USE_SSE_ASM) diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 249bccb443..b3b63cd3e4 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -30,7 +30,7 @@ */ -#include "glheader.h" +#include "main/glheader.h" #include "main/ffvertex_prog.h" #include "t_vp_build.h" diff --git a/src/mesa/tnl/t_vp_build.h b/src/mesa/tnl/t_vp_build.h index efe12e41a4..d6ebc66c04 100644 --- a/src/mesa/tnl/t_vp_build.h +++ b/src/mesa/tnl/t_vp_build.h @@ -27,7 +27,7 @@ #ifndef T_VP_BUILD_H #define T_VP_BUILD_H -#include "mtypes.h" +#include "main/mtypes.h" #define TNL_FIXED_FUNCTION_STATE_FLAGS (_NEW_PROGRAM | \ _NEW_LIGHT | \ diff --git a/src/mesa/vf/vf.c b/src/mesa/vf/vf.c index cb25f2e113..82f3d2b641 100644 --- a/src/mesa/vf/vf.c +++ b/src/mesa/vf/vf.c @@ -25,9 +25,9 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" #include "vf.h" diff --git a/src/mesa/vf/vf_generic.c b/src/mesa/vf/vf_generic.c index 68d8d0897b..baa00af29a 100644 --- a/src/mesa/vf/vf_generic.c +++ b/src/mesa/vf/vf_generic.c @@ -26,10 +26,10 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "simple_list.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/simple_list.h" #include "vf/vf.h" diff --git a/src/mesa/vf/vf_sse.c b/src/mesa/vf/vf_sse.c index c3a2166578..4d70196ffe 100644 --- a/src/mesa/vf/vf_sse.c +++ b/src/mesa/vf/vf_sse.c @@ -25,10 +25,10 @@ * Keith Whitwell */ -#include "glheader.h" -#include "colormac.h" -#include "simple_list.h" -#include "enums.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/simple_list.h" +#include "main/enums.h" #include "vf/vf.h" diff --git a/src/mesa/x86-64/x86-64.c b/src/mesa/x86-64/x86-64.c index dee09fd648..9ec43c841d 100644 --- a/src/mesa/x86-64/x86-64.c +++ b/src/mesa/x86-64/x86-64.c @@ -30,8 +30,8 @@ #ifdef USE_X86_64_ASM -#include "glheader.h" -#include "context.h" +#include "main/glheader.h" +#include "main/context.h" #include "math/m_xform.h" #include "tnl/t_context.h" #include "x86-64.h" diff --git a/src/mesa/x86/3dnow.c b/src/mesa/x86/3dnow.c index 4122ee4b00..c037a61761 100644 --- a/src/mesa/x86/3dnow.c +++ b/src/mesa/x86/3dnow.c @@ -28,8 +28,8 @@ * Holger Waechtler */ -#include "glheader.h" -#include "context.h" +#include "main/glheader.h" +#include "main/context.h" #include "math/m_xform.h" #include "tnl/t_context.h" diff --git a/src/mesa/x86/common_x86.c b/src/mesa/x86/common_x86.c index 0caa36a5a0..dc80d26fa9 100644 --- a/src/mesa/x86/common_x86.c +++ b/src/mesa/x86/common_x86.c @@ -49,7 +49,7 @@ #endif #include "common_x86_asm.h" -#include "imports.h" +#include "main/imports.h" int _mesa_x86_cpu_features = 0; diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c index 7a91364ed8..5c4bab7331 100644 --- a/src/mesa/x86/rtasm/x86sse.c +++ b/src/mesa/x86/rtasm/x86sse.c @@ -1,7 +1,7 @@ #ifdef USE_X86_ASM #if defined(__i386__) || defined(__386__) -#include "imports.h" +#include "main/imports.h" #include "x86sse.h" #define DISASSEM 0 diff --git a/src/mesa/x86/sse.c b/src/mesa/x86/sse.c index 4b016a1e85..1c185387c6 100644 --- a/src/mesa/x86/sse.c +++ b/src/mesa/x86/sse.c @@ -27,8 +27,8 @@ * Andre Werthmann */ -#include "glheader.h" -#include "context.h" +#include "main/glheader.h" +#include "main/context.h" #include "math/m_xform.h" #include "tnl/t_context.h" diff --git a/src/mesa/x86/x86.c b/src/mesa/x86/x86.c index 82caa42dbd..ce649f66b0 100644 --- a/src/mesa/x86/x86.c +++ b/src/mesa/x86/x86.c @@ -27,8 +27,8 @@ * Intel x86 assembly code by Josh Vanderhoof */ -#include "glheader.h" -#include "context.h" +#include "main/glheader.h" +#include "main/context.h" #include "math/m_xform.h" #include "tnl/t_context.h" -- cgit v1.2.3