Mesa (staging/21.2): pan/bi: Set the sample ID for blend shader LD_TILE

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 23 17:44:11 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: 286135613f02dd76727dfa15c195ce731163ad66
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=286135613f02dd76727dfa15c195ce731163ad66

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Wed Aug 18 22:08:31 2021 +0000

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 <alyssa at collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12478>
(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 d57aef204b0..06bb411a09f 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -283,7 +283,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));
 }
 



More information about the mesa-commit mailing list