radv: Call nir_lower_constant_initializers.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sun, 8 Jan 2017 22:17:38 +0000 (23:17 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 12 Jan 2017 20:39:46 +0000 (21:39 +0100)
Port of c5d664f9dc2d281c74844cef36ecb9f5862a8f6a
"anv/pipeline: Call nir_lower_constant_initializers"

Signed-off-by: Bas Nieuwenhuizen <basni@google.com>
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
src/amd/vulkan/radv_pipeline.c

index 03603f5ecc2cd6dcab6aeaa8c2e1d3fee924b1ed..d818938e1e417568079003f7df68fa555ea01625 100644 (file)
@@ -205,6 +205,13 @@ radv_shader_compile_to_nir(struct radv_device *device,
 
                free(spec_entries);
 
+               /* We have to lower away local constant initializers right before we
+                * inline functions.  That way they get properly initialized at the top
+                * of the function and not at the top of its caller.
+                */
+               nir_lower_constant_initializers(nir, nir_var_local);
+               nir_validate_shader(nir);
+
                nir_lower_returns(nir);
                nir_validate_shader(nir);
 
@@ -224,6 +231,12 @@ radv_shader_compile_to_nir(struct radv_device *device,
                                               nir_var_system_value);
                nir_validate_shader(nir);
 
+               /* Now that we've deleted all but the main function, we can go ahead and
+                * lower the rest of the constant initializers.
+                */
+               nir_lower_constant_initializers(nir, ~0);
+               nir_validate_shader(nir);
+
                nir_lower_system_values(nir);
                nir_validate_shader(nir);
        }