From 06e724c7b4ade29868531edb20900859f566a077 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 2 Mar 2018 03:00:41 +0100 Subject: tgsi/scan: use wrap-around shift behavior explicitly for file_mask The comment said it will only represent the lowest 32 regs. This was not entirely true in practice, since at least on x86 you'll get masked shifts (unless the compiler could recognize it already and toss it out). It turns out this actually works out alright (presumably noone uses it for temp regs) when increasing max sampler views, so make that behavior explicit. Albeit it feels a bit hacky (but in any case, explicit behavior there is better than undefined behavior). Reviewed-by: Jose Fonseca Reviewed-by: Brian Paul --- src/gallium/auxiliary/tgsi/tgsi_scan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary/tgsi') diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c index c35eff25ba8..4a2b3540639 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c @@ -585,8 +585,11 @@ scan_declaration(struct tgsi_shader_info *info, int buffer; unsigned index, target, type; - /* only first 32 regs will appear in this bitfield */ - info->file_mask[file] |= (1 << reg); + /* + * only first 32 regs will appear in this bitfield, if larger + * bits will wrap around. + */ + info->file_mask[file] |= (1u << (reg & 31)); info->file_count[file]++; info->file_max[file] = MAX2(info->file_max[file], (int)reg); -- cgit v1.2.3