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:
parent
e603248e07
commit
1e1eee992e
|
@ -203,11 +203,13 @@ panfrost_compile_blend_shader(
|
||||||
options.half = true;
|
options.half = true;
|
||||||
|
|
||||||
NIR_PASS_V(shader, nir_lower_blend, options);
|
NIR_PASS_V(shader, nir_lower_blend, options);
|
||||||
NIR_PASS_V(shader, pan_lower_framebuffer, format_desc, dev->quirks);
|
|
||||||
|
|
||||||
/* Compile the built shader */
|
/* 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);
|
midgard_compile_shader_nir(shader, &program, true, rt, dev->gpu_id, false);
|
||||||
|
|
||||||
/* Allow us to patch later */
|
/* Allow us to patch later */
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
#include "midgard_quirks.h"
|
#include "midgard_quirks.h"
|
||||||
|
#include "panfrost-quirks.h"
|
||||||
|
#include "panfrost/util/pan_lower_framebuffer.h"
|
||||||
|
|
||||||
#include "disassemble.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_var_copies);
|
||||||
NIR_PASS_V(nir, nir_lower_vars_to_ssa);
|
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,
|
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
|
||||||
glsl_type_size, 0);
|
glsl_type_size, 0);
|
||||||
NIR_PASS_V(nir, nir_lower_ssbo);
|
NIR_PASS_V(nir, nir_lower_ssbo);
|
||||||
|
|
|
@ -660,13 +660,14 @@ pan_lower_fb_load(nir_shader *shader,
|
||||||
nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, rewritten, &intr->instr);
|
nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, rewritten, &intr->instr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
pan_lower_framebuffer(nir_shader *shader,
|
pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
|
||||||
const struct util_format_description *desc,
|
unsigned quirks)
|
||||||
unsigned quirks)
|
|
||||||
{
|
{
|
||||||
/* Blend shaders are represented as special fragment shaders */
|
if (shader->info.stage != MESA_SHADER_FRAGMENT)
|
||||||
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
|
return false;
|
||||||
|
|
||||||
|
bool progress = false;
|
||||||
|
|
||||||
nir_foreach_function(func, shader) {
|
nir_foreach_function(func, shader) {
|
||||||
nir_foreach_block(block, func->impl) {
|
nir_foreach_block(block, func->impl) {
|
||||||
|
@ -682,6 +683,17 @@ pan_lower_framebuffer(nir_shader *shader,
|
||||||
if (!(is_load || is_store))
|
if (!(is_load || is_store))
|
||||||
continue;
|
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 =
|
enum pan_format_class fmt_class =
|
||||||
pan_format_class(desc, quirks, is_store);
|
pan_format_class(desc, quirks, is_store);
|
||||||
|
|
||||||
|
@ -689,12 +701,6 @@ pan_lower_framebuffer(nir_shader *shader,
|
||||||
if (fmt_class == PAN_FORMAT_NATIVE)
|
if (fmt_class == PAN_FORMAT_NATIVE)
|
||||||
continue;
|
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 b;
|
||||||
nir_builder_init(&b, func->impl);
|
nir_builder_init(&b, func->impl);
|
||||||
|
|
||||||
|
@ -707,10 +713,14 @@ pan_lower_framebuffer(nir_shader *shader,
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_instr_remove(instr);
|
nir_instr_remove(instr);
|
||||||
|
|
||||||
|
progress = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_metadata_preserve(func->impl, nir_metadata_block_index |
|
nir_metadata_preserve(func->impl, nir_metadata_block_index |
|
||||||
nir_metadata_dominance);
|
nir_metadata_dominance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_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);
|
enum pan_format_class pan_format_class_store(const struct util_format_description *desc, unsigned quirks);
|
||||||
|
|
||||||
void
|
bool pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
|
||||||
pan_lower_framebuffer(nir_shader *shader,
|
unsigned quirks);
|
||||||
const struct util_format_description *desc,
|
|
||||||
unsigned quirks);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue