Module: Mesa Branch: main Commit: fb2426db7a1eec78121609c0fb744c8f9cf885e9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb2426db7a1eec78121609c0fb744c8f9cf885e9
Author: Filip Gawin <[email protected]> Date: Tue May 17 18:10:21 2022 +0200 r300: keep negation if w is an inline constant (in dataflow swizzles pass) helps with: dEQP-GLES2.functional.shaders.random.conditionals.combined.73 on r300 and r400 Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16559> --- src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c | 9 ++++++--- src/gallium/drivers/r300/compiler/radeon_program_constants.h | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c b/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c index 2cc624f8982..a976d7ed8d6 100644 --- a/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c +++ b/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c @@ -97,6 +97,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler *c, { unsigned new_swizzle, chan, swz0, swz1, swz2, swz3, found_swizzle, swz; unsigned all_inline = 0; + bool w_inline_constant = false; float imms[4] = {0.0f, 0.0f, 0.0f, 0.0f}; if (!rc_src_reg_is_immediate(c, reg->File, reg->Index)) { @@ -321,7 +322,9 @@ static unsigned try_rewrite_constant(struct radeon_compiler *c, swz3 = GET_SWZ(reg->Swizzle, 3); /* We can skip this if the swizzle in channel w is an inline constant. */ - if (swz3 <= RC_SWIZZLE_W) { + if (is_swizzle_inline_constant(swz3)) { + w_inline_constant = true; + } else { for (chan = 0; chan < 3; chan++) { unsigned old_swz = GET_SWZ(reg->Swizzle, chan); unsigned new_swz = GET_SWZ(new_swizzle, chan); @@ -372,7 +375,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler *c, * * Swizzles with a value > RC_SWIZZLE_W are inline constants. */ - if (chan == 3 && old_swz > RC_SWIZZLE_W) { + if (chan == 3 && w_inline_constant) { continue; } @@ -412,7 +415,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler *c, * ONE, ZERO, HALF). */ reg->File = RC_FILE_CONSTANT; - reg->Negate = 0; + reg->Negate = w_inline_constant ? reg->Negate & (1 << 3) : 0; return 1; } diff --git a/src/gallium/drivers/r300/compiler/radeon_program_constants.h b/src/gallium/drivers/r300/compiler/radeon_program_constants.h index e54c6a892dc..6a8cbe333bf 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_constants.h +++ b/src/gallium/drivers/r300/compiler/radeon_program_constants.h @@ -115,6 +115,11 @@ typedef enum { RC_SWIZZLE_UNUSED } rc_swizzle; +static inline int is_swizzle_inline_constant(rc_swizzle swizzle){ + return swizzle >= RC_SWIZZLE_ZERO; + +} + #define RC_MAKE_SWIZZLE(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) #define RC_MAKE_SWIZZLE_SMEAR(a) RC_MAKE_SWIZZLE((a),(a),(a),(a)) #define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7)
