nir: remove dead glsl variables before lowering io.
authorDave Airlie <airlied@redhat.com>
Fri, 20 May 2016 20:48:05 +0000 (06:48 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 20 May 2016 22:56:45 +0000 (08:56 +1000)
For cull distance GLSL will let unsized unused arrays get
into the backend, we should nuke those straight away, to
save caring about them later.

This fixes:
arb_separate_shader_objects/linker/large-number-of-unused-varyings
as a side effect (even without culling changes).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/drivers/dri/i965/brw_nir.c

index 372b746453e6dac536d090530b76f983d6d47a36..9274f2e1616d6d240a8b327fed6907674a7bcbed 100644 (file)
@@ -561,6 +561,7 @@ brw_create_nir(struct brw_context *brw,
    /* First, lower the GLSL IR or Mesa IR to NIR */
    if (shader_prog) {
       nir = glsl_to_nir(shader_prog, stage, options);
+      nir_remove_dead_variables(nir, nir_var_shader_in | nir_var_shader_out);
       OPT_V(nir_lower_io_to_temporaries,
             nir_shader_get_entrypoint(nir),
             true, false);