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>
This commit is contained in:
Marek Olšák 2020-09-17 20:25:22 -04:00
parent a6abf175ef
commit ea77958fea
2 changed files with 20 additions and 1 deletions

View File

@ -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; 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 && instr->intrinsic == nir_intrinsic_load_per_vertex_output &&
!src_is_invocation_id(nir_get_io_vertex_index_src(instr))) !src_is_invocation_id(nir_get_io_vertex_index_src(instr)))
shader->info.tess.tcs_cross_invocation_outputs_read |= slot_mask; 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; break;
case nir_intrinsic_store_output: 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))) if (!nir_src_is_const(*nir_get_io_offset_src(instr)))
shader->info.outputs_accessed_indirectly |= slot_mask; 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; break;
case nir_intrinsic_load_subgroup_size: 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_sample_qualifier = false;
shader->info.fs.uses_discard = false; shader->info.fs.uses_discard = false;
shader->info.fs.uses_demote = 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; shader->info.fs.needs_helper_invocations = false;
} }
if (shader->info.stage == MESA_SHADER_TESS_CTRL) { if (shader->info.stage == MESA_SHADER_TESS_CTRL) {

View File

@ -248,6 +248,8 @@ typedef struct shader_info {
struct { struct {
bool uses_discard:1; bool uses_discard:1;
bool uses_demote: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 * True if this fragment shader requires helper invocations. This