[Mesa-dev] [PATCH] util/tgsi: add static assertion to catch opcode overflowing bitfield

Nicolai Hähnle nhaehnle at gmail.com
Tue Nov 7 16:15:10 UTC 2017


Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

On 07.11.2017 17:09, Brian Paul 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;
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list