[Piglit] [v3 10/11] ext_memory_object: Add helper for image type support

Topi Pohjolainen topi.pohjolainen at gmail.com
Thu Dec 21 12:02:53 UTC 2017


CC: Fredrik Hoeglund <fredrik at kde.org>

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 tests/spec/ext_memory_object/common.c    | 24 ++++++++++++++++++++++++
 tests/spec/ext_memory_object/common.h    |  4 ++++
 tests/spec/ext_memory_object/vk_common.c | 15 +++++++++++++++
 tests/spec/ext_memory_object/vk_common.h |  3 +++
 4 files changed, 46 insertions(+)

diff --git a/tests/spec/ext_memory_object/common.c b/tests/spec/ext_memory_object/common.c
index 2a7c0ba31..709f1c132 100644
--- a/tests/spec/ext_memory_object/common.c
+++ b/tests/spec/ext_memory_object/common.c
@@ -141,3 +141,27 @@ 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)
+{
+	const VkPhysicalDeviceImageFormatInfo2KHR info = {
+		.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR,
+		.format = layout->src_format,
+		.type = vk_get_image_type(layout->h, layout->z),
+		.tiling = layout->src_tiling,
+		.usage = VK_IMAGE_USAGE_SAMPLED_BIT |
+			 VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
+	};
+	VkImageFormatProperties2KHR props = {
+		.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR
+	};
+	PFN_vkGetPhysicalDeviceImageFormatProperties2KHR
+		vk_phys_dev_img_fmt_prop_2_khr =
+			vk_get_proc_addr_for_phys_dev_image_format_prop(
+				core->dev);
+
+	return vk_phys_dev_img_fmt_prop_2_khr(
+			core->phys_dev, &info, &props) == VK_SUCCESS;
+}
diff --git a/tests/spec/ext_memory_object/common.h b/tests/spec/ext_memory_object/common.h
index 240c305e8..dac536377 100644
--- a/tests/spec/ext_memory_object/common.h
+++ b/tests/spec/ext_memory_object/common.h
@@ -44,4 +44,8 @@ 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);
+
 #endif
diff --git a/tests/spec/ext_memory_object/vk_common.c b/tests/spec/ext_memory_object/vk_common.c
index ba12bff07..48b33006e 100644
--- a/tests/spec/ext_memory_object/vk_common.c
+++ b/tests/spec/ext_memory_object/vk_common.c
@@ -596,6 +596,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