v3d: Store the actual mask of color buffers present in the key.
[mesa.git] / src / broadcom / compiler / vir.c
index 6eb346ce9fd53867f0efbba853a109998be108e7..10105fbd8611e9ea7b2ff91ddd40097dc372ffcb 100644 (file)
@@ -611,6 +611,8 @@ v3d_lower_nir(struct v3d_compile *c)
 {
         struct nir_lower_tex_options tex_options = {
                 .lower_txd = true,
+                .lower_tg4_broadcom_swizzle = true,
+
                 .lower_rect = false, /* XXX: Use this on V3D 3.x */
                 .lower_txp = ~0,
                 /* Apply swizzles to all samplers. */
@@ -630,9 +632,14 @@ v3d_lower_nir(struct v3d_compile *c)
                         tex_options.saturate_t |= 1 << i;
                 if (c->key->tex[i].clamp_r)
                         tex_options.saturate_r |= 1 << i;
+                if (c->key->tex[i].return_size == 16) {
+                        tex_options.lower_tex_packing[i] =
+                                nir_lower_tex_packing_16;
+                }
         }
 
         NIR_PASS_V(c->s, nir_lower_tex, &tex_options);
+        NIR_PASS_V(c->s, nir_lower_system_values);
 }
 
 static void
@@ -775,6 +782,16 @@ v3d_fs_set_prog_data(struct v3d_compile *c,
         prog_data->discard = (c->s->info.fs.uses_discard ||
                               c->fs_key->sample_alpha_to_coverage);
         prog_data->uses_center_w = c->uses_center_w;
+
+        /* If the shader has some side effects and hasn't allowed early
+         * fragment tests, disable them.
+         */
+        if (!c->s->info.fs.early_fragment_tests &&
+            (c->s->info.num_images ||
+             c->s->info.num_ssbos ||
+             c->s->info.num_abos)) {
+                prog_data->discard = true;
+        }
 }
 
 static void
@@ -960,6 +977,7 @@ uint64_t *v3d_compile(const struct v3d_compiler *compiler,
 
         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, v3d_nir_lower_image_load_store);
         NIR_PASS_V(c->s, nir_lower_idiv);
 
         v3d_optimize_nir(c->s);