From 790565b06ec80de663820e136105ecb18125743f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 11 Jan 2016 10:55:57 -0800 Subject: [PATCH] anv/pipeline: Handle output lowering in anv_pipeline instead of spirv_to_nir 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 | 5 ----- src/vulkan/anv_pipeline.c | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/glsl/nir/spirv/spirv_to_nir.c b/src/glsl/nir/spirv/spirv_to_nir.c index 26c2e58..44d03652 100644 --- a/src/glsl/nir/spirv/spirv_to_nir.c +++ b/src/glsl/nir/spirv/spirv_to_nir.c @@ -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; } diff --git a/src/vulkan/anv_pipeline.c b/src/vulkan/anv_pipeline.c index 9054d76..db4e19b 100644 --- a/src/vulkan/anv_pipeline.c +++ b/src/vulkan/anv_pipeline.c @@ -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); } -- 2.7.4