nir: extend nir_opt_fragdepth to handle lowered IO
Reviewed-by: Qiang Yu <yuq825@gmail.com> Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21861>
This commit is contained in:
parent
2a9ef6b1f8
commit
10a362f582
1 changed files with 22 additions and 8 deletions
|
|
@ -63,23 +63,37 @@ nir_opt_fragdepth(nir_shader *shader)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
||||||
if (intrin->intrinsic != nir_intrinsic_store_deref)
|
if (intrin->intrinsic != nir_intrinsic_store_deref &&
|
||||||
|
intrin->intrinsic != nir_intrinsic_store_output)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
|
unsigned data_src;
|
||||||
if (!nir_deref_mode_is(deref, nir_var_shader_out))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
if (intrin->intrinsic == nir_intrinsic_store_deref) {
|
||||||
if (var->data.location != FRAG_RESULT_DEPTH)
|
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
|
||||||
continue;
|
if (!nir_deref_mode_is(deref, nir_var_shader_out))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||||
|
if (var->data.location != FRAG_RESULT_DEPTH)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
data_src = 1;
|
||||||
|
} else {
|
||||||
|
nir_io_semantics sem = nir_intrinsic_io_semantics(intrin);
|
||||||
|
|
||||||
|
if (sem.location != FRAG_RESULT_DEPTH)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
data_src = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* We found a write to gl_FragDepth */
|
/* We found a write to gl_FragDepth */
|
||||||
if (store_intrin) {
|
if (store_intrin) {
|
||||||
/* This isn't the only write: give up on this optimization */
|
/* This isn't the only write: give up on this optimization */
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
if (ssa_def_is_source_depth(intrin->src[1].ssa)) {
|
if (ssa_def_is_source_depth(intrin->src[data_src].ssa)) {
|
||||||
/* We're writing gl_FragCoord.z in gl_FragDepth: remember
|
/* We're writing gl_FragCoord.z in gl_FragDepth: remember
|
||||||
* intrin so we can try to remove it later. */
|
* intrin so we can try to remove it later. */
|
||||||
store_intrin = intrin;
|
store_intrin = intrin;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue