[Mesa-dev] [PATCH v3 32/43] i965/fs: Include support for SEND data_format bit for Render Targets

Jose Maria Casanova Crespo jmcasanova at igalia.com
Thu Oct 12 18:38:21 UTC 2017


>From intel Skylake PRM, vol 07, section "EU Overview", subsection
"Send Message" (page 905):

   "Bit 30: Data format. This field specifies the width of data read
            from sampler or written to render target. Format = U1 0
            Single Precision (32b), 1 Half Precision (16b)"

Also present on vol 02d, "Message Descriptor - Render Target Write"
(page 326).

It is worth to note that this bit is also present on
Cherryview/Braswell but not on Broadwell, both Gen8, so we can't check
for the presence of that bit based just on the gen (example: on
brw_inst.h).

Signed-off-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com>
Signed-off-by: Eduardo Lima <elima at igalia.com>
Signed-off-by: Alejandro PiƱeiro <apinheiro at igalia.com>
---
 src/intel/compiler/brw_eu.h                   |  6 ++++--
 src/intel/compiler/brw_eu_emit.c              | 25 ++++++++++++++++++++-----
 src/intel/compiler/brw_fs.cpp                 |  1 +
 src/intel/compiler/brw_fs_generator.cpp       |  3 ++-
 src/intel/compiler/brw_fs_surface_builder.cpp |  3 ++-
 src/intel/compiler/brw_inst.h                 |  1 +
 src/intel/compiler/brw_shader.h               |  7 +++++++
 src/intel/compiler/brw_vec4_generator.cpp     |  3 ++-
 8 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
index ca1ff21a83..6d5f131974 100644
--- a/src/intel/compiler/brw_eu.h
+++ b/src/intel/compiler/brw_eu.h
@@ -241,7 +241,8 @@ void brw_set_dp_write_message(struct brw_codegen *p,
 			      unsigned last_render_target,
 			      unsigned response_length,
 			      unsigned end_of_thread,
-			      unsigned send_commit_msg);
+			      unsigned send_commit_msg,
+			      unsigned data_format);
 
 void brw_urb_WRITE(struct brw_codegen *p,
 		   struct brw_reg dest,
@@ -293,7 +294,8 @@ void brw_fb_WRITE(struct brw_codegen *p,
 		   unsigned response_length,
 		   bool eot,
 		   bool last_render_target,
-		   bool header_present);
+		   bool header_present,
+		   unsigned data_format);
 
 brw_inst *gen9_fb_READ(struct brw_codegen *p,
                        struct brw_reg dst,
diff --git a/src/intel/compiler/brw_eu_emit.c b/src/intel/compiler/brw_eu_emit.c
index 8c83d8b500..61b36c3daf 100644
--- a/src/intel/compiler/brw_eu_emit.c
+++ b/src/intel/compiler/brw_eu_emit.c
@@ -516,7 +516,8 @@ brw_set_dp_write_message(struct brw_codegen *p,
 			 unsigned last_render_target,
 			 unsigned response_length,
 			 unsigned end_of_thread,
-			 unsigned send_commit_msg)
+			 unsigned send_commit_msg,
+			 unsigned data_format)
 {
    const struct gen_device_info *devinfo = p->devinfo;
    const unsigned sfid = (devinfo->gen >= 6 ? target_cache :
@@ -528,6 +529,16 @@ brw_set_dp_write_message(struct brw_codegen *p,
    brw_inst_set_binding_table_index(devinfo, insn, binding_table_index);
    brw_inst_set_dp_write_msg_type(devinfo, insn, msg_type);
    brw_inst_set_dp_write_msg_control(devinfo, insn, msg_control);
+   if (data_format) {
+      /* data_format is supported since CherryView. So we can't just set the
+       * any data_format value, because it would trigger an assertion on
+       * brw_inst_set_data_format for previous hw if they try to set it to
+       * zero. And we don't add an generation assert because as mentioned,
+       * brw_inst_set_data_format already does that.
+       */
+      brw_inst_set_data_format(devinfo, insn, data_format);
+   }
+
    brw_inst_set_rt_last(devinfo, insn, last_render_target);
    if (devinfo->gen < 7) {
       brw_inst_set_dp_write_commit(devinfo, insn, send_commit_msg);
@@ -1958,7 +1969,8 @@ void brw_oword_block_write_scratch(struct brw_codegen *p,
 			       0, /* not a render target */
 			       send_commit_msg, /* response_length */
 			       0, /* eot */
-			       send_commit_msg);
+			       send_commit_msg,
+			       0 /* data_format */);
    }
 }
 
@@ -2150,7 +2162,8 @@ void brw_fb_WRITE(struct brw_codegen *p,
                   unsigned response_length,
                   bool eot,
                   bool last_render_target,
-                  bool header_present)
+                  bool header_present,
+                  unsigned data_format)
 {
    const struct gen_device_info *devinfo = p->devinfo;
    const unsigned target_cache =
@@ -2198,7 +2211,8 @@ void brw_fb_WRITE(struct brw_codegen *p,
 			    last_render_target,
 			    response_length,
 			    eot,
-			    0 /* send_commit_msg */);
+			    0, /* send_commit_msg */
+			    data_format);
 }
 
 brw_inst *
