From 374da6fc41e955c261b7888a2809b7025fdf0f97 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 1 Mar 2022 15:48:51 -0800 Subject: [PATCH] =?UTF-8?q?i915g:=20Handle=20constants=20composed=20exclus?= =?UTF-8?q?ively=20of=200=20or=20=C2=B11=20specially?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can avoid some cases where a constant has to be loaded into a temporary register. v2: Update i915-g33-fails.txt. total instructions in shared programs: 788625 -> 782376 (-0.79%) instructions in affected programs: 166269 -> 160020 (-3.76%) helped: 1578 HURT: 0 helped stats (abs) min: 3 max: 21 x̄: 3.96 x̃: 3 helped stats (rel) min: 1.56% max: 33.33% x̄: 4.82% x̃: 3.45% 95% mean confidence interval for instructions value: -4.06 -3.86 95% mean confidence interval for instructions %-change: -5.00% -4.64% Instructions are helped. LOST: 0 GAINED: 35 Reviewed-by: Emma Anholt Part-of: --- .../drivers/i915/ci/i915-g33-fails.txt | 1 - src/gallium/drivers/i915/i915_fpc_translate.c | 42 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/i915/ci/i915-g33-fails.txt b/src/gallium/drivers/i915/ci/i915-g33-fails.txt index 69a2e68aa1b..30fdb2c1da4 100644 --- a/src/gallium/drivers/i915/ci/i915-g33-fails.txt +++ b/src/gallium/drivers/i915/ci/i915-g33-fails.txt @@ -43,7 +43,6 @@ dEQP-GLES2.functional.shaders.loops.for_constant_iterations.conditional_continue dEQP-GLES2.functional.shaders.loops.for_constant_iterations.double_continue_fragment,Fail dEQP-GLES2.functional.shaders.loops.for_constant_iterations.mixed_break_continue_fragment,Fail -dEQP-GLES2.functional.shaders.random.all_features.fragment.22,Fail dEQP-GLES2.functional.shaders.random.all_features.fragment.38,Fail dEQP-GLES2.functional.shaders.random.all_features.fragment.5,Fail dEQP-GLES2.functional.shaders.random.all_features.fragment.79,Fail diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c index 2e089a164b7..a17d73d8310 100644 --- a/src/gallium/drivers/i915/i915_fpc_translate.c +++ b/src/gallium/drivers/i915/i915_fpc_translate.c @@ -200,10 +200,50 @@ src_vector(struct i915_fp_compile *p, } break; - case TGSI_FILE_IMMEDIATE: + case TGSI_FILE_IMMEDIATE: { assert(index < p->num_immediates); + + uint8_t swiz[4] = { + source->Register.SwizzleX, + source->Register.SwizzleY, + source->Register.SwizzleZ, + source->Register.SwizzleW + }; + + uint8_t neg[4] = { + source->Register.Negate, + source->Register.Negate, + source->Register.Negate, + source->Register.Negate + }; + + unsigned i; + + for (i = 0; i < 4; i++) { + if (swiz[i] == TGSI_SWIZZLE_ZERO || swiz[i] == TGSI_SWIZZLE_ONE) { + continue; + } else if (p->immediates[index][swiz[i]] == 0.0) { + swiz[i] = TGSI_SWIZZLE_ZERO; + } else if (p->immediates[index][swiz[i]] == 1.0) { + swiz[i] = TGSI_SWIZZLE_ONE; + } else if (p->immediates[index][swiz[i]] == -1.0) { + swiz[i] = TGSI_SWIZZLE_ONE; + neg[i] ^= 1; + } else { + break; + } + } + + if (i == 4) { + return negate(swizzle(UREG(REG_TYPE_R, 0), + swiz[0], swiz[1], swiz[2], swiz[3]), + neg[0], neg[1], neg[2], neg[3]); + } + index = p->immediates_map[index]; FALLTHROUGH; + } + case TGSI_FILE_CONSTANT: src = UREG(REG_TYPE_CONST, index); break;