[Mesa-dev] [PATCH 3/7] i965: Let the caller of brw_set_dp_write/read_message control the target cache.

Francisco Jerez currojerez at riseup.net
Sat Jan 17 15:04:05 PST 2015


brw_set_dp_read_message already had a target_cache argument, but its
interpretation was rather contrived: On Gen7+ it was ignored and the data
cache was always used, on Gen6 the render cache was used if the caller asked
for it, otherwise it was ignored using the sampler cache instead.

brw_set_dp_write_message used the data cache on Gen7+ except for
RENDER_TARGET_WRITE messages, in which case it would use the render cache.  On
Gen6 the render cache was always used.

Makes no functional changes.  Some of the nested ternary operators introduced
here will go away in a future commit.
---
 src/mesa/drivers/dri/i965/brw_eu.h               |  1 +
 src/mesa/drivers/dri/i965/brw_eu_emit.c          | 58 ++++++++++++------------
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 16 ++++++-
 3 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index 22d5a0a..60f6f69 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -225,6 +225,7 @@ void brw_set_dp_write_message(struct brw_compile *p,
 			      unsigned binding_table_index,
 			      unsigned msg_control,
 			      unsigned msg_type,
+                              unsigned target_cache,
 			      unsigned msg_length,
 			      bool header_present,
 			      unsigned last_render_target,
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 8f15db9..c2e490d 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -675,6 +675,7 @@ brw_set_dp_write_message(struct brw_compile *p,
 			 unsigned binding_table_index,
 			 unsigned msg_control,
 			 unsigned msg_type,
+                         unsigned target_cache,
 			 unsigned msg_length,
 			 bool header_present,
 			 unsigned last_render_target,
@@ -683,20 +684,8 @@ brw_set_dp_write_message(struct brw_compile *p,
 			 unsigned send_commit_msg)
 {
    struct brw_context *brw = p->brw;
-   unsigned sfid;
-
-   if (brw->gen >= 7) {
-      /* Use the Render Cache for RT writes; otherwise use the Data Cache */
-      if (msg_type == GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE)
-	 sfid = GEN6_SFID_DATAPORT_RENDER_CACHE;
-      else
-	 sfid = GEN7_SFID_DATAPORT_DATA_CACHE;
-   } else if (brw->gen == 6) {
-      /* Use the render cache for all write messages. */
-      sfid = GEN6_SFID_DATAPORT_RENDER_CACHE;
-   } else {
-      sfid = BRW_SFID_DATAPORT_WRITE;
-   }
+   const unsigned sfid = (brw->gen >= 6 ? target_cache :
+                          BRW_SFID_DATAPORT_WRITE);
 
    brw_set_message_descriptor(p, insn, sfid, msg_length, response_length,
 			      header_present, end_of_thread);
@@ -722,18 +711,8 @@ brw_set_dp_read_message(struct brw_compile *p,
 			unsigned response_length)
 {
    struct brw_context *brw = p->brw;
-   unsigned sfid;
-
-   if (brw->gen >= 7) {
-      sfid = GEN7_SFID_DATAPORT_DATA_CACHE;
-   } else if (brw->gen == 6) {
-      if (target_cache == BRW_DATAPORT_READ_TARGET_RENDER_CACHE)
-	 sfid = GEN6_SFID_DATAPORT_RENDER_CACHE;
-      else
-	 sfid = GEN6_SFID_DATAPORT_SAMPLER_CACHE;
-   } else {
-      sfid = BRW_SFID_DATAPORT_READ;
-   }
+   const unsigned sfid = (brw->gen >= 6 ? target_cache :
+                          BRW_SFID_DATAPORT_READ);
 
    brw_set_message_descriptor(p, insn, sfid, msg_length, response_length,
 			      header_present, false);
@@ -1989,6 +1968,10 @@ void brw_oword_block_write_scratch(struct brw_compile *p,
 				   unsigned offset)
 {
    struct brw_context *brw = p->brw;
+   const unsigned target_cache =
+      (brw->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE :
+       brw->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE :
+       BRW_DATAPORT_READ_TARGET_RENDER_CACHE);
    uint32_t msg_control, msg_type;
    int mlen;
 
@@ -2077,6 +2060,7 @@ void brw_oword_block_write_scratch(struct brw_compile *p,
 			       255, /* binding table index (255=stateless) */
 			       msg_control,
 			       msg_type,
+                               target_cache,
 			       mlen,
 			       true, /* header_present */
 			       0, /* not a render target */
@@ -2102,6 +2086,10 @@ brw_oword_block_read_scratch(struct brw_compile *p,
 			     unsigned offset)
 {
    struct brw_context *brw = p->brw;
+   const unsigned target_cache =
+      (brw->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE :
+       brw->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE :
+       BRW_DATAPORT_READ_TARGET_RENDER_CACHE);
    uint32_t msg_control;
    int rlen;
 
@@ -2162,7 +2150,7 @@ brw_oword_block_read_scratch(struct brw_compile *p,
 			      255, /* binding table index (255=stateless) */
 			      msg_control,
 			      BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ, /* msg_type */
-			      BRW_DATAPORT_READ_TARGET_RENDER_CACHE,
+			      target_cache,
 			      1, /* msg_length */
                               true, /* header_present */
 			      rlen);
@@ -2217,6 +2205,10 @@ void brw_oword_block_read(struct brw_compile *p,
 			  uint32_t bind_table_index)
 {
    struct brw_context *brw = p->brw;
+   const unsigned target_cache =
+      (brw->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE :
+       brw->gen >= 6 ? GEN6_SFID_DATAPORT_SAMPLER_CACHE :
+       BRW_DATAPORT_READ_TARGET_DATA_CACHE);
 
    /* On newer hardware, offset is in units of owords. */
    if (brw->gen >= 6)
@@ -2256,7 +2248,7 @@ void brw_oword_block_read(struct brw_compile *p,
 			   bind_table_index,
 			   BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW,
 			   BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ,
-			   BRW_DATAPORT_READ_TARGET_DATA_CACHE,
+			   target_cache,
 			   1, /* msg_length */
                            true, /* header_present */
 			   1); /* response_length (1 reg, 2 owords!) */
@@ -2277,6 +2269,9 @@ void brw_fb_WRITE(struct brw_compile *p,
                   bool header_present)
 {
    struct brw_context *brw = p->brw;
+   const unsigned target_cache =
+      (brw->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE :
+       BRW_DATAPORT_READ_TARGET_RENDER_CACHE);
    brw_inst *insn;
    unsigned msg_type;
    struct brw_reg dest, src0;
@@ -2313,6 +2308,7 @@ void brw_fb_WRITE(struct brw_compile *p,
 			    binding_table_index,
 			    msg_control,
 			    msg_type,
+                            target_cache,
 			    msg_length,
 			    header_present,
 			    eot, /* last render target write */
@@ -2663,6 +2659,11 @@ brw_svb_write(struct brw_compile *p,
               unsigned binding_table_index,
               bool   send_commit_msg)
 {
+   const struct brw_context *brw = p->brw;
+   const unsigned target_cache =
+      (brw->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE :
+       brw->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE :
+       BRW_DATAPORT_READ_TARGET_RENDER_CACHE);
    brw_inst *insn;
 
    gen6_resolve_implied_move(p, &src0, msg_reg_nr);
@@ -2675,6 +2676,7 @@ brw_svb_write(struct brw_compile *p,
                             binding_table_index,
                             0, /* msg_control: ignored */
                             GEN6_DATAPORT_WRITE_MESSAGE_STREAMED_VB_WRITE,
+                            target_cache,
                             1, /* msg_length */
                             true, /* header_present */
                             0, /* last_render_target: ignored */
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index fd37a05..dfc50eb 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -889,6 +889,10 @@ vec4_generator::generate_scratch_read(vec4_instruction *inst,
                                       struct brw_reg dst,
                                       struct brw_reg index)
 {
+   const unsigned target_cache =
+      (brw->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE :
+       brw->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE :
+       BRW_DATAPORT_READ_TARGET_RENDER_CACHE);
    struct brw_reg header = brw_vec8_grf(0, 0);
 
    gen6_resolve_implied_move(p, &header, inst->base_mrf);
@@ -917,7 +921,7 @@ vec4_generator::generate_scratch_read(vec4_instruction *inst,
 			   255, /* binding table index: stateless access */
 			   BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD,
 			   msg_type,
-			   BRW_DATAPORT_READ_TARGET_RENDER_CACHE,
+                           target_cache,
 			   2, /* mlen */
                            true, /* header_present */
 			   1 /* rlen */);
@@ -929,6 +933,10 @@ vec4_generator::generate_scratch_write(vec4_instruction *inst,
                                        struct brw_reg src,
                                        struct brw_reg index)
 {
+   const unsigned target_cache =
+      (brw->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE :
+       brw->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE :
+       BRW_DATAPORT_READ_TARGET_RENDER_CACHE);
    struct brw_reg header = brw_vec8_grf(0, 0);
    bool write_commit;
 
@@ -988,6 +996,7 @@ vec4_generator::generate_scratch_write(vec4_instruction *inst,
 			    255, /* binding table index: stateless access */
 			    BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD,
 			    msg_type,
+                            target_cache,
 			    3, /* mlen */
 			    true, /* header present */
 			    false, /* not a render target write */
@@ -1004,6 +1013,9 @@ vec4_generator::generate_pull_constant_load(vec4_instruction *inst,
 {
    assert(index.file == BRW_IMMEDIATE_VALUE &&
 	  index.type == BRW_REGISTER_TYPE_UD);
+   const unsigned target_cache =
+      (brw->gen >= 6 ? GEN6_SFID_DATAPORT_SAMPLER_CACHE :
+       BRW_DATAPORT_READ_TARGET_DATA_CACHE);
    uint32_t surf_index = index.dw1.ud;
 
    struct brw_reg header = brw_vec8_grf(0, 0);
@@ -1034,7 +1046,7 @@ vec4_generator::generate_pull_constant_load(vec4_instruction *inst,
 			   surf_index,
 			   BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD,
 			   msg_type,
-			   BRW_DATAPORT_READ_TARGET_DATA_CACHE,
+                           target_cache,
 			   2, /* mlen */
                            true, /* header_present */
 			   1 /* rlen */);
-- 
2.1.3



More information about the mesa-dev mailing list