[Mesa-dev] [PATCH v2 3/8] tgsi/scan: add an assert for the size of the samplers_declared bitfield
Nicolai Hähnle
nhaehnle at gmail.com
Thu Apr 7 17:35:10 UTC 2016
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
The literal 1 is a (signed) int, and shifting into the sign bit is undefined
in C, so change occurences of 1 to 1u.
---
src/gallium/auxiliary/tgsi/tgsi_scan.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index d90fb1d..0eb8c68 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -464,7 +464,7 @@ scan_declaration(struct tgsi_shader_info *info,
}
}
} else if (file == TGSI_FILE_SAMPLER) {
- info->samplers_declared |= 1 << reg;
+ info->samplers_declared |= 1u << reg;
} else if (file == TGSI_FILE_SAMPLER_VIEW) {
unsigned target = fulldecl->SamplerView.Resource;
assert(target < TGSI_TEXTURE_UNKNOWN);
@@ -540,6 +540,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
for (i = 0; i < Elements(info->sampler_targets); i++)
info->sampler_targets[i] = TGSI_TEXTURE_UNKNOWN;
+ assert(sizeof(info->samplers_declared) * 8 >= PIPE_MAX_SAMPLERS);
+
/**
** Setup to begin parsing input shader
**/
--
2.5.0
More information about the mesa-dev
mailing list