pan/mdg: Do per-sample framebuffer loads
EXT_shader_framebuffer_fetch requires the fetched value to be per-sample, so we need to load the sample id when in a fragment shader. Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5930>
This commit is contained in:
@@ -866,7 +866,7 @@ intrinsic("bindless_resource_ir3", [1], dest_comp=1, indices=[DESC_SET], flags=[
|
|||||||
# src[] = { value }
|
# src[] = { value }
|
||||||
store("raw_output_pan", [], [])
|
store("raw_output_pan", [], [])
|
||||||
store("combined_output_pan", [1, 1, 1], [BASE, COMPONENT])
|
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>
|
# Loads the sampler paramaters <min_lod, max_lod, lod_bias>
|
||||||
# src[] = { sampler_index }
|
# src[] = { sampler_index }
|
||||||
|
@@ -1822,6 +1822,14 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
|
|||||||
|
|
||||||
ld.load_store.arg_2 = output_load_rt_addr(ctx->nir, instr);
|
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) {
|
if (ctx->quirks & MIDGARD_OLD_BLEND) {
|
||||||
ld.load_store.op = midgard_op_ld_color_buffer_32u_old;
|
ld.load_store.op = midgard_op_ld_color_buffer_32u_old;
|
||||||
ld.load_store.address = 16;
|
ld.load_store.address = 16;
|
||||||
|
@@ -660,16 +660,23 @@ pan_lower_fb_store(nir_shader *shader,
|
|||||||
nir_builder_instr_insert(b, &new->instr);
|
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
|
static void
|
||||||
pan_lower_fb_load(nir_shader *shader,
|
pan_lower_fb_load(nir_shader *shader,
|
||||||
nir_builder *b,
|
nir_builder *b,
|
||||||
nir_intrinsic_instr *intr,
|
nir_intrinsic_instr *intr,
|
||||||
const struct util_format_description *desc,
|
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_instr *new = nir_intrinsic_instr_create(shader,
|
||||||
nir_intrinsic_load_raw_output_pan);
|
nir_intrinsic_load_raw_output_pan);
|
||||||
new->num_components = 4;
|
new->num_components = 4;
|
||||||
|
new->src[0] = nir_src_for_ssa(pan_sample_id(b, sample));
|
||||||
|
|
||||||
nir_intrinsic_set_base(new, base);
|
nir_intrinsic_set_base(new, base);
|
||||||
|
|
||||||
@@ -765,6 +772,12 @@ pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
|
|||||||
if (fmt_class == PAN_FORMAT_NATIVE)
|
if (fmt_class == PAN_FORMAT_NATIVE)
|
||||||
continue;
|
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 b;
|
||||||
nir_builder_init(&b, func->impl);
|
nir_builder_init(&b, func->impl);
|
||||||
|
|
||||||
@@ -773,7 +786,7 @@ pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
|
|||||||
pan_lower_fb_store(shader, &b, intr, desc, quirks);
|
pan_lower_fb_store(shader, &b, intr, desc, quirks);
|
||||||
} else {
|
} else {
|
||||||
b.cursor = nir_after_instr(instr);
|
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);
|
nir_instr_remove(instr);
|
||||||
|
Reference in New Issue
Block a user