Mesa (main): mesa/st: add PIPE_CAP_DITHERING

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jun 18 18:23:17 UTC 2022


Module: Mesa
Branch: main
Commit: 371660b877344df6ccc5f2c3bd0f286ae4f3650b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=371660b877344df6ccc5f2c3bd0f286ae4f3650b

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Sep 23 10:06:53 2020 -0400

mesa/st: add PIPE_CAP_DITHERING

this is for drivers like zink that may or may not
handle dithering and so getting blend state changes
when this state changes isn't useful

Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17043>

---

 docs/gallium/screen.rst                | 1 +
 src/gallium/auxiliary/util/u_screen.c  | 1 +
 src/gallium/include/pipe/p_defines.h   | 1 +
 src/mesa/state_tracker/st_atom_blend.c | 3 ++-
 src/mesa/state_tracker/st_context.c    | 2 ++
 src/mesa/state_tracker/st_context.h    | 1 +
 6 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst
index 8ab60463eba..2e8b6e74a35 100644
--- a/docs/gallium/screen.rst
+++ b/docs/gallium/screen.rst
@@ -572,6 +572,7 @@ The integer capabilities:
 * ``PIPE_CAP_ATOMIC_FLOAT_MINMAX``: Atomic float point minimum,
   maximum, exchange and compare-and-swap support to buffer and shared variables.
 * ``PIPE_CAP_TGSI_DIV``: Whether opcode DIV is supported
+* ``PIPE_CAP_DITHERING``: Whether dithering is supported
 * ``PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD``: Whether texture lookups with
   explicit LOD is supported in the fragment shader.
 * ``PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES``: True if the driver supports
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c
index e80d8915f68..227e599f0b3 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -49,6 +49,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
    case PIPE_CAP_GRAPHICS:
    case PIPE_CAP_GL_CLAMP:
    case PIPE_CAP_MAX_RENDER_TARGETS:
+   case PIPE_CAP_DITHERING:
       return 1;
 
    case PIPE_CAP_OCCLUSION_QUERY:
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 50c89824d8d..cc7a482d05f 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -1010,6 +1010,7 @@ enum pipe_cap
    PIPE_CAP_ALLOW_DRAW_OUT_OF_ORDER,
    PIPE_CAP_MAX_CONSTANT_BUFFER_SIZE_UINT,
    PIPE_CAP_HARDWARE_GL_SELECT,
+   PIPE_CAP_DITHERING,
 
    PIPE_CAP_LAST,
    /* XXX do not add caps after PIPE_CAP_LAST! */
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c
index 4b73856b493..508a932e279 100644
--- a/src/mesa/state_tracker/st_atom_blend.c
+++ b/src/mesa/state_tracker/st_atom_blend.c
@@ -283,7 +283,8 @@ st_update_blend( struct st_context *st )
       /* no blending / logicop */
    }
 
-   blend->dither = ctx->Color.DitherFlag;
+   if (st->can_dither)
+      blend->dither = ctx->Color.DitherFlag;
 
    if (_mesa_is_multisample_enabled(ctx) &&
        !(ctx->DrawBuffer->_IntegerBuffers & 0x1)) {
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index c5cdadb3216..b9c69e52409 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -613,6 +613,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
       screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC);
    st->needs_rgb_dst_alpha_override =
       screen->get_param(screen, PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND);
+   st->can_dither =
+      screen->get_param(screen, PIPE_CAP_DITHERING);
    st->lower_flatshade =
       !screen->get_param(screen, PIPE_CAP_FLATSHADE);
    st->lower_alpha_test =
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 749d3a4fea5..2f1f2f84f45 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -153,6 +153,7 @@ struct st_context
    boolean has_single_pipe_stat;
    boolean has_indep_blend_func;
    boolean needs_rgb_dst_alpha_override;
+   boolean can_dither;
    boolean can_bind_const_buffer_as_vertex;
    boolean lower_flatshade;
    boolean lower_alpha_test;



More information about the mesa-commit mailing list