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

Fredrik Höglund fredrik at kde.org
Fri Dec 22 01:51:44 UTC 2017


On Thursday 21 December 2017, Topi Pohjolainen wrote:
> 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,
> +	};

You also need to include a VkPhysicalDeviceExternalImageFormatInfoKHR
struct in pNext here.

> +	VkImageFormatProperties2KHR props = {
> +		.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR
> +	};

And a VkExternalImageFormatPropertiesKHR struct here.

This function should only return true if
externalMemoryProperties.externalMemoryFeatures has
VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHR set.

The features to check for should probably be passed in a parameter though.

> +	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,
> 



More information about the Piglit mailing list