Mesa (main): zink: clamp max shader images to 32

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 18 18:08:18 UTC 2022


Module: Mesa
Branch: main
Commit: d275d6c32f672ba1fcbcb8c4cb1a6719a56b507d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d275d6c32f672ba1fcbcb8c4cb1a6719a56b507d

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Sat Apr 16 12:16:14 2022 -0400

zink: clamp max shader images to 32

NO MATTER WHAT.

Acked-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16013>

---

 src/gallium/drivers/zink/zink_compiler.c |  4 ++--
 src/gallium/drivers/zink/zink_context.h  | 10 +++++-----
 src/gallium/drivers/zink/zink_screen.c   |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index 08a86d629c2..7ded9703604 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -1749,8 +1749,8 @@ zink_binding(gl_shader_stage stage, VkDescriptorType type, int index)
 
       case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
       case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
-         assert(index < PIPE_MAX_SHADER_IMAGES);
-         return (stage * PIPE_MAX_SHADER_IMAGES) + index;
+         assert(index < ZINK_MAX_SHADER_IMAGES);
+         return (stage * ZINK_MAX_SHADER_IMAGES) + index;
 
       default:
          unreachable("unexpected type");
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index 18b6f688354..2f9c2fb6038 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -29,7 +29,7 @@
 
 #define ZINK_DEFAULT_MAX_DESCS 5000
 #define ZINK_DEFAULT_DESC_CLAMP (ZINK_DEFAULT_MAX_DESCS * 0.9)
-
+#define ZINK_MAX_SHADER_IMAGES 32
 #define ZINK_MAX_BINDLESS_HANDLES 1024
 
 #include "zink_clear.h"
@@ -213,7 +213,7 @@ struct zink_context {
    struct pipe_constant_buffer ubos[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
    struct pipe_shader_buffer ssbos[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
    uint32_t writable_ssbos[PIPE_SHADER_TYPES];
-   struct zink_image_view image_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
+   struct zink_image_view image_views[PIPE_SHADER_TYPES][ZINK_MAX_SHADER_IMAGES];
 
    struct pipe_framebuffer_state fb_state;
    struct zink_framebuffer *(*get_framebuffer)(struct zink_context*);
@@ -329,15 +329,15 @@ struct zink_context {
       uint8_t num_samplers[PIPE_SHADER_TYPES];
       uint8_t num_sampler_views[PIPE_SHADER_TYPES];
 
-      VkDescriptorImageInfo images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
-      VkBufferView texel_images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
+      VkDescriptorImageInfo images[PIPE_SHADER_TYPES][ZINK_MAX_SHADER_IMAGES];
+      VkBufferView texel_images[PIPE_SHADER_TYPES][ZINK_MAX_SHADER_IMAGES];
       uint8_t num_images[PIPE_SHADER_TYPES];
 
       VkDescriptorImageInfo fbfetch;
 
       struct zink_resource *descriptor_res[ZINK_DESCRIPTOR_TYPES][PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
       struct zink_descriptor_surface sampler_surfaces[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
-      struct zink_descriptor_surface image_surfaces[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
+      struct zink_descriptor_surface image_surfaces[PIPE_SHADER_TYPES][ZINK_MAX_SHADER_IMAGES];
 
       struct {
          struct util_idalloc tex_slots;
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index d87d2f40207..6d9aea21cfa 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -1015,7 +1015,7 @@ zink_get_shader_param(struct pipe_screen *pscreen,
       if (screen->info.feats.features.shaderStorageImageExtendedFormats &&
           screen->info.feats.features.shaderStorageImageWriteWithoutFormat)
          return MIN2(screen->info.props.limits.maxPerStageDescriptorStorageImages,
-                     PIPE_MAX_SHADER_IMAGES);
+                     ZINK_MAX_SHADER_IMAGES);
       return 0;
 
    case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD:



More information about the mesa-commit mailing list