From 6b2fa965c6cb062d7a30ed056bf905fc6fd7cc72 Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Fri, 7 Jul 2023 15:15:20 -0400 Subject: [PATCH] gallium: Remove `PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Part-of: --- docs/gallium/screen.rst | 1 - src/broadcom/ci/broadcom-rpi4-fails.txt | 1 - src/gallium/auxiliary/util/u_screen.c | 1 - src/gallium/drivers/crocus/crocus_screen.c | 1 - src/gallium/drivers/d3d12/d3d12_format.c | 3 +-- src/gallium/drivers/d3d12/d3d12_screen.cpp | 1 - src/gallium/drivers/freedreno/freedreno_screen.c | 1 - src/gallium/drivers/iris/iris_screen.c | 1 - src/gallium/drivers/softpipe/sp_screen.c | 1 - src/gallium/drivers/zink/zink_screen.c | 1 - src/gallium/include/pipe/p_defines.h | 1 - src/mesa/main/fbobject.c | 7 ++++--- 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 - src/panfrost/ci/panfrost-g52-fails.txt | 7 ------- 16 files changed, 6 insertions(+), 27 deletions(-) diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst index 581ea8278d8..d66453c76ed 100644 --- a/docs/gallium/screen.rst +++ b/docs/gallium/screen.rst @@ -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 diff --git a/src/broadcom/ci/broadcom-rpi4-fails.txt b/src/broadcom/ci/broadcom-rpi4-fails.txt index 845201f85d1..bcc01a12e21 100644 --- a/src/broadcom/ci/broadcom-rpi4-fails.txt +++ b/src/broadcom/ci/broadcom-rpi4-fails.txt @@ -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 diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 40218d26205..f7005cbcf2a 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -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: diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c index 3473a1723d6..deca4caf53e 100644 --- a/src/gallium/drivers/crocus/crocus_screen.c +++ b/src/gallium/drivers/crocus/crocus_screen.c @@ -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: diff --git a/src/gallium/drivers/d3d12/d3d12_format.c b/src/gallium/drivers/d3d12/d3d12_format.c index e653eab3d69..5ba7add2b88 100644 --- a/src/gallium/drivers/d3d12/d3d12_format.c +++ b/src/gallium/drivers/d3d12/d3d12_format.c @@ -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. \ */ \ diff --git a/src/gallium/drivers/d3d12/d3d12_screen.cpp b/src/gallium/drivers/d3d12/d3d12_screen.cpp index 3db6dcb2ec3..2279a1e8469 100644 --- a/src/gallium/drivers/d3d12/d3d12_screen.cpp +++ b/src/gallium/drivers/d3d12/d3d12_screen.cpp @@ -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; diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index de4b9606dff..eb488685c1a 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -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: diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 079e2b0b9d0..74094b016ce 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -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: diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 7d7006555ee..9a78fb8df48 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -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; diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index d3cf9578e17..813c032a316 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -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; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index a555a16ceac..d874cd7db8c 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -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, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index af02d7535a3..61787de934b 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -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) diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index a78a1c2ec06..607b2b151fe 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -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); diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 0527ccd0ac8..a14174ff25c 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -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 = diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index bc63dfb1487..d38ff6741ea 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -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; diff --git a/src/panfrost/ci/panfrost-g52-fails.txt b/src/panfrost/ci/panfrost-g52-fails.txt index 20c485a323f..d866c2ab01a 100644 --- a/src/panfrost/ci/panfrost-g52-fails.txt +++ b/src/panfrost/ci/panfrost-g52-fails.txt @@ -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 -- 2.34.1