nir: gather information about fbfetch and dual source color
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6758>
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index 9547278..90320cb 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -151,8 +151,15 @@
}
- if (var->data.fb_fetch_output)
+ if (var->data.fb_fetch_output) {
shader->info.outputs_read |= bitfield;
+ if (shader->info.stage == MESA_SHADER_FRAGMENT)
+ shader->info.fs.uses_fbfetch_output = true;
+ }
+
+ if (shader->info.stage == MESA_SHADER_FRAGMENT &&
+ !is_output_read && var->data.index == 1)
+ shader->info.fs.color_is_dual_source = true;
}
}
}
@@ -402,6 +409,10 @@
instr->intrinsic == nir_intrinsic_load_per_vertex_output &&
!src_is_invocation_id(nir_get_io_vertex_index_src(instr)))
shader->info.tess.tcs_cross_invocation_outputs_read |= slot_mask;
+
+ if (shader->info.stage == MESA_SHADER_FRAGMENT &&
+ nir_intrinsic_io_semantics(instr).fb_fetch_output)
+ shader->info.fs.uses_fbfetch_output = true;
break;
case nir_intrinsic_store_output:
@@ -416,6 +427,10 @@
if (!nir_src_is_const(*nir_get_io_offset_src(instr)))
shader->info.outputs_accessed_indirectly |= slot_mask;
}
+
+ if (shader->info.stage == MESA_SHADER_FRAGMENT &&
+ nir_intrinsic_io_semantics(instr).dual_source_blend_index)
+ shader->info.fs.color_is_dual_source = true;
break;
case nir_intrinsic_load_subgroup_size:
@@ -777,6 +792,8 @@
shader->info.fs.uses_sample_qualifier = false;
shader->info.fs.uses_discard = false;
shader->info.fs.uses_demote = false;
+ shader->info.fs.color_is_dual_source = false;
+ shader->info.fs.uses_fbfetch_output = false;
shader->info.fs.needs_helper_invocations = false;
}
if (shader->info.stage == MESA_SHADER_TESS_CTRL) {
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index eeb1cb0..23d174a 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -248,6 +248,8 @@
struct {
bool uses_discard:1;
bool uses_demote:1;
+ bool uses_fbfetch_output:1;
+ bool color_is_dual_source:1;
/**
* True if this fragment shader requires helper invocations. This