Is it safe to use a sampler2DArray to sample from a 2D image with 1 layer and VK_IMAGE_VIEW_TYPE_2D image view, using vec3(s, t, 0) ? It seems to be working locally but I don’t know if it’s undefined behavior/implementation dependent and I’d have to use sampler2D. I haven’t been able to find a definite answer.
You can create a view of a 2D image that is a 1-layer 2D array view. But you can’t use a 2D non-array view through an array sampler/descriptor. It doesn’t even work on the SPIR-V level, as the sampling instruction needs to state if the instruction is arrayed or not.
I assume the validation layers should have complained over this.
Ah yes you’re right, I am getting some complaints that I have missed.
the descriptor VkDescriptorSet 0x46ca6400000026d9 [Set 0, Binding 10, Index 0] ImageView type is VK_IMAGE_VIEW_TYPE_2D but the OpTypeImage has (Dim = 2D) and (Arrayed = 1).
The Vulkan spec states: If a VkImageView is accessed as a result of this command, then the image view’s viewType must match the Dim operand of the OpTypeImage as described in Compatibility Between SPIR-V Image Dimensions and Vulkan ImageView Types
(Vulkan® 1.4.304 - A Specification (with all registered extensions))
This must be it then. Thank you!