From 9075d635dec2aa9d338cdd9cd87aa779a4d93550 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 18 Aug 2021 22:08:31 +0000 Subject: [PATCH] pan/bi: Set the sample ID for blend shader LD_TILE Use the explicit sample mode and set the sample ID in the pixel indices structure to the current sample ID. This fixes tilebuffer loads in blend shaders on multisampled framebuffers. Make sure the new routine is broken out to a helper for use with ST_TILE in the next commit. Signed-off-by: Alyssa Rosenzweig Cc: mesa-stable Part-of: (cherry picked from commit 16394dc71a4e78bfeb762ffd05f314b329c17f54) --- .pick_status.json | 2 +- src/panfrost/bifrost/bifrost_compile.c | 44 ++++++++++++++++++-------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 78faabe6ab0..f23a8d26deb 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -760,7 +760,7 @@ "description": "pan/bi: Set the sample ID for blend shader LD_TILE", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 457916591c6..1402e46a017 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -425,6 +425,36 @@ bi_load_sample_id_to(bi_builder *b, bi_index dst) bi_imm_u8(16)); } +static bi_index +bi_load_sample_id(bi_builder *b) +{ + bi_index sample_id = bi_temp(b->shader); + bi_load_sample_id_to(b, sample_id); + return sample_id; +} + +static bi_index +bi_pixel_indices(bi_builder *b, unsigned rt) +{ + /* We want to load the current pixel. */ + struct bifrost_pixel_indices pix = { + .y = BIFROST_CURRENT_PIXEL, + .rt = rt + }; + + uint32_t indices_u32 = 0; + memcpy(&indices_u32, &pix, sizeof(indices_u32)); + bi_index indices = bi_imm_u32(indices_u32); + + /* Sample index above is left as zero. For multisampling, we need to + * fill in the actual sample ID in the lower byte */ + + if (b->shader->inputs->blend.nr_samples > 1) + indices = bi_iadd_u32(b, indices, bi_load_sample_id(b), false); + + return indices; +} + static void bi_emit_load_blend_input(bi_builder *b, nir_intrinsic_instr *instr) { @@ -1013,23 +1043,11 @@ bi_emit_ld_tile(bi_builder *b, nir_intrinsic_instr *instr) rt = (loc - FRAG_RESULT_DATA0); } - /* We want to load the current pixel. - * FIXME: The sample to load is currently hardcoded to 0. This should - * be addressed for multi-sample FBs. - */ - struct bifrost_pixel_indices pix = { - .y = BIFROST_CURRENT_PIXEL, - .rt = rt - }; - bi_index desc = b->shader->inputs->is_blend ? bi_imm_u32(b->shader->inputs->blend.bifrost_blend_desc >> 32) : bi_load_sysval(b, PAN_SYSVAL(RT_CONVERSION, rt | (size << 4)), 1, 0); - uint32_t indices = 0; - memcpy(&indices, &pix, sizeof(indices)); - - bi_ld_tile_to(b, bi_dest_index(&instr->dest), bi_imm_u32(indices), + bi_ld_tile_to(b, bi_dest_index(&instr->dest), bi_pixel_indices(b, rt), bi_register(60), desc, (instr->num_components - 1)); }