i965/fs: Hook up coherent framebuffer reads to the NIR front-end.
authorFrancisco Jerez <currojerez@riseup.net>
Fri, 19 Aug 2016 05:12:37 +0000 (22:12 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Fri, 26 Aug 2016 01:36:09 +0000 (18:36 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs_nir.cpp

index 7bb2d5259dc4bbd8aa8ba3cc624ddda36f3401b0..d604a5d2cb646e1f5524d48c1ac25dc344591b7e 100644 (file)
@@ -3213,6 +3213,22 @@ fs_visitor::emit_non_coherent_fb_read(const fs_builder &bld, const fs_reg &dst,
    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)
 {
@@ -3324,8 +3340,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(bld, 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(bld, tmp, target);
 
       for (unsigned j = 0; j < instr->num_components; j++) {
          bld.MOV(offset(dest, bld, j),