From 6e91f2df958c835a1973e32d71578fa295ef00a8 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 18 Nov 2013 21:13:13 +1300 Subject: [PATCH] i965/fs: add generator support for pixel interpolator query V5: - Split into separate opcodes - Pass message data in src1 immediate - Put noperspective bit in fs_inst rather than adding any junk to backend_instruction Signed-off-by: Chris Forbes Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_defines.h | 4 ++ src/mesa/drivers/dri/i965/brw_fs.cpp | 8 ++++ src/mesa/drivers/dri/i965/brw_fs.h | 7 ++++ .../drivers/dri/i965/brw_fs_generator.cpp | 40 +++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index e528232815b..8b73c5cf3d7 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -853,6 +853,10 @@ enum opcode { FS_OPCODE_UNPACK_HALF_2x16_SPLIT_X, FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y, FS_OPCODE_PLACEHOLDER_HALT, + FS_OPCODE_INTERPOLATE_AT_CENTROID, + FS_OPCODE_INTERPOLATE_AT_SAMPLE, + FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET, + FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET, VS_OPCODE_URB_WRITE, VS_OPCODE_PULL_CONSTANT_LOAD, diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index a3ad3756fd5..951d69f5130 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -370,6 +370,10 @@ fs_inst::is_send_from_grf() const { return (opcode == FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN7 || opcode == SHADER_OPCODE_SHADER_TIME_ADD || + opcode == FS_OPCODE_INTERPOLATE_AT_CENTROID || + opcode == FS_OPCODE_INTERPOLATE_AT_SAMPLE || + opcode == FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET || + opcode == FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET || (opcode == FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD && src[1].file == GRF) || (is_tex() && src[0].file == GRF)); @@ -837,6 +841,10 @@ fs_visitor::implied_mrf_writes(fs_inst *inst) return 2; case SHADER_OPCODE_UNTYPED_ATOMIC: case SHADER_OPCODE_UNTYPED_SURFACE_READ: + case FS_OPCODE_INTERPOLATE_AT_CENTROID: + case FS_OPCODE_INTERPOLATE_AT_SAMPLE: + case FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET: + case FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET: return 0; default: unreachable("not reached"); diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 537f10eabb3..1d3f9d0cdf1 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -196,6 +196,7 @@ public: bool shadow_compare:1; bool force_uncompressed:1; bool force_sechalf:1; + bool pi_noperspective:1; /**< Pixel interpolator noperspective flag */ }; /** @@ -623,6 +624,12 @@ private: struct brw_reg offset); void generate_mov_dispatch_to_flags(fs_inst *inst); + void generate_pixel_interpolator_query(fs_inst *inst, + struct brw_reg dst, + struct brw_reg src, + struct brw_reg msg_data, + unsigned msg_type); + void generate_set_omask(fs_inst *inst, struct brw_reg dst, struct brw_reg sample_mask); diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index eae55f00158..8e4a31d951f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -995,6 +995,26 @@ fs_generator::generate_mov_dispatch_to_flags(fs_inst *inst) brw_pop_insn_state(p); } +void +fs_generator::generate_pixel_interpolator_query(fs_inst *inst, + struct brw_reg dst, + struct brw_reg src, + struct brw_reg msg_data, + unsigned msg_type) +{ + assert(msg_data.file == BRW_IMMEDIATE_VALUE && + msg_data.type == BRW_REGISTER_TYPE_UD); + + brw_pixel_interpolator_query(p, + retype(dst, BRW_REGISTER_TYPE_UW), + src, + inst->pi_noperspective, + msg_type, + msg_data.dw1.ud, + inst->mlen, + inst->regs_written); +} + static uint32_t brw_file_from_reg(fs_reg *reg) { @@ -1730,6 +1750,26 @@ fs_generator::generate_code(exec_list *instructions) } break; + case FS_OPCODE_INTERPOLATE_AT_CENTROID: + generate_pixel_interpolator_query(inst, dst, src[0], src[1], + GEN7_PIXEL_INTERPOLATOR_LOC_CENTROID); + break; + + case FS_OPCODE_INTERPOLATE_AT_SAMPLE: + generate_pixel_interpolator_query(inst, dst, src[0], src[1], + GEN7_PIXEL_INTERPOLATOR_LOC_SAMPLE); + break; + + case FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET: + generate_pixel_interpolator_query(inst, dst, src[0], src[1], + GEN7_PIXEL_INTERPOLATOR_LOC_SHARED_OFFSET); + break; + + case FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET: + generate_pixel_interpolator_query(inst, dst, src[0], src[1], + GEN7_PIXEL_INTERPOLATOR_LOC_PER_SLOT_OFFSET); + break; + default: if (inst->opcode < (int) ARRAY_SIZE(opcode_descs)) { _mesa_problem(ctx, "Unsupported opcode `%s' in FS", -- 2.30.2