st_glsl_to_tgsi: don't try and pass 32-bit values to get_deref_offsets
authorDave Airlie <airlied@redhat.com>
Mon, 12 Jun 2017 19:33:19 +0000 (05:33 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 12 Jun 2017 23:29:54 +0000 (09:29 +1000)
Just use a temporary 16-bit index.

This fixes coverity issue, pointed to me by Ilia.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index c5d2e0fcd2f4039e952b01b5b5db0de1a9728bfc..798831613f105efd99f3d0b814a197e6976482f2 100644 (file)
@@ -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;