summaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan
diff options
context:
space:
mode:
authorJonathan Marek <[email protected]>2019-10-06 22:25:59 -0400
committerJonathan Marek <[email protected]>2019-10-15 07:56:20 -0400
commita5635a8a50404ca2c37ee7edc095790ed089f83d (patch)
treebed647b6c5703df794c6f9aba6aab785b066901a /src/freedreno/vulkan
parentd930be9f4cc16f07c4b1bcb8f5ec1bdc06a9c3bf (diff)
turnip: add missing nir passes
Avoids assert fails in ir3. Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]>
Diffstat (limited to 'src/freedreno/vulkan')
-rw-r--r--src/freedreno/vulkan/tu_shader.c55
1 files changed, 50 insertions, 5 deletions
diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c
index 5d7d5b0ff55..755cde4def6 100644
--- a/src/freedreno/vulkan/tu_shader.c
+++ b/src/freedreno/vulkan/tu_shader.c
@@ -323,7 +323,40 @@ tu_shader_create(struct tu_device *dev,
nir_print_shader(nir, stderr);
}
- /* TODO what needs to happen? */
+ /* multi step inlining procedure */
+ NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_function_temp);
+ NIR_PASS_V(nir, nir_lower_returns);
+ NIR_PASS_V(nir, nir_inline_functions);
+ NIR_PASS_V(nir, nir_opt_deref);
+ foreach_list_typed_safe(nir_function, func, node, &nir->functions) {
+ if (!func->is_entrypoint)
+ exec_node_remove(&func->node);
+ }
+ assert(exec_list_length(&nir->functions) == 1);
+ NIR_PASS_V(nir, nir_lower_constant_initializers, ~nir_var_function_temp);
+
+ /* Split member structs. We do this before lower_io_to_temporaries so that
+ * it doesn't lower system values to temporaries by accident.
+ */
+ NIR_PASS_V(nir, nir_split_var_copies);
+ NIR_PASS_V(nir, nir_split_per_member_structs);
+
+ NIR_PASS_V(nir, nir_remove_dead_variables,
+ nir_var_shader_in | nir_var_shader_out | nir_var_system_value | nir_var_mem_shared);
+
+ NIR_PASS_V(nir, nir_propagate_invariant);
+
+ NIR_PASS_V(nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir), true, true);
+
+ NIR_PASS_V(nir, nir_lower_global_vars_to_local);
+ NIR_PASS_V(nir, nir_split_var_copies);
+ NIR_PASS_V(nir, nir_lower_var_copies);
+
+ NIR_PASS_V(nir, nir_opt_copy_prop_vars);
+ NIR_PASS_V(nir, nir_opt_combine_stores, nir_var_all);
+
+ /* ir3 doesn't support indirect input/output */
+ NIR_PASS_V(nir, nir_lower_indirect_derefs, nir_var_shader_in | nir_var_shader_out);
switch (stage) {
case MESA_SHADER_VERTEX:
@@ -352,8 +385,6 @@ tu_shader_create(struct tu_device *dev,
nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms,
ir3_glsl_type_size);
- NIR_PASS_V(nir, nir_opt_copy_prop_vars);
-
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, nir_lower_frexp);
@@ -361,6 +392,18 @@ tu_shader_create(struct tu_device *dev,
NIR_PASS_V(nir, nir_lower_io, nir_var_all, ir3_glsl_type_size, 0);
+ if (stage == MESA_SHADER_FRAGMENT) {
+ /* NOTE: lower load_barycentric_at_sample first, since it
+ * produces load_barycentric_at_offset:
+ */
+ NIR_PASS_V(nir, ir3_nir_lower_load_barycentric_at_sample);
+ NIR_PASS_V(nir, ir3_nir_lower_load_barycentric_at_offset);
+
+ NIR_PASS_V(nir, ir3_nir_move_varying_inputs);
+ }
+
+ NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
+
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
shader->ir3_shader.compiler = dev->compiler;
@@ -401,8 +444,10 @@ tu_shader_compile_options_init(
*options = (struct tu_shader_compile_options) {
/* TODO ir3_key */
- .optimize = !(pipeline_info->flags &
- VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT),
+ /* TODO: VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT
+ * some optimizations need to happen otherwise shader might not compile
+ */
+ .optimize = true,
.include_binning_pass = true,
};
}