mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 18:50:10 +01:00
treewide: use nir_src_is_divergent() rather than checking the divergence of the SSA
Without LCSSA, divergence between src and def might differ. Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30787>
This commit is contained in:
parent
c8348139fd
commit
8d1abd4996
8 changed files with 14 additions and 12 deletions
|
|
@ -1285,7 +1285,7 @@ save_reusable_variables(nir_builder *b, lower_ngg_nogs_state *s)
|
|||
*/
|
||||
bool next_is_divergent_if =
|
||||
next_cf_node->type == nir_cf_node_if &&
|
||||
nir_cf_node_as_if(next_cf_node)->condition.ssa->divergent;
|
||||
nir_src_is_divergent(&nir_cf_node_as_if(next_cf_node)->condition);
|
||||
|
||||
if (next_is_loop || next_is_divergent_if) {
|
||||
block = nir_cf_node_cf_tree_next(next_cf_node);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ opt_non_uniform_tex_access(nir_tex_instr *tex)
|
|||
case nir_tex_src_texture_offset:
|
||||
case nir_tex_src_texture_handle:
|
||||
case nir_tex_src_texture_deref:
|
||||
if (tex->texture_non_uniform && !tex->src[i].src.ssa->divergent) {
|
||||
if (tex->texture_non_uniform && !nir_src_is_divergent(&tex->src[i].src)) {
|
||||
tex->texture_non_uniform = false;
|
||||
progress = true;
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ opt_non_uniform_tex_access(nir_tex_instr *tex)
|
|||
case nir_tex_src_sampler_offset:
|
||||
case nir_tex_src_sampler_handle:
|
||||
case nir_tex_src_sampler_deref:
|
||||
if (tex->sampler_non_uniform && !tex->src[i].src.ssa->divergent) {
|
||||
if (tex->sampler_non_uniform && !nir_src_is_divergent(&tex->src[i].src)) {
|
||||
tex->sampler_non_uniform = false;
|
||||
progress = true;
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ opt_non_uniform_access_intrin(nir_intrinsic_instr *intrin, unsigned handle_src)
|
|||
if (!has_non_uniform_access_intrin(intrin))
|
||||
return false;
|
||||
|
||||
if (intrin->src[handle_src].ssa->divergent)
|
||||
if (nir_src_is_divergent(&intrin->src[handle_src]))
|
||||
return false;
|
||||
|
||||
nir_intrinsic_set_access(intrin, nir_intrinsic_access(intrin) & ~ACCESS_NON_UNIFORM);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,8 @@ optimize_atomic(nir_builder *b, nir_intrinsic_instr *intrin, bool return_prev)
|
|||
nir_def *data = intrin->src[data_src].ssa;
|
||||
|
||||
/* Separate uniform reduction and scan is faster than doing a combined scan+reduce */
|
||||
bool combined_scan_reduce = return_prev && data->divergent;
|
||||
bool combined_scan_reduce = return_prev &&
|
||||
nir_src_is_divergent(&intrin->src[data_src]);
|
||||
nir_def *reduce = NULL, *scan = NULL;
|
||||
reduce_data(b, op, data, &reduce, combined_scan_reduce ? &scan : NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -1409,9 +1409,9 @@ gather_outputs(struct nir_builder *builder, nir_intrinsic_instr *intr, void *cb_
|
|||
* so we only propagate constants.
|
||||
* TODO: revisit this when workgroup divergence analysis is merged.
|
||||
*/
|
||||
const bool divergent = value->divergent ||
|
||||
const bool divergent = (!constant && linkage->producer_stage == MESA_SHADER_MESH) ||
|
||||
intr->instr.block->divergent ||
|
||||
(!constant && linkage->producer_stage == MESA_SHADER_MESH);
|
||||
nir_src_is_divergent(&intr->src[0]);
|
||||
|
||||
if (!out->producer.value) {
|
||||
/* This is the first store to this output. */
|
||||
|
|
|
|||
|
|
@ -4487,7 +4487,7 @@ emit_if(struct ir3_context *ctx, nir_if *nif)
|
|||
emit_conditional_branch(ctx, nif);
|
||||
}
|
||||
|
||||
ctx->block->divergent_condition = nif->condition.ssa->divergent;
|
||||
ctx->block->divergent_condition = nir_src_is_divergent(&nif->condition);
|
||||
|
||||
emit_cf_list(ctx, &nif->then_list);
|
||||
emit_cf_list(ctx, &nif->else_list);
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ static bool si_mark_divergent_texture_non_uniform(struct nir_shader *nir)
|
|||
|
||||
nir_tex_instr *tex = nir_instr_as_tex(instr);
|
||||
for (int i = 0; i < tex->num_srcs; i++) {
|
||||
bool divergent = tex->src[i].src.ssa->divergent;
|
||||
bool divergent = nir_src_is_divergent(&tex->src[i].src);
|
||||
|
||||
switch (tex->src[i].src_type) {
|
||||
case nir_tex_src_texture_deref:
|
||||
|
|
|
|||
|
|
@ -295,18 +295,19 @@ lower_cf_list(nir_builder *b, nir_def *esc_reg, struct scope *parent_scope,
|
|||
nir_if *nif = nir_cf_node_as_if(node);
|
||||
|
||||
nir_def *cond = nif->condition.ssa;
|
||||
bool divergent = nir_src_is_divergent(&nif->condition);
|
||||
nir_instr_clear_src(NULL, &nif->condition);
|
||||
|
||||
nir_block *then_block = nir_block_create(b->shader);
|
||||
nir_block *else_block = nir_block_create(b->shader);
|
||||
nir_block *merge_block = nir_block_create(b->shader);
|
||||
|
||||
const bool needs_sync = cond->divergent &&
|
||||
const bool needs_sync = divergent &&
|
||||
block_is_merge(nir_cf_node_as_block(nir_cf_node_next(node))) &&
|
||||
!parent_scope_will_sync(&nif->cf_node, parent_scope);
|
||||
|
||||
struct scope scope = push_scope(b, SCOPE_TYPE_IF_MERGE,
|
||||
parent_scope, cond->divergent,
|
||||
parent_scope, divergent,
|
||||
needs_sync, merge_block);
|
||||
|
||||
nir_goto_if(b, then_block, cond, else_block);
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ lower_cf_list(nir_builder *b, struct exec_list *cf_list)
|
|||
|
||||
case nir_cf_node_if: {
|
||||
nir_if *nif = nir_cf_node_as_if(node);
|
||||
if (nif->condition.ssa->divergent) {
|
||||
if (nir_src_is_divergent(&nif->condition)) {
|
||||
nir_block *succ = nir_cf_node_as_block(nir_cf_node_next(node));
|
||||
progress |= lower_non_uniform_cf_node(b, node, block, succ);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue