• Patrick Lerda's avatar
    panfrost: Fix unwanted valgrind message related to restart_index · c824104c
    Patrick Lerda authored
    As a reminder primitive_restart should always be checked before any access to restart_index.
    
    It seems that restart_index is only initialized when primitive_restart is set to a non-zero
    value. This patch is equivalent to the previous code but written in a way that the compiler
    will test primitive_restart first before trying to read restart_index.
    
    With commit ad864a7c
    
    :
    Conditional jump or move depends on uninitialised value(s)
       at 0xD33F1EC: panfrost_is_implicit_prim_restart (pan_cmdstream.c:2907)
       by 0xD33F1EC: panfrost_emit_primitive (pan_cmdstream.c:3073)
       by 0xD33F1EC: panfrost_draw_emit_tiler (pan_cmdstream.c:3440)
       by 0xD33F1EC: panfrost_direct_draw (pan_cmdstream.c:3595)
       by 0xD340467: panfrost_draw_vbo (pan_cmdstream.c:3889)
       by 0xD219119: u_vbuf_draw_vbo (u_vbuf.c:1498)
       by 0xD1C81F9: cso_multi_draw (cso_context.c:1644)
       by 0xCFBA19B: _mesa_draw_arrays.part.11 (draw.c:1324)
       by 0xCFBADA1: _mesa_draw_arrays (draw.c:1295)
       by 0xCFBADA1: _mesa_DrawArrays (draw.c:1533)
       by 0xD32EB: gl_vao_draw_data (in /usr/local/bin/mpv)
     Uninitialised value was created by a stack allocation
       at 0xCFBA14E: _mesa_draw_arrays.part.11 (draw.c:1289)
    
    With mesa-22.1.0-rc4:
    Conditional jump or move depends on uninitialised value(s)
       at 0xD36369C: panfrost_is_implicit_prim_restart (pan_cmdstream.c:2895)
       by 0xD36369C: panfrost_draw_emit_tiler (pan_cmdstream.c:3023)
       by 0xD36369C: panfrost_direct_draw (pan_cmdstream.c:3215)
       by 0xD3649BF: panfrost_draw_vbo (pan_cmdstream.c:3494)
       by 0xD23DE7D: u_vbuf_draw_vbo (u_vbuf.c:1498)
       by 0xD1ECBD1: cso_multi_draw (cso_context.c:1644)
       by 0xCFD60FF: _mesa_draw_arrays.part.11 (draw.c:1324)
       by 0xCFD6D11: _mesa_draw_arrays (draw.c:1295)
       by 0xCFD6D11: _mesa_DrawArrays (draw.c:1533)
       by 0xD32EB: gl_vao_draw_data (in /usr/local/bin/mpv)
     Uninitialised value was created by a stack allocation
       at 0xCFD60B2: _mesa_draw_arrays.part.11 (draw.c:1289)
    
    Signed-off-by: default avatarPatrick Lerda <patrick9876@free.fr>
    Reviewed-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa@collabora.com>
    Part-of: <!16389>
    c824104c