[Mesa-dev] [PATCH 37/47] i965/fs: Mark 16-bit outputs on FS store_output

Alejandro PiƱeiro apinheiro at igalia.com
Thu Aug 24 13:54:52 UTC 2017


From: Jose Maria Casanova Crespo <jmcasanova at igalia.com>

On SKL the render target write operations allow 16-bit format
output. This marks output registers as 16-bit using
BRW_REGISTER_TYPE_HF on the proper outputs target.

This allows to recognise when the data_format of 16-bit should be
enabled on render_target_write messages.

Signed-off-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com>
Signed-off-by: Eduardo Lima <elima at igalia.com>
---
 src/intel/compiler/brw_fs_nir.cpp | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp
index 71e79cbc852..732aba2a989 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -3139,13 +3139,16 @@ emit_coherent_fb_read(const fs_builder &bld, const fs_reg &dst, unsigned target)
 }
 
 static fs_reg
-alloc_temporary(const fs_builder &bld, unsigned size, fs_reg *regs, unsigned n)
+alloc_temporary(const fs_builder &bld, unsigned size, fs_reg *regs, unsigned n,
+                bool is_16bit)
 {
    if (n && regs[0].file != BAD_FILE) {
       return regs[0];
 
    } else {
-      const fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_F, size);
+      const brw_reg_type type =
+         is_16bit ? BRW_REGISTER_TYPE_HF : BRW_REGISTER_TYPE_F;
+      const fs_reg tmp = bld.vgrf(type, size);
 
       for (unsigned i = 0; i < n; i++)
          regs[i] = tmp;
@@ -3155,7 +3158,7 @@ alloc_temporary(const fs_builder &bld, unsigned size, fs_reg *regs, unsigned n)
 }
 
 static fs_reg
-alloc_frag_output(fs_visitor *v, unsigned location)
+alloc_frag_output(fs_visitor *v, unsigned location, bool is_16bit)
 {
    assert(v->stage == MESA_SHADER_FRAGMENT);
    const brw_wm_prog_key *const key =
@@ -3164,26 +3167,26 @@ alloc_frag_output(fs_visitor *v, unsigned location)
    const unsigned i = GET_FIELD(location, BRW_NIR_FRAG_OUTPUT_INDEX);
 
    if (i > 0 || (key->force_dual_color_blend && l == FRAG_RESULT_DATA1))
-      return alloc_temporary(v->bld, 4, &v->dual_src_output, 1);
+      return alloc_temporary(v->bld, 4, &v->dual_src_output, 1, is_16bit);
 
    else if (l == FRAG_RESULT_COLOR)
       return alloc_temporary(v->bld, 4, v->outputs,
-                             MAX2(key->nr_color_regions, 1));
+                             MAX2(key->nr_color_regions, 1),
+                             is_16bit);
 
    else if (l == FRAG_RESULT_DEPTH)
-      return alloc_temporary(v->bld, 1, &v->frag_depth, 1);
+      return alloc_temporary(v->bld, 1, &v->frag_depth, 1, is_16bit);
 
    else if (l == FRAG_RESULT_STENCIL)
-      return alloc_temporary(v->bld, 1, &v->frag_stencil, 1);
+      return alloc_temporary(v->bld, 1, &v->frag_stencil, 1, is_16bit);
 
    else if (l == FRAG_RESULT_SAMPLE_MASK)
-      return alloc_temporary(v->bld, 1, &v->sample_mask, 1);
+      return alloc_temporary(v->bld, 1, &v->sample_mask, 1, is_16bit);
 
    else if (l >= FRAG_RESULT_DATA0 &&
             l < FRAG_RESULT_DATA0 + BRW_MAX_DRAW_BUFFERS)
       return alloc_temporary(v->bld, 4,
-                             &v->outputs[l - FRAG_RESULT_DATA0], 1);
-
+                             &v->outputs[l - FRAG_RESULT_DATA0], 1, is_16bit);
    else
       unreachable("Invalid location");
 }
@@ -3247,7 +3250,7 @@ fs_visitor::nir_emit_fs_intrinsic(const fs_builder &bld,
          src = retype(src, outputs[location].type);
       }
 
-      fs_reg new_dest = retype(alloc_frag_output(this, location),
+      fs_reg new_dest = retype(alloc_frag_output(this, location, false),
                                src.type);
 
 
-- 
2.11.0



More information about the mesa-dev mailing list