Mesa (master): gallium: set sample mask to ~0 for clear, blit and gen_mipmap

Marek Olšák mareko at kemper.freedesktop.org
Sat Aug 4 13:01:10 UTC 2012


Module: Mesa
Branch: master
Commit: e7689303a8e4790c38cc69ae7a197712f98e8f5b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7689303a8e4790c38cc69ae7a197712f98e8f5b

Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Jul 24 11:17:29 2012 +0200

gallium: set sample mask to ~0 for clear, blit and gen_mipmap

The sample mask affects single-sampled rendering too (it's orthogonal
to the color mask).

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/auxiliary/cso_cache/cso_context.c |   13 ++++++++++++-
 src/gallium/auxiliary/cso_cache/cso_context.h |    2 ++
 src/gallium/auxiliary/util/u_blit.c           |    6 ++++++
 src/gallium/auxiliary/util/u_gen_mipmap.c     |    3 +++
 src/mesa/state_tracker/st_cb_clear.c          |    4 +++-
 5 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index b592c4f..26c73fb 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -114,7 +114,7 @@ struct cso_context {
    struct pipe_framebuffer_state fb, fb_saved;
    struct pipe_viewport_state vp, vp_saved;
    struct pipe_blend_color blend_color;
-   unsigned sample_mask;
+   unsigned sample_mask, sample_mask_saved;
    struct pipe_stencil_ref stencil_ref, stencil_ref_saved;
 };
 
@@ -265,6 +265,7 @@ struct cso_context *cso_create_context( struct pipe_context *pipe )
                                    ctx);
 
    ctx->pipe = pipe;
+   ctx->sample_mask_saved = ~0;
 
    cso_init_vbuf(ctx);
 
@@ -691,6 +692,16 @@ enum pipe_error cso_set_sample_mask(struct cso_context *ctx,
    return PIPE_OK;
 }
 
+void cso_save_sample_mask(struct cso_context *ctx)
+{
+   ctx->sample_mask_saved = ctx->sample_mask;
+}
+
+void cso_restore_sample_mask(struct cso_context *ctx)
+{
+   cso_set_sample_mask(ctx, ctx->sample_mask_saved);
+}
+
 enum pipe_error cso_set_stencil_ref(struct cso_context *ctx,
                                     const struct pipe_stencil_ref *sr)
 {
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index f01a0f2..f49b2b7 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -161,6 +161,8 @@ enum pipe_error cso_set_blend_color(struct cso_context *cso,
 
 enum pipe_error cso_set_sample_mask(struct cso_context *cso,
                                     unsigned stencil_mask);
+void cso_save_sample_mask(struct cso_context *ctx);
+void cso_restore_sample_mask(struct cso_context *ctx);
 
 enum pipe_error cso_set_stencil_ref(struct cso_context *cso,
                                     const struct pipe_stencil_ref *sr);
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index d2477d2..5ad2984 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -648,6 +648,7 @@ util_blit_pixels(struct blit_state *ctx,
    cso_save_blend(ctx->cso);
    cso_save_depth_stencil_alpha(ctx->cso);
    cso_save_rasterizer(ctx->cso);
+   cso_save_sample_mask(ctx->cso);
    cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_save_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_save_stream_outputs(ctx->cso);
@@ -665,6 +666,7 @@ util_blit_pixels(struct blit_state *ctx,
    else
       cso_set_blend(ctx->cso, &ctx->blend_keep_color);
 
+   cso_set_sample_mask(ctx->cso, ~0);
    cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
    cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
    cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
@@ -777,6 +779,7 @@ util_blit_pixels(struct blit_state *ctx,
    cso_restore_blend(ctx->cso);
    cso_restore_depth_stencil_alpha(ctx->cso);
    cso_restore_rasterizer(ctx->cso);
+   cso_restore_sample_mask(ctx->cso);
    cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_restore_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_restore_viewport(ctx->cso);
@@ -849,6 +852,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
    cso_save_blend(ctx->cso);
    cso_save_depth_stencil_alpha(ctx->cso);
    cso_save_rasterizer(ctx->cso);
+   cso_save_sample_mask(ctx->cso);
    cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_save_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_save_stream_outputs(ctx->cso);
@@ -863,6 +867,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
    /* set misc state we care about */
    cso_set_blend(ctx->cso, &ctx->blend_write_color);
    cso_set_depth_stencil_alpha(ctx->cso, &ctx->dsa_keep_depthstencil);
+   cso_set_sample_mask(ctx->cso, ~0);
    cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
    cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
    cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
@@ -921,6 +926,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
    cso_restore_blend(ctx->cso);
    cso_restore_depth_stencil_alpha(ctx->cso);
    cso_restore_rasterizer(ctx->cso);
+   cso_restore_sample_mask(ctx->cso);
    cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_restore_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_restore_viewport(ctx->cso);
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 222bf6b..c82c52c 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -1573,6 +1573,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_save_blend(ctx->cso);
    cso_save_depth_stencil_alpha(ctx->cso);
    cso_save_rasterizer(ctx->cso);
+   cso_save_sample_mask(ctx->cso);
    cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_save_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_save_stream_outputs(ctx->cso);
@@ -1590,6 +1591,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_set_depth_stencil_alpha(ctx->cso, is_depth ? &ctx->dsa_write_depth :
                                                     &ctx->dsa_keep_depth);
    cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
+   cso_set_sample_mask(ctx->cso, ~0);
    cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
    cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
 
@@ -1703,6 +1705,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_restore_blend(ctx->cso);
    cso_restore_depth_stencil_alpha(ctx->cso);
    cso_restore_rasterizer(ctx->cso);
+   cso_restore_sample_mask(ctx->cso);
    cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_restore_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT);
    cso_restore_framebuffer(ctx->cso);
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 3cd8756..e731b6b 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -217,6 +217,7 @@ clear_with_quad(struct gl_context *ctx,
    cso_save_stencil_ref(st->cso_context);
    cso_save_depth_stencil_alpha(st->cso_context);
    cso_save_rasterizer(st->cso_context);
+   cso_save_sample_mask(st->cso_context);
    cso_save_viewport(st->cso_context);
    cso_save_fragment_shader(st->cso_context);
    cso_save_stream_outputs(st->cso_context);
@@ -277,7 +278,7 @@ clear_with_quad(struct gl_context *ctx,
 
    cso_set_vertex_elements(st->cso_context, 2, st->velems_util_draw);
    cso_set_stream_outputs(st->cso_context, 0, NULL, 0);
-
+   cso_set_sample_mask(st->cso_context, ~0);
    cso_set_rasterizer(st->cso_context, &st->clear.raster);
 
    /* viewport state: viewport matching window dims */
@@ -313,6 +314,7 @@ clear_with_quad(struct gl_context *ctx,
    cso_restore_stencil_ref(st->cso_context);
    cso_restore_depth_stencil_alpha(st->cso_context);
    cso_restore_rasterizer(st->cso_context);
+   cso_restore_sample_mask(st->cso_context);
    cso_restore_viewport(st->cso_context);
    cso_restore_fragment_shader(st->cso_context);
    cso_restore_vertex_shader(st->cso_context);




More information about the mesa-commit mailing list