summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2011-10-06 20:58:18 -0700
committerPaul Berry <[email protected]>2011-10-11 11:08:13 -0700
commitd06cc42c3c85382600176d118d8bf492b4de6a55 (patch)
tree79ba7d98a3ae6fae438555c594749dc63a0a71c3 /src/mesa
parent7f3de70c3c8e9ec9dfc34ddd3a08c4b73c007541 (diff)
i965: Fix computation of abs(-x) in FS
When updating a register reference to reflect the fact that we were taking its absolute value, the fragment shader back-end failed to clear the negate flag, resulting in abs(-x) getting computed as -abs(x). I also found (and fixed) a similar problem in brw_eu.h, but I'm not aware of an actual manifestation of that problem. Fixes piglit test glsl-fs-abs-neg-with-intermediate.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_eu.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp5
2 files changed, 5 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index 8b2222b4f57..adc09f81630 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -698,6 +698,7 @@ static INLINE struct brw_reg negate( struct brw_reg reg )
static INLINE struct brw_reg brw_abs( struct brw_reg reg )
{
reg.abs = 1;
+ reg.negate = 0;
return reg;
}
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 6d17839df95..f73166274d1 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1363,8 +1363,11 @@ fs_visitor::register_coalesce()
scan_inst->src[i].reg == inst->dst.reg &&
scan_inst->src[i].reg_offset == inst->dst.reg_offset) {
fs_reg new_src = inst->src[0];
+ if (scan_inst->src[i].abs) {
+ new_src.negate = 0;
+ new_src.abs = 1;
+ }
new_src.negate ^= scan_inst->src[i].negate;
- new_src.abs |= scan_inst->src[i].abs;
scan_inst->src[i] = new_src;
}
}