Mesa (staging/22.0): llvmpipe: fix nr_sampler_view in key creation.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 17:52:04 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: 5cb25e4e94b5de1cb14d0a639ff17a0d886c4055
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5cb25e4e94b5de1cb14d0a639ff17a0d886c4055

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Mar 28 09:20:27 2022 +1000

llvmpipe: fix nr_sampler_view in key creation.

This was doing MAX2() but nr_sampler_views hasn't been initialised
yet.

Fixes: 690cc3bb803a ("llvmpipe: overhaul fs/cs variant keys to be simpler.")

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Reviewed-by: Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15603>
(cherry picked from commit dcadeb9a4778b12447dd5c37c80731df1fb1d78f)

---

 .pick_status.json                          | 2 +-
 src/gallium/drivers/llvmpipe/lp_state_cs.c | 3 ++-
 src/gallium/drivers/llvmpipe/lp_state_cs.h | 2 +-
 src/gallium/drivers/llvmpipe/lp_state_fs.c | 4 +++-
 src/gallium/drivers/llvmpipe/lp_state_fs.h | 2 +-
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index e8f042e0692..acafbdb13e7 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -6380,7 +6380,7 @@
         "description": "llvmpipe: fix nr_sampler_view in key creation.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 5,
+        "resolution": 1,
         "because_sha": "690cc3bb803a933c86a2f6f975e9f49b6edfd7a9"
     },
     {
diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c
index df7d440d4da..97f245a2075 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_cs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c
@@ -584,6 +584,8 @@ make_variant_key(struct llvmpipe_context *lp,
     */
    key->nr_samplers = shader->info.base.file_max[TGSI_FILE_SAMPLER] + 1;
 
+   if (shader->info.base.file_max[TGSI_FILE_SAMPLER_VIEW] != -1)
+      key->nr_sampler_views = shader->info.base.file_max[TGSI_FILE_SAMPLER_VIEW] + 1;
    struct lp_sampler_static_state *cs_sampler;
 
    cs_sampler = lp_cs_variant_key_samplers(key);
@@ -602,7 +604,6 @@ make_variant_key(struct llvmpipe_context *lp,
     * if we want to skip the holes here (without rescanning tgsi).
     */
    if (shader->info.base.file_max[TGSI_FILE_SAMPLER_VIEW] != -1) {
-      key->nr_sampler_views = shader->info.base.file_max[TGSI_FILE_SAMPLER_VIEW] + 1;
       for(i = 0; i < key->nr_sampler_views; ++i) {
          /*
           * Note sview may exceed what's representable by file_mask.
diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.h b/src/gallium/drivers/llvmpipe/lp_state_cs.h
index 8b578424b44..65682167280 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_cs.h
+++ b/src/gallium/drivers/llvmpipe/lp_state_cs.h
@@ -67,7 +67,7 @@ static inline struct lp_image_static_state *
 lp_cs_variant_key_images(const struct lp_compute_shader_variant_key *key)
 {
    return (struct lp_image_static_state *)
-      &(lp_cs_variant_key_samplers(key)[key->nr_samplers]);
+      &(lp_cs_variant_key_samplers(key)[MAX2(key->nr_samplers, key->nr_sampler_views)]);
 }
 
 struct lp_cs_variant_list_item
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 36386efbf49..90d03a34581 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -4299,6 +4299,9 @@ make_variant_key(struct llvmpipe_context *lp,
     */
    key->nr_samplers = shader->info.base.file_max[TGSI_FILE_SAMPLER] + 1;
 
+   if (shader->info.base.file_max[TGSI_FILE_SAMPLER_VIEW] != -1)
+      key->nr_sampler_views = shader->info.base.file_max[TGSI_FILE_SAMPLER_VIEW] + 1;
+
    struct lp_sampler_static_state *fs_sampler;
 
    fs_sampler = lp_fs_variant_key_samplers(key);
@@ -4318,7 +4321,6 @@ make_variant_key(struct llvmpipe_context *lp,
     * if we want to skip the holes here (without rescanning tgsi).
     */
    if (shader->info.base.file_max[TGSI_FILE_SAMPLER_VIEW] != -1) {
-      key->nr_sampler_views = shader->info.base.file_max[TGSI_FILE_SAMPLER_VIEW] + 1;
       for(i = 0; i < key->nr_sampler_views; ++i) {
          /*
           * Note sview may exceed what's representable by file_mask.
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.h b/src/gallium/drivers/llvmpipe/lp_state_fs.h
index f88ef70dbd2..71f377303f7 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.h
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.h
@@ -145,7 +145,7 @@ static inline struct lp_image_static_state *
 lp_fs_variant_key_images(struct lp_fragment_shader_variant_key *key)
 {
    return (struct lp_image_static_state *)
-      &(lp_fs_variant_key_samplers(key)[key->nr_samplers]);
+      &(lp_fs_variant_key_samplers(key)[MAX2(key->nr_samplers, key->nr_sampler_views)]);
 }
 
 /** doubly-linked list item */



More information about the mesa-commit mailing list