i965/fs: Make half() divide the register width by 2 and use it more

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Jason Ekstrand 2014-08-16 10:48:18 -07:00
parent 24d023b9fe
commit 004fbd5375
2 changed files with 13 additions and 5 deletions

View File

@ -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))));

View File

@ -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 &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));
}