Vulkan Compute Shader, writing to an Image 2D / alignment

Im trying to write to an 2D Image, which consists only of 1 float component. Just to see if it works. I made the observation, that when the width and height are either 16, 32, 64 everything is in its row / column.

here for example I’m using width=height=16:

Row: 0 0,1,2,3,0,0,0,0,8,0,0,0,0,0,0,0,
Row: 1 0,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,
Row: 2 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Row: 3 0,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,

when I’m using width=height=10 the alignment is kinda out of control:
(I would have expected the “1,2,3” in Row 1 at the same place like in Row 0)

Row: 0 0,1,2,3,0,0,0,0,8,0,
Row: 1 0,0,0,0,0,0,0,1,2,3,

My Question:
Do I have to do any transforms like VkImageBarrier to transform the image/memory in a form that I can use width,height different from 2^n? I’ve looked through the Vulkan Spec, but didn’t find anything about it.

My compute shader:

#version 450 core

layout(local_size_x = 16, local_size_y = 16) in;
layout(r32f, binding = 0) uniform image2D inStorage;

void main(void)
    imageStore(inStorage, ivec2(1,0), vec4(1));
    imageStore(inStorage, ivec2(2,0), vec4(2));
    imageStore(inStorage, ivec2(3,0), vec4(3));
    imageStore(inStorage, ivec2(8,0), vec4(8));

    imageStore(inStorage, ivec2(1,1), vec4(1));
    imageStore(inStorage, ivec2(2,1), vec4(2));
    imageStore(inStorage, ivec2(3,1), vec4(3));

    imageStore(inStorage, ivec2(1,3), vec4(1));
    imageStore(inStorage, ivec2(2,3), vec4(2));
    imageStore(inStorage, ivec2(3,3), vec4(3));

Im mapping the memory in this way:

res = vkMapMemory(m_device, m_imageStorage.memory, memoryOffset, VK_WHOLE_SIZE, 0, reinterpret_cast<void**>(&m_pImageStorageData));

I’m assuming you are correctly transitioning the image to linear layout before reading it back, otherwise all bets are off anyway.
Images can (and often do) contain padding to align pixel rows. To find out the organization of pixel rows in your image see vkGetImageSubresourceLayout and the VkSubresourceLayout struct it populates, specifically the rowPitch member.

Thank you for your answer. I didn’t transition the image, but I created it with .tiling = VK_IMAGE_TILING_LINEAR in VkImageCreateInfo. It seemed to be ok, and the validation layers didn’t show any error or warning.

To query VkSubresourceLayout worked for my situation.