pan/mdg: Do the pan_lower_framebuffer pass later

The pass is useful for EXT_shader_framebuffer_fetch, not just blend
shaders, so we should do it with the other lowering passes in
midgard_compile_shader_nir.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5755>
This commit is contained in:
Icecream95 2020-07-06 19:30:37 +12:00 committed by Marge Bot
parent e603248e07
commit 1e1eee992e
4 changed files with 35 additions and 18 deletions

View File

@ -203,11 +203,13 @@ panfrost_compile_blend_shader(
options.half = true;
NIR_PASS_V(shader, nir_lower_blend, options);
NIR_PASS_V(shader, pan_lower_framebuffer, format_desc, dev->quirks);
/* Compile the built shader */
panfrost_program program;
panfrost_program program = {
.rt_formats = {format}
};
midgard_compile_shader_nir(shader, &program, true, rt, dev->gpu_id, false);
/* Allow us to patch later */

View File

@ -48,6 +48,8 @@
#include "helpers.h"
#include "compiler.h"
#include "midgard_quirks.h"
#include "panfrost-quirks.h"
#include "panfrost/util/pan_lower_framebuffer.h"
#include "disassemble.h"
@ -2755,6 +2757,11 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
NIR_PASS_V(nir, nir_lower_var_copies);
NIR_PASS_V(nir, nir_lower_vars_to_ssa);
unsigned pan_quirks = panfrost_get_quirks(gpu_id);
if (is_blend)
NIR_PASS_V(nir, pan_lower_framebuffer,
program->rt_formats, pan_quirks);
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
glsl_type_size, 0);
NIR_PASS_V(nir, nir_lower_ssbo);

View File

@ -660,13 +660,14 @@ pan_lower_fb_load(nir_shader *shader,
nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, rewritten, &intr->instr);
}
void
pan_lower_framebuffer(nir_shader *shader,
const struct util_format_description *desc,
unsigned quirks)
bool
pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
unsigned quirks)
{
/* Blend shaders are represented as special fragment shaders */
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
if (shader->info.stage != MESA_SHADER_FRAGMENT)
return false;
bool progress = false;
nir_foreach_function(func, shader) {
nir_foreach_block(block, func->impl) {
@ -682,6 +683,17 @@ pan_lower_framebuffer(nir_shader *shader,
if (!(is_load || is_store))
continue;
nir_variable *var = nir_intrinsic_get_var(intr, 0);
if (var->data.mode != nir_var_shader_out)
continue;
if (var->data.location != FRAG_RESULT_COLOR)
continue;
const struct util_format_description *desc =
util_format_description(rt_fmts[0]);
enum pan_format_class fmt_class =
pan_format_class(desc, quirks, is_store);
@ -689,12 +701,6 @@ pan_lower_framebuffer(nir_shader *shader,
if (fmt_class == PAN_FORMAT_NATIVE)
continue;
/* Don't worry about MRT */
nir_variable *var = nir_intrinsic_get_var(intr, 0);
if (var->data.location != FRAG_RESULT_COLOR)
continue;
nir_builder b;
nir_builder_init(&b, func->impl);
@ -707,10 +713,14 @@ pan_lower_framebuffer(nir_shader *shader,
}
nir_instr_remove(instr);
progress = true;
}
}
nir_metadata_preserve(func->impl, nir_metadata_block_index |
nir_metadata_dominance);
}
return progress;
}

View File

@ -43,9 +43,7 @@ nir_alu_type pan_unpacked_type_for_format(const struct util_format_description *
enum pan_format_class pan_format_class_load(const struct util_format_description *desc, unsigned quirks);
enum pan_format_class pan_format_class_store(const struct util_format_description *desc, unsigned quirks);
void
pan_lower_framebuffer(nir_shader *shader,
const struct util_format_description *desc,
unsigned quirks);
bool pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
unsigned quirks);
#endif