[Mesa-dev] [PATCH] util/tgsi: add static assertion to catch opcode overflowing bitfield
Marek Olšák
maraeo at gmail.com
Tue Nov 7 16:11:50 UTC 2017
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Tue, Nov 7, 2017 at 5:09 PM, Brian Paul <brianp at vmware.com> wrote:
> I've noticed at least two places where we store the TGSI opcode in
> an unsigned:8 bitfield. We're at 249 opcodes now. If we hit 256 we'll
> need to grow those bitfields. Add a static assertion to detect that.
> ---
> src/gallium/auxiliary/tgsi/tgsi_info.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
> index 4e39950..ff4b150 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_info.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
> @@ -55,6 +55,11 @@ tgsi_get_opcode_info( uint opcode )
> {
> static boolean firsttime = 1;
>
> + /* If this assertion fails, increase tgsi_opcode_info::opcode
> + * and glsl_to_tgsi_instruction::op field sizes (and other locations?)
> + */
> + STATIC_ASSERT(TGSI_OPCODE_LAST <= 255);
> +
> if (firsttime) {
> unsigned i;
> firsttime = 0;
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list