| 18 | // These test check utils in the layer without needing to create a full Vulkan instance |
| 19 | |
| 20 | TEST_F(PositiveLayerUtils, GetEffectiveExtent) { |
| 21 | TEST_DESCRIPTION("Test unlikely GetEffectiveExtent edge cases"); |
| 22 | |
| 23 | VkImageCreateInfo ci = vku::InitStructHelper(); |
| 24 | VkExtent3D extent = {}; |
| 25 | |
| 26 | // Return zero extent if mip level doesn't exist |
| 27 | { |
| 28 | ci.mipLevels = 0; |
| 29 | ci.extent = {1, 1, 1}; |
| 30 | extent = GetEffectiveExtent(ci, VK_IMAGE_ASPECT_NONE, 1); |
| 31 | ASSERT_TRUE(extent.width == 0); |
| 32 | ASSERT_TRUE(extent.height == 0); |
| 33 | ASSERT_TRUE(extent.depth == 0); |
| 34 | |
| 35 | ci.mipLevels = 1; |
| 36 | extent = GetEffectiveExtent(ci, VK_IMAGE_ASPECT_NONE, 1); |
| 37 | ASSERT_TRUE(extent.width == 0); |
| 38 | ASSERT_TRUE(extent.height == 0); |
| 39 | ASSERT_TRUE(extent.depth == 0); |
| 40 | } |
| 41 | |
| 42 | // Check that 0 based extent is respected |
| 43 | { |
| 44 | ci.flags = 0; |
| 45 | ci.imageType = VK_IMAGE_TYPE_3D; |
| 46 | ci.mipLevels = 2; |
| 47 | ci.extent = {0, 0, 0}; |
| 48 | extent = GetEffectiveExtent(ci, VK_IMAGE_ASPECT_NONE, 1); |
| 49 | ASSERT_TRUE(extent.width == 0); |
| 50 | ASSERT_TRUE(extent.height == 0); |
| 51 | ASSERT_TRUE(extent.depth == 0); |
| 52 | |
| 53 | ci.extent = {16, 32, 0}; |
| 54 | extent = GetEffectiveExtent(ci, VK_IMAGE_ASPECT_NONE, 1); |
| 55 | ASSERT_TRUE(extent.width == 8); |
| 56 | ASSERT_TRUE(extent.height == 16); |
| 57 | ASSERT_TRUE(extent.depth == 0); |
| 58 | } |
| 59 | |
| 60 | // Corner sampled images |
| 61 | { |
| 62 | ci.flags = VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV; |
| 63 | ci.imageType = VK_IMAGE_TYPE_3D; |
| 64 | ci.mipLevels = 2; |
| 65 | ci.extent = {1, 1, 1}; |
| 66 | extent = GetEffectiveExtent(ci, VK_IMAGE_ASPECT_NONE, 1); |
| 67 | // The minimum level size is 2x2x2 for 3D corner sampled images. |
| 68 | ASSERT_TRUE(extent.width == 2); |
| 69 | ASSERT_TRUE(extent.height == 2); |
| 70 | ASSERT_TRUE(extent.depth == 2); |
| 71 | |
| 72 | ci.flags = VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV; |
| 73 | ci.imageType = VK_IMAGE_TYPE_3D; |
| 74 | ci.mipLevels = 2; |
| 75 | ci.extent = {4, 8, 16}; |
| 76 | extent = GetEffectiveExtent(ci, VK_IMAGE_ASPECT_NONE, 1); |
| 77 | ASSERT_TRUE(extent.width == 2); |
nothing calls this directly
no test coverage detected