zink: move db input attachment size check to screen init
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 20 Feb 2023 13:51:31 +0000 (08:51 -0500)
committerMarge Bot <emma+marge@anholt.net>
Wed, 22 Feb 2023 02:58:19 +0000 (02:58 +0000)
it'd be weird to crash later on after allowing db mode to init

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21398>

src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_screen.c
src/gallium/drivers/zink/zink_types.h

index bf5ac2f..489b722 100644 (file)
@@ -5220,7 +5220,6 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
          }
       }
       if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) {
-         assert(sizeof(ctx->di.fbfetch_db) <= screen->info.db_props.inputAttachmentDescriptorSize);
          /* cache null fbfetch descriptor info */
          ctx->di.fbfetch.imageView = zink_get_dummy_surface(ctx, 0)->image_view;
          ctx->di.fbfetch.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
index 9e68faf..d468913 100644 (file)
@@ -2905,6 +2905,10 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
          mesa_loge("Cannot use db descriptor mode without robustness2.nullDescriptor");
          goto fail;
       }
+      if (ZINK_FBFETCH_DESCRIPTOR_SIZE < screen->info.db_props.inputAttachmentDescriptorSize) {
+         mesa_loge("Cannot use db descriptor mode with inputAttachmentDescriptorSize(%u) > %u", (unsigned)screen->info.db_props.inputAttachmentDescriptorSize, ZINK_FBFETCH_DESCRIPTOR_SIZE);
+         goto fail;
+      }
       if (screen->compact_descriptors) {
          /* TODO: bindless */
          if (screen->info.db_props.maxDescriptorBufferBindings < 3) {
index 2aa87c9..c0025b7 100644 (file)
@@ -79,6 +79,8 @@
 /* enum zink_descriptor_type */
 #define ZINK_MAX_DESCRIPTOR_SETS 6
 #define ZINK_MAX_DESCRIPTORS_PER_TYPE (32 * ZINK_GFX_SHADER_COUNT)
+/* max size from gpuinfo */
+#define ZINK_FBFETCH_DESCRIPTOR_SIZE 64
 
 /* suballocator defines */
 #define NUM_SLAB_ALLOCATORS 3
@@ -1775,7 +1777,7 @@ struct zink_context {
       };
 
       VkDescriptorImageInfo fbfetch;
-      uint8_t fbfetch_db[64]; //max size from gpuinfo
+      uint8_t fbfetch_db[ZINK_FBFETCH_DESCRIPTOR_SIZE];
 
       /* the current state of the shadow swizzle data */
       struct zink_fs_shadow_key shadow;