broadcom/vc5: Add support for V3Dv4 signal bits.
[mesa.git] / src / broadcom / compiler / vir.c
index 99b31841b379eb85554f8aac74a0ca2546acc64f..c129bb047e679ce354c21397645af1ea45775ca0 100644 (file)
@@ -21,6 +21,7 @@
  * IN THE SOFTWARE.
  */
 
+#include "broadcom/common/v3d_device_info.h"
 #include "v3d_compiler.h"
 
 int
@@ -198,7 +199,7 @@ vir_depends_on_flags(struct qinst *inst)
 }
 
 bool
-vir_writes_r3(struct qinst *inst)
+vir_writes_r3(const struct v3d_device_info *devinfo, struct qinst *inst)
 {
         for (int i = 0; i < vir_get_nsrc(inst); i++) {
                 switch (inst->src[i].file) {
@@ -210,11 +211,18 @@ vir_writes_r3(struct qinst *inst)
                 }
         }
 
+        if (devinfo->ver < 41 && (inst->qpu.sig.ldvary ||
+                                  inst->qpu.sig.ldtlb ||
+                                  inst->qpu.sig.ldtlbu ||
+                                  inst->qpu.sig.ldvpm)) {
+                return true;
+        }
+
         return false;
 }
 
 bool
-vir_writes_r4(struct qinst *inst)
+vir_writes_r4(const struct v3d_device_info *devinfo, struct qinst *inst)
 {
         switch (inst->dst.file) {
         case QFILE_MAGIC:
@@ -231,7 +239,7 @@ vir_writes_r4(struct qinst *inst)
                 break;
         }
 
-        if (inst->qpu.sig.ldtmu)
+        if (devinfo->ver < 41 && inst->qpu.sig.ldtmu)
                 return true;
 
         return false;
@@ -541,6 +549,7 @@ static void
 v3d_lower_nir(struct v3d_compile *c)
 {
         struct nir_lower_tex_options tex_options = {
+                .lower_txd = true,
                 .lower_rect = false, /* XXX */
                 .lower_txp = ~0,
                 /* Apply swizzles to all samplers. */
@@ -553,6 +562,13 @@ v3d_lower_nir(struct v3d_compile *c)
         for (int i = 0; i < ARRAY_SIZE(c->key->tex); i++) {
                 for (int j = 0; j < 4; j++)
                         tex_options.swizzles[i][j] = c->key->tex[i].swizzle[j];
+
+                if (c->key->tex[i].clamp_s)
+                        tex_options.saturate_s |= 1 << i;
+                if (c->key->tex[i].clamp_t)
+                        tex_options.saturate_t |= 1 << i;
+                if (c->key->tex[i].clamp_r)
+                        tex_options.saturate_r |= 1 << i;
         }
 
         NIR_PASS_V(c->s, nir_lower_tex, &tex_options);
@@ -562,6 +578,7 @@ static void
 v3d_lower_nir_late(struct v3d_compile *c)
 {
         NIR_PASS_V(c->s, v3d_nir_lower_io, c);
+        NIR_PASS_V(c->s, v3d_nir_lower_txf_ms, c);
         NIR_PASS_V(c->s, nir_lower_idiv);
 }
 
@@ -705,10 +722,12 @@ v3d_set_fs_prog_data_inputs(struct v3d_compile *c,
         memcpy(prog_data->input_slots, c->input_slots,
                c->num_inputs * sizeof(*c->input_slots));
 
-        memcpy(prog_data->flat_shade_flags, c->flat_shade_flags,
-               sizeof(c->flat_shade_flags));
-        memcpy(prog_data->shade_model_flags, c->shade_model_flags,
-               sizeof(c->shade_model_flags));
+        STATIC_ASSERT(ARRAY_SIZE(prog_data->flat_shade_flags) >
+                      (V3D_MAX_FS_INPUTS - 1) / 24);
+        for (int i = 0; i < V3D_MAX_FS_INPUTS; i++) {
+                if (BITSET_TEST(c->flat_shade_flags, i))
+                        prog_data->flat_shade_flags[i / 24] |= 1 << (i % 24);
+        }
 }
 
 uint64_t *v3d_compile_fs(const struct v3d_compiler *compiler,