gallium: Remove `PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND`
authorLucas Fryzek <lfryzek@igalia.com>
Fri, 7 Jul 2023 19:15:20 +0000 (15:15 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 11 Jul 2023 15:52:08 +0000 (15:52 +0000)
Since the mesa state tracker can promote RGB texture formats
to RGBA texture formats (among other formats) without exposing
any of that information to a driver, it is more desirable to
have the behaviour of `PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND`
be the default. This avoids rendering bugs where an application
sets `DST_ALPHA` blending on a format where there is no alpha
channel, that has been promoted to a format that actually has an
alpha channel. The driver can instead rely on the common code
in the state tracker to convert the blending parameter to one
that reflects the limitations of the application requested format,
as long as `PIPE_CAP_INDEP_BLEND_FUNC` is supported.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24044>

16 files changed:
docs/gallium/screen.rst
src/broadcom/ci/broadcom-rpi4-fails.txt
src/gallium/auxiliary/util/u_screen.c
src/gallium/drivers/crocus/crocus_screen.c
src/gallium/drivers/d3d12/d3d12_format.c
src/gallium/drivers/d3d12/d3d12_screen.cpp
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/iris/iris_screen.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/zink/zink_screen.c
src/gallium/include/pipe/p_defines.h
src/mesa/main/fbobject.c
src/mesa/state_tracker/st_atom_blend.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h
src/panfrost/ci/panfrost-g52-fails.txt

index 581ea82..d66453c 100644 (file)
@@ -542,7 +542,6 @@ The integer capabilities:
   enable :ext:`GL_EXT_multisampled_render_to_texture`.
 * ``PIPE_CAP_IMAGE_ATOMIC_FLOAT_ADD``: Atomic floating point adds are
   supported on images, buffers, and shared memory.
-* ``PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND``: True if the driver needs blend state to use zero/one instead of destination alpha for RGB/XRGB formats.
 * ``PIPE_CAP_GLSL_TESS_LEVELS_AS_INPUTS``: True if the driver wants TESSINNER and TESSOUTER to be inputs (rather than system values) for tessellation evaluation shaders.
 * ``PIPE_CAP_DEST_SURFACE_SRGB_CONTROL``: Indicates whether the drivers
   supports switching the format between sRGB and linear for a surface that is
index 845201f..bcc01a1 100644 (file)
@@ -214,7 +214,6 @@ spec@arb_texture_float@fbo-blending-formats@GL_ALPHA32F_ARB,Fail
 spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY32F_ARB,Fail
 spec@arb_texture_float@fbo-blending-formats@GL_LUMINANCE32F_ARB,Fail
 spec@arb_texture_float@fbo-blending-formats@GL_LUMINANCE_ALPHA32F_ARB,Fail
-spec@arb_texture_float@fbo-blending-formats@GL_RGB16F,Fail
 spec@arb_texture_float@fbo-blending-formats@GL_RGB32F,Fail
 spec@arb_texture_float@fbo-blending-formats@GL_RGBA32F,Fail
 spec@arb_texture_float@texwrap formats bordercolor,Fail
index 40218d2..f7005cb 100644 (file)
@@ -100,7 +100,6 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
    case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
    case PIPE_CAP_SEAMLESS_CUBE_MAP:
    case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
-   case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND:
       return 0;
 
    case PIPE_CAP_SUPPORTED_PRIM_MODES_WITH_RESTART:
index 3473a17..deca4ca 100644 (file)
@@ -150,7 +150,6 @@ crocus_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART:
    case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX:
    case PIPE_CAP_INDEP_BLEND_ENABLE:
-   case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND:
    case PIPE_CAP_FS_COORD_ORIGIN_UPPER_LEFT:
    case PIPE_CAP_FS_COORD_PIXEL_CENTER_INTEGER:
    case PIPE_CAP_DEPTH_CLIP_DISABLE:
index e653eab..5ba7add 100644 (file)
@@ -82,8 +82,7 @@
    MAP_FORMAT_INT(R8G8B8A8) \
    MAP_FORMAT_SRGB(R8G8B8A8) \
 \
-   /* Since we report PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND and other caps, \
-    * we can rely on st/mesa to force the alpha to 1 for these, so we can \
+   /* We can rely on st/mesa to force the alpha to 1 for these, so we can \
     * just use RGBA. This is needed to support RGB configs, since some apps \
     * will only choose RGB (not RGBA) configs. \
     */ \
index 3db6dcb..2279a1e 100644 (file)
@@ -170,7 +170,6 @@ d3d12_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES:
    case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
-   case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND:
    case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
       return 1;
 
index de4b960..eb48868 100644 (file)
@@ -206,7 +206,6 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
    case PIPE_CAP_TEXTURE_BARRIER:
    case PIPE_CAP_INVALIDATE_BUFFER:
-   case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND:
    case PIPE_CAP_GLSL_TESS_LEVELS_AS_INPUTS:
    case PIPE_CAP_NIR_COMPACT_ARRAYS:
    case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE:
index 079e2b0..74094b0 100644 (file)
@@ -216,7 +216,6 @@ iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX:
    case PIPE_CAP_INDEP_BLEND_ENABLE:
    case PIPE_CAP_INDEP_BLEND_FUNC:
-   case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND:
    case PIPE_CAP_FS_COORD_ORIGIN_UPPER_LEFT:
    case PIPE_CAP_FS_COORD_PIXEL_CENTER_INTEGER:
    case PIPE_CAP_DEPTH_CLIP_DISABLE:
index 7d70065..9a78fb8 100644 (file)
@@ -143,7 +143,6 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
       return SP_MAX_TEXTURE_CUBE_LEVELS;
    case PIPE_CAP_BLEND_EQUATION_SEPARATE:
-   case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND:
       return 1;
    case PIPE_CAP_INDEP_BLEND_ENABLE:
       return 1;
index d3cf957..813c032 100644 (file)
@@ -590,7 +590,6 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
    case PIPE_CAP_LOAD_CONSTBUF:
    case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
-   case PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND:
    case PIPE_CAP_ALLOW_GLTHREAD_BUFFER_SUBDATA_OPT:
       return 1;
 
index a555a16..d874cd7 100644 (file)
@@ -914,7 +914,6 @@ enum pipe_cap
    PIPE_CAP_SURFACE_SAMPLE_COUNT,
    PIPE_CAP_IMAGE_ATOMIC_FLOAT_ADD,
    PIPE_CAP_QUERY_PIPELINE_STATISTICS_SINGLE,
-   PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND,
    PIPE_CAP_DEST_SURFACE_SRGB_CONTROL,
    PIPE_CAP_NIR_COMPACT_ARRAYS,
    PIPE_CAP_MAX_VARYINGS,
index af02d75..61787de 100644 (file)
@@ -1456,9 +1456,10 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
          if (baseFormat == GL_RGB)
             fb->_IsRGB |= (1 << i);
 
-         if ((baseFormat == GL_RGB && ctx->st->needs_rgb_dst_alpha_override) ||
-             (baseFormat == GL_LUMINANCE && !util_format_is_luminance(attFormat)) ||
-             (baseFormat == GL_INTENSITY && !util_format_is_intensity(attFormat)))
+         if (ctx->st->has_indep_blend_func &&
+             ((baseFormat == GL_RGB) ||
+              (baseFormat == GL_LUMINANCE && !util_format_is_luminance(attFormat)) ||
+              (baseFormat == GL_INTENSITY && !util_format_is_intensity(attFormat))))
             fb->_BlendForceAlphaToOne |= (1 << i);
 
          if (type == GL_FLOAT && _mesa_get_format_max_bits(attFormat) > 16)
index a78a1c2..607b2b1 100644 (file)
@@ -184,8 +184,7 @@ blend_per_rt(const struct st_context *st, unsigned num_cb)
 
    if (ctx->DrawBuffer->_BlendForceAlphaToOne) {
       /* Overriding requires independent blend functions (not just enables),
-       * require drivers exposing PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND to
-       * also expose PIPE_CAP_INDEP_BLEND_FUNC.
+       * requiring drivers to expose PIPE_CAP_INDEP_BLEND_FUNC.
        */
       assert(st->has_indep_blend_func);
 
index 0527ccd..a14174f 100644 (file)
@@ -619,8 +619,6 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
       screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE);
    st->has_indep_blend_func =
       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 =
index bc63dfb..d38ff67 100644 (file)
@@ -167,7 +167,6 @@ struct st_context
    bool has_pipeline_stat;
    bool has_indep_blend_enable;
    bool has_indep_blend_func;
-   bool needs_rgb_dst_alpha_override;
    bool can_dither;
    bool can_bind_const_buffer_as_vertex;
    bool lower_flatshade;
index 20c485a..d866c2a 100644 (file)
@@ -54,8 +54,6 @@ spec@arb_depth_buffer_float@fbo-stencil-gl_depth32f_stencil8-readpixels,Fail
 spec@arb_depth_clamp@depth-clamp-range,Fail
 spec@arb_direct_state_access@gettextureimage-formats,Fail
 spec@arb_direct_state_access@gettextureimage-formats init-by-rendering,Fail
-spec@arb_es2_compatibility@fbo-blending-formats,Fail
-spec@arb_es2_compatibility@fbo-blending-formats@GL_RGB565,Fail
 spec@arb_framebuffer_object@arb_framebuffer_object-depth-stencil-blit depth gl_depth32f_stencil8,Fail
 spec@arb_framebuffer_object@arb_framebuffer_object-depth-stencil-blit depth_stencil gl_depth32f_stencil8,Fail
 spec@arb_framebuffer_object@arb_framebuffer_object-depth-stencil-blit stencil gl_depth32f_stencil8,Fail
@@ -187,7 +185,6 @@ spec@ext_framebuffer_object@fbo-alphatest-formats@GL_INTENSITY4,Fail
 spec@ext_framebuffer_object@fbo-alphatest-formats@GL_INTENSITY8,Fail
 spec@ext_framebuffer_object@fbo-alphatest-formats@GL_INTENSITY,Fail
 spec@ext_framebuffer_object@fbo-blending-format-quirks,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@3,Fail
 spec@ext_framebuffer_object@fbo-blending-formats,Fail
 spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA4,Fail
 spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA8,Fail
@@ -201,10 +198,6 @@ spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE8_ALPHA8,Fail
 spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE8,Fail
 spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE_ALPHA,Fail
 spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_R3_G3_B2,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB10,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB8,Fail
-spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB,Fail
 spec@ext_framebuffer_object@fbo-blending-snorm,Fail
 spec@ext_framebuffer_object@fbo-clear-formats,Fail
 spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY4,Fail