# src[] = { value }
store("raw_output_pan", [], [])
store("combined_output_pan", [1, 1, 1], [BASE, COMPONENT])
-load("raw_output_pan", [], [BASE], [CAN_ELIMINATE, CAN_REORDER])
+load("raw_output_pan", [1], [BASE], [CAN_ELIMINATE, CAN_REORDER])
# Loads the sampler paramaters <min_lod, max_lod, lod_bias>
# src[] = { sampler_index }
ld.load_store.arg_2 = output_load_rt_addr(ctx->nir, instr);
+ if (nir_src_is_const(instr->src[0])) {
+ ld.load_store.arg_1 = nir_src_as_uint(instr->src[0]);
+ } else {
+ ld.load_store.varying_parameters = 2;
+ ld.src[1] = nir_src_index(ctx, &instr->src[0]);
+ ld.src_types[1] = nir_type_int32;
+ }
+
if (ctx->quirks & MIDGARD_OLD_BLEND) {
ld.load_store.op = midgard_op_ld_color_buffer_32u_old;
ld.load_store.address = 16;
nir_builder_instr_insert(b, &new->instr);
}
+static nir_ssa_def *
+pan_sample_id(nir_builder *b, int sample)
+{
+ return (sample >= 0) ? nir_imm_int(b, sample) : nir_load_sample_id(b);
+}
+
static void
pan_lower_fb_load(nir_shader *shader,
nir_builder *b,
nir_intrinsic_instr *intr,
const struct util_format_description *desc,
- unsigned base, unsigned quirks)
+ unsigned base, int sample, unsigned quirks)
{
nir_intrinsic_instr *new = nir_intrinsic_instr_create(shader,
nir_intrinsic_load_raw_output_pan);
new->num_components = 4;
+ new->src[0] = nir_src_for_ssa(pan_sample_id(b, sample));
nir_intrinsic_set_base(new, base);
if (fmt_class == PAN_FORMAT_NATIVE)
continue;
+ /* EXT_shader_framebuffer_fetch requires
+ * per-sample loads.
+ * MSAA blend shaders are not yet handled, so
+ * for now always load sample 0. */
+ int sample = is_blend ? 0 : -1;
+
nir_builder b;
nir_builder_init(&b, func->impl);
pan_lower_fb_store(shader, &b, intr, desc, quirks);
} else {
b.cursor = nir_after_instr(instr);
- pan_lower_fb_load(shader, &b, intr, desc, base, quirks);
+ pan_lower_fb_load(shader, &b, intr, desc, base, sample, quirks);
}
nir_instr_remove(instr);