[Mesa-dev] [RFC 22/27] i965/fs: Add generator support for fetching texture dimensions

Topi Pohjolainen topi.pohjolainen at intel.com
Sat Feb 22 01:05:48 PST 2014


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_defines.h        |  2 ++
 src/mesa/drivers/dri/i965/brw_fs.cpp           |  1 +
 src/mesa/drivers/dri/i965/brw_fs.h             |  3 +++
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 33 ++++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_shader.cpp       |  2 ++
 5 files changed, 41 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index e087fd0..4ddb23d 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -793,6 +793,8 @@ enum opcode {
    SHADER_OPCODE_TG4,
    SHADER_OPCODE_TG4_OFFSET,
 
+   SHADER_OPCODE_TEX_RESINFO,
+
    SHADER_OPCODE_SHADER_TIME_ADD,
 
    SHADER_OPCODE_UNTYPED_ATOMIC,
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index d600327..0f0f479 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -633,6 +633,7 @@ fs_visitor::implied_mrf_writes(fs_inst *inst)
    case SHADER_OPCODE_TXF_MCS:
    case SHADER_OPCODE_TG4:
    case SHADER_OPCODE_TG4_OFFSET:
+   case SHADER_OPCODE_TEX_RESINFO:
    case SHADER_OPCODE_TXL:
    case SHADER_OPCODE_TXS:
    case SHADER_OPCODE_LOD:
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index e02c025..b4b146a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -581,6 +581,9 @@ private:
    void generate_linterp(fs_inst *inst, struct brw_reg dst,
 			 struct brw_reg *src);
    void generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src);
+   void generate_tex_resinfo(fs_inst *inst,
+                             struct brw_reg dst,
+                             struct brw_reg src);
    void generate_math1_gen7(fs_inst *inst,
 			    struct brw_reg dst,
 			    struct brw_reg src);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 3f2060d..214c42b 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -613,6 +613,36 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src
    brw_mark_surface_used(&c->prog_data.base, surface_index);
 }
 
+void
+fs_generator::generate_tex_resinfo(fs_inst *inst,
+                                   struct brw_reg dst,
+                                   struct brw_reg src)
+{
+   const uint32_t surface_index =
+      c->prog_data.base.binding_table.texture_start + inst->sampler;
+   const uint32_t simd_mode = (dispatch_width == 16 &&
+                               !inst->force_uncompressed &&
+                               !inst->force_sechalf) ?
+                                  BRW_SAMPLER_SIMD_MODE_SIMD16 :
+                                  BRW_SAMPLER_SIMD_MODE_SIMD8;
+
+   assert(brw->gen >= 5);
+
+   brw_SAMPLE(p,
+              retype(dst, BRW_REGISTER_TYPE_UW),
+              brw->gen >= 7 ? -1 : 2,
+              src,
+              surface_index,
+              inst->sampler % 16,
+              GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO,
+              simd_mode == BRW_SAMPLER_SIMD_MODE_SIMD8 ? 4 : 8,
+              simd_mode == BRW_SAMPLER_SIMD_MODE_SIMD8 ? 1 : 2,
+              false,
+              simd_mode,
+              BRW_SAMPLER_RETURN_FORMAT_UINT32);
+
+   brw_mark_surface_used(&c->prog_data.base, surface_index);
+}
 
 /* For OPCODE_DDX and OPCODE_DDY, per channel of output we've got input
  * looking like:
@@ -1694,6 +1724,9 @@ fs_generator::generate_code(exec_list *instructions, FILE *dump_file)
       case SHADER_OPCODE_TG4_OFFSET:
 	 generate_tex(inst, dst, src[0]);
 	 break;
+      case SHADER_OPCODE_TEX_RESINFO:
+	 generate_tex_resinfo(inst, dst, src[0]);
+	 break;
       case FS_OPCODE_DDX:
 	 generate_ddx(inst, dst, src[0]);
 	 break;
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 38b268b..84a008d 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -454,6 +454,8 @@ brw_instruction_name(enum opcode op)
       return "tg4";
    case SHADER_OPCODE_TG4_OFFSET:
       return "tg4_offset";
+   case SHADER_OPCODE_TEX_RESINFO:
+      return "tex_resinfo";
 
    case SHADER_OPCODE_GEN4_SCRATCH_READ:
       return "gen4_scratch_read";
-- 
1.8.3.1



More information about the mesa-dev mailing list