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>
This commit is contained in:
Filip Gawin
2022-05-17 18:10:21 +02:00
committed by Marge Bot
parent c4cec84231
commit fb2426db7a
2 changed files with 11 additions and 3 deletions
@@ -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;
}
@@ -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)