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 */
#include "helpers.h"
#include "compiler.h"
#include "midgard_quirks.h"
+#include "panfrost-quirks.h"
+#include "panfrost/util/pan_lower_framebuffer.h"
#include "disassemble.h"
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);
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) {
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);
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);
}
nir_instr_remove(instr);
+
+ progress = true;
}
}
nir_metadata_preserve(func->impl, nir_metadata_block_index |
nir_metadata_dominance);
}
+
+ return progress;
}
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