Writing into a Vulkan external image from another API (CUDA)

Hi,
I created an external image in vulkan and am trying to write directly into its memory using Cuda.
The first issue that I noticed is that the image is not in the right tiling layout. So instead, I used VK_IMAGE_TILING_LINEAR and the image seems to be in the right layout.

Now, the issue that I am facing, is that the image does not seem to have the right stride. For some reason, it only looks right when the width of the image is divisible by 8, otherwise, the lines don’t align with each other and the whole image looks skewed as if the real width of the image is different than the provided value.

A naive solution that comes to mind is to align the width of the image to be a multiple of 8. But this value could be different on other hardware or other implementations.

Is there a way to force the real width of the external image?

Thanks in advance.

1 Like

I just found this alignment value in VkMemoryRequirements that I’m getting with vkGetImageMemoryRequirements that is equal to 128. I think this corresponds to 8*sizeof(vec4).

Can someone confirm my theory, please?

Take a look at VkSubresourceLayout and the function to query it: vkGetImageSubresourceLayout.

This is exactly what I was looking for. Thank you very much.