[Mesa-dev,8/9] i965/fs: Hook up coherent framebuffer reads to the NIR front-end.

Submitted by Francisco Jerez on July 28, 2016, 9:50 p.m.

Details

Message ID 20160728215016.27670-9-currojerez@riseup.net
State New
Headers show
Series "i965: Implement coherent framebuffer fetch on Gen9+." ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Francisco Jerez July 28, 2016, 9:50 p.m.
---
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index e3215da..85e111d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -3210,6 +3210,22 @@  emit_non_coherent_fb_read(fs_visitor *v, const fs_reg &dst, unsigned target)
    return inst;
 }
 
+/**
+ * Actual coherent framebuffer read implemented using the native render target
+ * read message.  Requires SKL+.
+ */
+static fs_inst *
+emit_coherent_fb_read(const fs_builder &bld, const fs_reg &dst, unsigned target)
+{
+   assert(bld.shader->devinfo->gen >= 9);
+   fs_inst *inst = bld.emit(FS_OPCODE_FB_READ_LOGICAL, dst);
+   inst->target = target;
+   inst->regs_written = 4 * inst->dst.component_size(inst->exec_size) /
+                        REG_SIZE;
+
+   return inst;
+}
+
 static fs_reg
 alloc_temporary(const fs_builder &bld, unsigned size, fs_reg *regs, unsigned n)
 {
@@ -3321,8 +3337,10 @@  fs_visitor::nir_emit_fs_intrinsic(const fs_builder &bld,
       const unsigned target = l - FRAG_RESULT_DATA0 + const_offset->u32[0];
       const fs_reg tmp = bld.vgrf(dest.type, 4);
 
-      assert(!reinterpret_cast<const brw_wm_prog_key *>(key)->coherent_fb_fetch);
-      emit_non_coherent_fb_read(this, tmp, target);
+      if (reinterpret_cast<const brw_wm_prog_key *>(key)->coherent_fb_fetch)
+         emit_coherent_fb_read(bld, tmp, target);
+      else
+         emit_non_coherent_fb_read(this, tmp, target);
 
       for (unsigned j = 0; j < instr->num_components; j++)
          bld.MOV(offset(dest, bld, j),