@@ -2751,7 +2765,8 @@ brw_svb_write(struct brw_codegen *p,
                             0, /* last_render_target: ignored */
                             send_commit_msg, /* response_length */
                             0, /* end_of_thread */
-                            send_commit_msg); /* send_commit_msg */
+                            send_commit_msg, /* send_commit_msg */
+                            0 /* data_format */);
 }
 
 static unsigned
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index bd0d32b741..901e855c0b 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -60,6 +60,7 @@ fs_inst::init(enum opcode opcode, uint8_t exec_size, const fs_reg &dst,
    this->sources = sources;
    this->exec_size = exec_size;
    this->base_mrf = -1;
+   this->data_format = 0;
 
    assert(dst.file != IMM && dst.file != UNIFORM);
 
diff --git a/src/intel/compiler/brw_fs_generator.cpp b/src/intel/compiler/brw_fs_generator.cpp
index c644524501..c766e72ecf 100644
--- a/src/intel/compiler/brw_fs_generator.cpp
+++ b/src/intel/compiler/brw_fs_generator.cpp
@@ -298,7 +298,8 @@ fs_generator::fire_fb_write(fs_inst *inst,
                 0,
                 inst->eot,
                 last_render_target,
-                inst->header_size != 0);
+                inst->header_size != 0,
+                inst->data_format);
 
    brw_mark_surface_used(&prog_data->base, surf_index);
 }
diff --git a/src/intel/compiler/brw_fs_surface_builder.cpp b/src/intel/compiler/brw_fs_surface_builder.cpp
index 2b5c21fe46..b38fce92d4 100644
--- a/src/intel/compiler/brw_fs_surface_builder.cpp
+++ b/src/intel/compiler/brw_fs_surface_builder.cpp
@@ -38,7 +38,7 @@ namespace brw {
          emit_send(const fs_builder &bld, enum opcode opcode,
                    const fs_reg &addr, const fs_reg &src, const fs_reg &surface,
                    unsigned dims, unsigned arg, unsigned rsize,
-                   brw_predicate pred = BRW_PREDICATE_NONE)
+                   brw_predicate pred = BRW_PREDICATE_NONE, unsigned data_format = 0)
          {
             /* Reduce the dynamically uniform surface index to a single
              * scalar.
@@ -50,6 +50,7 @@ namespace brw {
             const fs_reg dst = bld.vgrf(BRW_REGISTER_TYPE_UD, rsize);
             fs_inst *inst = bld.emit(opcode, dst, srcs, ARRAY_SIZE(srcs));
 
+            inst->data_format = data_format;
             inst->size_written = rsize * dst.component_size(inst->exec_size);
             inst->predicate = pred;
             return dst;
diff --git a/src/intel/compiler/brw_inst.h b/src/intel/compiler/brw_inst.h
index e9dad38f69..d821539924 100644
--- a/src/intel/compiler/brw_inst.h
+++ b/src/intel/compiler/brw_inst.h
@@ -334,6 +334,7 @@ FC(gen4_pop_count,  115, 112, devinfo->gen < 6)
  *  @{
  */
 F(eot,                 127, 127)
+FC(data_format,        126,  126, devinfo->gen >= 9 || devinfo->is_cherryview)
 FF(mlen,
    /* 4:   */ 119, 116,
    /* 4.5: */ 119, 116,
diff --git a/src/intel/compiler/brw_shader.h b/src/intel/compiler/brw_shader.h
index 30e7bf75c5..b530eef3fc 100644
--- a/src/intel/compiler/brw_shader.h
+++ b/src/intel/compiler/brw_shader.h
@@ -153,6 +153,13 @@ struct backend_instruction {
 
    uint32_t offset; /**< spill/unspill offset or texture offset bitfield */
    uint8_t mlen; /**< SEND message length */
+
+   /* Half Precision Data Format for 16-bit payload SEND messages
+    *  0 = 32-bit
+    *  1 = 16-bit
+    */
+   unsigned data_format:1;
+
    int8_t base_mrf; /**< First MRF in the SEND message, if mlen is nonzero. */
    uint8_t target; /**< MRT target. */
    unsigned size_written; /**< Data written to the destination register in bytes. */
diff --git a/src/intel/compiler/brw_vec4_generator.cpp b/src/intel/compiler/brw_vec4_generator.cpp
index 6a3a0a080c..d689635fc0 100644
--- a/src/intel/compiler/brw_vec4_generator.cpp
+++ b/src/intel/compiler/brw_vec4_generator.cpp
@@ -1254,7 +1254,8 @@ generate_scratch_write(struct brw_codegen *p,
 			    false, /* not a render target write */
 			    write_commit, /* rlen */
 			    false, /* eot */
-			    write_commit);
+			    write_commit,
+			    0 /* data_format */ );
 }
 
 static void
-- 
2.13.6



More information about the mesa-dev mailing list