panfrost: improve swizzle inversion
panfrost_invert_swizzle produces a (one-sided) inverse, that is a function g such that g(f(x)) = x. However, it is actually used in some cases where we want a two-sided inverse, where we also have f(g(x)) = x. An example is its use to pre-swizzle border color values so that a later pass will un-swizzle them. If the swizzle is not one-to-one this two sided inverse does not exist. However, we can do better than the original code, e.g. for an RRR1 swizzle inverse produced was originally B000, which when applied on the wrong side results in BBB1 as output, whereas R000 would produce the desired RRR1 output. Using the first valid component we see, rather than the last one, is thus usually better. The "correct" solution is to re-write all the code that uses an inverse to handle non-unique inverses. But frankly these uses only crop up in fairly niche cases like tests, and it's probably not worth spending a lot of effort to deal with these edge cases when this patch fixes most of them. Fixes some failing piglit ext_framebuffer_multisample tests. Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31060>
This commit is contained in:
@@ -17,8 +17,6 @@ spec@arb_base_instance@arb_base_instance-drawarrays,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_framebuffer_object@fbo-luminance-alpha,Fail
|
||||
spec@arb_framebuffer_srgb@fbo-fast-clear,Fail
|
||||
spec@arb_point_sprite@arb_point_sprite-mipmap,Fail
|
||||
spec@arb_shader_texture_lod@execution@arb_shader_texture_lod-texgradcube,Fail
|
||||
spec@arb_shader_texture_lod@execution@arb_shader_texture_lod-texgrad,Fail
|
||||
@@ -96,16 +94,8 @@ spec@ext_framebuffer_multisample@alpha-to-one-dual-src-blend 2,Fail
|
||||
spec@ext_framebuffer_multisample@alpha-to-one-dual-src-blend 4,Fail
|
||||
spec@ext_framebuffer_multisample@draw-buffers-alpha-to-one 2,Fail
|
||||
spec@ext_framebuffer_multisample@draw-buffers-alpha-to-one 4,Fail
|
||||
spec@ext_framebuffer_multisample@fast-clear,Fail
|
||||
spec@ext_framebuffer_multisample@formats 2,Fail
|
||||
spec@ext_framebuffer_multisample@formats 4,Fail
|
||||
spec@ext_framebuffer_multisample@formats all_samples,Fail
|
||||
spec@ext_framebuffer_multisample@sample-alpha-to-one 2,Fail
|
||||
spec@ext_framebuffer_multisample@sample-alpha-to-one 4,Fail
|
||||
spec@ext_framebuffer_object@fbo-alphatest-formats,Fail
|
||||
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,Fail
|
||||
spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA4,Fail
|
||||
@@ -121,31 +111,9 @@ 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-snorm,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY4,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY8,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE4_ALPHA4,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE4,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE8_ALPHA8,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE8,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE_ALPHA,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_INTENSITY4,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_INTENSITY8,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_INTENSITY,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE4_ALPHA4,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE4,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE8_ALPHA8,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE8,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE_ALPHA,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE,Fail
|
||||
spec@ext_framebuffer_object@fbo-fast-clear,Fail
|
||||
spec@ext_framebuffer_object@getteximage-formats init-by-clear-and-render,Fail
|
||||
spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail
|
||||
spec@ext_packed_float@query-rgba-signed-components,Fail
|
||||
spec@ext_texture_srgb@fbo-fast-clear,Fail
|
||||
spec@ext_transform_feedback2@draw-auto,Fail
|
||||
spec@ext_transform_feedback@builtin-varyings gl_clipdistance,Fail
|
||||
spec@ext_transform_feedback@change-size base-shrink,Fail
|
||||
|
||||
@@ -27,8 +27,6 @@ spec@arb_base_instance@arb_base_instance-drawarrays,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_framebuffer_object@fbo-luminance-alpha,Fail
|
||||
spec@arb_framebuffer_srgb@fbo-fast-clear,Fail
|
||||
spec@arb_point_sprite@arb_point_sprite-mipmap,Fail
|
||||
spec@arb_sample_shading@samplemask 2@0.250000 mask_in_one,Fail
|
||||
spec@arb_sample_shading@samplemask 2@0.500000 mask_in_one,Fail
|
||||
@@ -138,16 +136,8 @@ spec@ext_framebuffer_multisample@alpha-to-one-dual-src-blend 2,Fail
|
||||
spec@ext_framebuffer_multisample@alpha-to-one-dual-src-blend 4,Fail
|
||||
spec@ext_framebuffer_multisample@draw-buffers-alpha-to-one 2,Fail
|
||||
spec@ext_framebuffer_multisample@draw-buffers-alpha-to-one 4,Fail
|
||||
spec@ext_framebuffer_multisample@fast-clear,Fail
|
||||
spec@ext_framebuffer_multisample@formats 2,Fail
|
||||
spec@ext_framebuffer_multisample@formats 4,Fail
|
||||
spec@ext_framebuffer_multisample@formats all_samples,Fail
|
||||
spec@ext_framebuffer_multisample@sample-alpha-to-one 2,Fail
|
||||
spec@ext_framebuffer_multisample@sample-alpha-to-one 4,Fail
|
||||
spec@ext_framebuffer_object@fbo-alphatest-formats,Fail
|
||||
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,Fail
|
||||
spec@ext_framebuffer_object@fbo-blending-formats@GL_ALPHA4,Fail
|
||||
@@ -163,27 +153,6 @@ 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-snorm,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY4,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY8,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_INTENSITY,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE4_ALPHA4,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE4,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE8_ALPHA8,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE8,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE_ALPHA,Fail
|
||||
spec@ext_framebuffer_object@fbo-clear-formats@GL_LUMINANCE,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_INTENSITY4,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_INTENSITY8,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_INTENSITY,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE4_ALPHA4,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE4,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE8_ALPHA8,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE8,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE_ALPHA,Fail
|
||||
spec@ext_framebuffer_object@fbo-colormask-formats@GL_LUMINANCE,Fail
|
||||
spec@ext_framebuffer_object@fbo-fast-clear,Fail
|
||||
spec@ext_framebuffer_object@getteximage-formats init-by-clear-and-render,Fail
|
||||
spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail
|
||||
@@ -213,7 +182,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_srgb@fbo-fast-clear,Fail
|
||||
spec@ext_transform_feedback2@draw-auto,Fail
|
||||
spec@ext_transform_feedback@builtin-varyings gl_clipdistance,Fail
|
||||
spec@ext_transform_feedback@change-size base-shrink,Fail
|
||||
|
||||
@@ -45,7 +45,10 @@ panfrost_translate_swizzle_4(const unsigned char swizzle[4])
|
||||
void
|
||||
panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
|
||||
{
|
||||
/* First, default to all zeroes to prevent uninitialized junk */
|
||||
/* First, default to all zeroes, both to prevent uninitialized junk
|
||||
and to provide a known baseline so we can tell when components
|
||||
have been modified
|
||||
*/
|
||||
|
||||
for (unsigned c = 0; c < 4; ++c)
|
||||
out[c] = PIPE_SWIZZLE_0;
|
||||
@@ -60,8 +63,9 @@ panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
|
||||
if (i > PIPE_SWIZZLE_W)
|
||||
continue;
|
||||
|
||||
/* Invert */
|
||||
/* Invert (only if we haven't already applied) */
|
||||
unsigned idx = i - PIPE_SWIZZLE_X;
|
||||
out[idx] = PIPE_SWIZZLE_X + c;
|
||||
if (out[idx] == PIPE_SWIZZLE_0)
|
||||
out[idx] = PIPE_SWIZZLE_X + c;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user