i965/fs: Define framebuffer read virtual opcode.
authorFrancisco Jerez <currojerez@riseup.net>
Thu, 21 Jul 2016 23:52:33 +0000 (16:52 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Fri, 26 Aug 2016 01:36:08 +0000 (18:36 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_generator.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp

index 222ff8fdc3bb81b531ecc0350478c5c3485b08c9..f043661eda20189cc072e2cfe62f095c481f0037 100644 (file)
@@ -951,6 +951,9 @@ enum opcode {
    FS_OPCODE_FB_WRITE_LOGICAL,
 
    FS_OPCODE_REP_FB_WRITE,
+
+   FS_OPCODE_FB_READ,
+
    SHADER_OPCODE_RCP,
    SHADER_OPCODE_RSQ,
    SHADER_OPCODE_SQRT,
index 0cbb7de8e12e11cb5b66555c7bcba9d5296583de..cfbd66d297bbac554230ee1446915f5694a42b1b 100644 (file)
@@ -272,6 +272,7 @@ fs_inst::is_send_from_grf() const
    case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD:
       return src[1].file == VGRF;
    case FS_OPCODE_FB_WRITE:
+   case FS_OPCODE_FB_READ:
       return src[0].file == VGRF;
    default:
       if (is_tex())
@@ -824,6 +825,7 @@ fs_inst::regs_read(int arg) const
 {
    switch (opcode) {
    case FS_OPCODE_FB_WRITE:
+   case FS_OPCODE_FB_READ:
    case SHADER_OPCODE_URB_WRITE_SIMD8:
    case SHADER_OPCODE_URB_WRITE_SIMD8_PER_SLOT:
    case SHADER_OPCODE_URB_WRITE_SIMD8_MASKED:
index 7819f1ca3c0fac192094707a4ea1380a81f3ab8d..6ac3d27511b4cc617b8e16fea534a38a4f635940 100644 (file)
@@ -400,6 +400,8 @@ private:
                       struct brw_reg implied_header,
                       GLuint nr);
    void generate_fb_write(fs_inst *inst, struct brw_reg payload);
+   void generate_fb_read(fs_inst *inst, struct brw_reg dst,
+                         struct brw_reg payload);
    void generate_urb_read(fs_inst *inst, struct brw_reg dst, struct brw_reg payload);
    void generate_urb_write(fs_inst *inst, struct brw_reg payload);
    void generate_cs_terminate(fs_inst *inst, struct brw_reg payload);
index 22190f804f13a6b66e348a64cc6f57334e5ac208..c96e3e9acfedee34a505ef9bfe22cf47d17ce38b 100644 (file)
@@ -353,6 +353,22 @@ fs_generator::generate_fb_write(fs_inst *inst, struct brw_reg payload)
    }
 }
 
+void
+fs_generator::generate_fb_read(fs_inst *inst, struct brw_reg dst,
+                               struct brw_reg payload)
+{
+   brw_wm_prog_data *prog_data =
+      reinterpret_cast<brw_wm_prog_data *>(this->prog_data);
+   const unsigned surf_index =
+      prog_data->binding_table.render_target_start + inst->target;
+
+   gen9_fb_READ(p, dst, payload, surf_index,
+                inst->header_size, inst->regs_written,
+                prog_data->persample_dispatch);
+
+   brw_mark_surface_used(&prog_data->base, surf_index);
+}
+
 void
 fs_generator::generate_mov_indirect(fs_inst *inst,
                                     struct brw_reg dst,
@@ -1965,6 +1981,10 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width)
         generate_fb_write(inst, src[0]);
         break;
 
+      case FS_OPCODE_FB_READ:
+         generate_fb_read(inst, dst, src[0]);
+         break;
+
       case FS_OPCODE_MOV_DISPATCH_TO_FLAGS:
          generate_mov_dispatch_to_flags(inst);
          break;
index aa2c9d432fed24a84a6cb8db3e14b3d2270e816f..efe3d0ff0c378c193d0964cbc8122c64de4f4044 100644 (file)
@@ -165,6 +165,8 @@ brw_instruction_name(const struct brw_device_info *devinfo, enum opcode op)
       return "fb_write_logical";
    case FS_OPCODE_REP_FB_WRITE:
       return "rep_fb_write";
+   case FS_OPCODE_FB_READ:
+      return "fb_read";
 
    case SHADER_OPCODE_RCP:
       return "rcp";