Slightly modified from https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#_sample_code_2