From: Gert Wollny Date: Tue, 21 Jul 2020 09:43:08 +0000 (+0200) Subject: r600/sfn: Sort uniforms by binding and offset X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=df2acf8e26a88bef535e286ea52cbd5c6ec0d66c;p=mesa.git r600/sfn: Sort uniforms by binding and offset This is required to get atomics right. v2: rebase to use global variable lists Signed-off-by: Gert Wollny Part-of: --- diff --git a/src/gallium/drivers/r600/sfn/sfn_nir.cpp b/src/gallium/drivers/r600/sfn/sfn_nir.cpp index d65a1c92dcf..50edec14302 100644 --- a/src/gallium/drivers/r600/sfn/sfn_nir.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_nir.cpp @@ -484,6 +484,32 @@ bool r600_lower_ubo_to_align16(nir_shader *shader) nullptr); } +static void +insert_uniform_sorted(struct exec_list *var_list, nir_variable *new_var) +{ + nir_foreach_variable_in_list(var, var_list) { + if (var->data.binding > new_var->data.binding || + (var->data.binding == new_var->data.binding && + var->data.offset > new_var->data.offset)) { + exec_node_insert_node_before(&var->node, &new_var->node); + return; + } + } + exec_list_push_tail(var_list, &new_var->node); +} + +void sort_uniforms(nir_shader *shader) +{ + struct exec_list new_list; + exec_list_make_empty(&new_list); + + nir_foreach_uniform_variable_safe(var, shader) { + exec_node_remove(&var->node); + insert_uniform_sorted(&new_list, var); + } + exec_list_append(&shader->variables, &new_list); +} + } using r600::r600_nir_lower_int_tg4; @@ -661,6 +687,8 @@ int r600_shader_from_nir(struct r600_context *rctx, fprintf(stderr, "END PRE-OPT-NIR--------------------------------------\n\n"); } + r600::sort_uniforms(sel->nir); + NIR_PASS_V(sel->nir, nir_lower_vars_to_ssa); NIR_PASS_V(sel->nir, nir_lower_regs_to_ssa); NIR_PASS_V(sel->nir, nir_lower_phis_to_scalar);