From 42b226ef824ed61ccf51fa9a1198cba305ad5472 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Wed, 19 Feb 2014 15:21:07 +0100 Subject: i965: Make sure that backend_reg::type and brw_reg::type are consistent for fixed regs. And define non-mutating helper functions to retype fixed and normal regs with a common interface. At some point we may want to get rid of ::fixed_hw_reg completely and have fixed regs use the normal register data members (e.g. backend_reg::reg to select a fixed GRF number, src_reg::swizzle to store the swizzle, etc.), I have the feeling that this is not the last headache we're going to get because of the multiple ways to represent the same thing and the different register interface depending on the file a register is stored in... Reviewed-by: Paul Berry --- src/mesa/drivers/dri/i965/brw_fs.h | 7 +++++++ src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 1 + src/mesa/drivers/dri/i965/brw_vec4.cpp | 2 ++ src/mesa/drivers/dri/i965/brw_vec4.h | 14 ++++++++++++++ src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 2 ++ 5 files changed, 26 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index ce5050bd41a..4845156d74b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -129,6 +129,13 @@ public: fs_reg *reladdr; }; +static inline fs_reg +retype(fs_reg reg, unsigned type) +{ + reg.fixed_hw_reg.type = reg.type = type; + return reg; +} + static inline fs_reg offset(fs_reg reg, unsigned delta) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 82db1407e81..3f2060d86bb 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -1053,6 +1053,7 @@ brw_reg_from_fs_reg(fs_reg *reg) } break; case HW_REG: + assert(reg->type == reg->fixed_hw_reg.type); brw_reg = reg->fixed_hw_reg; break; case BAD_FILE: diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 53fb9ee222d..fbf7fb9e78b 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -118,6 +118,7 @@ src_reg::src_reg(struct brw_reg reg) this->file = HW_REG; this->fixed_hw_reg = reg; + this->type = reg.type; } src_reg::src_reg(dst_reg reg) @@ -188,6 +189,7 @@ dst_reg::dst_reg(struct brw_reg reg) this->file = HW_REG; this->fixed_hw_reg = reg; + this->type = reg.type; } dst_reg::dst_reg(src_reg reg) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index a592af2f128..9dc4f0162d1 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -140,6 +140,13 @@ public: src_reg *reladdr; }; +static inline src_reg +retype(src_reg reg, unsigned type) +{ + reg.fixed_hw_reg.type = reg.type = type; + return reg; +} + static inline src_reg offset(src_reg reg, unsigned delta) { @@ -192,6 +199,13 @@ public: src_reg *reladdr; }; +static inline dst_reg +retype(dst_reg reg, unsigned type) +{ + reg.fixed_hw_reg.type = reg.type = type; + return reg; +} + static inline dst_reg offset(dst_reg reg, unsigned delta) { diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index 058b639309b..e0c59bac3d7 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -50,6 +50,7 @@ vec4_instruction::get_dst(void) break; case HW_REG: + assert(dst.type == dst.fixed_hw_reg.type); brw_reg = dst.fixed_hw_reg; break; @@ -116,6 +117,7 @@ vec4_instruction::get_src(const struct brw_vec4_prog_data *prog_data, int i) break; case HW_REG: + assert(src[i].type == src[i].fixed_hw_reg.type); brw_reg = src[i].fixed_hw_reg; break; -- cgit v1.2.3