summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Maria Casanova Crespo <jmcasanova@igalia.com>2018-05-03 01:38:47 +0200
committerJuan A. Suarez Romero <jasuarez@igalia.com>2018-05-15 11:14:11 +0200
commitee99f7deafb33a3e5f409fd331ed3a5c6264b747 (patch)
tree3ed3ef8357a4b9518dcae8c6d7ede02d308fcb20
parentbbd5c75d7d6175dbdb5c44bf9b57bbbeed94a2c0 (diff)
intel/compiler: fix brw_imm_w for negative 16-bit integers
16-bit immediates need to replicate the 16-bit immediate value in both words of the 32-bit value. This needs to be careful to avoid sign-extension, which the previous implementation was not handling properly. For example, with the previous implementation, storing the value -3 would generate imm.d = 0xfffffffd due to signed integer sign extension, which is not correct. Instead, we should cast to uint16_t, which gives us the correct result: imm.ud = 0xfffdfffd. We only had a couple of cases hitting this path in the driver until now, one with value -1, which would work since all bits are one in this case, and another with value -2 in brw_clip_tri(), which would hit the aforementioned issue (this case only affects gen4 although we are not aware of whether this was causing an actual bug somewhere). v2: Make explicit uint32_t casting for left shift (Jason Ekstrand) Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Cc: "18.0 18.1" <mesa-stable@lists.freedesktop.org> (cherry picked from commit f0e6dacee529661393964725bed561c45405bae4)
-rw-r--r--src/intel/compiler/brw_reg.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/intel/compiler/brw_reg.h b/src/intel/compiler/brw_reg.h
index 17d5b97bf31..fb303079f2a 100644
--- a/src/intel/compiler/brw_reg.h
+++ b/src/intel/compiler/brw_reg.h
@@ -647,7 +647,7 @@ static inline struct brw_reg
brw_imm_w(int16_t w)
{
struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_W);
- imm.d = w | (w << 16);
+ imm.ud = (uint16_t)w | (uint32_t)(uint16_t)w << 16;
return imm;
}