zink: add VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA for WSI allocations
Since Zink doesn't use swapchains to create presentable images, drivers lose the capacity to identify memory allocations for them, which is a problem when the underlying platform has special requirements for these, such as needing to allocate them on a particular device. Including this struct in the pNext chain, which is the same thing that the Mesa Vulkan WSI code does when allocating memory for swapchain images, gives drivers a chance to identify and handle these memory allocations properly. v2: follow Zink's conventions for pNext chains (Mike) v3: add scanout parameter for VkImage creation (Daniel) v4: don't add a dependency on vulkan util (Erik) v5: include vulkan directory for Zink builds Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> (v2) Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7378>
This commit is contained in:
parent
98ebffc9f3
commit
92022f2846
|
@ -64,7 +64,7 @@ libzink = static_library(
|
|||
'zink',
|
||||
[files_libzink, zink_device_info, zink_nir_algebraic_c],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
|
||||
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_vulkan_wsi, inc_vulkan_util],
|
||||
dependencies: [dep_vulkan, idep_nir_headers],
|
||||
)
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "zink_context.h"
|
||||
#include "zink_screen.h"
|
||||
|
||||
#include "vulkan/wsi/wsi_common.h"
|
||||
|
||||
#include "util/slab.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/format/u_format.h"
|
||||
|
@ -225,6 +227,15 @@ resource_create(struct pipe_screen *pscreen,
|
|||
ici.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
res->layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
|
||||
struct wsi_image_create_info image_wsi_info = {
|
||||
VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA,
|
||||
NULL,
|
||||
.scanout = true,
|
||||
};
|
||||
|
||||
if (templ->bind & PIPE_BIND_SCANOUT)
|
||||
ici.pNext = &image_wsi_info;
|
||||
|
||||
VkResult result = vkCreateImage(screen->dev, &ici, NULL, &res->image);
|
||||
if (result != VK_SUCCESS) {
|
||||
FREE(res);
|
||||
|
@ -250,6 +261,8 @@ resource_create(struct pipe_screen *pscreen,
|
|||
if (templ->bind & PIPE_BIND_SHARED) {
|
||||
emai.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO;
|
||||
emai.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
|
||||
|
||||
emai.pNext = mai.pNext;
|
||||
mai.pNext = &emai;
|
||||
}
|
||||
|
||||
|
@ -263,7 +276,20 @@ resource_create(struct pipe_screen *pscreen,
|
|||
imfi.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
|
||||
imfi.fd = whandle->handle;
|
||||
|
||||
emai.pNext = &imfi;
|
||||
imfi.pNext = mai.pNext;
|
||||
mai.pNext = &imfi;
|
||||
}
|
||||
|
||||
struct wsi_memory_allocate_info memory_wsi_info = {
|
||||
VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA,
|
||||
NULL,
|
||||
};
|
||||
|
||||
if (templ->bind & PIPE_BIND_SCANOUT) {
|
||||
memory_wsi_info.implicit_sync = true;
|
||||
|
||||
memory_wsi_info.pNext = mai.pNext;
|
||||
mai.pNext = &memory_wsi_info;
|
||||
}
|
||||
|
||||
if (vkAllocateMemory(screen->dev, &mai, NULL, &res->mem) != VK_SUCCESS)
|
||||
|
|
|
@ -67,7 +67,7 @@ endif
|
|||
if with_platform_wayland
|
||||
subdir('egl/wayland/wayland-drm')
|
||||
endif
|
||||
if with_any_vk
|
||||
if with_any_vk or with_gallium_zink
|
||||
subdir('vulkan')
|
||||
endif
|
||||
if with_gallium_radeonsi or with_amd_vk
|
||||
|
|
|
@ -22,6 +22,7 @@ vk_api_xml = files('registry/vk.xml')
|
|||
vulkan_icd_symbols = files('vulkan-icd-symbols.txt')
|
||||
|
||||
inc_vulkan_wsi = include_directories('wsi')
|
||||
inc_vulkan_util = include_directories('util')
|
||||
|
||||
vulkan_wsi_args = []
|
||||
vulkan_wsi_deps = []
|
||||
|
|
Loading…
Reference in New Issue