anv/pipeline: Handle output lowering in anv_pipeline instead of spirv_to_nir
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 11 Jan 2016 18:55:57 +0000 (10:55 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 11 Jan 2016 19:06:06 +0000 (11:06 -0800)
While we're at it, we delete any unused variables.  This allows us to prune
variables that are not used in the current stage from the shader.

src/glsl/nir/spirv/spirv_to_nir.c
src/vulkan/anv_pipeline.c

index 26c2e58b9c3cd4cbe0b2236bd1e30dcd8bc39790..44d03652e982affd14135b06ca900240d640a183 100644 (file)
@@ -3526,10 +3526,5 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
 
    ralloc_free(b);
 
-   /* Because we can still have output reads in NIR, we need to lower
-    * outputs to temporaries before we are truely finished.
-    */
-   nir_lower_outputs_to_temporaries(entry_point->shader, entry_point);
-
    return entry_point;
 }
index 9054d76892d1a5d62bbfe805625ce092586c08d6..db4e19bf486ab1bfe67045abb80cab7878947513 100644 (file)
@@ -133,6 +133,13 @@ anv_shader_compile_to_nir(struct anv_device *device,
       assert(exec_list_length(&nir->functions) == 1);
       entry_point->name = ralloc_strdup(entry_point, "main");
 
+      nir_remove_dead_variables(nir, nir_var_shader_in);
+      nir_remove_dead_variables(nir, nir_var_shader_out);
+      nir_remove_dead_variables(nir, nir_var_system_value);
+      nir_validate_shader(nir);
+
+      nir_lower_outputs_to_temporaries(entry_point->shader, entry_point);
+
       nir_lower_system_values(nir);
       nir_validate_shader(nir);
    }