[Piglit] [v4 10/11] ext_memory_object: Add helper for image type support
Topi Pohjolainen
topi.pohjolainen at gmail.com
Fri Dec 22 10:28:44 UTC 2017
v2:
- use VkPhysicalDeviceExternalImageFormatInfoKHR (Fredrik)
- use VkExternalImageFormatPropertiesKHR and check for
VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHR (Fredrik)
- pass usage, handle type and the expected feature as args
(Fredrik)
CC: Fredrik Hoeglund <fredrik at kde.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
tests/spec/ext_memory_object/common.c | 39 ++++++++++++++++++++++++++++++++
tests/spec/ext_memory_object/common.h | 7 ++++++
tests/spec/ext_memory_object/vk_common.c | 15 ++++++++++++
tests/spec/ext_memory_object/vk_common.h | 3 +++
4 files changed, 64 insertions(+)
diff --git a/tests/spec/ext_memory_object/common.c b/tests/spec/ext_memory_object/common.c
index b07a8fcb0..246260fae 100644
--- a/tests/spec/ext_memory_object/common.c
+++ b/tests/spec/ext_memory_object/common.c
@@ -141,3 +141,42 @@ create_tex_from_vk_dev_mem(const struct tex_layout *layout,
assert(!"Invalid target");
}
}
+
+bool
+is_layout_supported(struct vk_core *core,
+ const struct vk_image_layout *layout,
+ VkImageUsageFlagBits usage,
+ VkExternalMemoryHandleTypeFlagBitsKHR handle_type,
+ VkExternalMemoryFeatureFlagBitsKHR feature_needed)
+{
+ const VkPhysicalDeviceExternalImageFormatInfoKHR ext_format_info = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHR,
+ .handleType = handle_type
+ };
+ const VkPhysicalDeviceImageFormatInfo2KHR info = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR,
+ .pNext = &ext_format_info,
+ .format = layout->src_format,
+ .type = vk_get_image_type(layout->h, layout->z),
+ .tiling = layout->src_tiling,
+ .usage = usage,
+ };
+ VkExternalImageFormatPropertiesKHR ext_img_prop = {
+ .sType = VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR
+ };
+ VkImageFormatProperties2KHR props = {
+ .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR,
+ .pNext = &ext_img_prop,
+ };
+ PFN_vkGetPhysicalDeviceImageFormatProperties2KHR
+ vk_phys_dev_img_fmt_prop_2_khr =
+ vk_get_proc_addr_for_phys_dev_image_format_prop(
+ core->dev);
+
+ if (vk_phys_dev_img_fmt_prop_2_khr(
+ core->phys_dev, &info, &props) != VK_SUCCESS)
+ return false;
+
+ return ext_img_prop.externalMemoryProperties.externalMemoryFeatures &
+ feature_needed;
+}
diff --git a/tests/spec/ext_memory_object/common.h b/tests/spec/ext_memory_object/common.h
index 240c305e8..993e225b9 100644
--- a/tests/spec/ext_memory_object/common.h
+++ b/tests/spec/ext_memory_object/common.h
@@ -44,4 +44,11 @@ void
create_tex_from_vk_dev_mem(const struct tex_layout *layout,
GLuint mem_obj, unsigned offset, GLuint *tex);
+bool
+is_layout_supported(struct vk_core *core,
+ const struct vk_image_layout *layout,
+ VkImageUsageFlagBits usage,
+ VkExternalMemoryHandleTypeFlagBitsKHR handle_type,
+ VkExternalMemoryFeatureFlagBitsKHR feature_needed);
+
#endif
diff --git a/tests/spec/ext_memory_object/vk_common.c b/tests/spec/ext_memory_object/vk_common.c
index f8dea7b6e..5d32d850d 100644
--- a/tests/spec/ext_memory_object/vk_common.c
+++ b/tests/spec/ext_memory_object/vk_common.c
@@ -598,6 +598,21 @@ vk_get_proc_addr_for_mem_fd(VkDevice dev)
return get_fd;
}
+PFN_vkGetPhysicalDeviceImageFormatProperties2KHR
+vk_get_proc_addr_for_phys_dev_image_format_prop(VkDevice dev)
+{
+ static PFN_vkGetPhysicalDeviceImageFormatProperties2KHR
+ get_prop = NULL;
+
+ if (get_prop == NULL)
+ get_prop = (PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)
+ vkGetDeviceProcAddr(
+ dev,
+ "vkGetPhysicalDeviceImageFormatProperties2KHR");
+
+ return get_prop;
+}
+
void
vk_create_simple_pipeline(struct vk_core *core,
const struct vk_image_layout *layout,
diff --git a/tests/spec/ext_memory_object/vk_common.h b/tests/spec/ext_memory_object/vk_common.h
index 0efccf37a..3f1e70255 100644
--- a/tests/spec/ext_memory_object/vk_common.h
+++ b/tests/spec/ext_memory_object/vk_common.h
@@ -160,6 +160,9 @@ vk_get_proc_addr_for_image_mem_req(VkDevice dev);
PFN_vkGetMemoryFdKHR
vk_get_proc_addr_for_mem_fd(VkDevice dev);
+PFN_vkGetPhysicalDeviceImageFormatProperties2KHR
+vk_get_proc_addr_for_phys_dev_image_format_prop(VkDevice dev);
+
void
vk_create_simple_pipeline(struct vk_core *core,
const struct vk_image_layout *layout,
--
2.14.1
More information about the Piglit
mailing list