diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-05-23 04:45:31 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-05-23 04:45:31 +0000 |
commit | 1e3bb66f697283b6bd192f3a000d99d637624079 (patch) | |
tree | 4fa9dfc6051e601827bebd269cc82209e5ac2c56 /lib/mesa/src/vulkan | |
parent | 644b24d7fd4147e54e47ade73d21466d60f0082c (diff) |
Import Mesa 19.0.5
Diffstat (limited to 'lib/mesa/src/vulkan')
-rw-r--r-- | lib/mesa/src/vulkan/wsi/wsi_common.c | 30 | ||||
-rw-r--r-- | lib/mesa/src/vulkan/wsi/wsi_common_display.c | 32 |
2 files changed, 45 insertions, 17 deletions
diff --git a/lib/mesa/src/vulkan/wsi/wsi_common.c b/lib/mesa/src/vulkan/wsi/wsi_common.c index 58e252141..6e0bc7be6 100644 --- a/lib/mesa/src/vulkan/wsi/wsi_common.c +++ b/lib/mesa/src/vulkan/wsi/wsi_common.c @@ -278,8 +278,8 @@ wsi_create_native_image(const struct wsi_swapchain *chain, .sType = VK_STRUCTURE_TYPE_WSI_FORMAT_MODIFIER_PROPERTIES_LIST_MESA, .pNext = NULL, }; - VkFormatProperties2KHR format_props = { - .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR, + VkFormatProperties2 format_props = { + .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2, .pNext = &modifier_props_list, }; wsi->GetPhysicalDeviceFormatProperties2KHR(wsi->pdevice, @@ -379,13 +379,13 @@ wsi_create_native_image(const struct wsi_swapchain *chain, .pNext = NULL, .implicit_sync = true, }; - const VkExportMemoryAllocateInfoKHR memory_export_info = { - .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR, + const VkExportMemoryAllocateInfo memory_export_info = { + .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO, .pNext = &memory_wsi_info, .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, }; - const VkMemoryDedicatedAllocateInfoKHR memory_dedicated_info = { - .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR, + const VkMemoryDedicatedAllocateInfo memory_dedicated_info = { + .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, .pNext = &memory_export_info, .image = image->image, .buffer = VK_NULL_HANDLE, @@ -431,7 +431,7 @@ wsi_create_native_image(const struct wsi_swapchain *chain, for (uint32_t p = 0; p < image->num_planes; p++) { const VkImageSubresource image_subresource = { - .aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT_KHR << p, + .aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT << p, .mipLevel = 0, .arrayLayer = 0, }; @@ -504,8 +504,8 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, uint32_t linear_size = linear_stride * pCreateInfo->imageExtent.height; linear_size = align_u32(linear_size, 4096); - const VkExternalMemoryBufferCreateInfoKHR prime_buffer_external_info = { - .sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR, + const VkExternalMemoryBufferCreateInfo prime_buffer_external_info = { + .sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO, .pNext = NULL, .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, }; @@ -530,13 +530,13 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, .pNext = NULL, .implicit_sync = true, }; - const VkExportMemoryAllocateInfoKHR prime_memory_export_info = { - .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR, + const VkExportMemoryAllocateInfo prime_memory_export_info = { + .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO, .pNext = &memory_wsi_info, .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, }; - const VkMemoryDedicatedAllocateInfoKHR prime_memory_dedicated_info = { - .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR, + const VkMemoryDedicatedAllocateInfo prime_memory_dedicated_info = { + .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, .pNext = &prime_memory_export_info, .image = VK_NULL_HANDLE, .buffer = image->prime.buffer, @@ -585,8 +585,8 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, wsi->GetImageMemoryRequirements(chain->device, image->image, &reqs); - const VkMemoryDedicatedAllocateInfoKHR memory_dedicated_info = { - .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR, + const VkMemoryDedicatedAllocateInfo memory_dedicated_info = { + .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, .pNext = NULL, .image = image->image, .buffer = VK_NULL_HANDLE, diff --git a/lib/mesa/src/vulkan/wsi/wsi_common_display.c b/lib/mesa/src/vulkan/wsi/wsi_common_display.c index 856040b4f..ccde1e0e6 100644 --- a/lib/mesa/src/vulkan/wsi/wsi_common_display.c +++ b/lib/mesa/src/vulkan/wsi/wsi_common_display.c @@ -834,6 +834,7 @@ wsi_display_surface_get_capabilities(VkIcdSurfaceBase *surface_base, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | + VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; return VK_SUCCESS; @@ -959,8 +960,8 @@ static void wsi_display_destroy_buffer(struct wsi_display *wsi, uint32_t buffer) { - (void) drmIoctl(wsi->fd, DRM_IOCTL_MODE_DESTROY_DUMB, - &((struct drm_mode_destroy_dumb) { .handle = buffer })); + (void) drmIoctl(wsi->fd, DRM_IOCTL_GEM_CLOSE, + &((struct drm_gem_close) { .handle = buffer })); } static VkResult @@ -1797,6 +1798,30 @@ fail_attr_init: return ret; } + +/* + * Local version fo the libdrm helper. Added to avoid depending on bleeding + * edge version of the library. + */ +static int +local_drmIsMaster(int fd) +{ + /* Detect master by attempting something that requires master. + * + * Authenticating magic tokens requires master and 0 is an + * internal kernel detail which we could use. Attempting this on + * a master fd would fail therefore fail with EINVAL because 0 + * is invalid. + * + * A non-master fd will fail with EACCES, as the kernel checks + * for master before attempting to do anything else. + * + * Since we don't want to leak implementation details, use + * EACCES. + */ + return drmAuthMagic(fd, 0) != -EACCES; +} + VkResult wsi_display_init_wsi(struct wsi_device *wsi_device, const VkAllocationCallbacks *alloc, @@ -1812,6 +1837,9 @@ wsi_display_init_wsi(struct wsi_device *wsi_device, } wsi->fd = display_fd; + if (wsi->fd != -1 && !local_drmIsMaster(wsi->fd)) + wsi->fd = -1; + wsi->alloc = alloc; list_inithead(&wsi->connectors); |