From 004fbd53759a8993198883a32d93c9e3f6a65bbd Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Sat, 16 Aug 2014 10:48:18 -0700 Subject: [PATCH] i965/fs: Make half() divide the register width by 2 and use it more Signed-off-by: Jason Ekstrand Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs.cpp | 14 ++++++++++---- src/mesa/drivers/dri/i965/brw_fs.h | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 80fa4f3dd9a..c710ad63a7a 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -1322,6 +1322,7 @@ fs_visitor::compute_sample_position(fs_reg dst, fs_reg int_sample_pos) fs_reg * fs_visitor::emit_samplepos_setup() { + fs_inst *inst; assert(brw->gen >= 6); this->current_annotation = "compute sample position"; @@ -1345,8 +1346,10 @@ fs_visitor::emit_samplepos_setup() stride(retype(brw_vec1_grf(payload.sample_pos_reg, 0), BRW_REGISTER_TYPE_B), 16, 8, 2); - fs_inst *inst = emit(MOV(int_sample_x, fs_reg(sample_pos_reg))); - if (dispatch_width == 16) { + if (dispatch_width == 8) { + emit(MOV(int_sample_x, fs_reg(sample_pos_reg))); + } else { + inst = emit(MOV(half(int_sample_x, 0), fs_reg(sample_pos_reg))); inst->force_uncompressed = true; inst = emit(MOV(half(int_sample_x, 1), fs_reg(suboffset(sample_pos_reg, 16)))); @@ -1355,8 +1358,11 @@ fs_visitor::emit_samplepos_setup() /* Compute gl_SamplePosition.x */ compute_sample_position(pos, int_sample_x); pos = offset(pos, 1); - inst = emit(MOV(int_sample_y, fs_reg(suboffset(sample_pos_reg, 1)))); - if (dispatch_width == 16) { + if (dispatch_width == 8) { + emit(MOV(int_sample_y, fs_reg(suboffset(sample_pos_reg, 1)))); + } else { + inst = emit(MOV(half(int_sample_y, 0), + fs_reg(suboffset(sample_pos_reg, 1)))); inst->force_uncompressed = true; inst = emit(MOV(half(int_sample_y, 1), fs_reg(suboffset(sample_pos_reg, 17)))); diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 30cce40dd2b..0d3931e479f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -145,10 +145,12 @@ byte_offset(fs_reg reg, unsigned delta) * Note: this also works if \c reg represents a SIMD16 pair of registers. */ static inline fs_reg -half(const fs_reg ®, unsigned idx) +half(fs_reg reg, unsigned idx) { assert(idx < 2); assert(idx == 0 || (reg.file != HW_REG && reg.file != IMM)); + assert(reg.width == 16); + reg.width = 8; return byte_offset(reg, 8 * idx * reg.stride * type_sz(reg.type)); } -- 2.30.2