spirv: Don't leak GS initialization to other stages
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 8 Nov 2019 23:58:15 +0000 (15:58 -0800)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Sat, 9 Nov 2019 00:28:21 +0000 (16:28 -0800)
The stage specific fields of shader_info are in an union.  We've
likely been lucky that this value was either overwritten or ignored by
other stages.  The recent change in shader_info layout in commit
84a1a2578da ("compiler: pack shader_info from 160 bytes to 96 bytes")
made this issue visible.

Fixes: cf2257069cb ("nir/spirv: Set a default number of invocations for geometry shaders")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/compiler/spirv/spirv_to_nir.c

index 4c1da666261c3e07c3d6faf7b31c64bfc9faa594..eeca640ba497dfde2c69af770057c5b61cbb0baa 100644 (file)
@@ -5152,7 +5152,8 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
    }
 
    /* Set shader info defaults */
-   b->shader->info.gs.invocations = 1;
+   if (stage == MESA_SHADER_GEOMETRY)
+      b->shader->info.gs.invocations = 1;
 
    /* Parse rounding mode execution modes. This has to happen earlier than
     * other changes in the execution modes since they can affect, for example,