Search code examples
transitionvulkan

vulkan - why a transition command needs an old layout information


Why an old layout information is needed for setting a new layout for an image.

As far as I understand, when setting an image layout, it became in specific memory arrangement tend for optimal need. So the new layout is not dependent on what was before. A memory layout for transfer reading (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) is always the same and it doesn't matter what layout was before, isn't it?

But even if the old layout information is needed for transition operation (because of some reason) - still, GPU hardware/driver knows the electronics circuits condition (memory layout in this case), so why do we need to give it an information it knows ?


Solution

  • A memory layout for transfer reading (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) is always the same and it doesn't matter what layout was before, isn't it?

    It does, if you want to convert it from the previous layout without losing the data. Otherwisely you indeed can use oldLayout=VK_IMAGE_LAYOUT_UNDEFINED.

    still, GPU hardware/driver knows the electronics circuits condition (memory layout in this case)

    It's not "electronic circuit". Potentially it's just a haystack of bits in RAM.

    Anyway. One paradigm of Vulkan is that it tries not to enforce memoization. Specifically it will often not remember state that is not part of vkCreate*. I think there is some functional programming influence...