[Mesa-dev] [PATCH 3/3] i965: Do not prepare antialiasing data if it is not required

Iago Toral Quiroga itoral at igalia.com
Tue May 27 03:50:16 PDT 2014


In Gen < 6 AA data will or will not be sent as part of the framebuffer write
SEND message depending on a runtime condition, so don't bother moving AA
data to the corresponding MRF register until we know that we need to send it.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78679
---
 src/mesa/drivers/dri/i965/brw_fs.h           |  1 +
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 23 ++++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index ab8912f..351d0b6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -452,6 +452,7 @@ public:
 
    void emit_color_write(int target, int index, int first_color_mrf);
    void emit_alpha_test();
+   void emit_aa(int mrf_aa_reg);
    void do_emit_fb_write(int target, int base_mrf, int mlen, bool eot,
                          bool header_present);
    void emit_fb_write(int target, int base_mrf, int mlen, bool eot,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 4c3897b..de1726f 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2731,6 +2731,17 @@ fs_visitor::emit_alpha_test()
 }
 
 void
+fs_visitor::emit_aa(int mrf_aa_reg)
+{
+   if (payload.aa_dest_stencil_reg) {
+      push_force_uncompressed();
+      emit(MOV(fs_reg(MRF, mrf_aa_reg),
+               fs_reg(brw_vec8_grf(payload.aa_dest_stencil_reg, 0))));
+      pop_force_uncompressed();
+   }
+}
+
+void
 fs_visitor::do_emit_fb_write(int target, int base_mrf, int mlen, bool eot,
                              bool header_present)
 {
@@ -2751,6 +2762,7 @@ fs_visitor::emit_fb_write(int target, int base_mrf, int mlen, bool eot,
                           bool header_present)
 {
    if (!runtime_check_aads_emit) {
+      emit_aa(base_mrf + 2);
       do_emit_fb_write(target, base_mrf, mlen, eot, header_present);
    } else {
       /* This can only happen in Gen < 6
@@ -2766,12 +2778,13 @@ fs_visitor::emit_fb_write(int target, int base_mrf, int mlen, bool eot,
       emit(IF(BRW_PREDICATE_NORMAL));
       {
          /* Shift message header one register since we are not sending
-          * AA data stored in base_mrf+2
+          * AA data in base_mrf+2
           */
          do_emit_fb_write(target, base_mrf + 1, mlen - 1, eot, header_present);
       }
       emit(BRW_OPCODE_ELSE);
       {
+         emit_aa(base_mrf + 2);
          do_emit_fb_write(target, base_mrf, mlen, eot, header_present);
       }
       emit(BRW_OPCODE_ENDIF);
@@ -2819,11 +2832,11 @@ fs_visitor::emit_fb_writes()
       nr += 2;
    }
 
+   /* AA data. Depending on runtime conditions we might not need to send it
+    * but we reserve space for it for now.
+    */
    if (payload.aa_dest_stencil_reg) {
-      push_force_uncompressed();
-      emit(MOV(fs_reg(MRF, nr++),
-               fs_reg(brw_vec8_grf(payload.aa_dest_stencil_reg, 0))));
-      pop_force_uncompressed();
+      nr += 1;
    }
 
    prog_data->uses_omask =
-- 
1.9.1



More information about the mesa-dev mailing list