From 46d2f2224fd6129aa44b8f34c593ad74520681fe Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Fri, 6 Nov 2020 09:20:42 +0100 Subject: [PATCH] zink: only add MESA WSI structs for specific devices Some drivers will drop warnings about seeing these structs in the pNext chain and not handling them. This change makes it so we only include the structs with Vulkan drivers that are known to require them for proper behavior (v3dv only for now) to avoid the warnings. It should be noted that here we are only supressing the messages from Zink. Since the Mesa Vulkan WSI code will include these structs, when native Vulkan Mesa drivers are used without Zink they might still dump these messages. Requested by Mike Blumenkrantz. Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/drivers/zink/zink_resource.c | 4 ++-- src/gallium/drivers/zink/zink_screen.c | 15 +++++++++++++++ src/gallium/drivers/zink/zink_screen.h | 3 +++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index dc7b6694b52..c2aaf0ccf34 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -233,7 +233,7 @@ resource_create(struct pipe_screen *pscreen, .scanout = true, }; - if (templ->bind & PIPE_BIND_SCANOUT) + if (screen->needs_mesa_wsi && (templ->bind & PIPE_BIND_SCANOUT)) ici.pNext = &image_wsi_info; VkResult result = vkCreateImage(screen->dev, &ici, NULL, &res->image); @@ -285,7 +285,7 @@ resource_create(struct pipe_screen *pscreen, NULL, }; - if (templ->bind & PIPE_BIND_SCANOUT) { + if (screen->needs_mesa_wsi && (templ->bind & PIPE_BIND_SCANOUT)) { memory_wsi_info.implicit_sync = true; memory_wsi_info.pNext = mai.pNext; diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 5ee02be415a..21cbca40cc4 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -1068,6 +1068,16 @@ zink_internal_setup_moltenvk(struct zink_screen *screen) } #endif // MVK_VERSION +static void +check_device_needs_mesa_wsi(struct zink_screen *screen) +{ + /* Raspberry Pi 4 V3DV driver */ + if (screen->info.props.vendorID == 0x14E4 && + screen->info.props.deviceID == 42) { + screen->needs_mesa_wsi = true; + } +} + static struct pipe_screen * zink_internal_create_screen(struct sw_winsys *winsys, int fd, const struct pipe_screen_config *config) { @@ -1100,6 +1110,11 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd, const struct pipe_ goto fail; } + /* Some Vulkan implementations have special requirements for WSI + * allocations. + */ + check_device_needs_mesa_wsi(screen); + #if defined(MVK_VERSION) zink_internal_setup_moltenvk(screen); #endif diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h index ed27159a234..d6ba712d6f3 100644 --- a/src/gallium/drivers/zink/zink_screen.h +++ b/src/gallium/drivers/zink/zink_screen.h @@ -67,6 +67,9 @@ struct zink_screen { uint32_t loader_version; bool have_physical_device_prop2_ext; bool have_debug_utils_ext; + + bool needs_mesa_wsi; + #if defined(MVK_VERSION) bool have_moltenvk; #endif