Mesa (master): qetnaviv: nir: use new immediates when possible

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Sep 28 04:54:19 UTC 2019


Module: Mesa
Branch: master
Commit: d446134d2a1224aca695f22b5641f1a483342906
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d446134d2a1224aca695f22b5641f1a483342906

Author: Jonathan Marek <jonathan at marek.ca>
Date:   Thu Sep 12 16:07:14 2019 -0400

qetnaviv: nir: use new immediates when possible

Note it can still be improved a bit:
* Use alu swizzle to determine if src is scalar
* Take into account new immediates in the multiple uniform src lowering

Signed-off-by: Jonathan Marek <jonathan at marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>

---

 .../drivers/etnaviv/etnaviv_compiler_nir_emit.h    | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h
index 20e6bb2d26c..b58ecd721b2 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir_emit.h
@@ -75,7 +75,9 @@ struct state {
 static inline hw_src
 src_swizzle(hw_src src, unsigned swizzle)
 {
-   src.swiz = inst_swiz_compose(src.swiz, swizzle);
+   if (src.rgroup != INST_RGROUP_IMMEDIATE)
+      src.swiz = inst_swiz_compose(src.swiz, swizzle);
+
    return src;
 }
 
@@ -114,6 +116,24 @@ const_add(uint64_t *c, uint64_t value)
 static hw_src
 const_src(struct state *state, nir_const_value *value, unsigned num_components)
 {
+   /* use inline immediates if possible */
+   if (state->c->specs->halti >= 2 && num_components == 1 &&
+       value[0].u64 >> 32 == ETNA_IMMEDIATE_CONSTANT) {
+      uint32_t bits = value[0].u32;
+
+      /* "float" - shifted by 12 */
+      if ((bits & 0xfff) == 0)
+         return etna_immediate_src(0, bits >> 12);
+
+      /* "unsigned" - raw 20 bit value */
+      if (bits < (1 << 20))
+         return etna_immediate_src(2, bits);
+
+      /* "signed" - sign extended 20-bit (sign included) value */
+      if (bits >= 0xfff80000)
+         return etna_immediate_src(1, bits);
+   }
+
    unsigned i;
    int swiz = -1;
    for (i = 0; swiz < 0; i++) {




More information about the mesa-commit mailing list