From 4f28e2827c9ccc26dc608a870209b4deab7b5882 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 9 Aug 2022 16:56:08 -0400 Subject: [PATCH] mesa: fix blending when using luminance/intensity emulation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit neither of these have a real alpha channel, so reuse the xrgb blend clamping here to ensure the "right" alpha value is used cc: mesa-stable fixes: spec@arb_texture_float@fbo-blending-formats Reviewed-by: Marek Olšák Part-of: --- src/broadcom/ci/broadcom-rpi4-fails.txt | 2 -- .../drivers/crocus/ci/crocus-g41-fails.txt | 2 -- .../drivers/virgl/ci/virpipe-gl-fails.txt | 6 ------ src/gallium/drivers/zink/ci/zink-lvp-fails.txt | 16 ---------------- src/mesa/main/fbobject.c | 8 +++++--- src/mesa/main/mtypes.h | 2 +- src/mesa/state_tracker/st_atom_blend.c | 7 +++---- 7 files changed, 9 insertions(+), 34 deletions(-) diff --git a/src/broadcom/ci/broadcom-rpi4-fails.txt b/src/broadcom/ci/broadcom-rpi4-fails.txt index eb9178f6894..fa3d432cbde 100644 --- a/src/broadcom/ci/broadcom-rpi4-fails.txt +++ b/src/broadcom/ci/broadcom-rpi4-fails.txt @@ -144,9 +144,7 @@ spec@arb_shader_texture_lod@execution@arb_shader_texture_lod-texgrad,Fail spec@arb_shader_texture_lod@execution@arb_shader_texture_lod-texgradcube,Fail spec@arb_texture_float@fbo-blending-formats,Fail spec@arb_texture_float@fbo-blending-formats@GL_ALPHA32F_ARB,Fail -spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY16F_ARB,Fail spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY32F_ARB,Fail -spec@arb_texture_float@fbo-blending-formats@GL_LUMINANCE16F_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 diff --git a/src/gallium/drivers/crocus/ci/crocus-g41-fails.txt b/src/gallium/drivers/crocus/ci/crocus-g41-fails.txt index bbc18be25f4..23bd35f3ef5 100644 --- a/src/gallium/drivers/crocus/ci/crocus-g41-fails.txt +++ b/src/gallium/drivers/crocus/ci/crocus-g41-fails.txt @@ -129,8 +129,6 @@ spec@arb_texture_cube_map@copyteximage cube,Fail # 16-bit so that texture filtering worked, since GL 2.1 let you do that. # Crocus instead decided to follow r300 and other GL2 hardware in using the # requested size for storage even if the HW can't filter textures with it. -spec@arb_texture_float@fbo-blending-formats,Fail -spec@arb_texture_float@fbo-blending-formats@GL_LUMINANCE32F_ARB,Fail spec@arb_texture_rg@fbo-blending-formats-float,Fail spec@arb_texture_rg@fbo-blending-formats-float@GL_RG32F,Fail spec@arb_texture_float@texwrap formats bordercolor,Fail diff --git a/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt b/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt index ffd9345e4fb..e915eef03d5 100644 --- a/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt +++ b/src/gallium/drivers/virgl/ci/virpipe-gl-fails.txt @@ -579,8 +579,6 @@ spec@arb_texture_cube_map_array@fbo-generatemipmap-cubemap array s3tc_dxt1,Fail spec@arb_texture_float@fbo-blending-formats,Fail spec@arb_texture_float@fbo-blending-formats@GL_ALPHA16F_ARB,Fail spec@arb_texture_float@fbo-blending-formats@GL_ALPHA32F_ARB,Fail -spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY16F_ARB,Fail -spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY32F_ARB,Fail spec@arb_texture_float@fbo-blending-formats@GL_RGB32F,Fail spec@arb_texture_float@fbo-clear-formats,Fail spec@arb_texture_float@fbo-clear-formats@GL_ALPHA16F_ARB,Fail @@ -778,10 +776,6 @@ spec@ext_texture_shared_exponent@texwrap formats bordercolor,Fail spec@ext_texture_shared_exponent@texwrap formats bordercolor-swizzled,Fail spec@ext_texture_shared_exponent@texwrap formats bordercolor-swizzled@GL_RGB9_E5- swizzled- border color only,Fail spec@ext_texture_shared_exponent@texwrap formats bordercolor@GL_RGB9_E5- border color only,Fail -spec@ext_texture_snorm@fbo-blending-formats,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_INTENSITY16_SNORM,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_INTENSITY8_SNORM,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_INTENSITY_SNORM,Fail spec@ext_texture_snorm@texwrap formats bordercolor,Fail spec@ext_texture_snorm@texwrap formats bordercolor-swizzled,Fail spec@ext_texture_snorm@texwrap formats bordercolor-swizzled@GL_ALPHA16_SNORM- swizzled- border color only,Fail diff --git a/src/gallium/drivers/zink/ci/zink-lvp-fails.txt b/src/gallium/drivers/zink/ci/zink-lvp-fails.txt index 7c6c523a753..669d2021e67 100644 --- a/src/gallium/drivers/zink/ci/zink-lvp-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-lvp-fails.txt @@ -137,10 +137,6 @@ spec@arb_sample_shading@samplemask 4 all@noms partition,Fail spec@arb_sample_shading@samplemask 4 all@sample mask_in_one,Fail spec@arb_shader_texture_lod@execution@arb_shader_texture_lod-texgrad,Fail spec@arb_texture_float@fbo-blending-formats,Fail -spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY16F_ARB,Fail -spec@arb_texture_float@fbo-blending-formats@GL_INTENSITY32F_ARB,Fail -spec@arb_texture_float@fbo-blending-formats@GL_LUMINANCE16F_ARB,Fail -spec@arb_texture_float@fbo-blending-formats@GL_LUMINANCE32F_ARB,Fail spec@arb_texture_float@fbo-blending-formats@GL_RGB32F,Fail spec@egl 1.4@eglterminate then unbind context,Fail @@ -165,11 +161,6 @@ spec@ext_framebuffer_multisample@interpolation 4 centroid-edges,Fail spec@ext_framebuffer_multisample@interpolation 4 non-centroid-deriv-disabled,Fail spec@ext_framebuffer_multisample@interpolation 4 non-centroid-disabled,Fail spec@ext_framebuffer_object@fbo-blending-formats,Fail -spec@ext_framebuffer_object@fbo-blending-formats@GL_INTENSITY,Fail -spec@ext_framebuffer_object@fbo-blending-formats@GL_INTENSITY12,Fail -spec@ext_framebuffer_object@fbo-blending-formats@GL_INTENSITY16,Fail -spec@ext_framebuffer_object@fbo-blending-formats@GL_INTENSITY4,Fail -spec@ext_framebuffer_object@fbo-blending-formats@GL_INTENSITY8,Fail spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE12,Fail spec@ext_framebuffer_object@fbo-blending-formats@GL_LUMINANCE16,Fail spec@ext_framebuffer_object@fbo-blending-formats@GL_RGB10,Fail @@ -201,13 +192,6 @@ spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_yvu420,Fail spec@ext_image_dma_buf_import@ext_image_dma_buf_import-transcode-nv12-as-r8-gr88,Fail spec@ext_image_dma_buf_import@ext_image_dma_buf_import-unsupported_format,Fail spec@ext_packed_float@query-rgba-signed-components,Fail -spec@ext_texture_snorm@fbo-blending-formats,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_INTENSITY16_SNORM,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_INTENSITY8_SNORM,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_INTENSITY_SNORM,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_LUMINANCE16_SNORM,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_LUMINANCE8_SNORM,Fail -spec@ext_texture_snorm@fbo-blending-formats@GL_LUMINANCE_SNORM,Fail spec@ext_texture_swizzle@depth_texture_mode_and_swizzle,Fail spec@intel_performance_query@intel_performance_query-issue_2235,Fail spec@khr_texture_compression_astc@array-gl,Fail diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 5127d9634c0..076d957e589 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1290,7 +1290,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, fb->_HasSNormOrFloatColorBuffer = GL_FALSE; fb->_HasAttachments = true; fb->_IntegerBuffers = 0; - fb->_RGBBuffers = 0; + fb->_BlendForceAlphaToOne = 0; fb->_FP32Buffers = 0; /* Start at -2 to more easily loop over all attachment points. @@ -1451,8 +1451,10 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, if (_mesa_is_format_integer_color(attFormat)) fb->_IntegerBuffers |= (1 << i); - if (baseFormat == GL_RGB) - fb->_RGBBuffers |= (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))) + fb->_BlendForceAlphaToOne |= (1 << i); if (type == GL_FLOAT && _mesa_get_format_max_bits(attFormat) > 16) fb->_FP32Buffers |= (1 << i); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 168d8fd871a..eea350fbd72 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2722,7 +2722,7 @@ struct gl_framebuffer bool _HasAttachments; GLbitfield _IntegerBuffers; /**< Which color buffers are integer valued */ - GLbitfield _RGBBuffers; /**< Which color buffers have baseformat == RGB */ + GLbitfield _BlendForceAlphaToOne; /**< Which color buffers need blend factor adjustment */ GLbitfield _FP32Buffers; /**< Which color buffers are FP32 */ /* ARB_color_buffer_float */ diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 508a932e279..68ea850bc4c 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -148,14 +148,14 @@ blend_per_rt(const struct st_context *st, unsigned num_cb) return GL_TRUE; } - if (st->needs_rgb_dst_alpha_override && ctx->DrawBuffer->_RGBBuffers) { + 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. */ assert(st->has_indep_blend_func); - /* If some of the buffers are RGB, we may need to override blend + /* If some of the buffers are RGB or emulated L/I, we may need to override blend * factors that reference destination-alpha to constants. We may * need different blend factor overrides per buffer (say one uses * a DST_ALPHA factor and another uses INV_DST_ALPHA), so we flip @@ -269,8 +269,7 @@ st_update_blend( struct st_context *st ) const struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i]; - if (st->needs_rgb_dst_alpha_override && rb && - (ctx->DrawBuffer->_RGBBuffers & (1 << i))) { + if (rb && (ctx->DrawBuffer->_BlendForceAlphaToOne & (1 << i))) { struct pipe_rt_blend_state *rt = &blend->rt[i]; rt->rgb_src_factor = fix_xrgb_alpha(rt->rgb_src_factor); rt->rgb_dst_factor = fix_xrgb_alpha(rt->rgb_dst_factor);