[Mesa-dev] [Mesa-dev, 1/2] i965: fix up asserts in brw_inst_set_jip()

Kenneth Graunke kenneth at whitecape.org
Sun Jan 29 07:25:26 UTC 2017


On Thu, Jan 26, 2017 at 01:50:41PM +1100, Timothy Arceri wrote:
> We are casting from a signed 32bit int to an unsigned 16bit int
> so shift 15 bits rather than 16.
> ---
>  src/mesa/drivers/dri/i965/brw_inst.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_inst.h b/src/mesa/drivers/dri/i965/brw_inst.h
> index 13fce97..9a777e5 100644
> --- a/src/mesa/drivers/dri/i965/brw_inst.h
> +++ b/src/mesa/drivers/dri/i965/brw_inst.h
> @@ -283,8 +283,8 @@ brw_inst_set_jip(const struct gen_device_info *devinfo,
>     if (devinfo->gen >= 8) {
>        brw_inst_set_bits(inst, 127, 96, (uint32_t)value);
>     } else {
> -      assert(value <= (1 << 16) - 1);
> -      assert(value > -(1 << 16));
> +      assert(value <= (1 << 15) - 1);
> +      assert(value > -(1 << 15));
>        brw_inst_set_bits(inst, 111, 96, (uint16_t)value);
>     }
>  }

Isn't -32768 legal?  It would be excluded by the above assertions.
A patch to make them:

      assert(value <= (1 << 15) - 1);
      assert(value >= -(1 << 15));

would be:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list