Browse Source

Vk: make image tight packing check more robust.

The check for memory size was enough for llvmpipe, but not for
SwiftShader. And now it wasn't enough for NVidia either, so let's just do
it properly.

Ideally of course this would compare always. Don't feel like doing that
right now tho, so it's just a TODO.
pull/419/merge
Vladimír Vondruš 2 years ago
parent
commit
3e4e1bde69
  1. 45
      src/Magnum/Vk/Test/ImageVkTest.cpp

45
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<const Color4ub>(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<const Vector4b>(a.dedicatedMemory().mapRead().prefix(4*4*4)), Containers::arrayView<Vector4b>({
{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<const Vector4ub>(a.dedicatedMemory().mapRead().prefix(4*4*4)), Containers::arrayView<Vector4ub>({
{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},

Loading…
Cancel
Save