[Mesa-dev] [PATCH v2 01/30] i965/fs: fix subreg_offset overflow in byte_offset()

Samuel Iglesias Gonsálvez siglesias at igalia.com
Thu May 12 11:35:38 UTC 2016


From: Iago Toral Quiroga <itoral at igalia.com>

This can happen if the register already has a non-zero subreg_offset
when byte_offset() is called.

v2 (Sam):
- Refactor byte_offset() (Jordan).

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_ir_fs.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h
index 86acdb2..305d91c 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h
@@ -80,19 +80,21 @@ retype(fs_reg reg, enum brw_reg_type type)
 static inline fs_reg
 byte_offset(fs_reg reg, unsigned delta)
 {
+   reg.subreg_offset += delta;
+
    switch (reg.file) {
    case BAD_FILE:
       break;
    case VGRF:
    case ATTR:
-      reg.reg_offset += delta / 32;
+      reg.reg_offset += reg.subreg_offset / 32;
       break;
    case MRF:
       reg.nr += delta / 32;
       break;
    case UNIFORM:
-      reg.reg_offset += delta / 4;
-      reg.subreg_offset += delta % 4;
+      reg.reg_offset += reg.subreg_offset / 4;
+      reg.subreg_offset %= 4;
       return reg;
    case ARF:
    case FIXED_GRF:
@@ -100,7 +102,7 @@ byte_offset(fs_reg reg, unsigned delta)
    default:
       assert(delta == 0);
    }
-   reg.subreg_offset += delta % 32;
+   reg.subreg_offset %= 32;
    return reg;
 }
 
-- 
2.5.0



More information about the mesa-dev mailing list