From de69fc1703f79e5c97e66b654de7a93b7abce8f0 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 18 Sep 2007 10:02:16 -0400 Subject: Finishing up rename of the setup state to the rasterizer state. --- src/mesa/state_tracker/st_atom_rasterizer.c | 224 ++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 src/mesa/state_tracker/st_atom_rasterizer.c (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c new file mode 100644 index 0000000000..cab8ad5cd6 --- /dev/null +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -0,0 +1,224 @@ +/************************************************************************** + * + * 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 "st_cache.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "st_atom.h" + +static GLuint translate_fill( GLenum mode ) +{ + switch (mode) { + case GL_POINT: + return PIPE_POLYGON_MODE_POINT; + case GL_LINE: + return PIPE_POLYGON_MODE_LINE; + case GL_FILL: + return PIPE_POLYGON_MODE_FILL; + default: + assert(0); + return 0; + } +} + +static GLboolean get_offset_flag( GLuint fill_mode, + const struct gl_polygon_attrib *p ) +{ + switch (fill_mode) { + case PIPE_POLYGON_MODE_POINT: + return p->OffsetPoint; + case PIPE_POLYGON_MODE_LINE: + return p->OffsetLine; + case PIPE_POLYGON_MODE_FILL: + return p->OffsetFill; + default: + assert(0); + return 0; + } +} + + +static void update_raster_state( struct st_context *st ) +{ + GLcontext *ctx = st->ctx; + struct pipe_rasterizer_state raster; + const struct pipe_rasterizer_state *cached; + + memset(&raster, 0, sizeof(raster)); + + /* _NEW_POLYGON, _NEW_BUFFERS + */ + { + if (ctx->Polygon.FrontFace == GL_CCW) + raster.front_winding = PIPE_WINDING_CCW; + else + raster.front_winding = PIPE_WINDING_CW; + + /* XXX + * I think the intention here is that user-created framebuffer objects + * use Y=0=TOP layout instead of OpenGL's normal Y=0=bottom layout. + * Flipping Y changes CW to CCW and vice-versa. + * But this is an implementation/driver-specific artifact - remove... + */ + if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) + raster.front_winding ^= PIPE_WINDING_BOTH; + } + + /* _NEW_LIGHT + */ + if (ctx->Light.ShadeModel == GL_FLAT) + raster.flatshade = 1; + + /* _NEW_LIGHT | _NEW_PROGRAM + * + * Back-face colors can come from traditional lighting (when + * GL_LIGHT_MODEL_TWO_SIDE is set) or from vertex programs (when + * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. + */ + if (ctx->VertexProgram._Enabled) { + raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; + } + else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { + raster.light_twoside = 1; + } + + /* _NEW_POLYGON + */ + if (ctx->Polygon.CullFlag) { + if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { + raster.cull_mode = PIPE_WINDING_BOTH; + } + else if (ctx->Polygon.CullFaceMode == GL_FRONT) { + raster.cull_mode = raster.front_winding; + } + else { + raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; + } + } + + /* _NEW_POLYGON + */ + { + GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); + GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); + + if (raster.front_winding == PIPE_WINDING_CW) { + raster.fill_cw = fill_front; + raster.fill_ccw = fill_back; + } + else { + raster.fill_cw = fill_back; + raster.fill_ccw = fill_front; + } + + /* Simplify when culling is active: + */ + if (raster.cull_mode & PIPE_WINDING_CW) { + raster.fill_cw = raster.fill_ccw; + } + + if (raster.cull_mode & PIPE_WINDING_CCW) { + raster.fill_ccw = raster.fill_cw; + } + } + + /* _NEW_POLYGON + */ + if (ctx->Polygon.OffsetUnits != 0.0 || + ctx->Polygon.OffsetFactor != 0.0) { + 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) + raster.poly_smooth = 1; + + if (ctx->Polygon.StippleFlag) + raster.poly_stipple_enable = 1; + + + /* _NEW_BUFFERS, _NEW_POLYGON + */ + if (raster.fill_cw != PIPE_POLYGON_MODE_FILL || + raster.fill_ccw != PIPE_POLYGON_MODE_FILL) + { + GLfloat mrd = (ctx->DrawBuffer ? + ctx->DrawBuffer->_MRD : + 1.0); + + raster.offset_units = ctx->Polygon.OffsetFactor * mrd; + raster.offset_scale = (ctx->Polygon.OffsetUnits * mrd * + st->polygon_offset_scale); + } + + /* _NEW_POINT + */ + raster.point_size = ctx->Point.Size; + raster.point_smooth = ctx->Point.SmoothFlag; + + /* _NEW_LINE + */ + 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 */ + raster.line_stipple_factor = ctx->Line.StippleFactor - 1; + + /* _NEW_MULTISAMPLE */ + if (ctx->Multisample.Enabled) + raster.multisample = 1; + + /* _NEW_SCISSOR */ + if (ctx->Scissor.Enabled) + raster.scissor = 1; + + 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_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_raster_state +}; -- cgit v1.2.3 From fe555c39bb7fd530298b5be4a8f06bff41726c86 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 19 Sep 2007 14:01:18 -0400 Subject: Convert the rasterizer cso to the new semantics. Basically make cso hold the driver specific struct, while managing the template. --- src/mesa/pipe/cso_cache/cso_cache.h | 5 ++++ src/mesa/pipe/failover/fo_context.h | 2 +- src/mesa/pipe/failover/fo_state.c | 35 ++++++++++++++++++++++++---- src/mesa/pipe/failover/fo_state_emit.c | 3 ++- src/mesa/pipe/i915simple/i915_state.c | 18 ++++++-------- src/mesa/pipe/p_context.h | 11 ++++----- src/mesa/pipe/softpipe/sp_state.h | 8 +++---- src/mesa/pipe/softpipe/sp_state_rasterizer.c | 18 ++++++-------- src/mesa/state_tracker/st_atom_rasterizer.c | 10 ++++---- src/mesa/state_tracker/st_cache.c | 20 +++++++++------- src/mesa/state_tracker/st_cache.h | 6 ++--- src/mesa/state_tracker/st_cb_clear.c | 8 +++---- 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 +- 15 files changed, 90 insertions(+), 66 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h index 7ac5908922..cd4b64eec4 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.h +++ b/src/mesa/pipe/cso_cache/cso_cache.h @@ -53,6 +53,11 @@ struct cso_blend { void *data; }; +struct cso_rasterizer { + struct pipe_rasterizer_state state; + void *data; +}; + enum cso_cache_type { CSO_BLEND, CSO_SAMPLER, diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index ea7fb109b3..a649899010 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -73,7 +73,7 @@ struct failover_context { const struct fo_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; + const struct fo_state *rasterizer; const struct pipe_shader_state *fragment_shader; const struct pipe_shader_state *vertex_shader; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index ba110a6e4f..25725625e0 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -183,17 +183,42 @@ failover_set_polygon_stipple( struct pipe_context *pipe, failover->hw->set_polygon_stipple( failover->hw, stipple ); } +static void * +failover_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *templ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + state->sw_state = failover->sw->create_rasterizer_state(pipe, templ); + state->hw_state = failover->hw->create_rasterizer_state(pipe, templ); + + return state; +} static void -failover_bind_rasterizer_state( struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup ) +failover_bind_rasterizer_state(struct pipe_context *pipe, + void *raster) { struct failover_context *failover = failover_context(pipe); - failover->rasterizer = setup; + failover->rasterizer = (struct fo_state *)raster; failover->dirty |= FO_NEW_RASTERIZER; - failover->hw->bind_rasterizer_state( failover->hw, setup ); + failover->hw->bind_rasterizer_state( failover->hw, raster ); +} + +static void +failover_delete_rasterizer_state(struct pipe_context *pipe, + void *raster) +{ + struct fo_state *state = (struct fo_state*)raster; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_rasterizer_state(pipe, state->sw_state); + failover->hw->delete_rasterizer_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); } @@ -284,7 +309,9 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.delete_blend_state = failover_delete_blend_state; failover->pipe.bind_sampler_state = failover_bind_sampler_state; failover->pipe.bind_depth_stencil_state = failover_bind_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; failover->pipe.bind_fs_state = failover_bind_fs_state; failover->pipe.bind_vs_state = failover_bind_vs_state; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index 72697c01a9..f2b0b1edc0 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -87,7 +87,8 @@ failover_state_emit( struct failover_context *failover ) failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple ); if (failover->dirty & FO_NEW_RASTERIZER) - failover->sw->bind_rasterizer_state( failover->sw, failover->rasterizer ); + failover->sw->bind_rasterizer_state( failover->sw, + failover->rasterizer->sw_state ); if (failover->dirty & FO_NEW_SCISSOR) failover->sw->set_scissor_state( failover->sw, &failover->scissor ); diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 4a4d26be65..66aa9a0274 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -371,23 +371,19 @@ static void i915_set_viewport_state( struct pipe_context *pipe, } -static const struct pipe_rasterizer_state * +static void * 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; + return 0; } static void i915_bind_rasterizer_state( struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup ) + void *setup ) { struct i915_context *i915 = i915_context(pipe); - i915->rasterizer = setup; + i915->rasterizer = (struct pipe_rasterizer_state *)setup; /* pass-through to draw module */ draw_set_rasterizer_state(i915->draw, setup); @@ -395,10 +391,10 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe, i915->dirty |= I915_NEW_RASTERIZER; } -static void i915_delete_rasterizer_state( struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup ) +static void i915_delete_rasterizer_state(struct pipe_context *pipe, + void *setup) { - free((struct pipe_rasterizer_state*)setup); + /* do nothing */ } static void i915_set_vertex_buffer( struct pipe_context *pipe, diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index adca6612d5..1c0ab794f0 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -99,13 +99,10 @@ 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 *); + 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 *); const struct pipe_depth_stencil_state * (*create_depth_stencil_state)( struct pipe_context *, diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 8e7776a6c7..a20ae1d4a2 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -58,13 +58,13 @@ 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 * +void * 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_bind_rasterizer_state(struct pipe_context *, + void *); void softpipe_delete_rasterizer_state(struct pipe_context *, - const struct pipe_rasterizer_state *); + void *); void softpipe_set_framebuffer_state( struct pipe_context *, const struct pipe_framebuffer_state * ); diff --git a/src/mesa/pipe/softpipe/sp_state_rasterizer.c b/src/mesa/pipe/softpipe/sp_state_rasterizer.c index d832adb91b..d7845cef82 100644 --- a/src/mesa/pipe/softpipe/sp_state_rasterizer.c +++ b/src/mesa/pipe/softpipe/sp_state_rasterizer.c @@ -32,34 +32,30 @@ -const struct pipe_rasterizer_state * +void * softpipe_create_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup) + 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; + return 0; } void softpipe_bind_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup) + void *setup) { struct softpipe_context *softpipe = softpipe_context(pipe); /* pass-through to draw module */ draw_set_rasterizer_state(softpipe->draw, setup); - softpipe->rasterizer = setup; + softpipe->rasterizer = (struct pipe_rasterizer_state *)setup; softpipe->dirty |= SP_NEW_RASTERIZER; } void softpipe_delete_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *rasterizer) + void *rasterizer) { - free((struct pipe_rasterizer_state*)rasterizer); + /* do nothing */ } diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index cab8ad5cd6..e0d83ddaea 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -73,7 +73,7 @@ static void update_raster_state( struct st_context *st ) { GLcontext *ctx = st->ctx; struct pipe_rasterizer_state raster; - const struct pipe_rasterizer_state *cached; + const struct cso_rasterizer *cso; memset(&raster, 0, sizeof(raster)); @@ -206,10 +206,10 @@ static void update_raster_state( struct st_context *st ) if (ctx->Scissor.Enabled) raster.scissor = 1; - cached = st_cached_rasterizer_state(st, &raster); - if (st->state.rasterizer != cached) { - st->state.rasterizer = cached; - st->pipe->bind_rasterizer_state( st->pipe, cached ); + cso = st_cached_rasterizer_state(st, &raster); + if (st->state.rasterizer != cso) { + st->state.rasterizer = cso; + st->pipe->bind_rasterizer_state(st->pipe, cso->data); } } diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index bd6c63b7a1..0f233cea58 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -95,22 +95,24 @@ 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( +const struct cso_rasterizer* st_cached_rasterizer_state( struct st_context *st, - const struct pipe_rasterizer_state *raster) + const struct pipe_rasterizer_state *templ) { - unsigned hash_key = cso_construct_key((void*)raster, + unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_rasterizer_state)); struct cso_hash_iter iter = cso_find_state_template(st->cache, hash_key, CSO_RASTERIZER, - (void*)raster); + (void*)templ); 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); + struct cso_rasterizer *cso = malloc(sizeof(struct cso_rasterizer)); + memcpy(&cso->state, templ, sizeof(struct pipe_rasterizer_state)); + cso->data = st->pipe->create_rasterizer_state(st->pipe, templ); + if (!cso->data) + cso->data = &cso->state; + iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER, cso); } - return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter)); + return (struct cso_rasterizer*)(cso_hash_iter_data(iter)); } struct pipe_shader_state * st_cached_fs_state( diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index fb0ff0d4db..5b8c6168a8 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -51,9 +51,9 @@ struct pipe_depth_stencil_state *st_cached_depth_stencil_state( struct st_context *st, 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); +const struct cso_rasterizer * +st_cached_rasterizer_state(struct st_context *st, + const struct pipe_rasterizer_state *raster); struct pipe_shader_state *st_cached_fs_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 3a6991754a..5d5efd9eae 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -345,7 +345,7 @@ clear_with_quad(GLcontext *ctx, /* setup state: nothing */ { struct pipe_rasterizer_state raster; - const struct pipe_rasterizer_state *cached; + const struct cso_rasterizer *cso; memset(&raster, 0, sizeof(raster)); #if 0 /* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD @@ -354,8 +354,8 @@ clear_with_quad(GLcontext *ctx, if (ctx->Scissor.Enabled) raster.scissor = 1; #endif - cached = st_cached_rasterizer_state(ctx->st, &raster); - pipe->bind_rasterizer_state(pipe, cached); + cso = st_cached_rasterizer_state(ctx->st, &raster); + pipe->bind_rasterizer_state(pipe, cso->data); } /* fragment shader state: color pass-through program */ @@ -415,7 +415,7 @@ clear_with_quad(GLcontext *ctx, pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil); pipe->bind_fs_state(pipe, st->state.fs); pipe->bind_vs_state(pipe, st->state.vs); - pipe->bind_rasterizer_state(pipe, st->state.rasterizer); + pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); 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 4a554cd5a4..0fd728c930 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -328,12 +328,12 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* setup state: just scissor */ { struct pipe_rasterizer_state setup; - struct pipe_rasterizer_state *cached; + const struct cso_rasterizer *cso; memset(&setup, 0, sizeof(setup)); if (ctx->Scissor.Enabled) setup.scissor = 1; - cached = st_cached_rasterizer_state(ctx->st, &setup); - pipe->bind_rasterizer_state(pipe, cached); + cso = st_cached_rasterizer_state(ctx->st, &setup); + pipe->bind_rasterizer_state(pipe, cso->data); } /* fragment shader state: TEX lookup program */ @@ -417,7 +417,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, draw_quad(ctx, x0, y0, z, x1, y1); /* restore GL state */ - pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer); + pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data); pipe->bind_fs_state(pipe, ctx->st->state.fs); pipe->bind_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 966574b67c..93b6425480 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -78,7 +78,7 @@ struct st_context const struct cso_blend *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; - const struct pipe_rasterizer_state *rasterizer; + const struct cso_rasterizer *rasterizer; const struct pipe_shader_state *fs; const struct pipe_shader_state *vs; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 6efe3ce8b8..e36c10d595 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -404,7 +404,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_rasterizer_state(draw, st->state.rasterizer); + draw_set_rasterizer_state(draw, st->state.rasterizer->data); draw_set_vertex_shader(draw, st->state.vs); /* XXX need to set vertex info too */ -- cgit v1.2.3 From cd4d732773e06e462e78b8f5bc9f3f1552a198ac Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 22 Oct 2007 11:41:31 -0600 Subject: add point_sprite flag to rasterizer state --- src/mesa/pipe/p_state.h | 1 + src/mesa/state_tracker/st_atom_rasterizer.c | 1 + 2 files changed, 2 insertions(+) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index daa74ec053..fd3f4f22b9 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -85,6 +85,7 @@ struct pipe_rasterizer_state unsigned poly_smooth:1; unsigned poly_stipple_enable:1; unsigned point_smooth:1; + unsigned point_sprite:1; unsigned multisample:1; /* XXX maybe more ms state in future */ unsigned line_smooth:1; unsigned line_stipple_enable:1; diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index e0d83ddaea..9fbd7dc09e 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -188,6 +188,7 @@ static void update_raster_state( struct st_context *st ) */ raster.point_size = ctx->Point.Size; raster.point_smooth = ctx->Point.SmoothFlag; + raster.point_sprite = ctx->Point.PointSprite; /* _NEW_LINE */ -- cgit v1.2.3 From 1b4852345954af9b582b03a91a3d8399b8fb0e92 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 22 Oct 2007 12:10:30 -0600 Subject: add support for sprite texcoord modes --- src/mesa/pipe/draw/draw_wide_prims.c | 27 ++++++++++++++++++++------- src/mesa/pipe/p_defines.h | 7 +++++++ src/mesa/pipe/p_state.h | 1 + src/mesa/state_tracker/st_atom_rasterizer.c | 12 ++++++++++++ 4 files changed, 40 insertions(+), 7 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/pipe/draw/draw_wide_prims.c b/src/mesa/pipe/draw/draw_wide_prims.c index 0d02e70814..917944a611 100644 --- a/src/mesa/pipe/draw/draw_wide_prims.c +++ b/src/mesa/pipe/draw/draw_wide_prims.c @@ -40,7 +40,8 @@ struct wide_stage { float half_line_width; float half_point_size; - uint texcoord[PIPE_MAX_SHADER_OUTPUTS]; + uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS]; + uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS]; uint num_texcoords; }; @@ -123,16 +124,26 @@ static void wide_line( struct draw_stage *stage, } +/** + * Set the vertex texcoords for sprite mode. + * Coords may be left untouched or set to a right-side-up or upside-down + * orientation. + */ static void set_texcoords(const struct wide_stage *wide, struct vertex_header *v, const float tc[4]) { uint i; for (i = 0; i < wide->num_texcoords; i++) { - uint j = wide->texcoord[i]; - v->data[j][0] = tc[0]; - v->data[j][1] = tc[1]; - v->data[j][2] = tc[2]; - v->data[j][3] = tc[3]; + if (wide->texcoord_mode[i] != PIPE_SPRITE_COORD_NONE) { + uint j = wide->texcoord_slot[i]; + v->data[j][0] = tc[0]; + if (wide->texcoord_mode[i] == PIPE_SPRITE_COORD_LOWER_LEFT) + v->data[j][1] = 1.0 - tc[1]; + else + v->data[j][1] = tc[1]; + v->data[j][2] = tc[2]; + v->data[j][3] = tc[3]; + } } } @@ -230,7 +241,9 @@ static void wide_begin( struct draw_stage *stage ) uint i, j = 0; for (i = 0; i < vs->state->num_outputs; i++) { if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) { - wide->texcoord[j++] = i; + wide->texcoord_slot[j] = i; + wide->texcoord_mode[j] = draw->rasterizer->sprite_coord_mode[j]; + j++; } } wide->num_texcoords = j; diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index d336f83998..9281d40bd3 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -308,4 +308,11 @@ #define PIPE_QUERY_TYPES 3 +/** + * Point sprite coord modes + */ +#define PIPE_SPRITE_COORD_NONE 0 +#define PIPE_SPRITE_COORD_UPPER_LEFT 1 +#define PIPE_SPRITE_COORD_LOWER_LEFT 2 + #endif diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index fd3f4f22b9..ecbcbd098a 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -96,6 +96,7 @@ struct pipe_rasterizer_state float point_size; /**< used when no per-vertex size */ float offset_units; float offset_scale; + ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */ }; diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 9fbd7dc09e..9f857e2837 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -74,6 +74,7 @@ static void update_raster_state( struct st_context *st ) GLcontext *ctx = st->ctx; struct pipe_rasterizer_state raster; const struct cso_rasterizer *cso; + uint i; memset(&raster, 0, sizeof(raster)); @@ -189,6 +190,17 @@ static void update_raster_state( struct st_context *st ) raster.point_size = ctx->Point.Size; raster.point_smooth = ctx->Point.SmoothFlag; raster.point_sprite = ctx->Point.PointSprite; + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { + if (ctx->Point.CoordReplace[i]) { + if (ctx->Point.SpriteOrigin == GL_UPPER_LEFT) + raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT; + else + raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT; + } + else { + raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; + } + } /* _NEW_LINE */ -- cgit v1.2.3 From beefc6011bce9e99cb46430186de1c13f027cb05 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 22 Oct 2007 12:19:54 -0600 Subject: new flag to control psize (from vertex shader or fixed size) --- src/mesa/pipe/draw/draw_wide_prims.c | 25 ++++++++++++++++++++++++- src/mesa/pipe/p_state.h | 1 + src/mesa/state_tracker/st_atom_rasterizer.c | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/pipe/draw/draw_wide_prims.c b/src/mesa/pipe/draw/draw_wide_prims.c index 917944a611..e61cc2e025 100644 --- a/src/mesa/pipe/draw/draw_wide_prims.c +++ b/src/mesa/pipe/draw/draw_wide_prims.c @@ -43,6 +43,8 @@ struct wide_stage { uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS]; uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS]; uint num_texcoords; + + int psize_slot; }; @@ -158,7 +160,7 @@ static void wide_point( struct draw_stage *stage, { const struct wide_stage *wide = wide_stage(stage); const boolean sprite = stage->draw->rasterizer->point_sprite; - float half_size = wide->half_point_size; + float half_size; float left_adj, right_adj; struct prim_header tri; @@ -174,6 +176,14 @@ static void wide_point( struct draw_stage *stage, float *pos2 = v2->data[0]; float *pos3 = v3->data[0]; + /* point size is either per-vertex or fixed size */ + if (wide->psize_slot >= 0) { + half_size = header->v[0]->data[wide->psize_slot][0]; + } + else { + half_size = wide->half_point_size; + } + left_adj = -half_size + 0.25; right_adj = half_size + 0.25; @@ -248,6 +258,19 @@ static void wide_begin( struct draw_stage *stage ) } wide->num_texcoords = j; } + + wide->psize_slot = -1; + if (draw->rasterizer->point_size_per_vertex) { + /* find PSIZ vertex output */ + const struct draw_vertex_shader *vs = draw->vertex_shader; + uint i; + for (i = 0; i < vs->state->num_outputs; i++) { + if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) { + wide->psize_slot = i; + break; + } + } + } stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index ecbcbd098a..4a18d25ab8 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -86,6 +86,7 @@ struct pipe_rasterizer_state unsigned poly_stipple_enable:1; unsigned point_smooth:1; unsigned point_sprite:1; + unsigned point_size_per_vertex:1; /**< size computed in vertex shader */ unsigned multisample:1; /* XXX maybe more ms state in future */ unsigned line_smooth:1; unsigned line_stipple_enable:1; diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 9f857e2837..2a7128dd27 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -201,6 +201,7 @@ static void update_raster_state( struct st_context *st ) raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; } } + raster.point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled; /* _NEW_LINE */ -- cgit v1.2.3 From 017f862de1f857bca29f09794539aaf411014f13 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 14 Dec 2007 12:25:25 -0700 Subject: Added origin_lower_left field to pipe_rasterizer_state This controls whether the window origin is considered to be the lower-left or upper-left corner. This effects computation of gl_FragCoord and the application of polygon stipple. --- src/mesa/pipe/p_state.h | 1 + src/mesa/pipe/softpipe/sp_prim_setup.c | 14 +++++++++++--- src/mesa/pipe/softpipe/sp_quad_stipple.c | 16 ++++++++++++---- src/mesa/state_tracker/st_atom_rasterizer.c | 2 ++ 4 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 43b710ff3b..af65d365bf 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -94,6 +94,7 @@ struct pipe_rasterizer_state unsigned line_stipple_factor:8; /**< [1..256] actually */ unsigned line_stipple_pattern:16; unsigned bypass_clipping:1; + unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */ float line_width; float point_size; /**< used when no per-vertex size */ diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 8d8dceadc5..2ccf5e2624 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -480,15 +480,23 @@ static void tri_persp_coeff( struct setup_stage *setup, static void setup_fragcoord_coeff(struct setup_stage *setup) { - const int winHeight = setup->softpipe->framebuffer.cbufs[0]->height; /*X*/ setup->coef[0].a0[0] = 0; setup->coef[0].dadx[0] = 1.0; setup->coef[0].dady[0] = 0.0; /*Y*/ - setup->coef[0].a0[1] = winHeight - 1; + if (setup->softpipe->rasterizer->origin_lower_left) { + /* y=0=bottom */ + const int winHeight = setup->softpipe->framebuffer.cbufs[0]->height; + setup->coef[0].a0[1] = winHeight - 1; + setup->coef[0].dady[1] = -1.0; + } + else { + /* y=0=top */ + setup->coef[0].a0[1] = 0.0; + setup->coef[0].dady[1] = 1.0; + } setup->coef[0].dadx[1] = 0.0; - setup->coef[0].dady[1] = -1.0; /*Z*/ setup->coef[0].a0[2] = setup->posCoef.a0[2]; setup->coef[0].dadx[2] = setup->posCoef.dadx[2]; diff --git a/src/mesa/pipe/softpipe/sp_quad_stipple.c b/src/mesa/pipe/softpipe/sp_quad_stipple.c index 04d95989c4..0c42963dfe 100644 --- a/src/mesa/pipe/softpipe/sp_quad_stipple.c +++ b/src/mesa/pipe/softpipe/sp_quad_stipple.c @@ -22,10 +22,18 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad) if (quad->prim == PRIM_TRI) { struct softpipe_context *softpipe = qs->softpipe; /* need to invert Y to index into OpenGL's stipple pattern */ - const int y0 = softpipe->framebuffer.cbufs[0]->height - 1 - quad->y0; - const int y1 = y0 - 1; - const unsigned stipple0 = softpipe->poly_stipple.stipple[y0 % 32]; - const unsigned stipple1 = softpipe->poly_stipple.stipple[y1 % 32]; + int y0, y1; + uint stipple0, stipple1; + if (softpipe->rasterizer->origin_lower_left) { + y0 = softpipe->framebuffer.cbufs[0]->height - 1 - quad->y0; + y1 = y0 - 1; + } + else { + y0 = quad->y0; + y1 = y0 + 1; + } + stipple0 = softpipe->poly_stipple.stipple[y0 % 32]; + stipple1 = softpipe->poly_stipple.stipple[y1 % 32]; #if 1 const int col0 = quad->x0 % 32; diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 2a7128dd27..5c6b89d78c 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -77,6 +77,8 @@ static void update_raster_state( struct st_context *st ) uint i; memset(&raster, 0, sizeof(raster)); + + raster.origin_lower_left = 1; /* Always true for OpenGL */ /* _NEW_POLYGON, _NEW_BUFFERS */ -- cgit v1.2.3 From 52da6b559a47eca2c1a8ec1b713e188f38e1d16a Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 18 Dec 2007 16:00:58 -0700 Subject: fix bug on GL_VERTEX_PROGRAM_TWO_SIDE path --- src/mesa/state_tracker/st_atom_rasterizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 5c6b89d78c..35fd506458 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -109,7 +109,7 @@ static void update_raster_state( struct st_context *st ) * GL_LIGHT_MODEL_TWO_SIDE is set) or from vertex programs (when * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. */ - if (ctx->VertexProgram._Enabled) { + if (ctx->VertexProgram._Current) { raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; } else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { -- cgit v1.2.3 From dd235ff1db6a2839607931cc07f9ba6e602ac3d4 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 16 Jan 2008 08:30:00 -0700 Subject: Fix a two-sided lighting bug (fixes samples/wave.c) --- src/mesa/state_tracker/st_atom_rasterizer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 35fd506458..beae36bca0 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -110,7 +110,14 @@ static void update_raster_state( struct st_context *st ) * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. */ if (ctx->VertexProgram._Current) { - raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; + if (ctx->VertexProgram._Enabled) { + /* user-defined program */ + raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; + } + else { + /* TNL-generated program */ + raster.light_twoside = ctx->Light.Enabled && ctx->Light.Model.TwoSide; + } } else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { raster.light_twoside = 1; -- cgit v1.2.3 From 2444f6c6a4c2f54c3198882c2256419628ca49d1 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 23 Jan 2008 08:24:30 -0700 Subject: gallium: fix computation of raster.point_size_per_vertex flag --- src/mesa/state_tracker/st_atom_rasterizer.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index beae36bca0..435d604af7 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -74,6 +74,7 @@ static void update_raster_state( struct st_context *st ) GLcontext *ctx = st->ctx; struct pipe_rasterizer_state raster; const struct cso_rasterizer *cso; + const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current; uint i; memset(&raster, 0, sizeof(raster)); @@ -210,7 +211,19 @@ static void update_raster_state( struct st_context *st ) raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; } } - raster.point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled; + if (vertProg) { + if (vertProg->Base.Id == 0) { + if (vertProg->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { + /* generated program which emits point size */ + raster.point_size_per_vertex = TRUE; + } + } + else if (ctx->VertexProgram.PointSizeEnabled) { + /* user-defined program and GL_VERTEX_PROGRAM_POINT_SIZE set */ + raster.point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled; + } + } + /* _NEW_LINE */ -- cgit v1.2.3 From 09ba1dd4ccb0ed907510cb9403b1fb1fb0ab3658 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 25 Feb 2008 16:25:24 -0700 Subject: gallium: clamp line width when creating raster state object --- src/mesa/state_tracker/st_atom_rasterizer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 435d604af7..229839d8b2 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -30,7 +30,7 @@ * Keith Whitwell */ - +#include "main/macros.h" #include "st_context.h" #include "st_cache.h" #include "pipe/p_context.h" @@ -227,8 +227,18 @@ static void update_raster_state( struct st_context *st ) /* _NEW_LINE */ - raster.line_width = ctx->Line.Width; raster.line_smooth = ctx->Line.SmoothFlag; + if (ctx->Line.SmoothFlag) { + raster.line_width = CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidthAA, + ctx->Const.MaxLineWidthAA); + } + else { + raster.line_width = CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidth, + ctx->Const.MaxLineWidth); + } + 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 */ -- cgit v1.2.3 From 339e7ec6805e6de8794514c0a935081b5d36d38f Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 11 Mar 2008 18:54:31 -0600 Subject: gallium: rework CSO-related code in state tracker Use the code in cso_context.c rather than st_cache.c. Basically, binding of state objects now goes through the CSO module. But Vertex/fragment shaders go through pipe->bind_fs/vs_state() since they're not cached by the CSO module at this time. Also, update softpipe driver to handle NULL state objects in various places. This happens during context destruction. May need to update other drivers... --- src/gallium/auxiliary/draw/draw_aaline.c | 3 +- src/gallium/auxiliary/draw/draw_aapoint.c | 3 +- src/gallium/auxiliary/draw/draw_pstipple.c | 3 +- src/gallium/drivers/softpipe/sp_state_fs.c | 3 +- src/mesa/sources | 1 - src/mesa/state_tracker/st_atom_blend.c | 52 ++++++-------- src/mesa/state_tracker/st_atom_depth.c | 60 +++++++--------- src/mesa/state_tracker/st_atom_rasterizer.c | 108 ++++++++++++++-------------- src/mesa/state_tracker/st_atom_sampler.c | 43 ++++++----- src/mesa/state_tracker/st_atom_shader.c | 28 ++------ src/mesa/state_tracker/st_cb_accum.c | 1 - src/mesa/state_tracker/st_cb_clear.c | 47 ++++++------ src/mesa/state_tracker/st_cb_drawpixels.c | 64 +++++++++-------- src/mesa/state_tracker/st_cb_program.c | 5 +- src/mesa/state_tracker/st_context.c | 9 ++- src/mesa/state_tracker/st_context.h | 19 ++--- src/mesa/state_tracker/st_debug.c | 6 +- src/mesa/state_tracker/st_draw.c | 13 ++-- src/mesa/state_tracker/st_gen_mipmap.c | 34 ++++----- src/mesa/state_tracker/st_mesa_to_tgsi.c | 5 +- src/mesa/state_tracker/st_mesa_to_tgsi.h | 2 +- src/mesa/state_tracker/st_program.c | 59 +++++++++------ src/mesa/state_tracker/st_program.h | 22 ++---- 23 files changed, 292 insertions(+), 298 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/gallium/auxiliary/draw/draw_aaline.c b/src/gallium/auxiliary/draw/draw_aaline.c index 3ec73b0800..6b1e640ae9 100644 --- a/src/gallium/auxiliary/draw/draw_aaline.c +++ b/src/gallium/auxiliary/draw/draw_aaline.c @@ -733,7 +733,8 @@ aaline_bind_fs_state(struct pipe_context *pipe, void *fs) /* save current */ aaline->fs = aafs; /* pass-through */ - aaline->driver_bind_fs_state(aaline->pipe, aafs->driver_fs); + aaline->driver_bind_fs_state(aaline->pipe, + (aafs ? aafs->driver_fs : NULL)); } diff --git a/src/gallium/auxiliary/draw/draw_aapoint.c b/src/gallium/auxiliary/draw/draw_aapoint.c index 70f696475f..99e9e9fe34 100644 --- a/src/gallium/auxiliary/draw/draw_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_aapoint.c @@ -800,7 +800,8 @@ aapoint_bind_fs_state(struct pipe_context *pipe, void *fs) /* save current */ aapoint->fs = aafs; /* pass-through */ - aapoint->driver_bind_fs_state(aapoint->pipe, aafs->driver_fs); + aapoint->driver_bind_fs_state(aapoint->pipe, + (aafs ? aafs->driver_fs : NULL)); } diff --git a/src/gallium/auxiliary/draw/draw_pstipple.c b/src/gallium/auxiliary/draw/draw_pstipple.c index b3e52dc1c7..ed50d0805a 100644 --- a/src/gallium/auxiliary/draw/draw_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pstipple.c @@ -595,7 +595,8 @@ pstip_bind_fs_state(struct pipe_context *pipe, void *fs) /* save current */ pstip->fs = aafs; /* pass-through */ - pstip->driver_bind_fs_state(pstip->pipe, aafs->driver_fs); + pstip->driver_bind_fs_state(pstip->pipe, + (aafs ? aafs->driver_fs : NULL)); } diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index eb641ed321..4eefd1d61f 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -120,7 +120,8 @@ softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) softpipe->vs = (const struct sp_vertex_shader *)vs; - draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data); + draw_bind_vertex_shader(softpipe->draw, + (softpipe->vs ? softpipe->vs->draw_data : NULL)); softpipe->dirty |= SP_NEW_VS; } diff --git a/src/mesa/sources b/src/mesa/sources index f0bf7b31fb..e3d5f22849 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -184,7 +184,6 @@ STATETRACKER_SOURCES = \ state_tracker/st_cb_readpixels.c \ state_tracker/st_cb_strings.c \ state_tracker/st_cb_texture.c \ - state_tracker/st_cache.c \ state_tracker/st_context.c \ state_tracker/st_debug.c \ state_tracker/st_draw.c \ diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 2a9d209153..6c13fc8141 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -33,11 +33,11 @@ #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "cso_cache/cso_context.h" /** @@ -155,44 +155,43 @@ translate_logicop(GLenum logicop) static void update_blend( struct st_context *st ) { - struct pipe_blend_state blend; - const struct cso_blend *cso; + struct pipe_blend_state *blend = &st->state.blend; - memset(&blend, 0, sizeof(blend)); + memset(blend, 0, sizeof(*blend)); if (st->ctx->Color.ColorLogicOpEnabled || (st->ctx->Color.BlendEnabled && st->ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) { /* logicop enabled */ - blend.logicop_enable = 1; - blend.logicop_func = translate_logicop(st->ctx->Color.LogicOp); + blend->logicop_enable = 1; + blend->logicop_func = translate_logicop(st->ctx->Color.LogicOp); } else if (st->ctx->Color.BlendEnabled) { /* blending enabled */ - blend.blend_enable = 1; + blend->blend_enable = 1; - blend.rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); + blend->rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); if (st->ctx->Color.BlendEquationRGB == GL_MIN || st->ctx->Color.BlendEquationRGB == GL_MAX) { /* Min/max are special */ - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ONE; + blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rgb_dst_factor = PIPE_BLENDFACTOR_ONE; } else { - blend.rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); - blend.rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); + blend->rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); + blend->rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); } - blend.alpha_func = translate_blend(st->ctx->Color.BlendEquationA); + blend->alpha_func = translate_blend(st->ctx->Color.BlendEquationA); if (st->ctx->Color.BlendEquationA == GL_MIN || st->ctx->Color.BlendEquationA == GL_MAX) { /* Min/max are special */ - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ONE; + blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->alpha_dst_factor = PIPE_BLENDFACTOR_ONE; } else { - blend.alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); - blend.alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); + blend->alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); + blend->alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); } } else { @@ -201,25 +200,18 @@ update_blend( struct st_context *st ) /* Colormask - maybe reverse these bits? */ if (st->ctx->Color.ColorMask[0]) - blend.colormask |= PIPE_MASK_R; + blend->colormask |= PIPE_MASK_R; if (st->ctx->Color.ColorMask[1]) - blend.colormask |= PIPE_MASK_G; + blend->colormask |= PIPE_MASK_G; if (st->ctx->Color.ColorMask[2]) - blend.colormask |= PIPE_MASK_B; + blend->colormask |= PIPE_MASK_B; if (st->ctx->Color.ColorMask[3]) - blend.colormask |= PIPE_MASK_A; + blend->colormask |= PIPE_MASK_A; if (st->ctx->Color.DitherFlag) - blend.dither = 1; + blend->dither = 1; - cso = st_cached_blend_state(st, &blend); - - if (st->state.blend != cso) { - /* state has changed */ - st->state.blend = cso; - /* bind new state */ - st->pipe->bind_blend_state(st->pipe, cso->data); - } + cso_set_blend(st->cso_context, blend); if (memcmp(st->ctx->Color.BlendColor, &st->state.blend_color, 4 * sizeof(GLfloat)) != 0) { /* state has changed */ diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index 7aecdbfbcc..827ad3b548 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -34,10 +34,10 @@ #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "cso_cache/cso_context.h" /** @@ -93,53 +93,47 @@ gl_stencil_op_to_pipe(GLenum func) static void update_depth_stencil_alpha(struct st_context *st) { - struct pipe_depth_stencil_alpha_state depth_stencil; - const struct cso_depth_stencil_alpha *cso; + struct pipe_depth_stencil_alpha_state *dsa = &st->state.depth_stencil; - memset(&depth_stencil, 0, sizeof(depth_stencil)); + memset(dsa, 0, sizeof(*dsa)); - depth_stencil.depth.enabled = st->ctx->Depth.Test; - depth_stencil.depth.writemask = st->ctx->Depth.Mask; - depth_stencil.depth.func = st_compare_func_to_pipe(st->ctx->Depth.Func); + dsa->depth.enabled = st->ctx->Depth.Test; + dsa->depth.writemask = st->ctx->Depth.Mask; + dsa->depth.func = st_compare_func_to_pipe(st->ctx->Depth.Func); if (st->ctx->Query.CurrentOcclusionObject && st->ctx->Query.CurrentOcclusionObject->Active) - depth_stencil.depth.occlusion_count = 1; + dsa->depth.occlusion_count = 1; if (st->ctx->Stencil.Enabled) { - 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; + dsa->stencil[0].enabled = 1; + dsa->stencil[0].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]); + dsa->stencil[0].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]); + dsa->stencil[0].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]); + dsa->stencil[0].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]); + dsa->stencil[0].ref_value = st->ctx->Stencil.Ref[0] & 0xff; + dsa->stencil[0].value_mask = st->ctx->Stencil.ValueMask[0] & 0xff; + dsa->stencil[0].write_mask = st->ctx->Stencil.WriteMask[0] & 0xff; if (st->ctx->Stencil.TestTwoSide) { - 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; + dsa->stencil[1].enabled = 1; + dsa->stencil[1].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]); + dsa->stencil[1].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]); + dsa->stencil[1].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]); + dsa->stencil[1].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]); + dsa->stencil[1].ref_value = st->ctx->Stencil.Ref[1] & 0xff; + dsa->stencil[1].value_mask = st->ctx->Stencil.ValueMask[1] & 0xff; + dsa->stencil[1].write_mask = st->ctx->Stencil.WriteMask[1] & 0xff; } } 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; + dsa->alpha.enabled = 1; + dsa->alpha.func = st_compare_func_to_pipe(st->ctx->Color.AlphaFunc); + dsa->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_alpha_state(st->pipe, cso->data); /* bind new state */ - } + cso_set_depth_stencil_alpha(st->cso_context, dsa); } diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 229839d8b2..77cef9236b 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -32,10 +32,11 @@ #include "main/macros.h" #include "st_context.h" -#include "st_cache.h" +#include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "st_atom.h" +#include "cso_cache/cso_context.h" + static GLuint translate_fill( GLenum mode ) { @@ -72,22 +73,21 @@ static GLboolean get_offset_flag( GLuint fill_mode, static void update_raster_state( struct st_context *st ) { GLcontext *ctx = st->ctx; - struct pipe_rasterizer_state raster; - const struct cso_rasterizer *cso; + struct pipe_rasterizer_state *raster = &st->state.rasterizer; const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current; uint i; - memset(&raster, 0, sizeof(raster)); + memset(raster, 0, sizeof(*raster)); - raster.origin_lower_left = 1; /* Always true for OpenGL */ + raster->origin_lower_left = 1; /* Always true for OpenGL */ /* _NEW_POLYGON, _NEW_BUFFERS */ { if (ctx->Polygon.FrontFace == GL_CCW) - raster.front_winding = PIPE_WINDING_CCW; + raster->front_winding = PIPE_WINDING_CCW; else - raster.front_winding = PIPE_WINDING_CW; + raster->front_winding = PIPE_WINDING_CW; /* XXX * I think the intention here is that user-created framebuffer objects @@ -96,13 +96,13 @@ static void update_raster_state( struct st_context *st ) * But this is an implementation/driver-specific artifact - remove... */ if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) - raster.front_winding ^= PIPE_WINDING_BOTH; + raster->front_winding ^= PIPE_WINDING_BOTH; } /* _NEW_LIGHT */ if (ctx->Light.ShadeModel == GL_FLAT) - raster.flatshade = 1; + raster->flatshade = 1; /* _NEW_LIGHT | _NEW_PROGRAM * @@ -113,28 +113,28 @@ static void update_raster_state( struct st_context *st ) if (ctx->VertexProgram._Current) { if (ctx->VertexProgram._Enabled) { /* user-defined program */ - raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; + raster->light_twoside = ctx->VertexProgram.TwoSideEnabled; } else { /* TNL-generated program */ - raster.light_twoside = ctx->Light.Enabled && ctx->Light.Model.TwoSide; + raster->light_twoside = ctx->Light.Enabled && ctx->Light.Model.TwoSide; } } else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { - raster.light_twoside = 1; + raster->light_twoside = 1; } /* _NEW_POLYGON */ if (ctx->Polygon.CullFlag) { if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - raster.cull_mode = PIPE_WINDING_BOTH; + raster->cull_mode = PIPE_WINDING_BOTH; } else if (ctx->Polygon.CullFaceMode == GL_FRONT) { - raster.cull_mode = raster.front_winding; + raster->cull_mode = raster->front_winding; } else { - raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; + raster->cull_mode = raster->front_winding ^ PIPE_WINDING_BOTH; } } @@ -144,23 +144,23 @@ static void update_raster_state( struct st_context *st ) GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); - if (raster.front_winding == PIPE_WINDING_CW) { - raster.fill_cw = fill_front; - raster.fill_ccw = fill_back; + if (raster->front_winding == PIPE_WINDING_CW) { + raster->fill_cw = fill_front; + raster->fill_ccw = fill_back; } else { - raster.fill_cw = fill_back; - raster.fill_ccw = fill_front; + raster->fill_cw = fill_back; + raster->fill_ccw = fill_front; } /* Simplify when culling is active: */ - if (raster.cull_mode & PIPE_WINDING_CW) { - raster.fill_cw = raster.fill_ccw; + if (raster->cull_mode & PIPE_WINDING_CW) { + raster->fill_cw = raster->fill_ccw; } - if (raster.cull_mode & PIPE_WINDING_CCW) { - raster.fill_ccw = raster.fill_cw; + if (raster->cull_mode & PIPE_WINDING_CCW) { + raster->fill_ccw = raster->fill_cw; } } @@ -168,95 +168,91 @@ static void update_raster_state( struct st_context *st ) */ if (ctx->Polygon.OffsetUnits != 0.0 || ctx->Polygon.OffsetFactor != 0.0) { - 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; + 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) - raster.poly_smooth = 1; + raster->poly_smooth = 1; if (ctx->Polygon.StippleFlag) - raster.poly_stipple_enable = 1; + raster->poly_stipple_enable = 1; /* _NEW_BUFFERS, _NEW_POLYGON */ - if (raster.fill_cw != PIPE_POLYGON_MODE_FILL || - raster.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); - raster.offset_units = ctx->Polygon.OffsetFactor * mrd; - raster.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 */ - raster.point_size = ctx->Point.Size; - raster.point_smooth = ctx->Point.SmoothFlag; - raster.point_sprite = ctx->Point.PointSprite; + raster->point_size = ctx->Point.Size; + raster->point_smooth = ctx->Point.SmoothFlag; + raster->point_sprite = ctx->Point.PointSprite; for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { if (ctx->Point.CoordReplace[i]) { if (ctx->Point.SpriteOrigin == GL_UPPER_LEFT) - raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT; + raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT; else - raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT; + raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT; } else { - raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; + raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; } } if (vertProg) { if (vertProg->Base.Id == 0) { if (vertProg->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { /* generated program which emits point size */ - raster.point_size_per_vertex = TRUE; + raster->point_size_per_vertex = TRUE; } } else if (ctx->VertexProgram.PointSizeEnabled) { /* user-defined program and GL_VERTEX_PROGRAM_POINT_SIZE set */ - raster.point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled; + raster->point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled; } } /* _NEW_LINE */ - raster.line_smooth = ctx->Line.SmoothFlag; + raster->line_smooth = ctx->Line.SmoothFlag; if (ctx->Line.SmoothFlag) { - raster.line_width = CLAMP(ctx->Line.Width, + raster->line_width = CLAMP(ctx->Line.Width, ctx->Const.MinLineWidthAA, ctx->Const.MaxLineWidthAA); } else { - raster.line_width = CLAMP(ctx->Line.Width, + raster->line_width = CLAMP(ctx->Line.Width, ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth); } - raster.line_stipple_enable = ctx->Line.StippleFlag; - raster.line_stipple_pattern = ctx->Line.StipplePattern; + 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 */ - raster.line_stipple_factor = ctx->Line.StippleFactor - 1; + raster->line_stipple_factor = ctx->Line.StippleFactor - 1; /* _NEW_MULTISAMPLE */ if (ctx->Multisample.Enabled) - raster.multisample = 1; + raster->multisample = 1; /* _NEW_SCISSOR */ if (ctx->Scissor.Enabled) - raster.scissor = 1; + raster->scissor = 1; - cso = st_cached_rasterizer_state(st, &raster); - if (st->state.rasterizer != cso) { - st->state.rasterizer = cso; - st->pipe->bind_rasterizer_state(st->pipe, cso->data); - } + cso_set_rasterizer(st->cso_context, raster); } const struct st_tracked_state st_update_rasterizer = { diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 1000f98ffc..1babba9b4f 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -33,11 +33,11 @@ #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "st_program.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "cso_cache/cso_context.h" /** @@ -124,9 +124,9 @@ update_samplers(struct st_context *st) /* loop over sampler units (aka tex image units) */ for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) { - struct pipe_sampler_state sampler; + struct pipe_sampler_state *sampler = st->state.samplers + su; - memset(&sampler, 0, sizeof(sampler)); + memset(sampler, 0, sizeof(*sampler)); if (fs->Base.Base.SamplersUsed & (1 << su)) { GLuint texUnit = fs->Base.Base.SamplerUnits[su]; @@ -135,37 +135,37 @@ update_samplers(struct st_context *st) assert(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->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_img_filter = gl_filter_to_img_filter(texobj->MinFilter); - sampler.min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter); - sampler.mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter); + sampler->min_img_filter = gl_filter_to_img_filter(texobj->MinFilter); + sampler->min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter); + sampler->mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter); if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB) - sampler.normalized_coords = 1; + sampler->normalized_coords = 1; - sampler.lod_bias = st->ctx->Texture.Unit[su].LodBias; + sampler->lod_bias = st->ctx->Texture.Unit[su].LodBias; #if 1 - sampler.min_lod = (texobj->MinLod) < 0.0 ? 0.0 : texobj->MinLod; - sampler.max_lod = texobj->MaxLod; + sampler->min_lod = (texobj->MinLod) < 0.0 ? 0.0 : texobj->MinLod; + sampler->max_lod = texobj->MaxLod; #else /* min/max lod should really be as follows (untested). * Also, calculate_first_last_level() needs to be overhauled * since today's hardware had real support for LOD clamping. */ - sampler.min_lod = MAX2(texobj->BaseLevel, texobj->MinLod); - sampler.max_lod = MIN2(texobj->MaxLevel, texobj->MaxLod); + sampler->min_lod = MAX2(texobj->BaseLevel, texobj->MinLod); + sampler->max_lod = MIN2(texobj->MaxLevel, texobj->MaxLod); #endif - sampler.max_anisotropy = texobj->MaxAnisotropy; + sampler->max_anisotropy = texobj->MaxAnisotropy; /* only care about ARB_shadow, not SGI shadow */ if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) { - sampler.compare = 1; - sampler.compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE; - sampler.compare_func + sampler->compare = 1; + sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE; + sampler->compare_func = st_compare_func_to_pipe(texobj->CompareFunc); } @@ -174,11 +174,10 @@ update_samplers(struct st_context *st) /* XXX more sampler state here */ } - st->state.sampler[su] = st_cached_sampler_state(st, &sampler)->data; + cso_single_sampler(st->cso_context, su, sampler); } - st->pipe->bind_sampler_states(st->pipe, st->state.num_samplers, - st->state.sampler); + cso_single_sampler_done(st->cso_context); } diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 10c131d554..0726688493 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -43,10 +43,9 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" -#include "cso_cache/cso_cache.h" +#include "cso_cache/cso_context.h" #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "st_program.h" #include "st_atom_shader.h" @@ -70,9 +69,6 @@ struct translated_vertex_program /** Maps VERT_RESULT_x to slot */ GLuint output_to_slot[VERT_RESULT_MAX]; - /** The program in TGSI format */ - struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; - /** Pointer to the translated vertex program */ struct st_vertex_program *vp; @@ -158,7 +154,7 @@ find_translated_vp(struct st_context *st, /* * Translate fragment program if needed. */ - if (!stfp->cso) { + if (!stfp->state.tokens) { GLuint inAttr, numIn = 0; for (inAttr = 0; inAttr < FRAG_ATTRIB_MAX; inAttr++) { @@ -175,11 +171,7 @@ find_translated_vp(struct st_context *st, assert(stfp->Base.Base.NumInstructions > 1); - (void) st_translate_fragment_program(st, stfp, - stfp->input_to_slot, - stfp->tokens, - ST_MAX_SHADER_TOKENS); - assert(stfp->cso); + st_translate_fragment_program(st, stfp, stfp->input_to_slot); } @@ -261,12 +253,8 @@ find_translated_vp(struct st_context *st, assert(stvp->Base.Base.NumInstructions > 1); - st_translate_vertex_program(st, stvp, - xvp->output_to_slot, - xvp->tokens, - ST_MAX_SHADER_TOKENS); + st_translate_vertex_program(st, stvp, xvp->output_to_slot); - assert(stvp->cso); xvp->vp = stvp; /* translated VP is up to date now */ @@ -296,12 +284,10 @@ update_linkage( struct st_context *st ) xvp = find_translated_vp(st, stvp, stfp); st->vp = stvp; - st->state.vs = xvp->vp; - st->pipe->bind_vs_state(st->pipe, st->state.vs->cso->data); - st->fp = stfp; - st->state.fs = stfp->cso; - st->pipe->bind_fs_state(st->pipe, st->state.fs->data); + + st->pipe->bind_vs_state(st->pipe, stvp->driver_shader); + st->pipe->bind_fs_state(st->pipe, stfp->driver_shader); st->vertex_result_to_slot = xvp->output_to_slot; } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 663c4f205d..f1fddc4e02 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -35,7 +35,6 @@ #include "main/macros.h" #include "st_context.h" -#include "st_cache.h" #include "st_cb_accum.h" #include "st_cb_fbo.h" #include "st_draw.h" diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index e712fd84cd..eae40f2a4f 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -35,7 +35,6 @@ #include "main/macros.h" #include "shader/prog_instruction.h" #include "st_atom.h" -#include "st_cache.h" #include "st_context.h" #include "st_cb_accum.h" #include "st_cb_clear.h" @@ -50,6 +49,8 @@ #include "pipe/p_defines.h" #include "pipe/p_winsys.h" +#include "cso_cache/cso_context.h" + @@ -157,8 +158,7 @@ make_frag_shader(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR); stfp = (struct st_fragment_program *) p; - st_translate_fragment_program(st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(st, stfp, NULL); return stfp; } @@ -206,9 +206,10 @@ make_vertex_shader(struct st_context *st) (1 << VERT_RESULT_HPOS)); stvp = (struct st_vertex_program *) p; - st_translate_vertex_program(st, stvp, NULL, - stvp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_vertex_program(st, stvp, NULL); +#if 0 assert(stvp->cso); +#endif return stvp; } @@ -284,7 +285,6 @@ clear_with_quad(GLcontext *ctx, /* blend state: RGBA masking */ { struct pipe_blend_state blend; - const struct cso_blend *cso; memset(&blend, 0, sizeof(blend)); if (color) { if (ctx->Color.ColorMask[0]) @@ -298,14 +298,12 @@ clear_with_quad(GLcontext *ctx, if (st->ctx->Color.DitherFlag) blend.dither = 1; } - cso = st_cached_blend_state(st, &blend); - pipe->bind_blend_state(pipe, cso->data); + cso_set_blend(st->cso_context, &blend); } /* depth_stencil state: always pass/set to ref value */ { 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; @@ -323,14 +321,13 @@ clear_with_quad(GLcontext *ctx, depth_stencil.stencil[0].value_mask = 0xff; depth_stencil.stencil[0].write_mask = ctx->Stencil.WriteMask[0] & 0xff; } - cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil); - pipe->bind_depth_stencil_alpha_state(pipe, cso->data); + + cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil); } /* rasterizer state: nothing */ { struct pipe_rasterizer_state raster; - const struct cso_rasterizer *cso; memset(&raster, 0, sizeof(raster)); #if 0 /* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD @@ -339,8 +336,7 @@ clear_with_quad(GLcontext *ctx, if (ctx->Scissor.Enabled) raster.scissor = 1; #endif - cso = st_cached_rasterizer_state(st, &raster); - pipe->bind_rasterizer_state(pipe, cso->data); + cso_set_rasterizer(st->cso_context, &raster); } /* fragment shader state: color pass-through program */ @@ -349,7 +345,7 @@ clear_with_quad(GLcontext *ctx, if (!stfp) { stfp = make_frag_shader(st); } - pipe->bind_fs_state(pipe, stfp->cso->data); + pipe->bind_fs_state(pipe, stfp->driver_shader); } /* vertex shader state: color/position pass-through */ @@ -358,7 +354,7 @@ clear_with_quad(GLcontext *ctx, if (!stvp) { stvp = make_vertex_shader(st); } - pipe->bind_vs_state(pipe, stvp->cso->data); + pipe->bind_vs_state(pipe, stvp->driver_shader); } /* viewport state: viewport matching window dims */ @@ -380,16 +376,19 @@ clear_with_quad(GLcontext *ctx, /* draw quad matching scissor rect (XXX verify coord round-off) */ draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); +#if 0 + /* Can't depend on old state objects still existing -- may have + * been deleted to make room in the hash, etc. (Should get + * fixed...) + */ + st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL); +#else /* Restore pipe state */ - pipe->bind_blend_state(pipe, st->state.blend->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->cso->data); - pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); + cso_set_rasterizer(st->cso_context, &st->state.rasterizer); + pipe->bind_fs_state(pipe, st->fp->driver_shader); + pipe->bind_vs_state(pipe, st->vp->driver_shader); +#endif pipe->set_viewport_state(pipe, &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 dee4c4132a..18ec9645c4 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -41,7 +41,6 @@ #include "st_context.h" #include "st_atom.h" #include "st_atom_constbuf.h" -#include "st_cache.h" #include "st_draw.h" #include "st_program.h" #include "st_cb_drawpixels.h" @@ -58,6 +57,7 @@ #include "pipe/p_winsys.h" #include "util/p_tile.h" #include "shader/prog_instruction.h" +#include "cso_cache/cso_context.h" /** @@ -159,8 +159,7 @@ make_bitmap_fragment_program(GLcontext *ctx) stfp = (struct st_fragment_program *) p; stfp->Base.UsesKill = GL_TRUE; - st_translate_fragment_program(ctx->st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(ctx->st, stfp, NULL); return stfp; } @@ -204,8 +203,7 @@ combined_bitmap_fragment_program(GLcontext *ctx) #endif /* translate to TGSI tokens */ - st_translate_fragment_program(st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(st, stfp, NULL); /* save new program, update serial numbers */ st->bitmap.user_prog_sn = st->fp->serialNo; @@ -266,8 +264,7 @@ combined_drawpix_fragment_program(GLcontext *ctx) #endif /* translate to TGSI tokens */ - st_translate_fragment_program(st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(st, stfp, NULL); /* save new program, update serial numbers */ st->pixel_xfer.xfer_prog_sn = st->pixel_xfer.program->serialNo; @@ -343,8 +340,7 @@ make_fragment_shader_z(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR) | (1 << FRAG_RESULT_DEPR); stfp = (struct st_fragment_program *) p; - st_translate_fragment_program(st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(st, stfp, NULL); return stfp; } @@ -421,8 +417,7 @@ st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor) } stvp = (struct st_vertex_program *) p; - st_translate_vertex_program(st, stvp, NULL, - stvp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_vertex_program(st, stvp, NULL); progs[passColor] = stvp; @@ -641,7 +636,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, const GLfloat *color, GLboolean invertTex) { + struct st_context *st = ctx->st; struct pipe_context *pipe = ctx->st->pipe; + struct cso_context *cso = ctx->st->cso_context; GLfloat x0, y0, x1, y1; GLuint maxSize; @@ -656,24 +653,23 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* setup state: just scissor */ { struct pipe_rasterizer_state setup; - const struct cso_rasterizer *cso; memset(&setup, 0, sizeof(setup)); if (ctx->Scissor.Enabled) setup.scissor = 1; - cso = st_cached_rasterizer_state(ctx->st, &setup); - pipe->bind_rasterizer_state(pipe, cso->data); + + cso_set_rasterizer(cso, &setup); } /* fragment shader state: TEX lookup program */ - pipe->bind_fs_state(pipe, stfp->cso->data); + pipe->bind_fs_state(pipe, stfp->driver_shader); /* vertex shader state: position + texcoord pass-through */ - pipe->bind_vs_state(pipe, stvp->cso->data); + pipe->bind_vs_state(pipe, stvp->driver_shader); + /* texture sampling state: */ { struct pipe_sampler_state sampler; - const struct cso_sampler *cso; memset(&sampler, 0, sizeof(sampler)); sampler.wrap_s = PIPE_TEX_WRAP_CLAMP; sampler.wrap_t = PIPE_TEX_WRAP_CLAMP; @@ -682,8 +678,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; sampler.normalized_coords = 1; - cso = st_cached_sampler_state(ctx->st, &sampler); - pipe->bind_sampler_states(pipe, 1, (void**)&cso->data); + + cso_single_sampler(cso, 0, &sampler); + cso_single_sampler_done(cso); } /* viewport state: viewport matching window dims */ @@ -723,14 +720,25 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, draw_quad(ctx, x0, y0, z, x1, y1, invertTex); /* restore GL state */ - pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data); - pipe->bind_fs_state(pipe, ctx->st->state.fs->data); - pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data); pipe->set_sampler_textures(pipe, ctx->st->state.num_textures, ctx->st->state.sampler_texture); - pipe->bind_sampler_states(pipe, ctx->st->state.num_samplers, - ctx->st->state.sampler); + pipe->set_viewport_state(pipe, &ctx->st->state.viewport); + +#if 0 + /* Can't depend on old state objects still existing -- may have + * been deleted to make room in the hash, etc. (Should get + * fixed...) + */ + st_invalidate_state(ctx, _NEW_COLOR | _NEW_TEXTURE); +#else + /* restore state */ + pipe->bind_fs_state(pipe, st->fp->driver_shader); + pipe->bind_vs_state(pipe, st->vp->driver_shader); + cso_set_rasterizer(cso, &st->state.rasterizer); + cso_set_samplers(cso, PIPE_MAX_SAMPLERS, + (const struct pipe_sampler_state **) st->state.sampler_list); +#endif } @@ -798,10 +806,10 @@ compatible_formats(GLenum format, GLenum type, enum pipe_format pipeFormat) static GLboolean any_fragment_ops(const struct st_context *st) { - 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) + if (st->state.depth_stencil.alpha.enabled || + st->state.depth_stencil.depth.enabled || + st->state.blend.blend_enable || + st->state.blend.logicop_enable) /* XXX more checks */ return GL_TRUE; else diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 61d4f4c41c..4dc76f19b1 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -168,11 +168,13 @@ static void st_program_string_notify( GLcontext *ctx, stfp->serialNo++; +#if 0 if (stfp->cso) { /* free the TGSI code */ // cso_delete(stfp->vs); stfp->cso = NULL; } +#endif stfp->param_state = stfp->Base.Base.Parameters->StateFlags; @@ -184,13 +186,14 @@ static void st_program_string_notify( GLcontext *ctx, stvp->serialNo++; +#if 0 if (stvp->cso) { /* free the CSO data */ st->pipe->delete_vs_state(st->pipe, stvp->cso->data); FREE((void *) stvp->cso); stvp->cso = NULL; } - +#endif if (stvp->draw_shader) { draw_delete_vertex_shader(st->draw, stvp->draw_shader); stvp->draw_shader = NULL; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 09e389f9dc..5458ab420e 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -56,6 +56,7 @@ #include "pipe/p_inlines.h" #include "draw/draw_context.h" #include "cso_cache/cso_cache.h" +#include "cso_cache/cso_context.h" /** @@ -78,6 +79,7 @@ void st_invalidate_state(GLcontext * ctx, GLuint new_state) static struct st_context * st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) { + uint i; struct st_context *st = CALLOC_STRUCT( st_context ); ctx->st = st; @@ -93,12 +95,15 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st->dirty.mesa = ~0; st->dirty.st = ~0; - st->cache = cso_cache_create(); + st->cso_context = cso_create_context(pipe); st_init_atoms( st ); st_init_draw( st ); st_init_generate_mipmap(st); + for (i = 0; i < PIPE_MAX_SAMPLERS; i++) + st->state.sampler_list[i] = &st->state.samplers[i]; + /* we want all vertex data to be placed in buffer objects */ vbo_use_buffer_objects(ctx); @@ -149,7 +154,7 @@ static void st_destroy_context_priv( struct st_context *st ) _vbo_DestroyContext(st->ctx); - cso_cache_delete( st->cache ); + cso_destroy_context(st->cso_context); _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 897a5109b7..e81aebba3d 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -74,14 +74,11 @@ struct st_context * Other state is just parameter values. */ struct { - const struct cso_alpha_test *alpha_test; - const struct cso_blend *blend; - void *sampler[PIPE_MAX_SAMPLERS]; - const struct cso_depth_stencil_alpha *depth_stencil; - const struct cso_rasterizer *rasterizer; - const struct cso_fragment_shader *fs; - struct st_vertex_program *vs; - + struct pipe_blend_state blend; + struct pipe_depth_stencil_alpha_state depth_stencil; + struct pipe_rasterizer_state rasterizer; + struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS]; struct pipe_blend_color blend_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; @@ -151,6 +148,10 @@ struct st_context /** For gen/render mipmap feature */ struct { + struct pipe_blend_state blend; + struct pipe_depth_stencil_alpha_state depthstencil; + struct pipe_rasterizer_state rasterizer; + void *blend_cso; void *depthstencil_cso; void *rasterizer_cso; @@ -158,7 +159,7 @@ struct st_context struct st_vertex_program *stvp; } gen_mipmap; - struct cso_cache *cache; + struct cso_context *cso_context; }; diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 5888bcb98a..9c13010da8 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -53,15 +53,15 @@ st_print_current(void) int i; printf("Vertex Transform Inputs:\n"); - for (i = 0; i < st->state.vs->cso->state.num_inputs; i++) { + for (i = 0; i < st->vp->state.num_inputs; i++) { printf(" Slot %d: VERT_ATTRIB_%d\n", i, st->vp->index_to_input[i]); } - tgsi_dump( st->state.vs->cso->state.tokens, 0 ); + tgsi_dump( st->vp->state.tokens, 0 ); if (st->vp->Base.Base.Parameters) _mesa_print_parameter_list(st->vp->Base.Base.Parameters); - tgsi_dump( st->state.fs->state.tokens, 0 ); + tgsi_dump( st->fp->state.tokens, 0 ); if (st->fp->Base.Base.Parameters) _mesa_print_parameter_list(st->fp->Base.Base.Parameters); } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 1c0fa8c6aa..98504e46c1 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -36,7 +36,6 @@ #include "vbo/vbo.h" #include "st_atom.h" -#include "st_cache.h" #include "st_context.h" #include "st_cb_bufferobjects.h" #include "st_draw.h" @@ -219,7 +218,7 @@ st_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = &ctx->st->state.vs->cso->state; + vs = &ctx->st->vp->state; /* loop over TGSI shader inputs to determine vertex buffer * and attribute info @@ -481,10 +480,10 @@ st_feedback_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = &ctx->st->state.vs->cso->state; + vs = &st->vp->state; - if (!st->state.vs->draw_shader) { - st->state.vs->draw_shader = draw_create_vertex_shader(draw, vs); + if (!st->vp->draw_shader) { + st->vp->draw_shader = draw_create_vertex_shader(draw, vs); } /* @@ -496,8 +495,8 @@ 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_rasterizer_state(draw, &st->state.rasterizer->state); - draw_bind_vertex_shader(draw, st->state.vs->draw_shader); + draw_set_rasterizer_state(draw, &st->state.rasterizer); + draw_bind_vertex_shader(draw, st->vp->draw_shader); set_feedback_vertex_format(ctx); /* loop over TGSI shader inputs to determine vertex buffer diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 3723e26d45..9c4e1032ef 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -38,6 +38,7 @@ #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" #include "cso_cache/cso_cache.h" +#include "cso_cache/cso_context.h" #include "st_context.h" #include "st_draw.h" @@ -89,8 +90,7 @@ make_tex_fragment_program(GLcontext *ctx) stfp = (struct st_fragment_program *) p; - st_translate_fragment_program(ctx->st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(ctx->st, stfp, NULL); return stfp; } @@ -118,6 +118,7 @@ st_init_generate_mipmap(struct st_context *st) blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; blend.colormask = PIPE_MASK_RGBA; + st->gen_mipmap.blend = blend; st->gen_mipmap.blend_cso = pipe->create_blend_state(pipe, &blend); memset(&depthstencil, 0, sizeof(depthstencil)); @@ -257,14 +258,14 @@ st_render_mipmap(struct st_context *st, sampler.normalized_coords = 1; - /* bind CSOs */ - pipe->bind_blend_state(pipe, st->gen_mipmap.blend_cso); - pipe->bind_depth_stencil_alpha_state(pipe, st->gen_mipmap.depthstencil_cso); - pipe->bind_rasterizer_state(pipe, st->gen_mipmap.rasterizer_cso); + /* bind state */ + cso_set_blend(st->cso_context, &st->gen_mipmap.blend); + cso_set_depth_stencil_alpha(st->cso_context, &st->gen_mipmap.depthstencil); + cso_set_rasterizer(st->cso_context, &st->gen_mipmap.rasterizer); /* bind shaders */ - pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->cso->data); - pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->cso->data); + pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->driver_shader); + pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->driver_shader); /* * XXX for small mipmap levels, it may be faster to use the software @@ -304,17 +305,18 @@ st_render_mipmap(struct st_context *st, /*pt->first_level = first_level_save;*/ /* restore pipe state */ - if (st->state.rasterizer) - pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); - if (st->state.fs) - pipe->bind_fs_state(pipe, st->state.fs->data); - if (st->state.vs) - pipe->bind_vs_state(pipe, st->state.vs->cso->data); - pipe->bind_sampler_states(pipe, st->state.num_samplers, - st->state.sampler); +#if 0 + cso_set_rasterizer(st->cso_context, &st->state.rasterizer); + cso_set_samplers(st->cso_context, st->state.samplers_list); + pipe->bind_fs_state(pipe, st->fp->shader_program); + pipe->bind_vs_state(pipe, st->vp->shader_program); pipe->set_sampler_textures(pipe, st->state.num_textures, st->state.sampler_texture); pipe->set_viewport_state(pipe, &st->state.viewport); +#else + /* XXX is this sufficient? */ + st_invalidate_state(st->ctx, _NEW_COLOR | _NEW_TEXTURE); +#endif return TRUE; } diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 97206752af..9446b012ad 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -683,8 +683,9 @@ find_temporaries(const struct gl_program *program, * \param tokens array to store translated tokens in * \param maxTokens size of the tokens array * + * \return number of tokens placed in 'tokens' buffer, or zero if error */ -GLboolean +GLuint tgsi_translate_mesa_program( uint procType, const struct gl_program *program, @@ -918,6 +919,6 @@ tgsi_translate_mesa_program( maxTokens - ti ); } - return GL_TRUE; + return ti; } diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index 3ababf1339..63fc855b53 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -39,7 +39,7 @@ extern "C" { struct tgsi_token; struct gl_program; -GLboolean +GLuint tgsi_translate_mesa_program( uint procType, const struct gl_program *program, diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index aa252c845a..0f8784e132 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -42,15 +42,29 @@ #include "tgsi/util/tgsi_dump.h" #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "st_program.h" #include "st_mesa_to_tgsi.h" +#include "cso_cache/cso_context.h" #define TGSI_DEBUG 0 +/** XXX we should use the version of this from p_util.h but including + * that header causes symbol collisions. + */ +static INLINE void * +mem_dup(const void *src, uint size) +{ + void *dup = MALLOC(size); + if (dup) + memcpy(dup, src, size); + return dup; +} + + + /** * Translate a Mesa vertex shader into a TGSI shader. * \param outputMapping to map vertex program output registers to TGSI @@ -61,15 +75,15 @@ void st_translate_vertex_program(struct st_context *st, struct st_vertex_program *stvp, - const GLuint outputMapping[], - struct tgsi_token *tokensOut, - GLuint maxTokens) + const GLuint outputMapping[]) { + struct pipe_context *pipe = st->pipe; + struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; GLuint defaultOutputMapping[VERT_RESULT_MAX]; struct pipe_shader_state vs; - const struct cso_vertex_shader *cso; GLuint attr, i; GLuint num_generic = 0; + GLuint num_tokens; memset(&vs, 0, sizeof(vs)); @@ -240,7 +254,7 @@ st_translate_vertex_program(struct st_context *st, /* XXX: fix static allocation of tokens: */ - tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX, + num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX, &stvp->Base.Base, /* inputs */ vs.num_inputs, @@ -252,20 +266,21 @@ st_translate_vertex_program(struct st_context *st, vs.num_outputs, outputMapping, vs.output_semantic_name, - vs.output_semantic_index, + vs.output_semantic_index, /* tokenized result */ - tokensOut, maxTokens); + tokens, ST_MAX_SHADER_TOKENS); - vs.tokens = tokensOut; + vs.tokens = (struct tgsi_token *) + mem_dup(tokens, num_tokens * sizeof(tokens[0])); - cso = st_cached_vs_state(st, &vs); - stvp->cso = cso; + stvp->state = vs; /* struct copy */ + stvp->driver_shader = pipe->create_vs_state(pipe, &vs); if (0) _mesa_print_program(&stvp->Base.Base); if (TGSI_DEBUG) - tgsi_dump( tokensOut, 0 ); + tgsi_dump( vs.tokens, 0 ); } @@ -280,10 +295,10 @@ st_translate_vertex_program(struct st_context *st, const struct cso_fragment_shader * st_translate_fragment_program(struct st_context *st, struct st_fragment_program *stfp, - const GLuint inputMapping[], - struct tgsi_token *tokensOut, - GLuint maxTokens) + const GLuint inputMapping[]) { + struct pipe_context *pipe = st->pipe; + struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; GLuint outputMapping[FRAG_RESULT_MAX]; GLuint defaultInputMapping[FRAG_ATTRIB_MAX]; struct pipe_shader_state fs; @@ -293,6 +308,7 @@ st_translate_fragment_program(struct st_context *st, const GLbitfield inputsRead = stfp->Base.Base.InputsRead; GLuint vslot = 0; GLuint num_generic = 0; + GLuint num_tokens; memset(&fs, 0, sizeof(fs)); @@ -401,7 +417,7 @@ st_translate_fragment_program(struct st_context *st, /* XXX: fix static allocation of tokens: */ - tgsi_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT, + num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT, &stfp->Base.Base, /* inputs */ fs.num_inputs, @@ -415,18 +431,19 @@ st_translate_fragment_program(struct st_context *st, fs.output_semantic_name, fs.output_semantic_index, /* tokenized result */ - tokensOut, maxTokens); + tokens, ST_MAX_SHADER_TOKENS); - fs.tokens = tokensOut; + fs.tokens = (struct tgsi_token *) + mem_dup(tokens, num_tokens * sizeof(tokens[0])); - cso = st_cached_fs_state(st, &fs); - stfp->cso = cso; + stfp->state = fs; /* struct copy */ + stfp->driver_shader = pipe->create_fs_state(pipe, &fs); if (0) _mesa_print_program(&stfp->Base.Base); if (TGSI_DEBUG) - tgsi_dump( tokensOut, 0/*TGSI_DUMP_VERBOSE*/ ); + tgsi_dump( fs.tokens, 0/*TGSI_DUMP_VERBOSE*/ ); return cso; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 31558af6ce..78786dcbb6 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -60,11 +60,8 @@ struct st_fragment_program /** map FP input back to VP output */ GLuint input_map[PIPE_MAX_SHADER_INPUTS]; - /** The program in TGSI format */ - struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; - - /** Pointer to the corresponding cached shader */ - const struct cso_fragment_shader *cso; + struct pipe_shader_state state; + struct pipe_shader_state *driver_shader; GLuint param_state; @@ -88,11 +85,8 @@ struct st_vertex_program /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */ GLuint index_to_input[PIPE_MAX_SHADER_INPUTS]; - /** The program in TGSI format */ - struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; - - /** Pointer to the corresponding cached shader */ - const struct cso_vertex_shader *cso; + struct pipe_shader_state state; + struct pipe_shader_state *driver_shader; /** For using our private draw module (glRasterPos) */ struct draw_vertex_shader *draw_shader; @@ -122,16 +116,12 @@ st_vertex_program( struct gl_vertex_program *vp ) extern const struct cso_fragment_shader * st_translate_fragment_program(struct st_context *st, struct st_fragment_program *fp, - const GLuint inputMapping[], - struct tgsi_token *tokens, - GLuint maxTokens); + const GLuint inputMapping[]); extern void 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); + const GLuint vert_output_to_slot[]); #endif -- cgit v1.2.3 From cbf42c45a15d6a132c7f7d4946c422ee3de35e6c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 14 Mar 2008 17:45:27 -0600 Subject: gallium: if point size not computed per vertex, apply size clamp immediately. Fixes glean pointAtten failure. --- src/mesa/state_tracker/st_atom_rasterizer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 77cef9236b..17d77f90ae 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -223,7 +223,12 @@ static void update_raster_state( struct st_context *st ) raster->point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled; } } - + if (!raster->point_size_per_vertex) { + /* clamp size now */ + raster->point_size = CLAMP(ctx->Point.Size, + ctx->Point.MinSize, + ctx->Point.MaxSize); + } /* _NEW_LINE */ -- cgit v1.2.3 From bc739440c29c551fcc44e9e12d0d9c170d8d24fb Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 2 Apr 2008 10:43:37 +0100 Subject: gallium: add temporary facility for rasterization-time clamping of point sizes --- src/gallium/auxiliary/draw/draw_wide_point.c | 14 +++++++++++++- src/gallium/include/pipe/p_state.h | 2 ++ src/mesa/state_tracker/st_atom_rasterizer.c | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/gallium/auxiliary/draw/draw_wide_point.c b/src/gallium/auxiliary/draw/draw_wide_point.c index c53f7e6cb3..86281ca3d8 100644 --- a/src/gallium/auxiliary/draw/draw_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_wide_point.c @@ -38,6 +38,8 @@ struct widepoint_stage { struct draw_stage stage; float half_point_size; + float point_size_min; + float point_size_max; uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS]; uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS]; @@ -128,7 +130,15 @@ static void widepoint_point( struct draw_stage *stage, /* point size is either per-vertex or fixed size */ if (wide->psize_slot >= 0) { - half_size = 0.5f * header->v[0]->data[wide->psize_slot][0]; + half_size = header->v[0]->data[wide->psize_slot][0]; + + /* XXX: temporary -- do this in the vertex shader?? + */ + half_size = CLAMP(half_size, + wide->point_size_min, + wide->point_size_max); + + half_size *= 0.5f; } else { half_size = wide->half_point_size; @@ -182,6 +192,8 @@ static void widepoint_first_point( struct draw_stage *stage, struct draw_context *draw = stage->draw; wide->half_point_size = 0.5f * draw->rasterizer->point_size; + wide->point_size_min = draw->rasterizer->point_size_min; + wide->point_size_max = draw->rasterizer->point_size_max; /* XXX we won't know the real size if it's computed by the vertex shader! */ if ((draw->rasterizer->point_size > draw->wide_point_threshold) || diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index a73028814e..e407e3bc72 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -118,6 +118,8 @@ struct pipe_rasterizer_state float line_width; float point_size; /**< used when no per-vertex size */ + float point_size_min; /* XXX - temporary, will go away */ + float point_size_max; /* XXX - temporary, will go away */ float offset_units; float offset_scale; ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */ diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 17d77f90ae..14c26c16c0 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -198,6 +198,10 @@ static void update_raster_state( struct st_context *st ) /* _NEW_POINT */ raster->point_size = ctx->Point.Size; + + raster->point_size_min = 0; /* temporary, will go away */ + raster->point_size_max = 1000; /* temporary, will go away */ + raster->point_smooth = ctx->Point.SmoothFlag; raster->point_sprite = ctx->Point.PointSprite; for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { -- cgit v1.2.3 From 8e33194837dd206d920889851d9cf22190100c99 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 2 Apr 2008 11:38:33 +0100 Subject: gallium: add a flag to turn on gl rasterization rules Use this to set up hardware rasterization (if your hardware can do it) or otherwise turn on various tweaks in the draw module. Currently only hooked up to point biasing code. --- src/gallium/auxiliary/draw/draw_wide_point.c | 19 +++++++++++++------ src/gallium/include/pipe/p_state.h | 1 + src/mesa/state_tracker/st_atom_rasterizer.c | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/gallium/auxiliary/draw/draw_wide_point.c b/src/gallium/auxiliary/draw/draw_wide_point.c index 86281ca3d8..6fc7c9fcd7 100644 --- a/src/gallium/auxiliary/draw/draw_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_wide_point.c @@ -41,6 +41,9 @@ struct widepoint_stage { float point_size_min; float point_size_max; + float xbias; + float ybias; + uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS]; uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS]; uint num_texcoords; @@ -126,8 +129,6 @@ static void widepoint_point( struct draw_stage *stage, float *pos2 = v2->data[0]; float *pos3 = v3->data[0]; - const float xbias = 0.0, ybias = -0.125; - /* point size is either per-vertex or fixed size */ if (wide->psize_slot >= 0) { half_size = header->v[0]->data[wide->psize_slot][0]; @@ -144,10 +145,10 @@ static void widepoint_point( struct draw_stage *stage, half_size = wide->half_point_size; } - left_adj = -half_size + xbias; - right_adj = half_size + xbias; - bot_adj = half_size + ybias; - top_adj = -half_size + ybias; + left_adj = -half_size + wide->xbias; + right_adj = half_size + wide->xbias; + bot_adj = half_size + wide->ybias; + top_adj = -half_size + wide->ybias; pos0[0] += left_adj; pos0[1] += top_adj; @@ -194,6 +195,12 @@ static void widepoint_first_point( struct draw_stage *stage, wide->half_point_size = 0.5f * draw->rasterizer->point_size; wide->point_size_min = draw->rasterizer->point_size_min; wide->point_size_max = draw->rasterizer->point_size_max; + wide->xbias = 0.0; + wide->ybias = 0.0; + + if (draw->rasterizer->gl_rasterization_rules) { + wide->ybias = -0.125; + } /* XXX we won't know the real size if it's computed by the vertex shader! */ if ((draw->rasterizer->point_size > draw->wide_point_threshold) || diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index e407e3bc72..3593446e1c 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -115,6 +115,7 @@ struct pipe_rasterizer_state still needed though, to indicate inputs/outputs */ unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */ unsigned flatshade_first:1; /**< take color attribute from the first vertex of a primitive */ + unsigned gl_rasterization_rules:1; /**< enable tweaks for GL rasterization? */ float line_width; float point_size; /**< used when no per-vertex size */ diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 14c26c16c0..bb14cf9045 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -261,6 +261,8 @@ static void update_raster_state( struct st_context *st ) if (ctx->Scissor.Enabled) raster->scissor = 1; + raster->gl_rasterization_rules = 1; + cso_set_rasterizer(st->cso_context, raster); } -- cgit v1.2.3 From 54507125e735ffa595e252282eaabf38095c21e1 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 2 May 2008 10:08:03 +0000 Subject: Some changed for non-C99 compilers --- src/mesa/state_tracker/st_atom_blend.c | 15 +++++--------- src/mesa/state_tracker/st_atom_clip.c | 15 +++++--------- src/mesa/state_tracker/st_atom_constbuf.c | 20 +++++++++--------- src/mesa/state_tracker/st_atom_depth.c | 10 ++++----- src/mesa/state_tracker/st_atom_fixedfunction.c | 10 ++++----- src/mesa/state_tracker/st_atom_framebuffer.c | 10 ++++----- src/mesa/state_tracker/st_atom_pixeltransfer.c | 10 ++++----- src/mesa/state_tracker/st_atom_rasterizer.c | 12 +++++------ src/mesa/state_tracker/st_atom_sampler.c | 15 +++++--------- src/mesa/state_tracker/st_atom_scissor.c | 15 +++++--------- src/mesa/state_tracker/st_atom_shader.c | 10 ++++----- src/mesa/state_tracker/st_atom_stipple.c | 10 ++++----- src/mesa/state_tracker/st_atom_texture.c | 15 +++++--------- src/mesa/state_tracker/st_atom_viewport.c | 10 ++++----- src/mesa/state_tracker/st_cb_clear.c | 2 +- src/mesa/state_tracker/st_draw.c | 5 +++-- src/mesa/state_tracker/st_extensions.c | 28 +++++++++++++------------- 17 files changed, 94 insertions(+), 118 deletions(-) mode change 100644 => 100755 src/mesa/state_tracker/st_atom_blend.c mode change 100644 => 100755 src/mesa/state_tracker/st_atom_clip.c mode change 100644 => 100755 src/mesa/state_tracker/st_atom_constbuf.c (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c old mode 100644 new mode 100755 index 2a0e92245c..35c09c3e08 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -223,15 +223,10 @@ 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, + "st_update_blend", /* name */ + { /* dirty */ + (_NEW_COLOR), /* XXX _NEW_BLEND someday? */ /* mesa */ + 0, /* st */ }, - .update = update_blend + update_blend, /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_clip.c b/src/mesa/state_tracker/st_atom_clip.c old mode 100644 new mode 100755 index a6f0568660..23d709b814 --- a/src/mesa/state_tracker/st_atom_clip.c +++ b/src/mesa/state_tracker/st_atom_clip.c @@ -62,15 +62,10 @@ 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, + "st_update_clip", /* name */ + { /* dirty */ + (_NEW_TRANSFORM), /* mesa */ + 0, /* st */ }, - .update = update_clip + update_clip /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c old mode 100644 new mode 100755 index 2b659aebbc..2856e0f0e0 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -113,12 +113,12 @@ static void update_vs_constants(struct st_context *st ) } const struct st_tracked_state st_update_vs_constants = { - .name = "st_update_vs_constants", - .dirty = { - .mesa = 0, /* set dynamically above */ - .st = ST_NEW_VERTEX_PROGRAM, + "st_update_vs_constants", /* name */ + { /* dirty */ + 0, /* set dynamically above */ /* mesa */ + ST_NEW_VERTEX_PROGRAM, /* st */ }, - .update = update_vs_constants + update_vs_constants /* update */ }; /* Fragment shader: @@ -132,11 +132,11 @@ static void update_fs_constants(struct st_context *st ) } const struct st_tracked_state st_update_fs_constants = { - .name = "st_update_fs_constants", - .dirty = { - .mesa = 0, /* set dynamically above */ - .st = ST_NEW_FRAGMENT_PROGRAM, + "st_update_fs_constants", /* name */ + { /* dirty */ + 0, /* set dynamically above */ /* mesa */ + ST_NEW_FRAGMENT_PROGRAM, /* st */ }, - .update = update_fs_constants + update_fs_constants /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index ef467582c0..0e791ceb20 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -142,10 +142,10 @@ update_depth_stencil_alpha(struct st_context *st) const struct st_tracked_state st_update_depth_stencil_alpha = { - .name = "st_update_depth_stencil", - .dirty = { - .mesa = (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR), - .st = 0, + "st_update_depth_stencil", /* name */ + { /* dirty */ + (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR), /* mesa */ + 0, /* st */ }, - .update = update_depth_stencil_alpha + update_depth_stencil_alpha /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_fixedfunction.c b/src/mesa/state_tracker/st_atom_fixedfunction.c index 3f137e1633..165567af70 100644 --- a/src/mesa/state_tracker/st_atom_fixedfunction.c +++ b/src/mesa/state_tracker/st_atom_fixedfunction.c @@ -55,12 +55,12 @@ static void update_tnl( struct st_context *st ) const struct st_tracked_state st_update_tnl = { - .name = "st_update_tnl", - .dirty = { - .mesa = TNL_FIXED_FUNCTION_STATE_FLAGS, - .st = 0 + "st_update_tnl", /* name */ + { /* dirty */ + TNL_FIXED_FUNCTION_STATE_FLAGS, /* mesa */ + 0 /* st */ }, - .update = update_tnl + update_tnl /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 14eeb58cc1..0a6974d8a7 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -96,11 +96,11 @@ 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, + "st_update_framebuffer", /* name */ + { /* dirty */ + _NEW_BUFFERS, /* mesa */ + 0, /* st */ }, - .update = update_framebuffer_state + update_framebuffer_state /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 76356bbad7..999c148449 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -463,10 +463,10 @@ update_pixel_transfer(struct st_context *st) const struct st_tracked_state st_update_pixel_transfer = { - .name = "st_update_pixel_transfer", - .dirty = { - .mesa = _NEW_PIXEL | _NEW_COLOR_MATRIX, - .st = 0, + "st_update_pixel_transfer", /* name */ + { /* dirty */ + _NEW_PIXEL | _NEW_COLOR_MATRIX, /* mesa */ + 0, /* st */ }, - .update = update_pixel_transfer + update_pixel_transfer /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index bb14cf9045..87a91d56d0 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -267,11 +267,11 @@ static void update_raster_state( struct st_context *st ) } 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, + "st_update_rasterizer", /* name */ + { /* dirty */ + (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | /* mesa */ + _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), + 0, /* st */ }, - .update = update_raster_state + update_raster_state /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 0237da3693..7515bb30cc 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -185,15 +185,10 @@ update_samplers(struct st_context *st) const struct st_tracked_state st_update_sampler = { - .name = "st_update_sampler", - .dirty = { - .mesa = _NEW_TEXTURE, - .st = 0, + "st_update_sampler", /* name */ + { /* dirty */ + _NEW_TEXTURE, /* mesa */ + 0, /* st */ }, - .update = update_samplers + update_samplers /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c index 59601e91a1..f5db492403 100644 --- a/src/mesa/state_tracker/st_atom_scissor.c +++ b/src/mesa/state_tracker/st_atom_scissor.c @@ -83,15 +83,10 @@ 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, + "st_update_scissor", /* name */ + { /* dirty */ + (_NEW_SCISSOR | _NEW_BUFFERS), /* mesa */ + 0, /* st */ }, - .update = update_scissor + update_scissor /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 3f5ec71112..652500f52a 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -281,10 +281,10 @@ update_linkage( struct st_context *st ) const struct st_tracked_state st_update_shader = { - .name = "st_update_shader", - .dirty = { - .mesa = 0, - .st = ST_NEW_VERTEX_PROGRAM | ST_NEW_FRAGMENT_PROGRAM + "st_update_shader", /* name */ + { /* dirty */ + 0, /* mesa */ + ST_NEW_VERTEX_PROGRAM | ST_NEW_FRAGMENT_PROGRAM /* st */ }, - .update = update_linkage + update_linkage /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_stipple.c b/src/mesa/state_tracker/st_atom_stipple.c index c91214059a..f395930ab4 100644 --- a/src/mesa/state_tracker/st_atom_stipple.c +++ b/src/mesa/state_tracker/st_atom_stipple.c @@ -54,10 +54,10 @@ 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, + "st_update_polygon_stipple", /* name */ + { /* dirty */ + (_NEW_POLYGONSTIPPLE), /* mesa */ + 0, /* st */ }, - .update = update_stipple + update_stipple /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index d15da5895a..f42b2f8d66 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -111,15 +111,10 @@ update_textures(struct st_context *st) const struct st_tracked_state st_update_texture = { - .name = "st_update_texture", - .dirty = { - .mesa = _NEW_TEXTURE, - .st = ST_NEW_FRAGMENT_PROGRAM, + "st_update_texture", /* name */ + { /* dirty */ + _NEW_TEXTURE, /* mesa */ + ST_NEW_FRAGMENT_PROGRAM, /* st */ }, - .update = update_textures + update_textures /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index eb3f62cfbe..4b51521470 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -82,10 +82,10 @@ 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, + "st_update_viewport", /* name */ + { /* dirty */ + _NEW_BUFFERS | _NEW_VIEWPORT, /* mesa */ + 0, /* st */ }, - .update = update_viewport + update_viewport /* update */ }; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index fe979f10bd..b7d7204633 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -34,8 +34,8 @@ #include "main/glheader.h" #include "main/macros.h" #include "shader/prog_instruction.h" -#include "st_atom.h" #include "st_context.h" +#include "st_atom.h" #include "st_cb_accum.h" #include "st_cb_clear.h" #include "st_cb_fbo.h" diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 0fe4d198bd..a3bffbfc95 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -35,8 +35,8 @@ #include "vbo/vbo.h" -#include "st_atom.h" #include "st_context.h" +#include "st_atom.h" #include "st_cb_bufferobjects.h" #include "st_draw.h" #include "st_program.h" @@ -549,9 +549,10 @@ st_feedback_draw_vbo(GLcontext *ctx, unsigned indexSize; struct gl_buffer_object *bufobj = ib->obj; struct st_buffer_object *stobj = st_buffer_object(bufobj); - index_buffer_handle = stobj->buffer; void *map; + index_buffer_handle = stobj->buffer; + switch (ib->type) { case GL_UNSIGNED_INT: indexSize = 4; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 260a2efe88..6f94ba39ae 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -38,17 +38,17 @@ #include "st_extensions.h" -static int min(int a, int b) +static int _min(int a, int b) { return (a < b) ? a : b; } -static int max(int a, int b) +static int _max(int a, int b) { return (a > b) ? a : b; } -static int clamp(int a, int min, int max) +static int _clamp(int a, int min, int max) { if (a < min) return min; @@ -69,42 +69,42 @@ void st_init_limits(struct st_context *st) struct gl_constants *c = &st->ctx->Const; c->MaxTextureLevels - = min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), MAX_TEXTURE_LEVELS); c->Max3DTextureLevels - = min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), MAX_3D_TEXTURE_LEVELS); c->MaxCubeTextureLevels - = min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), MAX_CUBE_TEXTURE_LEVELS); c->MaxTextureRectSize - = min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); + = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); c->MaxTextureUnits = c->MaxTextureImageUnits = c->MaxTextureCoordUnits - = min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS), + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS), MAX_TEXTURE_IMAGE_UNITS); c->MaxDrawBuffers - = clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), + = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), 1, MAX_DRAW_BUFFERS); c->MaxLineWidth - = max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); + = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); c->MaxLineWidthAA - = max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); + = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); c->MaxPointSize - = max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); + = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); c->MaxPointSizeAA - = max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); + = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); c->MaxTextureMaxAnisotropy - = max(2.0, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); + = _max(2.0, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); c->MaxTextureLodBias = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS); -- cgit v1.2.3 From 489fc4d10a57538de59a89e19ce752e4b7253d22 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 2 Jul 2008 20:08:27 +0200 Subject: mesa: fix issues around multisample enable multisample enable is enabled by default, however gl mandates multisample rendering rules only apply if there's also a multisampled buffer. --- src/mesa/drivers/dri/r300/r300_render.c | 2 +- src/mesa/main/mtypes.h | 1 + src/mesa/main/multisample.c | 2 +- src/mesa/main/state.c | 17 +++++++++++++++++ src/mesa/state_tracker/st_atom_rasterizer.c | 2 +- src/mesa/swrast/s_points.c | 2 +- 6 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index eee1e803a0..c809679e6c 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -359,7 +359,7 @@ static int r300Fallback(GLcontext * ctx) if (!r300->disable_lowimpact_fallback) { FALLBACK_IF(ctx->Polygon.StippleFlag); - FALLBACK_IF(ctx->Multisample.Enabled); + FALLBACK_IF(ctx->Multisample._Enabled); FALLBACK_IF(ctx->Line.StippleFlag); FALLBACK_IF(ctx->Line.SmoothFlag); FALLBACK_IF(ctx->Point.SmoothFlag); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 0a065541e1..00e7d5d395 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -961,6 +961,7 @@ struct gl_list_extensions struct gl_multisample_attrib { GLboolean Enabled; + GLboolean _Enabled; /**< true if Enabled and multisample buffer */ GLboolean SampleAlphaToCoverage; GLboolean SampleAlphaToOne; GLboolean SampleCoverage; diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c index e138087436..b9cfad9216 100644 --- a/src/mesa/main/multisample.c +++ b/src/mesa/main/multisample.c @@ -57,7 +57,7 @@ _mesa_SampleCoverageARB(GLclampf value, GLboolean invert) void _mesa_init_multisample(GLcontext *ctx) { - ctx->Multisample.Enabled = GL_FALSE; + ctx->Multisample.Enabled = GL_TRUE; ctx->Multisample.SampleAlphaToCoverage = GL_FALSE; ctx->Multisample.SampleAlphaToOne = GL_FALSE; ctx->Multisample.SampleCoverage = GL_FALSE; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 315253d90a..344af91e17 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -288,6 +288,20 @@ update_viewport_matrix(GLcontext *ctx) } +/** + * Update derived multisample state. + */ +static void +update_multisample(GLcontext *ctx) +{ + ctx->Multisample._Enabled = GL_FALSE; + if (ctx->DrawBuffer) { + if (ctx->DrawBuffer->Visual.sampleBuffers) + ctx->Multisample._Enabled = GL_TRUE; + } +} + + /** * Update derived color/blend/logicop state. */ @@ -425,6 +439,9 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT)) update_viewport_matrix(ctx); + if (new_state & _NEW_MULTISAMPLE) + update_multisample( ctx ); + if (new_state & _NEW_COLOR) update_color( ctx ); diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 87a91d56d0..ff40bb4312 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -254,7 +254,7 @@ static void update_raster_state( struct st_context *st ) raster->line_stipple_factor = ctx->Line.StippleFactor - 1; /* _NEW_MULTISAMPLE */ - if (ctx->Multisample.Enabled) + if (ctx->Multisample._Enabled) raster->multisample = 1; /* _NEW_SCISSOR */ diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index c0f32e9c91..f4b3650210 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -250,7 +250,7 @@ smooth_point(GLcontext *ctx, const SWvertex *vert) size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); /* alpha attenuation / fade factor */ - if (ctx->Multisample.Enabled) { + if (ctx->Multisample._Enabled) { if (vert->pointSize >= ctx->Point.Threshold) { alphaAtten = 1.0F; } -- cgit v1.2.3 From 6c534b830c6f5427c391c5225c34561141c201ba Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 15 Jul 2008 11:26:38 +0200 Subject: st: Silence compiler warnings on Windows. --- src/mesa/state_tracker/st_atom_framebuffer.c | 2 +- src/mesa/state_tracker/st_atom_rasterizer.c | 2 +- src/mesa/state_tracker/st_atom_viewport.c | 6 +++--- src/mesa/state_tracker/st_cb_accum.c | 2 +- src/mesa/state_tracker/st_cb_clear.c | 14 +++++++------- src/mesa/state_tracker/st_cb_drawpixels.c | 12 ++++++------ src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- src/mesa/state_tracker/st_cb_texture.c | 8 ++++---- 8 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index d46c3ee16c..80df3b0506 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -59,7 +59,7 @@ update_renderbuffer_surface(struct st_context *st, strb->surface->texture != texture || strb->surface->width != rtt_width || strb->surface->height != rtt_height) { - int level; + GLuint level; /* find matching mipmap level size */ for (level = 0; level <= texture->last_level; level++) { if (texture->width[level] == rtt_width && diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index ff40bb4312..9f4e1c1c69 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -188,7 +188,7 @@ static void update_raster_state( struct st_context *st ) { GLfloat mrd = (ctx->DrawBuffer ? ctx->DrawBuffer->_MRD : - 1.0); + 1.0f); raster->offset_units = ctx->Polygon.OffsetFactor * mrd; raster->offset_scale = (ctx->Polygon.OffsetUnits * mrd * diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index b105909e96..8b9f1abda4 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -62,9 +62,9 @@ update_viewport( struct st_context *st ) GLfloat x = (GLfloat)ctx->Viewport.X; GLfloat y = (GLfloat)ctx->Viewport.Y; GLfloat z = ctx->Viewport.Near; - GLfloat half_width = (GLfloat)ctx->Viewport.Width / 2.0; - GLfloat half_height = (GLfloat)ctx->Viewport.Height / 2.0; - GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) / 2.0; + GLfloat half_width = (GLfloat)ctx->Viewport.Width / 2.0f; + GLfloat half_height = (GLfloat)ctx->Viewport.Height / 2.0f; + GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) / 2.0f; st->state.viewport.scale[0] = half_width; st->state.viewport.scale[1] = half_height * yScale; diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index c0e8c6bf33..a992e08ff6 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -290,7 +290,7 @@ accum_return(GLcontext *ctx, GLfloat value, for (ch = 0; ch < 4; ch++) { if (colormask[ch]) { GLfloat val = abuf[i * 4 + ch] * value; - abuf[i * 4 + ch] = CLAMP(val, 0.0, 1.0); + abuf[i * 4 + ch] = CLAMP(val, 0.0f, 1.0f); } else { abuf[i * 4 + ch] = cbuf[i * 4 + ch]; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index cdfcdcee72..e475f022d3 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -203,17 +203,17 @@ clear_with_quad(GLcontext *ctx, GLboolean color, GLboolean depth, GLboolean stencil) { struct st_context *st = ctx->st; - const GLfloat x0 = ctx->DrawBuffer->_Xmin; - const GLfloat x1 = ctx->DrawBuffer->_Xmax; + const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin; + const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax; GLfloat y0, y1; if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - y0 = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax; - y1 = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin; + y0 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax); + y1 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin); } else { - y0 = ctx->DrawBuffer->_Ymin; - y1 = ctx->DrawBuffer->_Ymax; + y0 = (GLfloat) ctx->DrawBuffer->_Ymin; + y1 = (GLfloat) ctx->DrawBuffer->_Ymax; } /* @@ -286,7 +286,7 @@ clear_with_quad(GLcontext *ctx, cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); /* draw quad matching scissor rect (XXX verify coord round-off) */ - draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); + draw_quad(ctx, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor); /* Restore pipe state */ cso_restore_blend(st->cso_context); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 6b0137dcf8..2ebfcaf82b 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -423,8 +423,8 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, /* setup vertex data */ { const struct gl_framebuffer *fb = st->ctx->DrawBuffer; - const GLfloat fb_width = fb->Width; - const GLfloat fb_height = fb->Height; + const GLfloat fb_width = (GLfloat) fb->Width; + const GLfloat fb_height = (GLfloat) fb->Height; const GLfloat clip_x0 = x0 / fb_width * 2.0f - 1.0f; const GLfloat clip_y0 = y0 / fb_height * 2.0f - 1.0f; const GLfloat clip_x1 = x1 / fb_width * 2.0f - 1.0f; @@ -571,8 +571,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* viewport state: viewport matching window dims */ { - const float width = ctx->DrawBuffer->Width; - const float height = ctx->DrawBuffer->Height; + const float width = (float) ctx->DrawBuffer->Width; + const float height = (float) ctx->DrawBuffer->Height; struct pipe_viewport_state vp; vp.scale[0] = 0.5f * width; vp.scale[1] = -0.5f * height; @@ -600,9 +600,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, * Recall that these coords are transformed by the current * vertex shader and viewport transformation. */ - x0 = x; + x0 = (GLfloat) x; x1 = x + width * ctx->Pixel.ZoomX; - y0 = y; + y0 = (GLfloat) y; y1 = y + height * ctx->Pixel.ZoomY; //if(!color) draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex); diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 3cb7b68bea..3b30c2a61b 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -135,7 +135,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) struct rastpos_stage *rs = rastpos_stage(stage); GLcontext *ctx = rs->ctx; struct st_context *st = ctx->st; - const GLfloat height = ctx->DrawBuffer->Height; + const GLfloat height = (GLfloat) ctx->DrawBuffer->Height; const GLuint *outputMapping = st->vertex_result_to_slot; const GLfloat *pos; GLuint i; diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 73f8b8f788..de782e8232 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -285,7 +285,7 @@ guess_and_alloc_texture(struct st_context *st, assert(!stObj->pt); if (stObj->pt && - stImage->level > stObj->base.BaseLevel && + (GLint) stImage->level > stObj->base.BaseLevel && (stImage->base.Width == 1 || (stObj->base.Target != GL_TEXTURE_1D && stImage->base.Height == 1) || @@ -296,7 +296,7 @@ guess_and_alloc_texture(struct st_context *st, /* If this image disrespects BaseLevel, allocate from level zero. * Usually BaseLevel == 0, so it's unlikely to happen. */ - if (stImage->level < stObj->base.BaseLevel) + if ((GLint) stImage->level < stObj->base.BaseLevel) firstLevel = 0; else firstLevel = stObj->base.BaseLevel; @@ -810,7 +810,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, texImage->Height, format, type); GLuint depth; - int i; + GLuint i; GLubyte *dest; /* Map */ @@ -1383,7 +1383,7 @@ calculate_first_last_level(struct st_texture_object *stObj) } else { firstLevel = 0; - lastLevel = MIN2(tObj->MaxLevel, tObj->Image[0][tObj->BaseLevel]->WidthLog2); + lastLevel = MIN2(tObj->MaxLevel, (int) tObj->Image[0][tObj->BaseLevel]->WidthLog2); } break; case GL_TEXTURE_RECTANGLE_NV: -- cgit v1.2.3 From e552140a9a55fcadfe7f28c74a7e0aa1c68cdc93 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 11 Aug 2008 15:04:55 -0600 Subject: gallium: added _NEW_PROGRAM to dependencies --- src/mesa/state_tracker/st_atom_rasterizer.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 9f4e1c1c69..e286dc5116 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -267,11 +267,17 @@ static void update_raster_state( struct st_context *st ) } const struct st_tracked_state st_update_rasterizer = { - "st_update_rasterizer", /* name */ - { /* dirty */ - (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | /* mesa */ - _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), - 0, /* st */ + "st_update_rasterizer", /* name */ + { + (_NEW_BUFFERS | + _NEW_LIGHT | + _NEW_LINE | + _NEW_MULTISAMPLE | + _NEW_POINT | + _NEW_POLYGON | + _NEW_PROGRAM | + _NEW_SCISSOR), /* mesa state dependencies*/ + 0, /* state tracker dependencies */ }, - update_raster_state /* update */ + update_raster_state /* update function */ }; -- cgit v1.2.3 From 1a820f52f6fa125786538c1adf2aa350e66b8c1e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 14:32:33 -0600 Subject: gallium: clean-up/fix msaa override in state tracker --- src/mesa/state_tracker/st_atom_rasterizer.c | 2 +- src/mesa/state_tracker/st_context.c | 15 +++++++++++++++ src/mesa/state_tracker/st_context.h | 6 ++++++ src/mesa/state_tracker/st_framebuffer.c | 11 +++++------ 4 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index e286dc5116..fc47896c24 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -254,7 +254,7 @@ static void update_raster_state( struct st_context *st ) raster->line_stipple_factor = ctx->Line.StippleFactor - 1; /* _NEW_MULTISAMPLE */ - if (ctx->Multisample._Enabled) + if (ctx->Multisample._Enabled || st->force_msaa) raster->multisample = 1; /* _NEW_SCISSOR */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 534c7c12ac..cca808d328 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -88,6 +88,19 @@ void st_invalidate_state(GLcontext * ctx, GLuint new_state) } +/** + * Check for multisample env var override. + */ +int +st_get_msaa(void) +{ + const char *msaa = _mesa_getenv("__GL_FSAA_MODE"); + if (msaa) + return atoi(msaa); + return 0; +} + + static struct st_context * st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) { @@ -141,6 +154,8 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st->pixel_xfer.cache = _mesa_new_program_cache(); + st->force_msaa = st_get_msaa(); + /* GL limits and extensions */ st_init_limits(st); st_init_extensions(st); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 4314d9af5c..1d1aca3111 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -181,6 +181,8 @@ struct st_context struct blit_state *blit; struct cso_context *cso_context; + + int force_msaa; }; @@ -238,4 +240,8 @@ st_fb_orientation(const struct gl_framebuffer *fb) } +extern int +st_get_msaa(void); + + #endif diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 0f4a03fa48..ec8928f200 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -51,13 +51,12 @@ st_create_framebuffer( const __GLcontextModes *visual, { struct st_framebuffer *stfb = CALLOC_STRUCT(st_framebuffer); if (stfb) { - int samples = 0; - const char *msaa_override = _mesa_getenv("__GL_FSAA_MODE"); + int samples = st_get_msaa(); + + if (visual->sampleBuffers) + samples = visual->samples; + _mesa_initialize_framebuffer(&stfb->Base, visual); - if (visual->sampleBuffers) samples = visual->samples; - if (msaa_override) { - samples = _mesa_atoi(msaa_override); - } { /* fake frontbuffer */ -- cgit v1.2.3 From f7556fdd40ed2719beaba271eee4a7551e212ad1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 9 Oct 2008 16:39:59 -0600 Subject: mesa: rasterizer state depends on ST_NEW_VERTEX_PROGRAM Check for per-vertex point size must be done when vertex program changes. --- src/mesa/state_tracker/st_atom_rasterizer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index fc47896c24..5eef4ebe92 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -215,6 +215,9 @@ static void update_raster_state( struct st_context *st ) raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; } } + + /* ST_NEW_VERTEX_PROGRAM + */ if (vertProg) { if (vertProg->Base.Id == 0) { if (vertProg->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { @@ -277,7 +280,7 @@ const struct st_tracked_state st_update_rasterizer = { _NEW_POLYGON | _NEW_PROGRAM | _NEW_SCISSOR), /* mesa state dependencies*/ - 0, /* state tracker dependencies */ + ST_NEW_VERTEX_PROGRAM, /* state tracker dependencies */ }, update_raster_state /* update function */ }; -- cgit v1.2.3 From 52406c80d67d3e101d1da0f5babaabac202d31d5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Dec 2008 16:00:20 -0700 Subject: gallium: fix two-sided lighting test in state tracker This fixes two-sided lighting for vertex shaders. --- src/mesa/state_tracker/st_atom_rasterizer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/mesa/state_tracker/st_atom_rasterizer.c') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 5eef4ebe92..ea76487bcf 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -107,12 +107,15 @@ static void update_raster_state( struct st_context *st ) /* _NEW_LIGHT | _NEW_PROGRAM * * Back-face colors can come from traditional lighting (when - * GL_LIGHT_MODEL_TWO_SIDE is set) or from vertex programs (when + * GL_LIGHT_MODEL_TWO_SIDE is set) or from vertex programs/shaders (when * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. */ if (ctx->VertexProgram._Current) { - if (ctx->VertexProgram._Enabled) { - /* user-defined program */ + if (ctx->VertexProgram._Enabled || + (ctx->Shader.CurrentProgram && + ctx->Shader.CurrentProgram->VertexProgram && + ctx->Shader.CurrentProgram->LinkStatus)) { + /* user-defined vertex program or shader */ raster->light_twoside = ctx->VertexProgram.TwoSideEnabled; } else { -- cgit v1.2.3