diff --git a/src/Magnum/Vk/Test/ImageVkTest.cpp b/src/Magnum/Vk/Test/ImageVkTest.cpp index 8cc5bd5fc..f28993350 100644 --- a/src/Magnum/Vk/Test/ImageVkTest.cpp +++ b/src/Magnum/Vk/Test/ImageVkTest.cpp @@ -376,8 +376,21 @@ void ImageVkTest::cmdClearColorImageFloat() { .end(); queue().submit({SubmitInfo{}.setCommandBuffers({cmd})}).wait(); - CORRADE_EXPECT_FAIL_IF(a.dedicatedMemory().size() != 4*4*4 && !device().properties().name().hasPrefix("SwiftShader"), + /* Check if the image is actually tightly packed for the comparison */ + /** @todo make this a builtin, returning a StridedArrayView for pixels */ + VkSubresourceLayout layout; + { + VkImageSubresource subresource{}; + subresource.arrayLayer = 0; + subresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + subresource.mipLevel = 0; + device()->GetImageSubresourceLayout(device(), a, &subresource, &layout); + } + CORRADE_EXPECT_FAIL_IF(layout.rowPitch != 4*4, "The image doesn't have a tightly-packed memory, the following check won't work."); + + /* The image memory may be tightly packed but still actually larger than + what was requested. Compare just the prefix. */ CORRADE_COMPARE_AS(Containers::arrayCast(a.dedicatedMemory().mapRead().prefix(4*4*4)), Containers::arrayView({ 0xdeadc0de_rgba, 0xdeadc0de_rgba, 0xdeadc0de_rgba, 0xdeadc0de_rgba, 0xdeadc0de_rgba, 0xdeadc0de_rgba, 0xdeadc0de_rgba, 0xdeadc0de_rgba, @@ -416,8 +429,21 @@ void ImageVkTest::cmdClearColorImageSignedIntegral() { .end(); queue().submit({SubmitInfo{}.setCommandBuffers({cmd})}).wait(); - CORRADE_EXPECT_FAIL_IF(a.dedicatedMemory().size() != 4*4*4 && !device().properties().name().hasPrefix("SwiftShader"), + /* Check if the image is actually tightly packed for the comparison */ + /** @todo make this a builtin, returning a StridedArrayView for pixels */ + VkSubresourceLayout layout; + { + VkImageSubresource subresource{}; + subresource.arrayLayer = 0; + subresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + subresource.mipLevel = 0; + device()->GetImageSubresourceLayout(device(), a, &subresource, &layout); + } + CORRADE_EXPECT_FAIL_IF(layout.rowPitch != 4*4, "The image doesn't have a tightly-packed memory, the following check won't work."); + + /* The image memory may be tightly packed but still actually larger than + what was requested. Compare just the prefix. */ CORRADE_COMPARE_AS(Containers::arrayCast(a.dedicatedMemory().mapRead().prefix(4*4*4)), Containers::arrayView({ {15, -7, 2, -1}, {15, -7, 2, -1}, {15, -7, 2, -1}, {15, -7, 2, -1}, {15, -7, 2, -1}, {15, -7, 2, -1}, {15, -7, 2, -1}, {15, -7, 2, -1}, @@ -456,8 +482,21 @@ void ImageVkTest::cmdClearColorImageUnsignedIntegral() { .end(); queue().submit({SubmitInfo{}.setCommandBuffers({cmd})}).wait(); - CORRADE_EXPECT_FAIL_IF(a.dedicatedMemory().size() != 4*4*4 && !device().properties().name().hasPrefix("SwiftShader"), + /* Check if the image is actually tightly packed for the comparison */ + /** @todo make this a builtin, returning a StridedArrayView for pixels */ + VkSubresourceLayout layout; + { + VkImageSubresource subresource{}; + subresource.arrayLayer = 0; + subresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + subresource.mipLevel = 0; + device()->GetImageSubresourceLayout(device(), a, &subresource, &layout); + } + CORRADE_EXPECT_FAIL_IF(layout.rowPitch != 4*4, "The image doesn't have a tightly-packed memory, the following check won't work."); + + /* The image memory may be tightly packed but still actually larger than + what was requested. Compare just the prefix. */ CORRADE_COMPARE_AS(Containers::arrayCast(a.dedicatedMemory().mapRead().prefix(4*4*4)), Containers::arrayView({ {15, 37, 2, 1}, {15, 37, 2, 1}, {15, 37, 2, 1}, {15, 37, 2, 1}, {15, 37, 2, 1}, {15, 37, 2, 1}, {15, 37, 2, 1}, {15, 37, 2, 1},