+ /* Multiple planes are not supported. 2 requirements should be enough but use 4 for robustness. */ + VkSparseImageMemoryRequirements sparse_requirements_array[4];
This doesn't seem all that robust. In particular, I don't think there's anything in the spec putting an upper bound on the number of requirements returned, or anything preventing (future) extensions from increasing that.
+ for (i = 0; i < requirement_count; ++i) + { + if (!(sparse_requirements_array[i].formatProperties.aspectMask & VK_IMAGE_ASPECT_METADATA_BIT)) + { + sparse_requirements = sparse_requirements_array[i]; + break; + } + }
Somewhat similarly, we seem to be making assumptions here about the possible aspect mask bits.