v3d: Implement ALPHA_TO_COVERAGE.
authorEric Anholt <eric@anholt.net>
Tue, 19 Jun 2018 23:27:17 +0000 (16:27 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 20 Jun 2018 16:30:46 +0000 (09:30 -0700)
There's a convenient "FTOC" instruction for generating the coverage now,
unlike vc4.  This fixes
dEQP-GLES3.functional.multisample.fbo_4_samples.proportionality_alpha_to_coverage

src/broadcom/compiler/nir_to_vir.c
src/broadcom/compiler/vir.c

index 4cbdb764eab7b96e4bde518ebbff58e71b2d5f24..267d61a25abd3834b5dc9b64d46107164df81e37 100644 (file)
@@ -920,6 +920,16 @@ emit_frag_end(struct v3d_compile *c)
                         has_any_tlb_color_write = true;
         }
 
+        if (c->fs_key->sample_alpha_to_coverage && c->output_color_var[0]) {
+                struct nir_variable *var = c->output_color_var[0];
+                struct qreg *color = &c->outputs[var->data.driver_location * 4];
+
+                vir_SETMSF_dest(c, vir_reg(QFILE_NULL, 0),
+                                vir_AND(c,
+                                        vir_MSF(c),
+                                        vir_FTOC(c, color[3])));
+        }
+
         if (c->output_position_index != -1) {
                 struct qinst *inst = vir_MOV_dest(c,
                                                   vir_reg(QFILE_TLBU, 0),
@@ -930,7 +940,9 @@ emit_frag_end(struct v3d_compile *c)
                                        TLB_TYPE_DEPTH |
                                        TLB_DEPTH_TYPE_PER_PIXEL |
                                        0xffffff00);
-        } else if (c->s->info.fs.uses_discard || !has_any_tlb_color_write) {
+        } else if (c->s->info.fs.uses_discard ||
+                   c->fs_key->sample_alpha_to_coverage ||
+                   !has_any_tlb_color_write) {
                 /* Emit passthrough Z if it needed to be delayed until shader
                  * end due to potential discards.
                  *
index 28e25cb23e226acf3ff485ad5a11ecf590d316a9..2754924e6c163c82ebfd95b6df78cbbaef60dba9 100644 (file)
@@ -840,7 +840,8 @@ uint64_t *v3d_compile_fs(const struct v3d_compiler *compiler,
         v3d_set_fs_prog_data_inputs(c, prog_data);
         prog_data->writes_z = (c->s->info.outputs_written &
                                (1 << FRAG_RESULT_DEPTH));
-        prog_data->discard = c->s->info.fs.uses_discard;
+        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;
 
         return v3d_return_qpu_insts(c, final_assembly_size);