From ea77958fea2b358a9b3de0bf5022e5c72ef63064 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 17 Sep 2020 20:25:22 -0400 Subject: [PATCH] nir: gather information about fbfetch and dual source color Reviewed-by: Eric Anholt Part-of: --- src/compiler/nir/nir_gather_info.c | 19 ++++++++++++++++++- src/compiler/shader_info.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) 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 @@ set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len, } - 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 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, 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 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, 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 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint) 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 @@ typedef struct shader_info { 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 -- 2.7.4