From 1a859ecf4a4728cb321b1f68d51491cd285a3c03 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Feb 2010 21:23:27 +0100 Subject: gallium: don't put stencil ref value in pipe_depth_stencil_alpha_state This will make driver's life a bit harder, however it makes sense that stencil reference value is not part of the pipe_depth_stencil_alpha_state, because it often (there are some algorithms which require this) changes more frequently than the rest of the dsa state. This is also encouraged by some graphic APIs. Treat it similar to pipe_blend_color. --- src/gallium/auxiliary/cso_cache/cso_context.c | 11 ++++ src/gallium/auxiliary/cso_cache/cso_context.h | 4 ++ src/gallium/auxiliary/util/u_blitter.c | 75 ++++++++++----------------- src/gallium/include/pipe/p_context.h | 5 +- src/gallium/include/pipe/p_state.h | 5 +- src/mesa/state_tracker/st_atom_depth.c | 10 +++- 6 files changed, 60 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index c638239e80..47867e888a 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -93,6 +93,7 @@ struct cso_context { struct pipe_framebuffer_state fb, fb_saved; struct pipe_viewport_state vp, vp_saved; struct pipe_blend_color blend_color; + struct pipe_stencil_ref stencil_ref; }; @@ -1069,6 +1070,16 @@ enum pipe_error cso_set_blend_color(struct cso_context *ctx, return PIPE_OK; } +enum pipe_error cso_set_stencil_ref(struct cso_context *ctx, + const struct pipe_stencil_ref *sr) +{ + if (memcmp(&ctx->stencil_ref, sr, sizeof(ctx->stencil_ref))) { + ctx->stencil_ref = *sr; + ctx->pipe->set_stencil_ref(ctx->pipe, sr); + } + return PIPE_OK; +} + enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle) { diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index d2089b1c88..3a6fff21e2 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -174,6 +174,10 @@ enum pipe_error cso_set_blend_color(struct cso_context *cso, const struct pipe_blend_color *bc); +enum pipe_error cso_set_stencil_ref(struct cso_context *cso, + const struct pipe_stencil_ref *sr); + + #ifdef __cplusplus } #endif diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index f3b4491d17..0504538258 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -60,13 +60,12 @@ struct blitter_context_priv float vertices[4][2][4]; /**< {pos, color} or {pos, texcoord} */ /* Templates for various state objects. */ - struct pipe_depth_stencil_alpha_state template_dsa; struct pipe_sampler_state template_sampler_state; /* Constant state objects. */ /* Vertex shaders. */ void *vs_col; /**< Vertex shader which passes {pos, color} to the output */ - void *vs_tex; /**blend_write_color = pipe->create_blend_state(pipe, &blend); /* depth stencil alpha state objects */ - dsa = &ctx->template_dsa; ctx->dsa_keep_depth_stencil = - pipe->create_depth_stencil_alpha_state(pipe, dsa); + pipe->create_depth_stencil_alpha_state(pipe, &dsa); - dsa->depth.enabled = 1; - dsa->depth.writemask = 1; - dsa->depth.func = PIPE_FUNC_ALWAYS; + dsa.depth.enabled = 1; + dsa.depth.writemask = 1; + dsa.depth.func = PIPE_FUNC_ALWAYS; ctx->dsa_write_depth_keep_stencil = - pipe->create_depth_stencil_alpha_state(pipe, dsa); - - dsa->stencil[0].enabled = 1; - dsa->stencil[0].func = PIPE_FUNC_ALWAYS; - dsa->stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE; - dsa->stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE; - dsa->stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE; - dsa->stencil[0].valuemask = 0xff; - dsa->stencil[0].writemask = 0xff; + pipe->create_depth_stencil_alpha_state(pipe, &dsa); + + dsa.stencil[0].enabled = 1; + dsa.stencil[0].func = PIPE_FUNC_ALWAYS; + dsa.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE; + dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE; + dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE; + dsa.stencil[0].valuemask = 0xff; + dsa.stencil[0].writemask = 0xff; + ctx->dsa_write_depth_stencil = + pipe->create_depth_stencil_alpha_state(pipe, &dsa); /* The DSA state objects which write depth and stencil are created * on-demand. */ @@ -210,12 +210,8 @@ void util_blitter_destroy(struct blitter_context *blitter) pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_keep_stencil); - - for (i = 0; i < 0xff; i++) - if (ctx->dsa_write_depth_stencil[i]) - pipe->delete_depth_stencil_alpha_state(pipe, - ctx->dsa_write_depth_stencil[i]); - + pipe->delete_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil); + pipe->delete_rasterizer_state(pipe, ctx->rs_state); pipe->delete_vs_state(pipe, ctx->vs_col); pipe->delete_vs_state(pipe, ctx->vs_tex); @@ -412,26 +408,6 @@ static void blitter_draw_quad(struct blitter_context_priv *ctx) 2); /* attribs/vert */ } -static INLINE -void *blitter_get_state_write_depth_stencil( - struct blitter_context_priv *ctx, - unsigned stencil) -{ - struct pipe_context *pipe = ctx->pipe; - - stencil &= 0xff; - - /* Create the DSA state on-demand. */ - if (!ctx->dsa_write_depth_stencil[stencil]) { - ctx->template_dsa.stencil[0].ref_value = stencil; - - ctx->dsa_write_depth_stencil[stencil] = - pipe->create_depth_stencil_alpha_state(pipe, &ctx->template_dsa); - } - - return ctx->dsa_write_depth_stencil[stencil]; -} - static INLINE void **blitter_get_sampler_state(struct blitter_context_priv *ctx, int miplevel) @@ -559,9 +535,13 @@ void util_blitter_clear(struct blitter_context *blitter, else pipe->bind_blend_state(pipe, ctx->blend_keep_color); - if (clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) - pipe->bind_depth_stencil_alpha_state(pipe, - blitter_get_state_write_depth_stencil(ctx, stencil)); + if (clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) { + struct pipe_stencil_ref sr; + memset (&sr, 0, sizeof(sr)); + sr.ref_value[0] = stencil & 0xff; + pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil); + pipe->set_stencil_ref(pipe, &sr); + } else pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); @@ -573,6 +553,7 @@ void util_blitter_clear(struct blitter_context *blitter, blitter_set_rectangle(ctx, 0, 0, width, height, depth); blitter_draw_quad(ctx); blitter_restore_CSOs(ctx); + /* XXX driver's responsibility to restore stencil refs? */ } static boolean diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index f1e6a60e04..f82b77903e 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -186,8 +186,11 @@ struct pipe_context { void (*set_blend_color)( struct pipe_context *, const struct pipe_blend_color * ); + void (*set_stencil_ref)( struct pipe_context *, + const struct pipe_stencil_ref * ); + void (*set_clip_state)( struct pipe_context *, - const struct pipe_clip_state * ); + const struct pipe_clip_state * ); void (*set_constant_buffer)( struct pipe_context *, uint shader, uint index, diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 68369570b9..80e02ae70e 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -199,7 +199,6 @@ struct pipe_stencil_state unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */ unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */ unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */ - ubyte ref_value; ubyte valuemask; ubyte writemask; }; @@ -251,6 +250,10 @@ struct pipe_blend_color float color[4]; }; +struct pipe_stencil_ref +{ + ubyte ref_value[2]; +}; struct pipe_framebuffer_state { diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index 88b80a07fc..4395c68209 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -94,9 +94,11 @@ static void update_depth_stencil_alpha(struct st_context *st) { struct pipe_depth_stencil_alpha_state *dsa = &st->state.depth_stencil; + struct pipe_stencil_ref sr; GLcontext *ctx = st->ctx; memset(dsa, 0, sizeof(*dsa)); + memset(&sr, 0, sizeof(sr)); if (ctx->Depth.Test && ctx->DrawBuffer->Visual.depthBits > 0) { dsa->depth.enabled = 1; @@ -110,9 +112,9 @@ update_depth_stencil_alpha(struct st_context *st) dsa->stencil[0].fail_op = gl_stencil_op_to_pipe(ctx->Stencil.FailFunc[0]); dsa->stencil[0].zfail_op = gl_stencil_op_to_pipe(ctx->Stencil.ZFailFunc[0]); dsa->stencil[0].zpass_op = gl_stencil_op_to_pipe(ctx->Stencil.ZPassFunc[0]); - dsa->stencil[0].ref_value = ctx->Stencil.Ref[0] & 0xff; dsa->stencil[0].valuemask = ctx->Stencil.ValueMask[0] & 0xff; dsa->stencil[0].writemask = ctx->Stencil.WriteMask[0] & 0xff; + sr.ref_value[0] = ctx->Stencil.Ref[0] & 0xff; if (ctx->Stencil._TestTwoSide) { const GLuint back = ctx->Stencil._BackFace; @@ -124,10 +126,15 @@ update_depth_stencil_alpha(struct st_context *st) dsa->stencil[1].ref_value = ctx->Stencil.Ref[back] & 0xff; dsa->stencil[1].valuemask = ctx->Stencil.ValueMask[back] & 0xff; dsa->stencil[1].writemask = ctx->Stencil.WriteMask[back] & 0xff; + sr.ref_value[1] = ctx->Stencil.Ref[back] & 0xff; } else { + /* This should be unnecessary. Drivers must not expect this to + * contain valid data, except the enabled bit + */ dsa->stencil[1] = dsa->stencil[0]; dsa->stencil[1].enabled = 0; + sr.ref_value[1] = sr.ref_value[0]; } } @@ -138,6 +145,7 @@ update_depth_stencil_alpha(struct st_context *st) } cso_set_depth_stencil_alpha(st->cso_context, dsa); + cso_set_stencil_ref(st->cso_context, &sr); } -- cgit v1.2.3 From c59446a4930ec93e55f7cd3d1fffe46585cbe506 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Feb 2010 21:26:35 +0100 Subject: gallium: make valuemask/writemask in pipe_stencil_state bitfield members More consistent with other state data, might allow some compilers to pack the struct better (doesn't matter for gcc). --- src/gallium/include/pipe/p_state.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 80e02ae70e..23748acbdc 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -199,8 +199,8 @@ struct pipe_stencil_state unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */ unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */ unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */ - ubyte valuemask; - ubyte writemask; + unsigned valuemask:8; + unsigned writemask:8; }; -- cgit v1.2.3 From 98f8c4d0bb702c69fcddb504ddb702abc3aacc06 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Feb 2010 21:48:43 +0100 Subject: docs: fix up documentation for stencil ref value changes Also fix and clarify depth/stencil/alpha documentation a bit. --- src/gallium/docs/source/context.rst | 5 +++-- src/gallium/docs/source/cso/dsa.rst | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index a7669575b9..9080addba4 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -49,8 +49,9 @@ Non-CSO State These pieces of state are too small, variable, and/or trivial to have CSO objects. They all follow simple, one-method binding calls, e.g. -``set_edgeflags``. - +``set_blend_color``. +* ``set_stencil_ref`` sets the stencil front and back reference values + which are used as comparison values in stencil test. * ``set_blend_color`` * ``set_clip_state`` * ``set_polygon_stipple`` diff --git a/src/gallium/docs/source/cso/dsa.rst b/src/gallium/docs/source/cso/dsa.rst index 12abaa9d6f..1bbe381f9e 100644 --- a/src/gallium/docs/source/cso/dsa.rst +++ b/src/gallium/docs/source/cso/dsa.rst @@ -11,9 +11,9 @@ they are all stored in one structure. During actual execution, the order of operations done on fragments is always: +* Alpha * Stencil * Depth -* Alpha Depth Members ------------- @@ -28,15 +28,18 @@ func Stencil Members --------------- -XXX document valuemask, writemask - enabled Whether the stencil test is enabled. For the second stencil, whether the - two-sided stencil is enabled. + two-sided stencil is enabled. If two-sided stencil is disabled, the other + fields for the second array member are not valid. func The stencil test function. One of PIPE_FUNC. -ref_value - Stencil test reference value; used for certain functions. +valuemask + Stencil test value mask; this is ANDed with the value in the stencil + buffer and the reference value before doing the stencil comparison test. +writemask + Stencil test writemask; this controls which bits of the stencil buffer + are written. fail_op The operation to carry out if the stencil test fails. One of PIPE_STENCIL_OP. -- cgit v1.2.3 From 903bb045b506ed5d64d1de90d8a17bb9d0d56a44 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Feb 2010 18:46:43 +0100 Subject: gallium: adapt state trackers to stencil ref change --- src/gallium/state_trackers/python/p_context.i | 6 +++++- .../state_trackers/python/retrace/interpreter.py | 7 +++++-- src/gallium/state_trackers/vega/polygon.c | 18 ++++++++---------- 3 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index ce893dad45..3f36ccb621 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -130,11 +130,15 @@ struct st_context { /* * Parameter-like state (or properties) */ - + void set_blend_color(const struct pipe_blend_color *state ) { cso_set_blend_color($self->cso, state); } + void set_stencil_ref(const struct pipe_stencil_ref *state ) { + cso_set_stencil_ref($self->cso, state); + } + void set_clip(const struct pipe_clip_state *state ) { $self->pipe->set_clip_state($self->pipe, state); } diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 190db43b08..7277701279 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -430,12 +430,15 @@ class Context(Object): def delete_fs_state(self, state): pass - + delete_vs_state = delete_fs_state - + def set_blend_color(self, state): self.real.set_blend_color(state) + def set_stencil_ref(self, state): + self.real.set_stencil_ref(state) + def set_clip_state(self, state): _state = gallium.Clip() _state.nr = state.nr diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c index f56ea0c8b4..c06dbf5206 100644 --- a/src/gallium/state_trackers/vega/polygon.c +++ b/src/gallium/state_trackers/vega/polygon.c @@ -307,6 +307,7 @@ static void draw_polygon(struct vg_context *ctx, void polygon_fill(struct polygon *poly, struct vg_context *ctx) { struct pipe_depth_stencil_alpha_state dsa; + struct pipe_stencil_ref sr; struct pipe_blend_state blend; VGfloat bounds[4]; VGfloat min_x, min_y, max_x, max_y; @@ -325,6 +326,9 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx) set_blend_for_fill(&blend); memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state)); + memset(&sr, 0, sizeof(struct pipe_stencil_ref)); + /* only need a fixed 0. Rely on default or move it out at least? */ + cso_set_stencil_ref(ctx->cso_context, &sr); cso_save_blend(ctx->cso_context); cso_save_depth_stencil_alpha(ctx->cso_context); @@ -336,7 +340,6 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx) dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_INVERT; dsa.stencil[0].func = PIPE_FUNC_ALWAYS; - dsa.stencil[0].ref_value = 0; dsa.stencil[0].valuemask = ~0; cso_set_blend(ctx->cso_context, &blend); @@ -352,7 +355,6 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx) dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_INCR_WRAP; dsa.stencil[0].func = PIPE_FUNC_ALWAYS; - dsa.stencil[0].ref_value = 0; dsa.stencil[0].valuemask = ~0; /* back */ @@ -362,7 +364,6 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx) dsa.stencil[1].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[1].zpass_op = PIPE_STENCIL_OP_DECR_WRAP; dsa.stencil[1].func = PIPE_FUNC_ALWAYS; - dsa.stencil[1].ref_value = 0; dsa.stencil[1].valuemask = ~0; cso_set_blend(ctx->cso_context, &blend); @@ -375,7 +376,6 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx) cso_save_rasterizer(ctx->cso_context); dsa.stencil[0].func = PIPE_FUNC_ALWAYS; - dsa.stencil[0].ref_value = 0; dsa.stencil[0].valuemask = ~0; raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; @@ -407,7 +407,6 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx) dsa.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE; dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE; - dsa.stencil[0].ref_value = 0; dsa.stencil[0].valuemask = dsa.stencil[0].writemask; dsa.stencil[1].enabled = 0; memcpy(&dsa.depth, &ctx->state.g3d.dsa.depth, @@ -425,6 +424,7 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) { struct array *polys = polyarray->array; struct pipe_depth_stencil_alpha_state dsa; + struct pipe_stencil_ref sr; struct pipe_blend_state blend; VGfloat min_x = polyarray->min_x; VGfloat min_y = polyarray->min_y; @@ -442,6 +442,9 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) set_blend_for_fill(&blend); memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state)); + memset(&sr, 0, sizeof(struct pipe_stencil_ref)); + /* only need a fixed 0. Rely on default or move it out at least? */ + cso_set_stencil_ref(ctx->cso_context, &sr); cso_save_blend(ctx->cso_context); cso_save_depth_stencil_alpha(ctx->cso_context); @@ -453,7 +456,6 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_INVERT; dsa.stencil[0].func = PIPE_FUNC_ALWAYS; - dsa.stencil[0].ref_value = 0; dsa.stencil[0].valuemask = ~0; cso_set_blend(ctx->cso_context, &blend); @@ -472,7 +474,6 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_INCR_WRAP; dsa.stencil[0].func = PIPE_FUNC_ALWAYS; - dsa.stencil[0].ref_value = 0; dsa.stencil[0].valuemask = ~0; /* back */ @@ -482,7 +483,6 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) dsa.stencil[1].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[1].zpass_op = PIPE_STENCIL_OP_DECR_WRAP; dsa.stencil[1].func = PIPE_FUNC_ALWAYS; - dsa.stencil[1].ref_value = 0; dsa.stencil[1].valuemask = ~0; cso_set_blend(ctx->cso_context, &blend); @@ -498,7 +498,6 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) cso_save_rasterizer(ctx->cso_context); dsa.stencil[0].func = PIPE_FUNC_ALWAYS; - dsa.stencil[0].ref_value = 0; dsa.stencil[0].valuemask = ~0; raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; @@ -536,7 +535,6 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) dsa.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE; dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE; - dsa.stencil[0].ref_value = 0; dsa.stencil[0].valuemask = dsa.stencil[0].writemask; dsa.stencil[1].enabled = 0; memcpy(&dsa.depth, &ctx->state.g3d.dsa.depth, -- cgit v1.2.3 From 658e94578f8004c01eb8c64254728912527e0c2f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Feb 2010 18:59:43 +0100 Subject: softpipe: adapt to stencil ref changes --- src/gallium/drivers/softpipe/sp_context.c | 1 + src/gallium/drivers/softpipe/sp_context.h | 1 + src/gallium/drivers/softpipe/sp_quad_depth_test.c | 2 +- src/gallium/drivers/softpipe/sp_state.h | 7 +++++-- src/gallium/drivers/softpipe/sp_state_blend.c | 14 ++++++++++++-- src/gallium/drivers/softpipe/sp_video_context.c | 1 - 6 files changed, 20 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 2b22ce256e..ddc35bcd62 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -246,6 +246,7 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->pipe.delete_gs_state = softpipe_delete_gs_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; + softpipe->pipe.set_stencil_ref = softpipe_set_stencil_ref; softpipe->pipe.set_clip_state = softpipe_set_clip_state; softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 62f9e7aad3..95def72c54 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -62,6 +62,7 @@ struct softpipe_context { /** Other rendering state */ struct pipe_blend_color blend_color; + struct pipe_stencil_ref stencil_ref; struct pipe_clip_state clip; struct pipe_buffer *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; struct pipe_framebuffer_state framebuffer; diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index a981775cbd..499eebd671 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -519,7 +519,7 @@ depth_stencil_test_quad(struct quad_stage *qs, failOp = softpipe->depth_stencil->stencil[face].fail_op; zFailOp = softpipe->depth_stencil->stencil[face].zfail_op; zPassOp = softpipe->depth_stencil->stencil[face].zpass_op; - ref = softpipe->depth_stencil->stencil[face].ref_value; + ref = softpipe->stencil_ref.ref_value[face]; wrtMask = softpipe->depth_stencil->stencil[face].writemask; valMask = softpipe->depth_stencil->stencil[face].valuemask; diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index a83cae7361..4370bbeaee 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -132,13 +132,16 @@ void softpipe_bind_rasterizer_state(struct pipe_context *, void *); void softpipe_delete_rasterizer_state(struct pipe_context *, void *); void softpipe_set_framebuffer_state( struct pipe_context *, - const struct pipe_framebuffer_state * ); + const struct pipe_framebuffer_state * ); void softpipe_set_blend_color( struct pipe_context *pipe, const struct pipe_blend_color *blend_color ); +void softpipe_set_stencil_ref( struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref ); + void softpipe_set_clip_state( struct pipe_context *, - const struct pipe_clip_state * ); + const struct pipe_clip_state * ); void softpipe_set_constant_buffer(struct pipe_context *, uint shader, uint index, diff --git a/src/gallium/drivers/softpipe/sp_state_blend.c b/src/gallium/drivers/softpipe/sp_state_blend.c index 95ab323433..c63a49e90b 100644 --- a/src/gallium/drivers/softpipe/sp_state_blend.c +++ b/src/gallium/drivers/softpipe/sp_state_blend.c @@ -61,7 +61,7 @@ void softpipe_delete_blend_state(struct pipe_context *pipe, void softpipe_set_blend_color( struct pipe_context *pipe, - const struct pipe_blend_color *blend_color ) + const struct pipe_blend_color *blend_color ) { struct softpipe_context *softpipe = softpipe_context(pipe); @@ -80,7 +80,7 @@ void softpipe_set_blend_color( struct pipe_context *pipe, void * softpipe_create_depth_stencil_state(struct pipe_context *pipe, - const struct pipe_depth_stencil_alpha_state *depth_stencil) + const struct pipe_depth_stencil_alpha_state *depth_stencil) { return mem_dup(depth_stencil, sizeof(*depth_stencil)); } @@ -101,3 +101,13 @@ softpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth) { FREE( depth ); } + +void softpipe_set_stencil_ref( struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref ) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + + softpipe->stencil_ref = *stencil_ref; + + softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA; +} diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c index d8b5b31e95..7a3a636167 100644 --- a/src/gallium/drivers/softpipe/sp_video_context.c +++ b/src/gallium/drivers/softpipe/sp_video_context.c @@ -209,7 +209,6 @@ init_pipe_state(struct sp_mpeg12_context *ctx) dsa.stencil[i].fail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[i].zpass_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[i].zfail_op = PIPE_STENCIL_OP_KEEP; - dsa.stencil[i].ref_value = 0; dsa.stencil[i].valuemask = 0; dsa.stencil[i].writemask = 0; } -- cgit v1.2.3 From 0786f38b46c1dd33a0a0032c238b92742b5d71e2 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Feb 2010 19:07:26 +0100 Subject: trace: adapt to stencil ref changes --- src/gallium/drivers/trace/tr_context.c | 19 +++++++++++++++++++ src/gallium/drivers/trace/tr_dump_state.c | 17 ++++++++++++++++- src/gallium/drivers/trace/tr_dump_state.h | 2 ++ 3 files changed, 37 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 34ceaa41c1..866e228cec 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -791,6 +791,24 @@ trace_context_set_blend_color(struct pipe_context *_pipe, } +static INLINE void +trace_context_set_stencil_ref(struct pipe_context *_pipe, + const struct pipe_stencil_ref *state) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + + trace_dump_call_begin("pipe_context", "set_stencil_ref"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(stencil_ref, state); + + pipe->set_stencil_ref(pipe, state); + + trace_dump_call_end(); +} + + static INLINE void trace_context_set_clip_state(struct pipe_context *_pipe, const struct pipe_clip_state *state) @@ -1291,6 +1309,7 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.bind_vs_state = trace_context_bind_vs_state; tr_ctx->base.delete_vs_state = trace_context_delete_vs_state; tr_ctx->base.set_blend_color = trace_context_set_blend_color; + tr_ctx->base.set_stencil_ref = trace_context_set_stencil_ref; tr_ctx->base.set_clip_state = trace_context_set_clip_state; tr_ctx->base.set_constant_buffer = trace_context_set_constant_buffer; tr_ctx->base.set_framebuffer_state = trace_context_set_framebuffer_state; diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 6648539a0f..62fa09accf 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -301,7 +301,6 @@ void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_ trace_dump_member(uint, &state->stencil[i], fail_op); trace_dump_member(uint, &state->stencil[i], zpass_op); trace_dump_member(uint, &state->stencil[i], zfail_op); - trace_dump_member(uint, &state->stencil[i], ref_value); trace_dump_member(uint, &state->stencil[i], valuemask); trace_dump_member(uint, &state->stencil[i], writemask); trace_dump_struct_end(); @@ -381,6 +380,22 @@ void trace_dump_blend_color(const struct pipe_blend_color *state) trace_dump_struct_end(); } +void trace_dump_stencil_ref(const struct pipe_stencil_ref *state) +{ + if (!trace_dumping_enabled_locked()) + return; + + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_stencil_ref"); + + trace_dump_member_array(uint, state, ref_value); + + trace_dump_struct_end(); +} void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state) { diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h index c7860fd6e1..825519d044 100644 --- a/src/gallium/drivers/trace/tr_dump_state.h +++ b/src/gallium/drivers/trace/tr_dump_state.h @@ -59,6 +59,8 @@ void trace_dump_blend_state(const struct pipe_blend_state *state); void trace_dump_blend_color(const struct pipe_blend_color *state); +void trace_dump_stencil_ref(const struct pipe_stencil_ref *state); + void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state); void trace_dump_sampler_state(const struct pipe_sampler_state *state); -- cgit v1.2.3 From dfc02e3784e521c07a22ff2ffc4bf02f022e9898 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Feb 2010 21:14:18 +0100 Subject: st/mesa: more fixes for stencil ref change. compiles. Might need to do something to make it possible to save/restore stencil ref. --- src/mesa/state_tracker/st_atom_depth.c | 1 - src/mesa/state_tracker/st_cb_clear.c | 21 ++++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index 4395c68209..3c07afba9a 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -123,7 +123,6 @@ update_depth_stencil_alpha(struct st_context *st) dsa->stencil[1].fail_op = gl_stencil_op_to_pipe(ctx->Stencil.FailFunc[back]); dsa->stencil[1].zfail_op = gl_stencil_op_to_pipe(ctx->Stencil.ZFailFunc[back]); dsa->stencil[1].zpass_op = gl_stencil_op_to_pipe(ctx->Stencil.ZPassFunc[back]); - dsa->stencil[1].ref_value = ctx->Stencil.Ref[back] & 0xff; dsa->stencil[1].valuemask = ctx->Stencil.ValueMask[back] & 0xff; dsa->stencil[1].writemask = ctx->Stencil.WriteMask[back] & 0xff; sr.ref_value[1] = ctx->Stencil.Ref[back] & 0xff; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 0c7bcb8597..ed92e3928e 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -192,6 +192,7 @@ clear_with_quad(GLcontext *ctx, GLboolean color, GLboolean depth, GLboolean stencil) { struct st_context *st = ctx->st; + struct pipe_stencil_ref stencil_ref; const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin; const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax; GLfloat y0, y1; @@ -247,6 +248,7 @@ clear_with_quad(GLcontext *ctx, { struct pipe_depth_stencil_alpha_state depth_stencil; memset(&depth_stencil, 0, sizeof(depth_stencil)); + memset(&stencil_ref, 0, sizeof(stencil_ref)); if (depth) { depth_stencil.depth.enabled = 1; depth_stencil.depth.writemask = 1; @@ -259,9 +261,10 @@ clear_with_quad(GLcontext *ctx, depth_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE; depth_stencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE; depth_stencil.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE; - depth_stencil.stencil[0].ref_value = ctx->Stencil.Clear; depth_stencil.stencil[0].valuemask = 0xff; depth_stencil.stencil[0].writemask = ctx->Stencil.WriteMask[0] & 0xff; + stencil_ref.ref_value[0] = ctx->Stencil.Clear; + cso_set_stencil_ref(st->cso_context, &stencil_ref); } cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil); @@ -281,6 +284,22 @@ clear_with_quad(GLcontext *ctx, cso_restore_rasterizer(st->cso_context); cso_restore_fragment_shader(st->cso_context); cso_restore_vertex_shader(st->cso_context); + + /* cannot restore stencil ref. Try to reconstruct? */ + if (stencil) { + if (ctx->Stencil.Enabled && ctx->DrawBuffer->Visual.stencilBits > 0) { + stencil_ref.ref_value[0] = ctx->Stencil.Ref[0] & 0xff; + if (ctx->Stencil._TestTwoSide) { + const GLuint back = ctx->Stencil._BackFace; + stencil_ref.ref_value[1] = ctx->Stencil.Ref[back] & 0xff; + } + else { + stencil_ref.ref_value[1] = stencil_ref.ref_value[0]; + } + } + cso_set_stencil_ref(st->cso_context, &stencil_ref); + } + } -- cgit v1.2.3 From 5365d4189535b91f6a0681ac150666e2ac6265a9 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Feb 2010 21:17:46 +0100 Subject: fo: adapt to stencil ref changes --- src/gallium/drivers/failover/fo_context.h | 8 +++++--- src/gallium/drivers/failover/fo_state.c | 17 +++++++++++++++-- src/gallium/drivers/failover/fo_state_emit.c | 5 ++++- 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h index 191a44c3df..bb1a168ea7 100644 --- a/src/gallium/drivers/failover/fo_context.h +++ b/src/gallium/drivers/failover/fo_context.h @@ -51,9 +51,10 @@ #define FO_NEW_VERTEX 0x2000 #define FO_NEW_VERTEX_SHADER 0x4000 #define FO_NEW_BLEND_COLOR 0x8000 -#define FO_NEW_CLEAR_COLOR 0x10000 -#define FO_NEW_VERTEX_BUFFER 0x20000 -#define FO_NEW_VERTEX_ELEMENT 0x40000 +#define FO_NEW_STENCIL_REF 0x10000 +#define FO_NEW_CLEAR_COLOR 0x20000 +#define FO_NEW_VERTEX_BUFFER 0x40000 +#define FO_NEW_VERTEX_ELEMENT 0x80000 @@ -79,6 +80,7 @@ struct failover_context { const struct fo_state *vertex_shader; struct pipe_blend_color blend_color; + struct pipe_stencil_ref stencil_ref; struct pipe_clip_state clip; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index c189d1d82c..970606a3f5 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -90,7 +90,7 @@ failover_delete_blend_state( struct pipe_context *pipe, static void failover_set_blend_color( struct pipe_context *pipe, - const struct pipe_blend_color *blend_color ) + const struct pipe_blend_color *blend_color ) { struct failover_context *failover = failover_context(pipe); @@ -100,9 +100,21 @@ failover_set_blend_color( struct pipe_context *pipe, failover->hw->set_blend_color( failover->hw, blend_color ); } +static void +failover_set_stencil_ref( struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref ) +{ + struct failover_context *failover = failover_context(pipe); + + failover->stencil_ref = *stencil_ref; + failover->dirty |= FO_NEW_STENCIL_REF; + failover->sw->set_stencil_ref( failover->sw, stencil_ref ); + failover->hw->set_stencil_ref( failover->hw, stencil_ref ); +} + static void failover_set_clip_state( struct pipe_context *pipe, - const struct pipe_clip_state *clip ) + const struct pipe_clip_state *clip ) { struct failover_context *failover = failover_context(pipe); @@ -533,6 +545,7 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.delete_vs_state = failover_delete_vs_state; failover->pipe.set_blend_color = failover_set_blend_color; + failover->pipe.set_stencil_ref = failover_set_stencil_ref; failover->pipe.set_clip_state = failover_set_clip_state; failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; diff --git a/src/gallium/drivers/failover/fo_state_emit.c b/src/gallium/drivers/failover/fo_state_emit.c index a3341e33f8..5c00080842 100644 --- a/src/gallium/drivers/failover/fo_state_emit.c +++ b/src/gallium/drivers/failover/fo_state_emit.c @@ -65,7 +65,10 @@ failover_state_emit( struct failover_context *failover ) if (failover->dirty & FO_NEW_DEPTH_STENCIL) failover->sw->bind_depth_stencil_alpha_state( failover->sw, - failover->depth_stencil->sw_state ); + failover->depth_stencil->sw_state ); + + if (failover->dirty & FO_NEW_STENCIL_REF) + failover->sw->set_stencil_ref( failover->sw, &failover->stencil_ref ); if (failover->dirty & FO_NEW_FRAMEBUFFER) failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer ); -- cgit v1.2.3 From 4ea2f61e5ae556fa4141cd226ecbf1521e9f16ff Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Feb 2010 21:18:12 +0100 Subject: identity: adapt to stencil ref changes --- src/gallium/drivers/identity/id_context.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 9955380e1f..8248b2a413 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -388,6 +388,17 @@ identity_set_blend_color(struct pipe_context *_pipe, blend_color); } +static void +identity_set_stencil_ref(struct pipe_context *_pipe, + const struct pipe_stencil_ref *stencil_ref) +{ + struct identity_context *id_pipe = identity_context(_pipe); + struct pipe_context *pipe = id_pipe->pipe; + + pipe->set_stencil_ref(pipe, + stencil_ref); +} + static void identity_set_clip_state(struct pipe_context *_pipe, const struct pipe_clip_state *clip) @@ -723,6 +734,7 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.bind_vs_state = identity_bind_vs_state; id_pipe->base.delete_vs_state = identity_delete_vs_state; id_pipe->base.set_blend_color = identity_set_blend_color; + id_pipe->base.set_stencil_ref = identity_set_stencil_ref; id_pipe->base.set_clip_state = identity_set_clip_state; id_pipe->base.set_constant_buffer = identity_set_constant_buffer; id_pipe->base.set_framebuffer_state = identity_set_framebuffer_state; -- cgit v1.2.3 From 6a509ec6dd16f93758a308a0f0eb1b032f099693 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Feb 2010 21:20:24 +0100 Subject: llvmpipe: adapt to stencil ref changes since the driver doesn't actually handle stencil yet the code won't do much. --- src/gallium/drivers/llvmpipe/lp_context.c | 1 + src/gallium/drivers/llvmpipe/lp_context.h | 1 + src/gallium/drivers/llvmpipe/lp_state.h | 7 +++++-- src/gallium/drivers/llvmpipe/lp_state_blend.c | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 43d610631d..808f490361 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -148,6 +148,7 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) llvmpipe->pipe.delete_vs_state = llvmpipe_delete_vs_state; llvmpipe->pipe.set_blend_color = llvmpipe_set_blend_color; + llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref; llvmpipe->pipe.set_clip_state = llvmpipe_set_clip_state; llvmpipe->pipe.set_constant_buffer = llvmpipe_set_constant_buffer; llvmpipe->pipe.set_framebuffer_state = llvmpipe_set_framebuffer_state; diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index 3bde485ac0..955c7eb8e0 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -61,6 +61,7 @@ struct llvmpipe_context { /** Other rendering state */ struct pipe_blend_color blend_color; + struct pipe_stencil_ref stencil_ref; struct pipe_clip_state clip; struct pipe_buffer *constants[PIPE_SHADER_TYPES]; struct pipe_framebuffer_state framebuffer; diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index 8f68f12bed..9beba32271 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -152,13 +152,16 @@ void llvmpipe_bind_rasterizer_state(struct pipe_context *, void *); void llvmpipe_delete_rasterizer_state(struct pipe_context *, void *); void llvmpipe_set_framebuffer_state( struct pipe_context *, - const struct pipe_framebuffer_state * ); + const struct pipe_framebuffer_state * ); void llvmpipe_set_blend_color( struct pipe_context *pipe, const struct pipe_blend_color *blend_color ); +void llvmpipe_set_stencil_ref( struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref ); + void llvmpipe_set_clip_state( struct pipe_context *, - const struct pipe_clip_state * ); + const struct pipe_clip_state * ); void llvmpipe_set_constant_buffer(struct pipe_context *, uint shader, uint index, diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c index 9b950e82d8..8bb89f96c2 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c @@ -121,3 +121,24 @@ llvmpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth) { FREE( depth ); } + +void llvmpipe_set_stencil_ref( struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref ) +{ + struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + + if(!stencil_ref) + return; + + if(memcmp(&llvmpipe->stencil_ref, stencil_ref, sizeof *stencil_ref) == 0) + return; + + draw_flush(llvmpipe->draw); + + memcpy(&llvmpipe->stencil_ref, stencil_ref, sizeof *stencil_ref); + + /* not sure. want new flag? */ + llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA; +} + + -- cgit v1.2.3 From 9381a2777c1a36c1b88de9edf04141c485569259 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Feb 2010 21:21:30 +0100 Subject: svga: adapt to stencil ref changes also add some disabled code to handle blendcolor? --- src/gallium/drivers/svga/svga_context.h | 3 ++- src/gallium/drivers/svga/svga_pipe_depthstencil.c | 14 ++++++++-- src/gallium/drivers/svga/svga_state_rss.c | 31 ++++++++++++++++++++--- 3 files changed, 42 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index f9a641c6df..03302e2a6e 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -116,7 +116,6 @@ struct svga_depth_stencil_state { /* SVGA3D has one ref/mask/writemask triple shared between front & * back face stencil. We really need two: */ - unsigned stencil_ref:8; unsigned stencil_mask:8; unsigned stencil_writemask:8; @@ -199,6 +198,7 @@ struct svga_state struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct pipe_blend_color blend_color; + struct pipe_stencil_ref stencil_ref; struct pipe_clip_state clip; struct pipe_viewport_state viewport; @@ -376,6 +376,7 @@ struct svga_context #define SVGA_NEW_VS_RESULT 0x1000000 #define SVGA_NEW_ZERO_STRIDE 0x2000000 #define SVGA_NEW_TEXTURE_FLAGS 0x4000000 +#define SVGA_NEW_STENCIL_REF 0x8000000 diff --git a/src/gallium/drivers/svga/svga_pipe_depthstencil.c b/src/gallium/drivers/svga/svga_pipe_depthstencil.c index 12bbd233a5..c317bec6d5 100644 --- a/src/gallium/drivers/svga/svga_pipe_depthstencil.c +++ b/src/gallium/drivers/svga/svga_pipe_depthstencil.c @@ -89,7 +89,6 @@ svga_create_depth_stencil_state(struct pipe_context *pipe, /* SVGA3D has one ref/mask/writemask triple shared between front & * back face stencil. We really need two: */ - ds->stencil_ref = templ->stencil[0].ref_value & 0xff; ds->stencil_mask = templ->stencil[0].valuemask & 0xff; ds->stencil_writemask = templ->stencil[0].writemask & 0xff; } @@ -102,7 +101,6 @@ svga_create_depth_stencil_state(struct pipe_context *pipe, ds->stencil[1].zfail = svga_translate_stencil_op(templ->stencil[1].zfail_op); ds->stencil[1].pass = svga_translate_stencil_op(templ->stencil[1].zpass_op); - ds->stencil_ref = templ->stencil[1].ref_value & 0xff; ds->stencil_mask = templ->stencil[1].valuemask & 0xff; ds->stencil_writemask = templ->stencil[1].writemask & 0xff; } @@ -139,12 +137,24 @@ static void svga_delete_depth_stencil_state(struct pipe_context *pipe, } +static void svga_set_stencil_ref( struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref ) +{ + struct svga_context *svga = svga_context(pipe); + + svga->curr.stencil_ref = *stencil_ref; + + svga->dirty |= SVGA_NEW_STENCIL_REF; +} + void svga_init_depth_stencil_functions( struct svga_context *svga ) { svga->pipe.create_depth_stencil_alpha_state = svga_create_depth_stencil_state; svga->pipe.bind_depth_stencil_alpha_state = svga_bind_depth_stencil_state; svga->pipe.delete_depth_stencil_alpha_state = svga_delete_depth_stencil_state; + + svga->pipe.set_stencil_ref = svga_set_stencil_ref; } diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c index 5ce9b4ef4f..68828c252f 100644 --- a/src/gallium/drivers/svga/svga_state_rss.c +++ b/src/gallium/drivers/svga/svga_state_rss.c @@ -26,6 +26,9 @@ #include "util/u_inlines.h" #include "pipe/p_defines.h" #include "util/u_math.h" +#if 0 +#include "util/u_pack_color.h" +#endif #include "svga_context.h" #include "svga_state.h" @@ -100,6 +103,23 @@ static int emit_rss( struct svga_context *svga, } } +#if 0 + /* FIXME: shouldn't we emit blend color here */ + if (dirty & SVGA_NEW_BLEND_COLOR) { + union util_color uc; + ubyte r = float_to_ubyte(svga->curr.blend_color.color[0]); + ubyte g = float_to_ubyte(svga->curr.blend_color.color[1]); + ubyte b = float_to_ubyte(svga->curr.blend_color.color[2]); + ubyte a = float_to_ubyte(svga->curr.blend_color.color[3]); + + util_pack_color_ub( r, g, b, a, + PIPE_FORMAT_B8G8R8A8_UNORM, &uc); + + EMIT_RS( svga, uc.ui, BLENDCOLOR, fail ); + } +#endif + + if (dirty & (SVGA_NEW_DEPTH_STENCIL | SVGA_NEW_RAST)) { const struct svga_depth_stencil_state *curr = svga->curr.depth; @@ -123,8 +143,7 @@ static int emit_rss( struct svga_context *svga, EMIT_RS( svga, curr->stencil[0].fail, STENCILFAIL, fail ); EMIT_RS( svga, curr->stencil[0].zfail, STENCILZFAIL, fail ); EMIT_RS( svga, curr->stencil[0].pass, STENCILPASS, fail ); - - EMIT_RS( svga, curr->stencil_ref, STENCILREF, fail ); + EMIT_RS( svga, curr->stencil_mask, STENCILMASK, fail ); EMIT_RS( svga, curr->stencil_writemask, STENCILWRITEMASK, fail ); } @@ -160,7 +179,6 @@ static int emit_rss( struct svga_context *svga, EMIT_RS( svga, curr->stencil[ccw].zfail, CCWSTENCILZFAIL, fail ); EMIT_RS( svga, curr->stencil[ccw].pass, CCWSTENCILPASS, fail ); - EMIT_RS( svga, curr->stencil_ref, STENCILREF, fail ); EMIT_RS( svga, curr->stencil_mask, STENCILMASK, fail ); EMIT_RS( svga, curr->stencil_writemask, STENCILWRITEMASK, fail ); } @@ -178,6 +196,9 @@ static int emit_rss( struct svga_context *svga, } } + if (dirty & SVGA_NEW_STENCIL_REF) { + EMIT_RS( svga, svga->curr.stencil_ref.ref_value[0], STENCILREF, fail ); + } if (dirty & SVGA_NEW_RAST) { @@ -257,7 +278,11 @@ struct svga_tracked_state svga_hw_rss = "hw rss state", (SVGA_NEW_BLEND | +#if 0 + SVGA_NEW_BLEND_COLOR | +#endif SVGA_NEW_DEPTH_STENCIL | + SVGA_NEW_STENCIL_REF | SVGA_NEW_RAST | SVGA_NEW_FRAME_BUFFER | SVGA_NEW_NEED_PIPELINE), -- cgit v1.2.3 From b75adabc89e34083ac302ac9bafc8d80b62ac14c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 04:06:01 +0100 Subject: gallium: also save/restore stencil_ref in cso_save/restore_depth_stencil_alpha makes life of state trackers easier --- src/gallium/auxiliary/cso_cache/cso_context.c | 9 ++++++--- src/mesa/state_tracker/st_cb_clear.c | 19 ++----------------- 2 files changed, 8 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 47867e888a..e110f051af 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -93,7 +93,7 @@ struct cso_context { struct pipe_framebuffer_state fb, fb_saved; struct pipe_viewport_state vp, vp_saved; struct pipe_blend_color blend_color; - struct pipe_stencil_ref stencil_ref; + struct pipe_stencil_ref stencil_ref, stencil_ref_saved; }; @@ -746,6 +746,7 @@ void cso_save_depth_stencil_alpha(struct cso_context *ctx) { assert(!ctx->depth_stencil_saved); ctx->depth_stencil_saved = ctx->depth_stencil; + ctx->stencil_ref_saved = ctx->stencil_ref; } void cso_restore_depth_stencil_alpha(struct cso_context *ctx) @@ -755,6 +756,10 @@ void cso_restore_depth_stencil_alpha(struct cso_context *ctx) ctx->pipe->bind_depth_stencil_alpha_state(ctx->pipe, ctx->depth_stencil_saved); } ctx->depth_stencil_saved = NULL; + if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved, sizeof(ctx->stencil_ref))) { + ctx->stencil_ref = ctx->stencil_ref_saved; + ctx->pipe->set_stencil_ref(ctx->pipe, &ctx->stencil_ref); + } } @@ -1058,8 +1063,6 @@ void cso_restore_viewport(struct cso_context *ctx) } - - enum pipe_error cso_set_blend_color(struct cso_context *ctx, const struct pipe_blend_color *bc) { diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index ed92e3928e..74ec85107f 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -192,7 +192,6 @@ clear_with_quad(GLcontext *ctx, GLboolean color, GLboolean depth, GLboolean stencil) { struct st_context *st = ctx->st; - struct pipe_stencil_ref stencil_ref; const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin; const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax; GLfloat y0, y1; @@ -248,7 +247,6 @@ clear_with_quad(GLcontext *ctx, { struct pipe_depth_stencil_alpha_state depth_stencil; memset(&depth_stencil, 0, sizeof(depth_stencil)); - memset(&stencil_ref, 0, sizeof(stencil_ref)); if (depth) { depth_stencil.depth.enabled = 1; depth_stencil.depth.writemask = 1; @@ -256,6 +254,8 @@ clear_with_quad(GLcontext *ctx, } if (stencil) { + struct pipe_stencil_ref stencil_ref; + memset(&stencil_ref, 0, sizeof(stencil_ref)); depth_stencil.stencil[0].enabled = 1; depth_stencil.stencil[0].func = PIPE_FUNC_ALWAYS; depth_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE; @@ -285,21 +285,6 @@ clear_with_quad(GLcontext *ctx, cso_restore_fragment_shader(st->cso_context); cso_restore_vertex_shader(st->cso_context); - /* cannot restore stencil ref. Try to reconstruct? */ - if (stencil) { - if (ctx->Stencil.Enabled && ctx->DrawBuffer->Visual.stencilBits > 0) { - stencil_ref.ref_value[0] = ctx->Stencil.Ref[0] & 0xff; - if (ctx->Stencil._TestTwoSide) { - const GLuint back = ctx->Stencil._BackFace; - stencil_ref.ref_value[1] = ctx->Stencil.Ref[back] & 0xff; - } - else { - stencil_ref.ref_value[1] = stencil_ref.ref_value[0]; - } - } - cso_set_stencil_ref(st->cso_context, &stencil_ref); - } - } -- cgit v1.2.3 From 263406addb90ca7599ddfb210944ab0dd63b973c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 18:15:10 +0100 Subject: gallium: give pipe_stencil_ref its own cso_save/restore functions seems cleaner, and other dynamic state like viewport is handled that way too --- src/gallium/auxiliary/cso_cache/cso_context.c | 19 ++++++++++++++----- src/gallium/auxiliary/cso_cache/cso_context.h | 2 ++ src/mesa/state_tracker/st_cb_clear.c | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index e110f051af..b5241fa64c 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -746,7 +746,6 @@ void cso_save_depth_stencil_alpha(struct cso_context *ctx) { assert(!ctx->depth_stencil_saved); ctx->depth_stencil_saved = ctx->depth_stencil; - ctx->stencil_ref_saved = ctx->stencil_ref; } void cso_restore_depth_stencil_alpha(struct cso_context *ctx) @@ -756,10 +755,6 @@ void cso_restore_depth_stencil_alpha(struct cso_context *ctx) ctx->pipe->bind_depth_stencil_alpha_state(ctx->pipe, ctx->depth_stencil_saved); } ctx->depth_stencil_saved = NULL; - if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved, sizeof(ctx->stencil_ref))) { - ctx->stencil_ref = ctx->stencil_ref_saved; - ctx->pipe->set_stencil_ref(ctx->pipe, &ctx->stencil_ref); - } } @@ -1083,6 +1078,20 @@ enum pipe_error cso_set_stencil_ref(struct cso_context *ctx, return PIPE_OK; } +void cso_save_stencil_ref(struct cso_context *ctx) +{ + ctx->stencil_ref_saved = ctx->stencil_ref; +} + + +void cso_restore_stencil_ref(struct cso_context *ctx) +{ + if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved, sizeof(ctx->stencil_ref))) { + ctx->stencil_ref = ctx->stencil_ref_saved; + ctx->pipe->set_stencil_ref(ctx->pipe, &ctx->stencil_ref); + } +} + enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle) { diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index 3a6fff21e2..707b3c2cee 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -176,6 +176,8 @@ enum pipe_error cso_set_blend_color(struct cso_context *cso, enum pipe_error cso_set_stencil_ref(struct cso_context *cso, const struct pipe_stencil_ref *sr); +void cso_save_stencil_ref(struct cso_context *cso); +void cso_restore_stencil_ref(struct cso_context *cso); #ifdef __cplusplus diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 74ec85107f..898c32293d 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -215,6 +215,7 @@ clear_with_quad(GLcontext *ctx, */ cso_save_blend(st->cso_context); + cso_save_stencil_ref(st->cso_context); cso_save_depth_stencil_alpha(st->cso_context); cso_save_rasterizer(st->cso_context); cso_save_fragment_shader(st->cso_context); @@ -280,6 +281,7 @@ clear_with_quad(GLcontext *ctx, /* Restore pipe state */ cso_restore_blend(st->cso_context); + cso_restore_stencil_ref(st->cso_context); cso_restore_depth_stencil_alpha(st->cso_context); cso_restore_rasterizer(st->cso_context); cso_restore_fragment_shader(st->cso_context); -- cgit v1.2.3 From 388109c04dc92ed81d1dbe6209120c95bdbc83cd Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 18:16:09 +0100 Subject: i915g: adapt to stencil ref changes --- src/gallium/drivers/i915/i915_context.h | 1 + src/gallium/drivers/i915/i915_state.c | 18 +++++++++++++----- src/gallium/drivers/i915/i915_state_dynamic.c | 9 ++++++++- src/gallium/drivers/i915/i915_state_immediate.c | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 1479d2201a..da769e7b29 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -232,6 +232,7 @@ struct i915_context struct i915_fragment_shader *fs; struct pipe_blend_color blend_color; + struct pipe_stencil_ref stencil_ref; struct pipe_clip_state clip; /* XXX unneded */ struct pipe_buffer *constants[PIPE_SHADER_TYPES]; diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index beb26e996a..14a9314dab 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -190,7 +190,7 @@ static void i915_delete_blend_state(struct pipe_context *pipe, void *blend) } static void i915_set_blend_color( struct pipe_context *pipe, - const struct pipe_blend_color *blend_color ) + const struct pipe_blend_color *blend_color ) { struct i915_context *i915 = i915_context(pipe); draw_flush(i915->draw); @@ -200,6 +200,17 @@ static void i915_set_blend_color( struct pipe_context *pipe, i915->dirty |= I915_NEW_BLEND; } +static void i915_set_stencil_ref( struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref ) +{ + struct i915_context *i915 = i915_context(pipe); + draw_flush(i915->draw); + + i915->stencil_ref = *stencil_ref; + + i915->dirty |= I915_NEW_DEPTH_STENCIL; +} + static void * i915_create_sampler_state(struct pipe_context *pipe, const struct pipe_sampler_state *sampler) @@ -334,11 +345,9 @@ i915_create_depth_stencil_state(struct pipe_context *pipe, int fop = i915_translate_stencil_op(depth_stencil->stencil[0].fail_op); int dfop = i915_translate_stencil_op(depth_stencil->stencil[0].zfail_op); int dpop = i915_translate_stencil_op(depth_stencil->stencil[0].zpass_op); - int ref = depth_stencil->stencil[0].ref_value & 0xff; cso->stencil_LIS5 |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE | - (ref << S5_STENCIL_REF_SHIFT) | (test << S5_STENCIL_TEST_FUNC_SHIFT) | (fop << S5_STENCIL_FAIL_SHIFT) | (dfop << S5_STENCIL_PASS_Z_FAIL_SHIFT) | @@ -350,7 +359,6 @@ i915_create_depth_stencil_state(struct pipe_context *pipe, int fop = i915_translate_stencil_op(depth_stencil->stencil[1].fail_op); int dfop = i915_translate_stencil_op(depth_stencil->stencil[1].zfail_op); int dpop = i915_translate_stencil_op(depth_stencil->stencil[1].zpass_op); - int ref = depth_stencil->stencil[1].ref_value & 0xff; int tmask = depth_stencil->stencil[1].valuemask & 0xff; int wmask = depth_stencil->stencil[1].writemask & 0xff; @@ -359,7 +367,6 @@ i915_create_depth_stencil_state(struct pipe_context *pipe, BFO_ENABLE_STENCIL_TWO_SIDE | BFO_ENABLE_STENCIL_REF | BFO_STENCIL_TWO_SIDE | - (ref << BFO_STENCIL_REF_SHIFT) | (test << BFO_STENCIL_TEST_SHIFT) | (fop << BFO_STENCIL_FAIL_SHIFT) | (dfop << BFO_STENCIL_PASS_Z_FAIL_SHIFT) | @@ -777,6 +784,7 @@ i915_init_state_functions( struct i915_context *i915 ) i915->base.delete_vs_state = i915_delete_vs_state; i915->base.set_blend_color = i915_set_blend_color; + i915->base.set_stencil_ref = i915_set_stencil_ref; i915->base.set_clip_state = i915_set_clip_state; i915->base.set_constant_buffer = i915_set_constant_buffer; i915->base.set_framebuffer_state = i915_set_framebuffer_state; diff --git a/src/gallium/drivers/i915/i915_state_dynamic.c b/src/gallium/drivers/i915/i915_state_dynamic.c index 86126a5a15..9c6723b391 100644 --- a/src/gallium/drivers/i915/i915_state_dynamic.c +++ b/src/gallium/drivers/i915/i915_state_dynamic.c @@ -94,9 +94,16 @@ const struct i915_tracked_state i915_upload_MODES4 = { static void upload_BFO( struct i915_context *i915 ) { + unsigned bfo[2]; + bfo[0] = i915->depth_stencil->bfo[0]; + bfo[1] = i915->depth_stencil->bfo[1]; + /* I don't get it only allowed to set a ref mask when the enable bit is set? */ + if (bfo[0] & BFO_ENABLE_STENCIL_REF) { + bfo[0] |= i915->stencil_ref.ref_value[1] << BFO_STENCIL_REF_SHIFT; + } set_dynamic_indirect( i915, I915_DYNAMIC_BFO_0, - &(i915->depth_stencil->bfo[0]), + &(bfo[0]), 2 ); } diff --git a/src/gallium/drivers/i915/i915_state_immediate.c b/src/gallium/drivers/i915/i915_state_immediate.c index 8c16bb4e27..d2c6f15143 100644 --- a/src/gallium/drivers/i915/i915_state_immediate.c +++ b/src/gallium/drivers/i915/i915_state_immediate.c @@ -129,6 +129,8 @@ static void upload_S5( struct i915_context *i915 ) unsigned LIS5 = 0; LIS5 |= i915->depth_stencil->stencil_LIS5; + /* hope it's safe to set stencil ref value even if stencil test is disabled? */ + LIS5 |= i915->stencil_ref.ref_value[0] << S5_STENCIL_REF_SHIFT; LIS5 |= i915->blend->LIS5; -- cgit v1.2.3 From 0b659dee69f82905677eadc3be5eb728a774ce9b Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 18:16:52 +0100 Subject: i965g: adapt to stencil ref changes while there also potentially fix logic ops (were never enabled before) --- src/gallium/drivers/i965/brw_cc.c | 25 ++++++++++++++++++++++--- src/gallium/drivers/i965/brw_context.h | 3 ++- src/gallium/drivers/i965/brw_pipe_depth.c | 12 ++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/i965/brw_cc.c b/src/gallium/drivers/i965/brw_cc.c index 4a543276f5..cc8e380c68 100644 --- a/src/gallium/drivers/i965/brw_cc.c +++ b/src/gallium/drivers/i965/brw_cc.c @@ -65,14 +65,33 @@ combine_cc3( struct brw_cc3 a, struct brw_cc3 b ) return ca.cc3; } +static INLINE struct brw_cc1 +combine_cc1( struct brw_cc1 a, struct brw_cc1 b ) +{ + union { struct brw_cc1 cc1; unsigned i; } ca, cb; + ca.cc1 = a; + cb.cc1 = b; + ca.i |= cb.i; + return ca.cc1; +} + +static INLINE struct brw_cc2 +combine_cc2( struct brw_cc2 a, struct brw_cc2 b ) +{ + union { struct brw_cc2 cc2; unsigned i; } ca, cb; + ca.cc2 = a; + cb.cc2 = b; + ca.i |= cb.i; + return ca.cc2; +} static int prepare_cc_unit( struct brw_context *brw ) { brw->cc.cc.cc0 = brw->curr.zstencil->cc0; - brw->cc.cc.cc1 = brw->curr.zstencil->cc1; - brw->cc.cc.cc2 = brw->curr.zstencil->cc2; + brw->cc.cc.cc1 = combine_cc1( brw->curr.zstencil->cc1, brw->curr.cc1_stencil_ref ); + brw->cc.cc.cc2 = combine_cc2( brw->curr.zstencil->cc2, brw->curr.blend->cc2 ); brw->cc.cc.cc3 = combine_cc3( brw->curr.zstencil->cc3, brw->curr.blend->cc3 ); - + brw->cc.cc.cc5 = brw->curr.blend->cc5; brw->cc.cc.cc6 = brw->curr.blend->cc6; brw->cc.cc.cc7 = brw->curr.zstencil->cc7; diff --git a/src/gallium/drivers/i965/brw_context.h b/src/gallium/drivers/i965/brw_context.h index 19fda423de..12cfa7b049 100644 --- a/src/gallium/drivers/i965/brw_context.h +++ b/src/gallium/drivers/i965/brw_context.h @@ -153,7 +153,6 @@ struct brw_blend_state { struct brw_surf_ss0 ss0; }; - struct brw_rasterizer_state; struct brw_immediate_data { @@ -560,12 +559,14 @@ struct brw_context struct pipe_scissor_state scissor; struct pipe_viewport_state viewport; + struct pipe_stencil_ref stencil_ref; struct pipe_framebuffer_state fb; struct pipe_clip_state ucp; struct pipe_buffer *vertex_constants; struct pipe_buffer *fragment_constants; struct brw_blend_constant_color bcc; + struct brw_cc1 cc1_stencil_ref; struct brw_polygon_stipple bps; struct brw_cc_viewport ccv; diff --git a/src/gallium/drivers/i965/brw_pipe_depth.c b/src/gallium/drivers/i965/brw_pipe_depth.c index e010d76e0d..b7000d5e33 100644 --- a/src/gallium/drivers/i965/brw_pipe_depth.c +++ b/src/gallium/drivers/i965/brw_pipe_depth.c @@ -72,7 +72,6 @@ static void create_bcc_state( struct brw_depth_stencil_state *zstencil, translate_stencil_op(templ->stencil[0].zfail_op); zstencil->cc0.stencil_pass_depth_pass_op = translate_stencil_op(templ->stencil[0].zpass_op); - zstencil->cc1.stencil_ref = templ->stencil[0].ref_value; zstencil->cc1.stencil_write_mask = templ->stencil[0].writemask; zstencil->cc1.stencil_test_mask = templ->stencil[0].valuemask; @@ -86,7 +85,6 @@ static void create_bcc_state( struct brw_depth_stencil_state *zstencil, translate_stencil_op(templ->stencil[1].zfail_op); zstencil->cc0.bf_stencil_pass_depth_pass_op = translate_stencil_op(templ->stencil[1].zpass_op); - zstencil->cc1.bf_stencil_ref = templ->stencil[1].ref_value; zstencil->cc2.bf_stencil_write_mask = templ->stencil[1].writemask; zstencil->cc2.bf_stencil_test_mask = templ->stencil[1].valuemask; } @@ -159,9 +157,19 @@ static void brw_delete_depth_stencil_state(struct pipe_context *pipe, FREE(cso); } +static void brw_set_stencil_ref(struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref) +{ + struct brw_context *brw = brw_context(pipe); + brw->curr.cc1_stencil_ref.stencil_ref = stencil_ref->ref_value[0]; + brw->curr.cc1_stencil_ref.bf_stencil_ref = stencil_ref->ref_value[1]; + + brw->state.dirty.mesa |= PIPE_NEW_DEPTH_STENCIL_ALPHA; +} void brw_pipe_depth_stencil_init( struct brw_context *brw ) { + brw->base.set_stencil_ref = brw_set_stencil_ref; brw->base.create_depth_stencil_alpha_state = brw_create_depth_stencil_state; brw->base.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state; brw->base.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state; -- cgit v1.2.3 From 94c035f61d38e198382c90b1a113817dc018ea36 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 18:18:11 +0100 Subject: cell: adapt to stencil ref changes not betting this compiles, some of the code handling stencil test seems incomplete and/or never called? --- src/gallium/drivers/cell/ppu/cell_context.h | 1 + src/gallium/drivers/cell/ppu/cell_gen_fragment.c | 50 +++++++++++++--------- src/gallium/drivers/cell/ppu/cell_pipe_state.c | 14 ++++++ .../drivers/cell/ppu/cell_state_per_fragment.c | 18 ++++---- 4 files changed, 54 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index 905cd5db39..a77cc5b906 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -114,6 +114,7 @@ struct cell_context struct spe_function logic_op; struct pipe_blend_color blend_color; + struct pipe_stencil_ref stencil_ref; struct pipe_clip_state clip; struct pipe_buffer *constants[2]; struct pipe_framebuffer_state framebuffer; diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c index 0dab34075d..b58fe3764b 100644 --- a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c @@ -1175,7 +1175,8 @@ gen_colormask(struct spe_function *f, */ static void gen_stencil_test(struct spe_function *f, - const struct pipe_stencil_state *state, + const struct pipe_stencil_state *state, + const unsigned ref_value, uint stencil_max_value, int fragment_mask_reg, int fbS_reg, @@ -1189,7 +1190,7 @@ gen_stencil_test(struct spe_function *f, case PIPE_FUNC_EQUAL: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & (s == reference) */ - spe_compare_equal_uint(f, stencil_pass_reg, fbS_reg, state->ref_value); + spe_compare_equal_uint(f, stencil_pass_reg, fbS_reg, ref_value); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); } else { @@ -1197,7 +1198,7 @@ gen_stencil_test(struct spe_function *f, uint tmp_masked_stencil = spe_allocate_available_register(f); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_compare_equal_uint(f, stencil_pass_reg, tmp_masked_stencil, - state->valuemask & state->ref_value); + state->valuemask & ref_value); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_masked_stencil); } @@ -1206,7 +1207,7 @@ gen_stencil_test(struct spe_function *f, case PIPE_FUNC_NOTEQUAL: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & ~(s == reference) */ - spe_compare_equal_uint(f, stencil_pass_reg, fbS_reg, state->ref_value); + spe_compare_equal_uint(f, stencil_pass_reg, fbS_reg, ref_value); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); } else { @@ -1214,7 +1215,7 @@ gen_stencil_test(struct spe_function *f, int tmp_masked_stencil = spe_allocate_available_register(f); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_compare_equal_uint(f, stencil_pass_reg, tmp_masked_stencil, - state->valuemask & state->ref_value); + state->valuemask & ref_value); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_masked_stencil); } @@ -1223,7 +1224,7 @@ gen_stencil_test(struct spe_function *f, case PIPE_FUNC_LESS: if (state->valuemask == stencil_max_value) { /* stencil_pass = fragment_mask & (reference < s) */ - spe_compare_greater_uint(f, stencil_pass_reg, fbS_reg, state->ref_value); + spe_compare_greater_uint(f, stencil_pass_reg, fbS_reg, ref_value); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); } else { @@ -1231,7 +1232,7 @@ gen_stencil_test(struct spe_function *f, int tmp_masked_stencil = spe_allocate_available_register(f); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_compare_greater_uint(f, stencil_pass_reg, tmp_masked_stencil, - state->valuemask & state->ref_value); + state->valuemask & ref_value); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_masked_stencil); } @@ -1246,7 +1247,7 @@ gen_stencil_test(struct spe_function *f, * treats its operands as unsigned - no sign extension. */ int tmp_reg = spe_allocate_available_register(f); - spe_load_uint(f, tmp_reg, state->ref_value); + spe_load_uint(f, tmp_reg, ref_value); spe_clgt(f, stencil_pass_reg, tmp_reg, fbS_reg); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_reg); @@ -1255,7 +1256,7 @@ gen_stencil_test(struct spe_function *f, /* stencil_pass = fragment_mask & ((reference&mask) > (s&mask)) */ int tmp_reg = spe_allocate_available_register(f); int tmp_masked_stencil = spe_allocate_available_register(f); - spe_load_uint(f, tmp_reg, state->valuemask & state->ref_value); + spe_load_uint(f, tmp_reg, state->valuemask & ref_value); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_clgt(f, stencil_pass_reg, tmp_reg, tmp_masked_stencil); spe_and(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); @@ -1269,7 +1270,7 @@ gen_stencil_test(struct spe_function *f, /* stencil_pass = fragment_mask & (reference >= s) * = fragment_mask & ~(s > reference) */ spe_compare_greater_uint(f, stencil_pass_reg, fbS_reg, - state->ref_value); + ref_value); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); } else { @@ -1277,7 +1278,7 @@ gen_stencil_test(struct spe_function *f, int tmp_masked_stencil = spe_allocate_available_register(f); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_compare_greater_uint(f, stencil_pass_reg, tmp_masked_stencil, - state->valuemask & state->ref_value); + state->valuemask & ref_value); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_masked_stencil); } @@ -1289,7 +1290,7 @@ gen_stencil_test(struct spe_function *f, * = fragment_mask & ~(reference > s) */ /* As above, we have to do this by loading a register */ int tmp_reg = spe_allocate_available_register(f); - spe_load_uint(f, tmp_reg, state->ref_value); + spe_load_uint(f, tmp_reg, ref_value); spe_clgt(f, stencil_pass_reg, tmp_reg, fbS_reg); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); spe_release_register(f, tmp_reg); @@ -1298,7 +1299,7 @@ gen_stencil_test(struct spe_function *f, /* stencil_pass = fragment_mask & ~((reference&mask) > (s&mask)) */ int tmp_reg = spe_allocate_available_register(f); int tmp_masked_stencil = spe_allocate_available_register(f); - spe_load_uint(f, tmp_reg, state->ref_value & state->valuemask); + spe_load_uint(f, tmp_reg, ref_value & state->valuemask); spe_and_uint(f, tmp_masked_stencil, fbS_reg, state->valuemask); spe_clgt(f, stencil_pass_reg, tmp_reg, tmp_masked_stencil); spe_andc(f, stencil_pass_reg, fragment_mask_reg, stencil_pass_reg); @@ -1453,6 +1454,7 @@ gen_stencil_values(struct spe_function *f, static void gen_get_stencil_values(struct spe_function *f, const struct pipe_stencil_state *stencil, + const unsigned ref_value, const uint depth_enabled, int fbS_reg, int *fail_reg, @@ -1488,7 +1490,7 @@ gen_get_stencil_values(struct spe_function *f, } else { *fail_reg = spe_allocate_available_register(f); - gen_stencil_values(f, stencil->fail_op, stencil->ref_value, + gen_stencil_values(f, stencil->fail_op, ref_value, 0xff, fbS_reg, *fail_reg); } @@ -1501,7 +1503,7 @@ gen_get_stencil_values(struct spe_function *f, } else { *zfail_reg = spe_allocate_available_register(f); - gen_stencil_values(f, stencil->zfail_op, stencil->ref_value, + gen_stencil_values(f, stencil->zfail_op, ref_value, 0xff, fbS_reg, *zfail_reg); } @@ -1516,7 +1518,7 @@ gen_get_stencil_values(struct spe_function *f, } else { *zpass_reg = spe_allocate_available_register(f); - gen_stencil_values(f, stencil->zpass_op, stencil->ref_value, + gen_stencil_values(f, stencil->zpass_op, ref_value, 0xff, fbS_reg, *zpass_reg); } } @@ -1528,7 +1530,8 @@ gen_get_stencil_values(struct spe_function *f, */ static boolean gen_stencil_depth_test(struct spe_function *f, - const struct pipe_depth_stencil_alpha_state *dsa, + const struct pipe_depth_stencil_alpha_state *dsa, + const struct pipe_stencil_ref *stencil_ref, const uint facing, const int mask_reg, const int fragZ_reg, const int fbZ_reg, const int fbS_reg) @@ -1542,6 +1545,7 @@ gen_stencil_depth_test(struct spe_function *f, boolean need_to_writemask_stencil_values; struct pipe_stencil_state *stencil; + unsigned stencil_ref_value; /* Registers. We may or may not actually allocate these, depending * on whether the state values indicate that we need them. @@ -1579,9 +1583,11 @@ gen_stencil_depth_test(struct spe_function *f, */ if (facing == CELL_FACING_BACK && dsa->stencil[1].enabled) { stencil = &dsa->stencil[1]; + ref_value = stencil_ref->ref_value[1]; } else { stencil = &dsa->stencil[0]; + ref_value = stencil_ref->ref_value[0]; } /* Calculate the writemask. If the writemask is trivial (either @@ -1641,7 +1647,7 @@ gen_stencil_depth_test(struct spe_function *f, */ spe_comment(f, 0, "Running basic stencil test"); stencil_pass_reg = spe_allocate_available_register(f); - gen_stencil_test(f, stencil, 0xff, mask_reg, fbS_reg, stencil_pass_reg); + gen_stencil_test(f, stencil, ref_value, 0xff, mask_reg, fbS_reg, stencil_pass_reg); /* Generate code that, given the mask of valid fragments and the * mask of valid fragments that passed the stencil test, computes @@ -1678,7 +1684,7 @@ gen_stencil_depth_test(struct spe_function *f, spe_comment(f, 0, facing == CELL_FACING_FRONT ? "Computing front-facing stencil values" : "Computing back-facing stencil values"); - gen_get_stencil_values(f, stencil, dsa->depth.enabled, fbS_reg, + gen_get_stencil_values(f, stencil, ref_value, dsa->depth.enabled, fbS_reg, &stencil_fail_values, &stencil_pass_depth_fail_values, &stencil_pass_depth_pass_values); } @@ -1818,6 +1824,7 @@ gen_stencil_depth_test(struct spe_function *f, static void gen_depth_stencil(struct cell_context *cell, const struct pipe_depth_stencil_alpha_state *dsa, + const struct pipe_stencil_ref *stencil_ref, struct spe_function *f, uint facing, int mask_reg, @@ -1940,7 +1947,7 @@ gen_depth_stencil(struct cell_context *cell, * gen_stencil_depth_test() function must ignore the * fbZ_reg register if depth is not enabled. */ - write_depth_stencil = gen_stencil_depth_test(f, dsa, facing, + write_depth_stencil = gen_stencil_depth_test(f, dsa, stencil_ref, facing, mask_reg, fragZ_reg, fbZ_reg, fbS_reg); } @@ -2029,6 +2036,7 @@ cell_gen_fragment_function(struct cell_context *cell, struct spe_function *f) { const struct pipe_depth_stencil_alpha_state *dsa = cell->depth_stencil; + const struct pipe_stencil_ref *stencil_ref = &cell->stencil_ref; const struct pipe_blend_state *blend = cell->blend; const struct pipe_blend_color *blend_color = &cell->blend_color; const enum pipe_format color_format = cell->framebuffer.cbufs[0]->format; @@ -2101,7 +2109,7 @@ cell_gen_fragment_function(struct cell_context *cell, /* generate depth and/or stencil test code */ if (dsa->depth.enabled || dsa->stencil[0].enabled) { - gen_depth_stencil(cell, dsa, f, + gen_depth_stencil(cell, dsa, stencil_ref, f, facing, mask_reg, depth_tile_reg, diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c index 3259c58687..3d8b4409c7 100644 --- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c +++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c @@ -112,6 +112,19 @@ cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *dsa) } +static void +cell_set_stencil_ref(struct pipe_context *pipe, + const struct pipe_stencil_ref *stencil_ref) +{ + struct cell_context *cell = cell_context(pipe); + + draw_flush(cell->draw); + + cell->stencil_ref = *stencil_ref; + + cell->dirty |= CELL_NEW_DEPTH_STENCIL; +} + static void cell_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) @@ -397,6 +410,7 @@ cell_init_state_functions(struct cell_context *cell) cell->pipe.delete_rasterizer_state = cell_delete_rasterizer_state; cell->pipe.set_blend_color = cell_set_blend_color; + cell->pipe.set_stencil_ref = cell_set_stencil_ref; cell->pipe.set_clip_state = cell_set_clip_state; cell->pipe.set_framebuffer_state = cell_set_framebuffer_state; diff --git a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c index 21af7ed1c3..07be5e92ea 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c @@ -282,6 +282,7 @@ emit_stencil_op(struct spe_function *f, */ static int emit_stencil_test(struct pipe_depth_stencil_alpha_state *dsa, + struct pipe_stencil_ref *sr, unsigned face, struct spe_function *f, int mask, @@ -296,7 +297,7 @@ emit_stencil_test(struct pipe_depth_stencil_alpha_state *dsa, int stencil_pass = spe_allocate_available_register(f); int face_stencil = spe_allocate_available_register(f); int stencil_src = stencil; - const unsigned ref = (dsa->stencil[face].ref_value + const unsigned ref = (sr->ref_value[face] & dsa->stencil[face].valuemask); boolean complement = FALSE; int stored; @@ -406,7 +407,7 @@ emit_stencil_test(struct pipe_depth_stencil_alpha_state *dsa, emit_stencil_op(f, face_stencil, stencil_src, stencil_fail, dsa->stencil[face].fail_op, - dsa->stencil[face].ref_value); + sr->ref_value[face]); stencil_src = face_stencil; } @@ -421,7 +422,7 @@ emit_stencil_test(struct pipe_depth_stencil_alpha_state *dsa, emit_stencil_op(f, face_stencil, stencil_src, depth_fail, dsa->stencil[face].zfail_op, - dsa->stencil[face].ref_value); + sr->ref_value[face]); stencil_src = face_stencil; } @@ -429,7 +430,7 @@ emit_stencil_test(struct pipe_depth_stencil_alpha_state *dsa, && (dsa->stencil[face].zpass_op != PIPE_STENCIL_OP_KEEP)) { emit_stencil_op(f, face_stencil, stencil_src, depth_pass, dsa->stencil[face].zpass_op, - dsa->stencil[face].ref_value); + sr->ref_value[face]); stencil_src = face_stencil; } } @@ -463,7 +464,8 @@ emit_stencil_test(struct pipe_depth_stencil_alpha_state *dsa, void -cell_generate_depth_stencil_test(struct cell_depth_stencil_alpha_state *cdsa) +cell_generate_depth_stencil_test(struct cell_depth_stencil_alpha_state *cdsa, + struct pipe_stencil_ref *sr) { struct pipe_depth_stencil_alpha_state *const dsa = &cdsa->base; struct spe_function *const f = &cdsa->code; @@ -499,13 +501,13 @@ cell_generate_depth_stencil_test(struct cell_depth_stencil_alpha_state *cdsa) if (dsa->stencil[0].enabled) { const int front_depth_pass = spe_allocate_available_register(f); - int front_stencil = emit_stencil_test(dsa, 0, f, mask, + int front_stencil = emit_stencil_test(dsa, sr, 0, f, mask, depth_mask, depth_complement, stencil, front_depth_pass); if (dsa->stencil[1].enabled) { const int back_depth_pass = spe_allocate_available_register(f); - int back_stencil = emit_stencil_test(dsa, 1, f, mask, + int back_stencil = emit_stencil_test(dsa, sr, 1, f, mask, depth_mask, depth_complement, stencil, back_depth_pass); @@ -579,7 +581,7 @@ cell_generate_depth_stencil_test(struct cell_depth_stencil_alpha_state *cdsa) dsa->stencil[i].zfail_op, dsa->stencil[i].zpass_op); printf("# ref value / value mask / write mask: %02x %02x %02x\n", - dsa->stencil[i].ref_value, + sr->ref_value[i], dsa->stencil[i].valuemask, dsa->stencil[i].writemask); } -- cgit v1.2.3 From bf4b0773c570017c1c3ec80da769bf5c39a685b2 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 18:48:57 +0100 Subject: r300g: adapt to stencil ref changes --- src/gallium/drivers/r300/r300_context.h | 2 ++ src/gallium/drivers/r300/r300_emit.c | 5 +++-- src/gallium/drivers/r300/r300_state.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 8461757812..ba64b3eb72 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -318,6 +318,8 @@ struct r300_context { struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; int vertex_element_count; + struct pipe_stencil_ref stencil_ref; + /* Bitmask of dirty state objects. */ uint32_t dirty_state; /* Flag indicating whether or not the HW is dirty. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index ae83511a85..59709e7d64 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -114,6 +114,7 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state) struct r300_screen* r300screen = r300_screen(r300->context.screen); struct pipe_framebuffer_state* fb = (struct pipe_framebuffer_state*)r300->fb_state.state; + struct pipe_stencil_ref stencil_ref = r300->stencil_ref; CS_LOCALS(r300); BEGIN_CS(r300screen->caps->is_r500 ? 8 : 6); @@ -128,10 +129,10 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state) OUT_CS(0); } - OUT_CS(dsa->stencil_ref_mask); + OUT_CS(dsa->stencil_ref_mask | stencil_ref.ref_value[0]); if (r300screen->caps->is_r500) { - OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf); + OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf | stencil_ref.ref_value[1]); } END_CS; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index d07e90860c..a6a4f99d73 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -425,7 +425,7 @@ static void* (r300_translate_stencil_op(state->stencil[0].zfail_op) << R300_S_FRONT_ZFAIL_OP_SHIFT); - dsa->stencil_ref_mask = (state->stencil[0].ref_value) | + dsa->stencil_ref_mask = (state->stencil[0].valuemask << R300_STENCILMASK_SHIFT) | (state->stencil[0].writemask << R300_STENCILWRITEMASK_SHIFT); @@ -444,7 +444,7 @@ static void* if (caps->is_r500) { dsa->z_buffer_control |= R500_STENCIL_REFMASK_FRONT_BACK; - dsa->stencil_ref_bf = (state->stencil[1].ref_value) | + dsa->stencil_ref_bf = (state->stencil[1].valuemask << R300_STENCILMASK_SHIFT) | (state->stencil[1].writemask << @@ -488,6 +488,14 @@ static void r300_delete_dsa_state(struct pipe_context* pipe, FREE(state); } +static void r300_set_stencil_ref(struct pipe_context* pipe, + const struct pipe_stencil_ref* sr) +{ + struct r300_context* r300 = r300_context(pipe); + r300->stencil_ref = *sr; + r300->dsa_state.dirty = TRUE; +} + static void r300_set_framebuffer_state(struct pipe_context* pipe, const struct pipe_framebuffer_state* state) @@ -1087,6 +1095,8 @@ void r300_init_state_functions(struct r300_context* r300) r300->context.bind_depth_stencil_alpha_state = r300_bind_dsa_state; r300->context.delete_depth_stencil_alpha_state = r300_delete_dsa_state; + r300->context.set_stencil_ref = r300_set_stencil_ref; + r300->context.set_framebuffer_state = r300_set_framebuffer_state; r300->context.create_fs_state = r300_create_fs_state; -- cgit v1.2.3 From ed0f3b08b65679452132a9caeef1509a8dac23b9 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 19:01:10 +0100 Subject: gallium: make u_blitter code save/restore stencil ref values --- src/gallium/auxiliary/util/u_blitter.c | 2 ++ src/gallium/auxiliary/util/u_blitter.h | 8 ++++++++ src/gallium/drivers/r300/r300_blit.c | 1 + 3 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 0504538258..1f7e25b84f 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -262,6 +262,8 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx) ctx->blitter.saved_fs = INVALID_PTR; ctx->blitter.saved_vs = INVALID_PTR; + pipe->set_stencil_ref(pipe, &ctx->blitter.saved_stencil_ref); + /* restore the state objects which are required to be saved before copy/fill */ if (ctx->blitter.saved_fb_state.nr_cbufs != ~0) { diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 3da5a6ca52..a2f17073ac 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -47,6 +47,7 @@ struct blitter_context void *saved_fs, *saved_vs; /**< fragment shader, vertex shader */ struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */ + struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */ int saved_num_sampler_states; void *saved_sampler_states[32]; @@ -169,6 +170,13 @@ void util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter, blitter->saved_dsa_state = state; } +static INLINE +void util_blitter_save_stencil_ref(struct blitter_context *blitter, + const struct pipe_stencil_ref *state) +{ + blitter->saved_stencil_ref = *state; +} + static INLINE void util_blitter_save_rasterizer(struct blitter_context *blitter, void *state) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index cdedb30220..faaf9523cb 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -27,6 +27,7 @@ static void r300_blitter_save_states(struct r300_context* r300) { util_blitter_save_blend(r300->blitter, r300->blend_state.state); util_blitter_save_depth_stencil_alpha(r300->blitter, r300->dsa_state.state); + util_blitter_save_stencil_ref(r300->blitter, &(r300->stencil_ref)); util_blitter_save_rasterizer(r300->blitter, r300->rs_state.state); util_blitter_save_fragment_shader(r300->blitter, r300->fs); util_blitter_save_vertex_shader(r300->blitter, r300->vs); -- cgit v1.2.3 From bedb6faec0882cf01ae8773f2ea685135471a87b Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 20:55:33 +0100 Subject: nv30: adapt to stencil ref changes not sure if this has any hope of working --- src/gallium/drivers/nv30/nv30_context.h | 6 +++++- src/gallium/drivers/nv30/nv30_state.c | 21 ++++++++++++++++----- src/gallium/drivers/nv30/nv30_state_emit.c | 1 + src/gallium/drivers/nv30/nv30_state_zsa.c | 24 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index b3b26f7f94..ca3d6aca7f 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -61,7 +61,8 @@ enum nv30_state_index { NV30_STATE_VTXBUF = 31, NV30_STATE_VTXFMT = 32, NV30_STATE_VTXATTR = 33, - NV30_STATE_MAX = 34 + NV30_STATE_SR = 34, + NV30_STATE_MAX = 35 }; #include "nv30_screen.h" @@ -79,6 +80,7 @@ enum nv30_state_index { #define NV30_NEW_FRAGPROG (1 << 10) #define NV30_NEW_ARRAYS (1 << 11) #define NV30_NEW_UCP (1 << 12) +#define NV30_NEW_SR (1 << 13) struct nv30_rasterizer_state { struct pipe_rasterizer_state pipe; @@ -129,6 +131,7 @@ struct nv30_context { struct nv30_zsa_state *zsa; struct nv30_blend_state *blend; struct pipe_blend_color blend_colour; + struct pipe_stencil_ref stencil_ref; struct pipe_viewport_state viewport; struct pipe_framebuffer_state framebuffer; struct pipe_buffer *idxbuf; @@ -194,6 +197,7 @@ extern struct nv30_state_entry nv30_state_viewport; extern struct nv30_state_entry nv30_state_framebuffer; extern struct nv30_state_entry nv30_state_fragtex; extern struct nv30_state_entry nv30_state_vbo; +extern struct nv30_state_entry nv30_state_sr; /* nv30_vbo.c */ extern void nv30_draw_arrays(struct pipe_context *, unsigned mode, diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index f775938ba7..8fc6856ee5 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -435,7 +435,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(5, 21, 0); + struct nouveau_stateobj *so = so_new(6, 20, 0); struct nouveau_grobj *rankine = nv30->screen->rankine; so_method(so, rankine, NV34TCL_DEPTH_FUNC, 3); @@ -449,11 +449,11 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, so_data (so, float_to_ubyte(cso->alpha.ref_value)); if (cso->stencil[0].enabled) { - so_method(so, rankine, NV34TCL_STENCIL_FRONT_ENABLE, 8); + so_method(so, rankine, NV34TCL_STENCIL_FRONT_ENABLE, 3); so_data (so, cso->stencil[0].enabled ? 1 : 0); so_data (so, cso->stencil[0].writemask); so_data (so, nvgl_comparison_op(cso->stencil[0].func)); - so_data (so, cso->stencil[0].ref_value); + so_method(so, rankine, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4); so_data (so, cso->stencil[0].valuemask); so_data (so, nvgl_stencil_op(cso->stencil[0].fail_op)); so_data (so, nvgl_stencil_op(cso->stencil[0].zfail_op)); @@ -464,11 +464,11 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe, } if (cso->stencil[1].enabled) { - so_method(so, rankine, NV34TCL_STENCIL_BACK_ENABLE, 8); + so_method(so, rankine, NV34TCL_STENCIL_BACK_ENABLE, 3); so_data (so, cso->stencil[1].enabled ? 1 : 0); so_data (so, cso->stencil[1].writemask); so_data (so, nvgl_comparison_op(cso->stencil[1].func)); - so_data (so, cso->stencil[1].ref_value); + so_method(so, rankine, NV34TCL_STENCIL_BACK_FUNC_MASK, 4); so_data (so, cso->stencil[1].valuemask); so_data (so, nvgl_stencil_op(cso->stencil[1].fail_op)); so_data (so, nvgl_stencil_op(cso->stencil[1].zfail_op)); @@ -582,6 +582,16 @@ nv30_set_blend_color(struct pipe_context *pipe, nv30->dirty |= NV30_NEW_BCOL; } +static void +nv30_set_stencil_ref(struct pipe_context *pipe, + const struct pipe_stencil_ref *sr) +{ + struct nv30_context *nv30 = nv30_context(pipe); + + nv30->stencil_ref = *sr; + nv30->dirty |= NV30_NEW_SR; +} + static void nv30_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) @@ -704,6 +714,7 @@ nv30_init_state_functions(struct nv30_context *nv30) nv30->pipe.delete_fs_state = nv30_fp_state_delete; nv30->pipe.set_blend_color = nv30_set_blend_color; + nv30->pipe.set_stencil_ref = nv30_set_stencil_ref; nv30->pipe.set_clip_state = nv30_set_clip_state; nv30->pipe.set_constant_buffer = nv30_set_constant_buffer; nv30->pipe.set_framebuffer_state = nv30_set_framebuffer_state; diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c index d9650f63eb..deefe7fd8d 100644 --- a/src/gallium/drivers/nv30/nv30_state_emit.c +++ b/src/gallium/drivers/nv30/nv30_state_emit.c @@ -12,6 +12,7 @@ static struct nv30_state_entry *render_states[] = { &nv30_state_blend, &nv30_state_blend_colour, &nv30_state_zsa, + &nv30_state_sr, &nv30_state_viewport, &nv30_state_vbo, NULL diff --git a/src/gallium/drivers/nv30/nv30_state_zsa.c b/src/gallium/drivers/nv30/nv30_state_zsa.c index 0940b7269b..6c0baa8be7 100644 --- a/src/gallium/drivers/nv30/nv30_state_zsa.c +++ b/src/gallium/drivers/nv30/nv30_state_zsa.c @@ -15,3 +15,27 @@ struct nv30_state_entry nv30_state_zsa = { .hw = NV30_STATE_ZSA } }; + +static boolean +nv30_state_sr_validate(struct nv30_context *nv30) +{ + struct nouveau_stateobj *so = so_new(2, 2, 0); + struct pipe_stencil_ref *sr = &nv30->stencil_ref; + + so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_FRONT_FUNC_REF, 1); + so_data (so, sr->ref_value[0]; + so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_BACK_FUNC_REF, 1); + so_data (so, sr->ref_value[1]; + + so_ref(so, &nv30->state.hw[NV30_STATE_SR]); + so_ref(NULL, &so); + return TRUE; +} + +struct nv30_state_entry nv30_state_sr = { + .validate = nv30_state_sr_validate, + .dirty = { + .pipe = NV30_NEW_SR, + .hw = NV30_STATE_SR + } +}; -- cgit v1.2.3 From dc8c0959bd2b0fb9927f365d3e75e6a9e3c9cf14 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 22:48:31 +0100 Subject: nv40: adapt to stencil ref changes --- src/gallium/drivers/nv40/nv40_context.h | 6 +++++- src/gallium/drivers/nv40/nv40_state.c | 21 ++++++++++++++++----- src/gallium/drivers/nv40/nv40_state_emit.c | 2 ++ src/gallium/drivers/nv40/nv40_state_zsa.c | 24 ++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index 958a48f2a4..4861924dac 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -61,7 +61,8 @@ enum nv40_state_index { NV40_STATE_VTXBUF = 31, NV40_STATE_VTXFMT = 32, NV40_STATE_VTXATTR = 33, - NV40_STATE_MAX = 34 + NV40_STATE_SR = 34, + NV40_STATE_MAX = 35 }; #include "nv40_screen.h" @@ -79,6 +80,7 @@ enum nv40_state_index { #define NV40_NEW_FRAGPROG (1 << 10) #define NV40_NEW_ARRAYS (1 << 11) #define NV40_NEW_UCP (1 << 12) +#define NV40_NEW_SR (1 << 13) struct nv40_rasterizer_state { struct pipe_rasterizer_state pipe; @@ -144,6 +146,7 @@ struct nv40_context { struct nv40_zsa_state *zsa; struct nv40_blend_state *blend; struct pipe_blend_color blend_colour; + struct pipe_stencil_ref stencil_ref; struct pipe_viewport_state viewport; struct pipe_framebuffer_state framebuffer; struct pipe_buffer *idxbuf; @@ -215,6 +218,7 @@ extern struct nv40_state_entry nv40_state_framebuffer; extern struct nv40_state_entry nv40_state_fragtex; extern struct nv40_state_entry nv40_state_vbo; extern struct nv40_state_entry nv40_state_vtxfmt; +extern struct nv40_state_entry nv40_state_sr; /* nv40_vbo.c */ extern void nv40_draw_arrays(struct pipe_context *, unsigned mode, diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c index 51b40e51e4..d068be6243 100644 --- a/src/gallium/drivers/nv40/nv40_state.c +++ b/src/gallium/drivers/nv40/nv40_state.c @@ -445,7 +445,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso)); - struct nouveau_stateobj *so = so_new(4, 21, 0); + struct nouveau_stateobj *so = so_new(6, 20, 0); struct nouveau_grobj *curie = nv40->screen->curie; so_method(so, curie, NV40TCL_DEPTH_FUNC, 3); @@ -459,11 +459,11 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe, so_data (so, float_to_ubyte(cso->alpha.ref_value)); if (cso->stencil[0].enabled) { - so_method(so, curie, NV40TCL_STENCIL_FRONT_ENABLE, 8); + so_method(so, curie, NV40TCL_STENCIL_FRONT_ENABLE, 3); so_data (so, cso->stencil[0].enabled ? 1 : 0); so_data (so, cso->stencil[0].writemask); so_data (so, nvgl_comparison_op(cso->stencil[0].func)); - so_data (so, cso->stencil[0].ref_value); + so_method(so, curie, NV40TCL_STENCIL_FRONT_FUNC_MASK, 4); so_data (so, cso->stencil[0].valuemask); so_data (so, nvgl_stencil_op(cso->stencil[0].fail_op)); so_data (so, nvgl_stencil_op(cso->stencil[0].zfail_op)); @@ -474,11 +474,11 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe, } if (cso->stencil[1].enabled) { - so_method(so, curie, NV40TCL_STENCIL_BACK_ENABLE, 8); + so_method(so, curie, NV40TCL_STENCIL_BACK_ENABLE, 3); so_data (so, cso->stencil[1].enabled ? 1 : 0); so_data (so, cso->stencil[1].writemask); so_data (so, nvgl_comparison_op(cso->stencil[1].func)); - so_data (so, cso->stencil[1].ref_value); + so_method(so, curie, NV40TCL_STENCIL_BACK_FUNC_MASK, 4); so_data (so, cso->stencil[1].valuemask); so_data (so, nvgl_stencil_op(cso->stencil[1].fail_op)); so_data (so, nvgl_stencil_op(cso->stencil[1].zfail_op)); @@ -592,6 +592,16 @@ nv40_set_blend_color(struct pipe_context *pipe, nv40->dirty |= NV40_NEW_BCOL; } + static void +nv40_set_stencil_ref(struct pipe_context *pipe, + const struct pipe_stencil_ref *sr) +{ + struct nv40_context *nv40 = nv40_context(pipe); + + nv40->stencil_ref = *sr; + nv40->dirty |= NV40_NEW_SR; +} + static void nv40_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) @@ -719,6 +729,7 @@ nv40_init_state_functions(struct nv40_context *nv40) nv40->pipe.delete_fs_state = nv40_fp_state_delete; nv40->pipe.set_blend_color = nv40_set_blend_color; + nv40->pipe.set_stencil_ref = nv40_set_stencil_ref; nv40->pipe.set_clip_state = nv40_set_clip_state; nv40->pipe.set_constant_buffer = nv40_set_constant_buffer; nv40->pipe.set_framebuffer_state = nv40_set_framebuffer_state; diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c index 1c4007a129..8990f303ce 100644 --- a/src/gallium/drivers/nv40/nv40_state_emit.c +++ b/src/gallium/drivers/nv40/nv40_state_emit.c @@ -13,6 +13,7 @@ static struct nv40_state_entry *render_states[] = { &nv40_state_blend, &nv40_state_blend_colour, &nv40_state_zsa, + &nv40_state_sr, &nv40_state_viewport, &nv40_state_vbo, NULL @@ -29,6 +30,7 @@ static struct nv40_state_entry *swtnl_states[] = { &nv40_state_blend, &nv40_state_blend_colour, &nv40_state_zsa, + &nv40_state_sr, &nv40_state_viewport, &nv40_state_vtxfmt, NULL diff --git a/src/gallium/drivers/nv40/nv40_state_zsa.c b/src/gallium/drivers/nv40/nv40_state_zsa.c index fb760677c8..4c734f4864 100644 --- a/src/gallium/drivers/nv40/nv40_state_zsa.c +++ b/src/gallium/drivers/nv40/nv40_state_zsa.c @@ -15,3 +15,27 @@ struct nv40_state_entry nv40_state_zsa = { .hw = NV40_STATE_ZSA } }; + +static boolean +nv40_state_sr_validate(struct nv40_context *nv40) +{ + struct nouveau_stateobj *so = so_new(2, 2, 0); + struct pipe_stencil_ref *sr = &nv40->stencil_ref; + + so_method(so, nv40->screen->rankine, NV40TCL_STENCIL_FRONT_FUNC_REF, 1); + so_data (so, sr->ref_value[0]; + so_method(so, nv40->screen->rankine, NV40TCL_STENCIL_BACK_FUNC_REF, 1); + so_data (so, sr->ref_value[1]; + + so_ref(so, &nv40->state.hw[NV40_STATE_SR]); + so_ref(NULL, &so); + return TRUE; +} + +struct nv40_state_entry nv40_state_sr = { + .validate = nv40_state_sr_validate, + .dirty = { + .pipe = NV40_NEW_SR, + .hw = NV40_STATE_SR + } +}; -- cgit v1.2.3 From 67479eea365954396679714901c11175253bb13b Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 22:48:39 +0100 Subject: nv50: adapt to stencil ref changes --- src/gallium/drivers/nv50/nv50_context.h | 3 +++ src/gallium/drivers/nv50/nv50_state.c | 20 +++++++++++++++----- src/gallium/drivers/nv50/nv50_state_validate.c | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 14cef4c0bf..b4de3e2ba5 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -50,6 +50,7 @@ #define NV50_NEW_ARRAYS (1 << 14) #define NV50_NEW_SAMPLER (1 << 15) #define NV50_NEW_TEXTURE (1 << 16) +#define NV50_NEW_STENCIL_REF (1 << 17) struct nv50_blend_stateobj { struct pipe_blend_state pipe; @@ -120,6 +121,7 @@ struct nv50_state { struct nouveau_stateobj *blend; struct nouveau_stateobj *blend_colour; struct nouveau_stateobj *zsa; + struct nouveau_stateobj *stencil_ref; struct nouveau_stateobj *rast; struct nouveau_stateobj *stipple; struct nouveau_stateobj *scissor; @@ -155,6 +157,7 @@ struct nv50_context { struct nv50_zsa_stateobj *zsa; struct nv50_rasterizer_stateobj *rasterizer; struct pipe_blend_color blend_colour; + struct pipe_stencil_ref stencil_ref; struct pipe_poly_stipple stipple; struct pipe_scissor_state scissor; struct pipe_viewport_state viewport; diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 7c531b50a5..05d519a2f9 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -447,7 +447,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe, { struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_zsa_stateobj *zsa = CALLOC_STRUCT(nv50_zsa_stateobj); - struct nouveau_stateobj *so = so_new(8, 22, 0); + struct nouveau_stateobj *so = so_new(9, 21, 0); so_method(so, tesla, NV50TCL_DEPTH_WRITE_ENABLE, 1); so_data (so, cso->depth.writemask ? 1 : 0); @@ -462,13 +462,13 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe, } if (cso->stencil[0].enabled) { - so_method(so, tesla, NV50TCL_STENCIL_FRONT_ENABLE, 8); + so_method(so, tesla, NV50TCL_STENCIL_FRONT_ENABLE, 5); so_data (so, 1); so_data (so, nvgl_stencil_op(cso->stencil[0].fail_op)); so_data (so, nvgl_stencil_op(cso->stencil[0].zfail_op)); so_data (so, nvgl_stencil_op(cso->stencil[0].zpass_op)); so_data (so, nvgl_comparison_op(cso->stencil[0].func)); - so_data (so, cso->stencil[0].ref_value); + so_method(so, tesla, NV50TCL_STENCIL_FRONT_MASK, 2); so_data (so, cso->stencil[0].writemask); so_data (so, cso->stencil[0].valuemask); } else { @@ -483,8 +483,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe, so_data (so, nvgl_stencil_op(cso->stencil[1].zfail_op)); so_data (so, nvgl_stencil_op(cso->stencil[1].zpass_op)); so_data (so, nvgl_comparison_op(cso->stencil[1].func)); - so_method(so, tesla, NV50TCL_STENCIL_BACK_FUNC_REF, 3); - so_data (so, cso->stencil[1].ref_value); + so_method(so, tesla, NV50TCL_STENCIL_BACK_MASK, 2); so_data (so, cso->stencil[1].writemask); so_data (so, cso->stencil[1].valuemask); } else { @@ -633,6 +632,16 @@ nv50_set_blend_color(struct pipe_context *pipe, nv50->dirty |= NV50_NEW_BLEND_COLOUR; } + static void +nv50_set_stencil_ref(struct pipe_context *pipe, + const struct pipe_stencil_ref *sr) +{ + struct nv50_context *nv50 = nv50_context(pipe); + + nv50->stencil_ref = *sr; + nv50->dirty |= NV50_NEW_STENCIL_REF; +} + static void nv50_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) @@ -761,6 +770,7 @@ nv50_init_state_functions(struct nv50_context *nv50) nv50->pipe.delete_gs_state = nv50_gp_state_delete; nv50->pipe.set_blend_color = nv50_set_blend_color; + nv50->pipe.set_stencil_ref = nv50_set_stencil_ref; nv50->pipe.set_clip_state = nv50_set_clip_state; nv50->pipe.set_constant_buffer = nv50_set_constant_buffer; nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state; diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index ee28fa63c1..3afeb2b241 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -205,6 +205,8 @@ nv50_state_emit(struct nv50_context *nv50) nv50->state.dirty |= NV50_NEW_RASTERIZER; if (nv50->state.blend_colour) nv50->state.dirty |= NV50_NEW_BLEND_COLOUR; + if (nv50->state.stencil_ref) + nv50->state.dirty |= NV50_NEW_STENCIL_REF; if (nv50->state.stipple) nv50->state.dirty |= NV50_NEW_STIPPLE; if (nv50->state.scissor) @@ -242,6 +244,8 @@ nv50_state_emit(struct nv50_context *nv50) so_emit(chan, nv50->state.rast); if (nv50->state.dirty & NV50_NEW_BLEND_COLOUR) so_emit(chan, nv50->state.blend_colour); + if (nv50->state.dirty & NV50_NEW_STENCIL_REF) + so_emit(chan, nv50->state.stencil_ref); if (nv50->state.dirty & NV50_NEW_STIPPLE) so_emit(chan, nv50->state.stipple); if (nv50->state.dirty & NV50_NEW_SCISSOR) @@ -325,6 +329,16 @@ nv50_state_validate(struct nv50_context *nv50) so_ref(NULL, &so); } + if (nv50->dirty & NV50_NEW_STENCIL_REF) { + so = so_new(2, 2, 0); + so_method(so, tesla, NV50TCL_STENCIL_FRONT_FUNC_REF, 1); + so_data (so, nv50->stencil_ref.ref_value[0]; + so_method(so, tesla, NV50TCL_STENCIL_BACK_FUNC_REF, 1); + so_data (so, nv50->stencil_ref.ref_value[1]; + so_ref(so, &nv50->state.stencil_ref); + so_ref(NULL, &so); + } + if (nv50->dirty & NV50_NEW_STIPPLE) { so = so_new(1, 32, 0); so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32); -- cgit v1.2.3 From 16d520f6d69edb112887d8db1e014a521a34f532 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Feb 2010 23:11:03 +0100 Subject: nouveau: fix compile errors... --- src/gallium/drivers/nv30/nv30_state_zsa.c | 4 ++-- src/gallium/drivers/nv40/nv40_state_zsa.c | 8 ++++---- src/gallium/drivers/nv50/nv50_state_validate.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/nv30/nv30_state_zsa.c b/src/gallium/drivers/nv30/nv30_state_zsa.c index 6c0baa8be7..88cd74f180 100644 --- a/src/gallium/drivers/nv30/nv30_state_zsa.c +++ b/src/gallium/drivers/nv30/nv30_state_zsa.c @@ -23,9 +23,9 @@ nv30_state_sr_validate(struct nv30_context *nv30) struct pipe_stencil_ref *sr = &nv30->stencil_ref; so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_FRONT_FUNC_REF, 1); - so_data (so, sr->ref_value[0]; + so_data (so, sr->ref_value[0]); so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_BACK_FUNC_REF, 1); - so_data (so, sr->ref_value[1]; + so_data (so, sr->ref_value[1]); so_ref(so, &nv30->state.hw[NV30_STATE_SR]); so_ref(NULL, &so); diff --git a/src/gallium/drivers/nv40/nv40_state_zsa.c b/src/gallium/drivers/nv40/nv40_state_zsa.c index 4c734f4864..9cbe7da6db 100644 --- a/src/gallium/drivers/nv40/nv40_state_zsa.c +++ b/src/gallium/drivers/nv40/nv40_state_zsa.c @@ -22,10 +22,10 @@ nv40_state_sr_validate(struct nv40_context *nv40) struct nouveau_stateobj *so = so_new(2, 2, 0); struct pipe_stencil_ref *sr = &nv40->stencil_ref; - so_method(so, nv40->screen->rankine, NV40TCL_STENCIL_FRONT_FUNC_REF, 1); - so_data (so, sr->ref_value[0]; - so_method(so, nv40->screen->rankine, NV40TCL_STENCIL_BACK_FUNC_REF, 1); - so_data (so, sr->ref_value[1]; + so_method(so, nv40->screen->curie, NV40TCL_STENCIL_FRONT_FUNC_REF, 1); + so_data (so, sr->ref_value[0]); + so_method(so, nv40->screen->curie, NV40TCL_STENCIL_BACK_FUNC_REF, 1); + so_data (so, sr->ref_value[1]); so_ref(so, &nv40->state.hw[NV40_STATE_SR]); so_ref(NULL, &so); diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 3afeb2b241..0be6abbb17 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -332,9 +332,9 @@ nv50_state_validate(struct nv50_context *nv50) if (nv50->dirty & NV50_NEW_STENCIL_REF) { so = so_new(2, 2, 0); so_method(so, tesla, NV50TCL_STENCIL_FRONT_FUNC_REF, 1); - so_data (so, nv50->stencil_ref.ref_value[0]; + so_data (so, nv50->stencil_ref.ref_value[0]); so_method(so, tesla, NV50TCL_STENCIL_BACK_FUNC_REF, 1); - so_data (so, nv50->stencil_ref.ref_value[1]; + so_data (so, nv50->stencil_ref.ref_value[1]); so_ref(so, &nv50->state.stencil_ref); so_ref(NULL, &so); } -- cgit v1.2.3 From ebe12d50064370e4ddec21a1e087b24295940319 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 12 Feb 2010 00:43:38 +0100 Subject: gallium: make max_anisotropy a unsigned bitfield member saves us a dword in sampler state, hw can't do non-integer aniso degree anyway. To allow aniso 1x (which seems of dubious value but some hardware (radeons) have such a mode, and even d3d allows specifiying it) redefine anisotropic filtering as disabled only if max_anistropy is 0. --- src/gallium/docs/source/cso/sampler.rst | 4 +++- src/gallium/drivers/i915/i915_state.c | 4 ++-- src/gallium/drivers/i965/brw_pipe_sampler.c | 8 +++----- src/gallium/drivers/nv30/nv30_state.c | 6 +++--- src/gallium/drivers/nv40/nv40_state.c | 14 +++++++------- src/gallium/drivers/nv50/nv50_state.c | 10 +++++----- src/gallium/drivers/r300/r300_state.c | 2 +- src/gallium/drivers/r300/r300_state_inlines.h | 10 +++++----- src/gallium/drivers/svga/svga_pipe_sampler.c | 4 ++-- src/gallium/drivers/trace/tr_dump_state.c | 2 +- src/gallium/include/pipe/p_state.h | 2 +- src/mesa/state_tracker/st_atom_sampler.c | 2 +- 12 files changed, 34 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/gallium/docs/source/cso/sampler.rst b/src/gallium/docs/source/cso/sampler.rst index 044ffffcb4..77979fc44d 100644 --- a/src/gallium/docs/source/cso/sampler.rst +++ b/src/gallium/docs/source/cso/sampler.rst @@ -45,4 +45,6 @@ border_color RGBA color used for out-of-bounds coordinates. max_anisotropy Maximum filtering to apply anisotropically to textures. Setting this to - 1.0 effectively disables anisotropic filtering. + 0 disables anisotropic filtering. Any other setting enables anisotropic + filtering, however it's not unexpected some drivers only will change their + filtering with a setting of 2 and higher. diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 14a9314dab..62169918e2 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -228,10 +228,10 @@ i915_create_sampler_state(struct pipe_context *pipe, minFilt = translate_img_filter( sampler->min_img_filter ); magFilt = translate_img_filter( sampler->mag_img_filter ); - if (sampler->max_anisotropy > 1.0) + if (sampler->max_anisotropy > 1) minFilt = magFilt = FILTER_ANISOTROPIC; - if (sampler->max_anisotropy > 2.0) { + if (sampler->max_anisotropy > 2) { cso->state[0] |= SS2_MAX_ANISO_4; } diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c index 6aab561004..c7c0e2ae95 100644 --- a/src/gallium/drivers/i965/brw_pipe_sampler.c +++ b/src/gallium/drivers/i965/brw_pipe_sampler.c @@ -114,14 +114,12 @@ brw_create_sampler_state( struct pipe_context *pipe, /* XXX: anisotropy logic slightly changed: */ - if (template->max_anisotropy > 1.0) { + if (template->max_anisotropy > 1) { sampler->ss0.min_filter = BRW_MAPFILTER_ANISOTROPIC; sampler->ss0.mag_filter = BRW_MAPFILTER_ANISOTROPIC; - if (template->max_anisotropy > 2.0) { - sampler->ss3.max_aniso = MIN2((template->max_anisotropy - 2) / 2, - BRW_ANISORATIO_16); - } + sampler->ss3.max_aniso = MIN2((template->max_anisotropy - 2) / 2, + BRW_ANISORATIO_16); } sampler->ss1.r_wrap_mode = translate_wrap_mode(template->wrap_r); diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index 8fc6856ee5..d911c80707 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -139,13 +139,13 @@ nv30_sampler_state_create(struct pipe_context *pipe, ps->en = 0; - if (cso->max_anisotropy >= 8.0) { + if (cso->max_anisotropy >= 8) { ps->en |= NV34TCL_TX_ENABLE_ANISO_8X; } else - if (cso->max_anisotropy >= 4.0) { + if (cso->max_anisotropy >= 4) { ps->en |= NV34TCL_TX_ENABLE_ANISO_4X; } else - if (cso->max_anisotropy >= 2.0) { + if (cso->max_anisotropy >= 2) { ps->en |= NV34TCL_TX_ENABLE_ANISO_2X; } diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c index d068be6243..2073bf0735 100644 --- a/src/gallium/drivers/nv40/nv40_state.c +++ b/src/gallium/drivers/nv40/nv40_state.c @@ -132,26 +132,26 @@ nv40_sampler_state_create(struct pipe_context *pipe, (wrap_mode(cso->wrap_r) << NV40TCL_TEX_WRAP_R_SHIFT)); ps->en = 0; - if (cso->max_anisotropy >= 2.0) { + if (cso->max_anisotropy >= 2) { /* no idea, binary driver sets it, works without it.. meh.. */ ps->wrap |= (1 << 5); - if (cso->max_anisotropy >= 16.0) { + if (cso->max_anisotropy >= 16) { ps->en |= NV40TCL_TEX_ENABLE_ANISO_16X; } else - if (cso->max_anisotropy >= 12.0) { + if (cso->max_anisotropy >= 12) { ps->en |= NV40TCL_TEX_ENABLE_ANISO_12X; } else - if (cso->max_anisotropy >= 10.0) { + if (cso->max_anisotropy >= 10) { ps->en |= NV40TCL_TEX_ENABLE_ANISO_10X; } else - if (cso->max_anisotropy >= 8.0) { + if (cso->max_anisotropy >= 8) { ps->en |= NV40TCL_TEX_ENABLE_ANISO_8X; } else - if (cso->max_anisotropy >= 6.0) { + if (cso->max_anisotropy >= 6) { ps->en |= NV40TCL_TEX_ENABLE_ANISO_6X; } else - if (cso->max_anisotropy >= 4.0) { + if (cso->max_anisotropy >= 4) { ps->en |= NV40TCL_TEX_ENABLE_ANISO_4X; } else { ps->en |= NV40TCL_TEX_ENABLE_ANISO_2X; diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 05d519a2f9..7d304907b6 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -202,18 +202,18 @@ nv50_sampler_state_create(struct pipe_context *pipe, break; } - if (cso->max_anisotropy >= 16.0) + if (cso->max_anisotropy >= 16) tsc[0] |= (7 << 20); else - if (cso->max_anisotropy >= 12.0) + if (cso->max_anisotropy >= 12) tsc[0] |= (6 << 20); else { - tsc[0] |= (int)(cso->max_anisotropy * 0.5f) << 20; + tsc[0] |= (cso->max_anisotropy >> 1) << 20; - if (cso->max_anisotropy >= 4.0) + if (cso->max_anisotropy >= 4) tsc[1] |= NV50TSC_1_1_UNKN_ANISO_35; else - if (cso->max_anisotropy >= 2.0) + if (cso->max_anisotropy >= 2) tsc[1] |= NV50TSC_1_1_UNKN_ANISO_15; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index a6a4f99d73..8d68aa230b 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -777,7 +777,7 @@ static void* sampler->filter0 |= r300_translate_tex_filters(state->min_img_filter, state->mag_img_filter, state->min_mip_filter, - state->max_anisotropy > 1.0); + state->max_anisotropy > 0); /* Unfortunately, r300-r500 don't support floating-point mipmap lods. */ /* We must pass these to the emit function to clamp them properly. */ diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 5df6815221..779ba2c7be 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -312,15 +312,15 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip, return retval; } -static INLINE uint32_t r300_anisotropy(float max_aniso) +static INLINE uint32_t r300_anisotropy(unsigned max_aniso) { - if (max_aniso >= 16.0f) { + if (max_aniso >= 16) { return R300_TX_MAX_ANISO_16_TO_1; - } else if (max_aniso >= 8.0f) { + } else if (max_aniso >= 8) { return R300_TX_MAX_ANISO_8_TO_1; - } else if (max_aniso >= 4.0f) { + } else if (max_aniso >= 4) { return R300_TX_MAX_ANISO_4_TO_1; - } else if (max_aniso >= 2.0f) { + } else if (max_aniso >= 2) { return R300_TX_MAX_ANISO_2_TO_1; } else { return R300_TX_MAX_ANISO_1_TO_1; diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index b70081343d..2a9adfbb06 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -102,8 +102,8 @@ svga_create_sampler_state(struct pipe_context *pipe, cso->mipfilter = translate_mip_filter(sampler->min_mip_filter); cso->magfilter = translate_img_filter( sampler->mag_img_filter ); cso->minfilter = translate_img_filter( sampler->min_img_filter ); - cso->aniso_level = MAX2( (unsigned) sampler->max_anisotropy, 1 ); - if(cso->aniso_level != 1) + cso->aniso_level = MAX2( sampler->max_anisotropy, 1 ); + if(sampler->max_anisotropy) cso->magfilter = cso->minfilter = SVGA3D_TEX_FILTER_ANISOTROPIC; cso->lod_bias = sampler->lod_bias; cso->addressu = translate_wrap_mode(sampler->wrap_s); diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 62fa09accf..a4c7255126 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -435,11 +435,11 @@ void trace_dump_sampler_state(const struct pipe_sampler_state *state) trace_dump_member(uint, state, compare_mode); trace_dump_member(uint, state, compare_func); trace_dump_member(bool, state, normalized_coords); + trace_dump_member(uint, state, max_anisotropy); trace_dump_member(float, state, lod_bias); trace_dump_member(float, state, min_lod); trace_dump_member(float, state, max_lod); trace_dump_member_array(float, state, border_color); - trace_dump_member(float, state, max_anisotropy); trace_dump_struct_end(); } diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 23748acbdc..5ac5c87813 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -281,10 +281,10 @@ struct pipe_sampler_state unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */ unsigned compare_func:3; /**< PIPE_FUNC_x */ unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */ + unsigned max_anisotropy:6; float lod_bias; /**< LOD/lambda bias */ float min_lod, max_lod; /**< LOD clamp range, after bias */ float border_color[4]; - float max_anisotropy; }; diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 9d63f1c6ab..a8262a5e1a 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -211,7 +211,7 @@ update_samplers(struct st_context *st) teximg ? teximg->_BaseFormat : GL_RGBA, sampler->border_color); - sampler->max_anisotropy = texobj->MaxAnisotropy; + sampler->max_anisotropy = (texobj->MaxAnisotropy == 1.0 ? 0 : (GLuint)texobj->MaxAnisotropy); /* only care about ARB_shadow, not SGI shadow */ if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) { -- cgit v1.2.3 From 8a92c2b23c7b6fbd869119e33f4ed7ce3ac0faf5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 12 Feb 2010 09:43:18 -0700 Subject: cell: declare stencil_value variable --- src/gallium/drivers/cell/ppu/cell_gen_fragment.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c index b58fe3764b..8915dd1dd5 100644 --- a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c @@ -1555,6 +1555,7 @@ gen_stencil_depth_test(struct spe_function *f, int stencil_writemask_reg; int zmask_reg; int newS_reg; + unsigned stencil_value; /* Stenciling is quite complex: up to six different configurable stencil * operations/calculations can be required (three each for front-facing -- cgit v1.2.3 From 0ad0d8125a1882701dac416d1889e7721a58ee8a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 12 Feb 2010 09:47:34 -0700 Subject: cell: re-fix undeclared var --- src/gallium/drivers/cell/ppu/cell_gen_fragment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c index 8915dd1dd5..0282aa452c 100644 --- a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c @@ -1555,7 +1555,7 @@ gen_stencil_depth_test(struct spe_function *f, int stencil_writemask_reg; int zmask_reg; int newS_reg; - unsigned stencil_value; + unsigned ref_value; /* Stenciling is quite complex: up to six different configurable stencil * operations/calculations can be required (three each for front-facing -- cgit v1.2.3 From 6c35e178d352a8b00eda9bf1c5c45c975852226f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 12 Feb 2010 11:06:04 -0700 Subject: cell: include cell_context.h --- src/gallium/drivers/cell/ppu/cell_screen.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index 7681e3411e..9214ac162b 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -33,6 +33,7 @@ #include "pipe/p_screen.h" #include "cell/common.h" +#include "cell_context.h" #include "cell_screen.h" #include "cell_texture.h" #include "cell_winsys.h" -- cgit v1.2.3 From e4afe725ee280396c65e541a96467072f5293e77 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 12 Feb 2010 11:06:19 -0700 Subject: cell: remove unused var --- src/gallium/drivers/cell/ppu/cell_gen_fragment.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c index 0282aa452c..70683bb367 100644 --- a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c @@ -1545,7 +1545,6 @@ gen_stencil_depth_test(struct spe_function *f, boolean need_to_writemask_stencil_values; struct pipe_stencil_state *stencil; - unsigned stencil_ref_value; /* Registers. We may or may not actually allocate these, depending * on whether the state values indicate that we need them. -- cgit v1.2.3 From 0087f9dc0690e5de139f89ea4577b1824b918757 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 12 Feb 2010 11:07:01 -0700 Subject: cell: adjust structure padding The size of some core Gallium state structures has changed so the padding on some cell structs needed to be adjusted to keep them a multiple of 16 bytes. --- src/gallium/drivers/cell/common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/cell/common.h b/src/gallium/drivers/cell/common.h index 7f2b33c2dc..bbb112fd33 100644 --- a/src/gallium/drivers/cell/common.h +++ b/src/gallium/drivers/cell/common.h @@ -230,6 +230,7 @@ struct cell_command_rasterizer { opcode_t opcode; /**< CELL_CMD_STATE_RASTERIZER */ struct pipe_rasterizer_state rasterizer; + uint32_t pad[1]; }; @@ -326,7 +327,7 @@ struct cell_command_sampler opcode_t opcode; /**< CELL_CMD_STATE_SAMPLER */ uint unit; struct pipe_sampler_state state; - uint32_t pad_[2]; + uint32_t pad_[3]; }; -- cgit v1.2.3