[Mesa-dev] [PATCH] st_glsl_to_tgsi: don't try and pass 32-bit values to get_deref_offsets

Samuel Pitoiset samuel.pitoiset at gmail.com
Mon Jun 12 20:00:53 UTC 2017


Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

On 06/12/2017 09:41 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> Just use a temporary 16-bit index.
> 
> This fixes coverity issue, pointed to me by Ilia.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>   src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index c5d2e0f..7988316 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -3776,10 +3776,11 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
>   
>      st_src_reg reladdr;
>      st_src_reg image(PROGRAM_IMAGE, 0, GLSL_TYPE_UINT);
> -
> +   uint16_t index;
>      get_deref_offsets(img, &sampler_array_size, &sampler_base,
> -                     (uint16_t*)&image.index, &reladdr, true);
> +                     &index, &reladdr, true);
>   
> +   image.index = index;
>      if (reladdr.file != PROGRAM_UNDEFINED) {
>         image.reladdr = ralloc(mem_ctx, st_src_reg);
>         *image.reladdr = reladdr;
> @@ -4391,9 +4392,11 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
>   
>      st_src_reg sampler(PROGRAM_SAMPLER, 0, GLSL_TYPE_UINT);
>   
> +   uint16_t index;
>      get_deref_offsets(ir->sampler, &sampler_array_size, &sampler_base,
> -                     (uint16_t *)&sampler.index, &reladdr, true);
> +                     &index, &reladdr, true);
>   
> +   sampler.index = index;
>      if (reladdr.file != PROGRAM_UNDEFINED) {
>         sampler.reladdr = ralloc(mem_ctx, st_src_reg);
>         *sampler.reladdr = reladdr;
> 


More information about the mesa-dev mailing list