[Mesa-dev] [RFC v2 19/23] RFC: anv/wsi: Use VK_MESAX_external_image_dma_buf
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Thu Aug 31 04:24:31 UTC 2017
From: Chad Versace <chadversary at chromium.org>
When creating a VkSurface for X11, we created the underlying VkImage by
calling anv_image_create() and passing driver-private info to it. We can
now accomplish the same thing without driver-private info, using VK_MESAX_external_image_dma_buf.
In anv_wsi.c, replace the combo of
anv_image_create() + struct anv_image_create_info
with
anv_CreateImage() + VkExportImageDmaBufInfoMESAX
No intended change in behavior.
---
src/intel/Makefile.vulkan.am | 3 ---
src/intel/vulkan/anv_formats.c | 6 ++++--
src/intel/vulkan/anv_image.c | 5 +++--
src/intel/vulkan/anv_wsi.c | 19 +++++++++++++------
4 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/src/intel/Makefile.vulkan.am b/src/intel/Makefile.vulkan.am
index fa9b6ba724..0b5bfe9870 100644
--- a/src/intel/Makefile.vulkan.am
+++ b/src/intel/Makefile.vulkan.am
@@ -65,9 +65,6 @@ noinst_HEADERS += \
$(top_srcdir)/include/vulkan/vk_platform.h \
$(top_srcdir)/include/vulkan/vulkan.h
-vulkan_include_HEADERS = \
- $(top_srcdir)/include/vulkan/vulkan_intel.h
-
lib_LTLIBRARIES += vulkan/libvulkan_intel.la
check_LTLIBRARIES += vulkan/libvulkan-test.la
diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 64cbe69718..46792e8844 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -476,7 +476,8 @@ get_dma_buf_format_props(struct anv_physical_device *phys_dev,
&props->modifierCount);
VkFormatFeatureFlags image_features = 0;
- if (vk_format == VK_FORMAT_R8G8B8A8_UNORM) {
+ if (vk_format == VK_FORMAT_R8G8B8A8_UNORM ||
+ vk_format == VK_FORMAT_B8G8R8A8_UNORM) {
/* FINISHME: Support more formats for dma_buf images. */
/* For dma_buf images, we must use the exact format provided by the
@@ -764,7 +765,8 @@ get_dma_buf_image_format_props(struct anv_physical_device *phys_dev,
"VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
}
- if (base_info->format != VK_FORMAT_R8G8B8A8_UNORM) {
+ if (base_info->format != VK_FORMAT_R8G8B8A8_UNORM &&
+ base_info->format != VK_FORMAT_B8G8R8A8_UNORM) {
/* FINISHME: Support more formats for dma_buf images. */
return vk_errorf(VK_ERROR_FORMAT_NOT_SUPPORTED,
"dma_buf images do not support VkFormat 0x%x",
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 1f8e5a208d..241b7c9fe0 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -661,8 +661,9 @@ get_image_dma_buf_props(const struct anv_image *image,
&dma_buf_props->planeCount);
bool ok UNUSED;
- /* For now, we support exactly one format for dma_buf images. */
- assert(image->vk_format == VK_FORMAT_R8G8B8A8_UNORM);
+ /* For now, we support exactly two formats for dma_buf images. */
+ assert(image->vk_format == VK_FORMAT_R8G8B8A8_UNORM ||
+ image->vk_format == VK_FORMAT_B8G8R8A8_UNORM);
/* For now, We don't support dma_buf images with auxiliary surfaces. */
assert(image->aux_surface.isl.size == 0);
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index b86e4f1b4a..8f01f62e8a 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -185,11 +185,7 @@ anv_wsi_image_create(VkDevice device_h,
struct anv_image *image;
VkResult result;
- result = anv_image_create(anv_device_to_handle(device),
- &(struct anv_image_create_info) {
- .isl_tiling_flags = ISL_TILING_X_BIT,
- .stride = 0,
- .vk_info =
+ result = anv_CreateImage(anv_device_to_handle(device),
&(VkImageCreateInfo) {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.imageType = VK_IMAGE_TYPE_2D,
@@ -207,7 +203,18 @@ anv_wsi_image_create(VkDevice device_h,
.usage = (pCreateInfo->imageUsage |
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT),
.flags = 0,
- }},
+ .pNext =
+ &(VkExternalMemoryImageCreateInfoKHR) {
+ .sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR,
+ .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_MESAX,
+ .pNext =
+ &(VkExportImageDmaBufInfoMESAX) {
+ .sType = VK_STRUCTURE_TYPE_EXPORT_IMAGE_DMA_BUF_INFO_MESAX,
+ .drmFormatModifierCount = 1,
+ .pDrmFormatModifiers = (uint64_t[]) {
+ I915_FORMAT_MOD_X_TILED,
+ },
+ }}},
NULL,
&image_h);
if (result != VK_SUCCESS)
--
2.13.0
More information about the mesa-dev
mailing list