Module: Mesa Branch: main Commit: 685bd95de9187faa8e17115f48dbe5456ef310ec URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=685bd95de9187faa8e17115f48dbe5456ef310ec
Author: Mike Blumenkrantz <[email protected]> Date: Mon Feb 20 08:51:31 2023 -0500 zink: move db input attachment size check to screen init 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 | 1 - src/gallium/drivers/zink/zink_screen.c | 4 ++++ src/gallium/drivers/zink/zink_types.h | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index bf5ac2f9332..489b72288cc 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -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; diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 9e68faf8baf..d4689138c30 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -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) { diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 2aa87c95d6e..c0025b74700 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -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;
