Skip to content

Commit bee5e6c

Browse files
ziga-lunargspencer-lunarg
authored andcommitted
tests: Fix ycbcr layout test
1 parent 00021f7 commit bee5e6c

File tree

1 file changed

+52
-5
lines changed

1 file changed

+52
-5
lines changed

tests/unit/ycbcr_positive.cpp

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* Copyright (c) 2015-2025 The Khronos Group Inc.
3-
* Copyright (c) 2015-2025 Valve Corporation
4-
* Copyright (c) 2015-2025 LunarG, Inc.
2+
* Copyright (c) 2015-2026 The Khronos Group Inc.
3+
* Copyright (c) 2015-2026 Valve Corporation
4+
* Copyright (c) 2015-2026 LunarG, Inc.
55
* Copyright (c) 2015-2025 Google, Inc.
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -301,9 +301,56 @@ TEST_F(PositiveYcbcr, ImageLayout) {
301301
vk::CmdCopyBufferToImage(m_command_buffer, buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &copy_region);
302302
m_command_buffer.End();
303303
m_default_queue->SubmitAndWait(m_command_buffer);
304+
}
305+
306+
TEST_F(PositiveYcbcr, ImageLayoutUpdate) {
307+
TEST_DESCRIPTION(
308+
"Test to verify that views of multiplanar images have layouts tracked correctly by changing the image's layout then using "
309+
"a view of that image");
310+
SetTargetApiVersion(VK_API_VERSION_1_1);
311+
AddRequiredFeature(vkt::Feature::samplerYcbcrConversion);
312+
RETURN_IF_SKIP(Init());
313+
InitRenderTarget();
314+
315+
if (!FormatFeaturesAreSupported(Gpu(), VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM, VK_IMAGE_TILING_OPTIMAL,
316+
VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT) &&
317+
!FormatFeaturesAreSupported(Gpu(), VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM, VK_IMAGE_TILING_OPTIMAL,
318+
VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT)) {
319+
GTEST_SKIP() << "Required formats/features not supported";
320+
}
321+
auto ci = vku::InitStruct<VkImageCreateInfo>();
322+
ci.flags = 0;
323+
ci.imageType = VK_IMAGE_TYPE_2D;
324+
ci.format = VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM; // All planes of equal extent
325+
ci.tiling = VK_IMAGE_TILING_OPTIMAL;
326+
ci.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
327+
ci.extent = {256, 256, 1};
328+
ci.mipLevels = 1;
329+
ci.arrayLayers = 1;
330+
ci.samples = VK_SAMPLE_COUNT_1_BIT;
331+
332+
// Verify format
333+
VkFormatFeatureFlags features = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
334+
if (!IsImageFormatSupported(Gpu(), ci, features)) {
335+
// Assume there's low ROI on searching for different mp formats
336+
GTEST_SKIP() << "Multiplane image format not supported";
337+
}
338+
vkt::Image image(*m_device, ci, vkt::set_layout);
339+
vkt::Buffer buffer(*m_device, 128 * 128 * 3, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
340+
341+
VkBufferImageCopy copy_region = {};
342+
copy_region.bufferRowLength = 128;
343+
copy_region.bufferImageHeight = 128;
344+
copy_region.imageSubresource = {VK_IMAGE_ASPECT_PLANE_1_BIT, 0, 0, 1};
345+
copy_region.imageExtent = {64, 64, 1};
346+
347+
vk::ResetCommandBuffer(m_command_buffer, 0);
348+
m_command_buffer.Begin();
349+
image.ImageMemoryBarrier(m_command_buffer, 0, 0, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
350+
vk::CmdCopyBufferToImage(m_command_buffer, buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &copy_region);
351+
m_command_buffer.End();
352+
m_default_queue->SubmitAndWait(m_command_buffer);
304353

305-
// Test to verify that views of multiplanar images have layouts tracked correctly
306-
// by changing the image's layout then using a view of that image
307354
vkt::SamplerYcbcrConversion conversion(*m_device, VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM);
308355
auto conversion_info = conversion.ConversionInfo();
309356
vkt::Sampler sampler(*m_device, SafeSaneSamplerCreateInfo(&conversion_info));

0 commit comments

Comments
 (0)