diff options
author | Dave Houlton <daveh@lunarg.com> | 2017-03-27 17:25:54 -0600 |
---|---|---|
committer | Dave Houlton <daveh@lunarg.com> | 2017-03-29 15:07:42 -0600 |
commit | 1c55ba02ac8e31fad486ae3ffcf7d207a5e4179a (patch) | |
tree | 3674872535774d04f73a3ff4d9ca0a00543fc905 /tests | |
parent | ae22b47919734a44da5b77a7a54161fc4a86499e (diff) |
layers: refactor layer utils
Split format-related helper fxns out of vk_layer_utils.cpp into a new
file vk_format_utils.cpp. Remove the duplicated fxns in the render
framework and share the new format utils across both projects.
Rename the util fxns into CamelCase per coding std.
Change-Id: I0f9a34bc5931dfca085dfdc8d4800664aec526cf
Diffstat (limited to 'tests')
-rw-r--r-- | tests/layer_validation_tests.cpp | 58 | ||||
-rw-r--r-- | tests/vkrenderframework.cpp | 75 | ||||
-rw-r--r-- | tests/vkrenderframework.h | 4 |
3 files changed, 55 insertions, 82 deletions
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp index aea592aa..b4ea72e9 100644 --- a/tests/layer_validation_tests.cpp +++ b/tests/layer_validation_tests.cpp @@ -35,6 +35,7 @@ #include "icd-spv.h" #include "test_common.h" #include "vk_layer_config.h" +#include "vk_format_utils.h" #include "vk_validation_error_messages.h" #include "vkrenderframework.h" @@ -356,7 +357,6 @@ class VkLayerTest : public VkRenderFramework { InitState(features, flags); } - protected: ErrorMonitor *m_errorMonitor; bool m_enableWSI; @@ -1346,7 +1346,8 @@ TEST_F(VkLayerTest, SparseBindingImageBufferCreate) { TEST_F(VkLayerTest, SparseResidencyImageCreateUnsupportedTypes) { TEST_DESCRIPTION("Create images with sparse residency with unsupported types"); - ASSERT_NO_FATAL_FAILURE(InitFramework(instance_layer_names, instance_extension_names, device_extension_names, myDbgFunc, m_errorMonitor)); + ASSERT_NO_FATAL_FAILURE( + InitFramework(instance_layer_names, instance_extension_names, device_extension_names, myDbgFunc, m_errorMonitor)); // Determine which device feature are available VkPhysicalDeviceFeatures available_features = {}; @@ -1413,7 +1414,8 @@ TEST_F(VkLayerTest, SparseResidencyImageCreateUnsupportedTypes) { TEST_F(VkLayerTest, SparseResidencyImageCreateUnsupportedSamples) { TEST_DESCRIPTION("Create images with sparse residency with unsupported tiling or sample counts"); - ASSERT_NO_FATAL_FAILURE(InitFramework(instance_layer_names, instance_extension_names, device_extension_names, myDbgFunc, m_errorMonitor)); + ASSERT_NO_FATAL_FAILURE( + InitFramework(instance_layer_names, instance_extension_names, device_extension_names, myDbgFunc, m_errorMonitor)); // Determine which device feature are available VkPhysicalDeviceFeatures available_features = {}; @@ -2167,8 +2169,7 @@ TEST_F(VkLayerTest, InvalidUsageBits) { m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Invalid usage flag for image "); ASSERT_NO_FATAL_FAILURE(Init()); - - auto format = find_depth_stencil_format(m_device); + auto format = FindDepthStencilFormat(gpu()); if (!format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -8757,7 +8758,7 @@ TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { ASSERT_NO_FATAL_FAILURE(Init()); ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -8908,7 +8909,7 @@ TEST_F(VkLayerTest, InvalidBarriers) { m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -9984,7 +9985,7 @@ TEST_F(VkLayerTest, DSAspectBitsErrors) { VkResult err; ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -11720,7 +11721,7 @@ TEST_F(VkLayerTest, InvalidImageLayout) { // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -15953,7 +15954,7 @@ TEST_F(VkLayerTest, ImageLayerViewTests) { TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -17054,7 +17055,7 @@ TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { "vkCmdCopyImage called with unmatched source and dest image depth"); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -17240,7 +17241,7 @@ TEST_F(VkLayerTest, CopyImageSampleCountMismatch) { TEST_F(VkLayerTest, CopyImageAspectMismatch) { TEST_DESCRIPTION("Image copies with aspect mask errors"); ASSERT_NO_FATAL_FAILURE(Init()); - auto ds_format = find_depth_stencil_format(m_device); + auto ds_format = FindDepthStencilFormat(gpu()); if (!ds_format) { return; } @@ -17268,8 +17269,10 @@ TEST_F(VkLayerTest, CopyImageAspectMismatch) { copyRegion.extent = {64, 128, 1}; // Submitting command before command buffer is in recording state - m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "You must call vkBeginCommandBuffer");// VALIDATION_ERROR_01192); - vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), depth_image.handle(), VK_IMAGE_LAYOUT_GENERAL, depth_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); + m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, + "You must call vkBeginCommandBuffer"); // VALIDATION_ERROR_01192); + vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), depth_image.handle(), VK_IMAGE_LAYOUT_GENERAL, depth_image.handle(), + VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); m_errorMonitor->VerifyFound(); m_commandBuffer->BeginCommandBuffer(); @@ -17277,25 +17280,28 @@ TEST_F(VkLayerTest, CopyImageAspectMismatch) { // Src and dest aspect masks don't match copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT; m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01197); - vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), VK_IMAGE_LAYOUT_GENERAL, ds_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); + vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), VK_IMAGE_LAYOUT_GENERAL, ds_image.handle(), + VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); m_errorMonitor->VerifyFound(); copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; // Illegal combinations of aspect bits - VU 01221 - copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; // color must be alone + copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; // color must be alone copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01221); // These aspect/format mismatches are redundant but unavoidable here m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01200); m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01201); - vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); + vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), + VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); m_errorMonitor->VerifyFound(); // Metadata aspect is illegal - VU 01222 copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01222); // These aspect/format mismatches are redundant but unavoidable here - vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); + vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), + VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); m_errorMonitor->VerifyFound(); copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; @@ -17743,7 +17749,7 @@ TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { "Combination depth/stencil image formats can have only the "); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -17866,7 +17872,7 @@ TEST_F(VkLayerTest, ClearImageErrors) { "ClearDepthStencilImage with a color image."); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -17951,7 +17957,7 @@ TEST_F(VkLayerTest, CommandQueueFlags) { ASSERT_NO_FATAL_FAILURE(Init()); uint32_t queueFamilyIndex = m_device->QueueFamilyWithoutCapabilities(VK_QUEUE_GRAPHICS_BIT); - if(queueFamilyIndex == UINT32_MAX) { + if (queueFamilyIndex == UINT32_MAX) { printf(" Non-graphics queue family not found; skipped.\n"); return; } else { @@ -18357,7 +18363,7 @@ TEST_F(VkPositiveLayerTest, SecondaryCommandBufferImageLayoutTransitions) { VkResult err; m_errorMonitor->ExpectSuccess(); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { return; } @@ -20304,7 +20310,7 @@ TEST_F(VkPositiveLayerTest, StencilLoadOp) { "CLEAR. stencil[Load|Store]Op used to be ignored."); VkResult result = VK_SUCCESS; ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -20478,7 +20484,7 @@ TEST_F(VkPositiveLayerTest, BarrierLayoutToImageUsage) { m_errorMonitor->ExpectSuccess(); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -21885,7 +21891,7 @@ TEST_F(VkPositiveLayerTest, ValidRenderPassAttachmentLayoutWithLoadOp) { "valid *READ_ONLY* layout."); m_errorMonitor->ExpectSuccess(); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; @@ -21933,7 +21939,7 @@ TEST_F(VkPositiveLayerTest, RenderPassDepthStencilLayoutTransition) { "transition has correctly occurred at queue submit time with no validation errors."); ASSERT_NO_FATAL_FAILURE(Init()); - auto depth_format = find_depth_stencil_format(m_device); + auto depth_format = FindDepthStencilFormat(gpu()); if (!depth_format) { printf(" No Depth + Stencil format found. Skipped.\n"); return; diff --git a/tests/vkrenderframework.cpp b/tests/vkrenderframework.cpp index 161216b4..ff7b50c0 100644 --- a/tests/vkrenderframework.cpp +++ b/tests/vkrenderframework.cpp @@ -21,6 +21,7 @@ */ #include "vkrenderframework.h" +#include "vk_format_utils.h" #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define GET_DEVICE_PROC_ADDR(dev, entrypoint) \ @@ -29,47 +30,13 @@ assert(fp##entrypoint != NULL); \ } -// TODO : These functions are duplicated is vk_layer_utils.cpp, share code -// Return true if format contains depth and stencil information -bool vk_format_is_depth_and_stencil(VkFormat format) { - bool is_ds = false; - - switch (format) { - case VK_FORMAT_D16_UNORM_S8_UINT: - case VK_FORMAT_D24_UNORM_S8_UINT: - case VK_FORMAT_D32_SFLOAT_S8_UINT: - is_ds = true; - break; - default: - break; - } - return is_ds; -} - -// Return true if format is a stencil-only format -bool vk_format_is_stencil_only(VkFormat format) { return (format == VK_FORMAT_S8_UINT); } - -// Return true if format is a depth-only format -bool vk_format_is_depth_only(VkFormat format) { - bool is_depth = false; - - switch (format) { - case VK_FORMAT_D16_UNORM: - case VK_FORMAT_X8_D24_UNORM_PACK32: - case VK_FORMAT_D32_SFLOAT: - is_depth = true; - break; - default: - break; - } - - return is_depth; -} - -VkFormat find_depth_stencil_format(VkDeviceObj *device) { +// Format search helpers +VkFormat FindDepthStencilFormat(VkPhysicalDevice phy) { VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT}; for (uint32_t i = 0; i < sizeof(ds_formats); i++) { - VkFormatProperties format_props = device->format_properties(ds_formats[i]); + VkFormatProperties format_props; + vkGetPhysicalDeviceFormatProperties(phy, ds_formats[i], &format_props); + if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { return ds_formats[i]; } @@ -414,8 +381,7 @@ VkDeviceObj::VkDeviceObj(uint32_t id, VkPhysicalDevice obj, std::vector<const ch queue_props = phy().queue_properties(); } -uint32_t VkDeviceObj::QueueFamilyWithoutCapabilities(VkQueueFlags capabilities) -{ +uint32_t VkDeviceObj::QueueFamilyWithoutCapabilities(VkQueueFlags capabilities) { // Find a queue family without desired capabilities for (uint32_t i = 0; i < queue_props.size(); i++) { if ((queue_props[i].queueFlags & capabilities) == 0) { @@ -425,13 +391,11 @@ uint32_t VkDeviceObj::QueueFamilyWithoutCapabilities(VkQueueFlags capabilities) return UINT32_MAX; } - void VkDeviceObj::get_device_queue() { ASSERT_NE(true, graphics_queues().empty()); m_queue = graphics_queues()[0]->handle(); } - VkDescriptorSetObj::VkDescriptorSetObj(VkDeviceObj *device) : m_device(device), m_nextSlot(0) {} VkDescriptorSetObj::~VkDescriptorSetObj() { @@ -601,7 +565,8 @@ void VkImageObj::ImageMemoryBarrier(VkCommandBufferObj *cmd_buf, VkImageAspectFl VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | - VK_MEMORY_INPUT_COPY_BIT*/, VkImageLayout image_layout) { + VK_MEMORY_INPUT_COPY_BIT*/, + VkImageLayout image_layout) { const VkImageSubresourceRange subresourceRange = subresource_range(aspect, 0, 1, 0, 1); VkImageMemoryBarrier barrier; barrier = image_memory_barrier(output_mask, input_mask, layout(), image_layout, subresourceRange); @@ -759,11 +724,11 @@ void VkImageObj::init(uint32_t w, uint32_t h, VkFormat fmt, VkFlags usage, VkIma newLayout = m_descriptorImageInfo.imageLayout; VkImageAspectFlags image_aspect = 0; - if (vk_format_is_depth_and_stencil(fmt)) { + if (VkFormatIsDepthAndStencil(fmt)) { image_aspect = VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; - } else if (vk_format_is_depth_only(fmt)) { + } else if (VkFormatIsDepthOnly(fmt)) { image_aspect = VK_IMAGE_ASPECT_DEPTH_BIT; - } else if (vk_format_is_stencil_only(fmt)) { + } else if (VkFormatIsStencilOnly(fmt)) { image_aspect = VK_IMAGE_ASPECT_STENCIL_BIT; } else { // color image_aspect = VK_IMAGE_ASPECT_COLOR_BIT; @@ -794,11 +759,11 @@ void VkImageObj::init(const VkImageCreateInfo *create_info) { vk_testing::Image::init(*m_device, *create_info, 0); VkImageAspectFlags image_aspect = 0; - if (vk_format_is_depth_and_stencil(create_info->format)) { + if (VkFormatIsDepthAndStencil(create_info->format)) { image_aspect = VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; - } else if (vk_format_is_depth_only(create_info->format)) { + } else if (VkFormatIsDepthOnly(create_info->format)) { image_aspect = VK_IMAGE_ASPECT_DEPTH_BIT; - } else if (vk_format_is_stencil_only(create_info->format)) { + } else if (VkFormatIsStencilOnly(create_info->format)) { image_aspect = VK_IMAGE_ASPECT_STENCIL_BIT; } else { // color image_aspect = VK_IMAGE_ASPECT_COLOR_BIT; @@ -998,7 +963,8 @@ void VkConstantBufferObj::BufferMemoryBarrier(VkFlags srcAccessMask /*= VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | - VK_MEMORY_OUTPUT_COPY_BIT*/, VkFlags dstAccessMask /*= + VK_MEMORY_OUTPUT_COPY_BIT*/, + VkFlags dstAccessMask /*= VK_ACCESS_HOST_READ_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT | VK_ACCESS_INDEX_READ_BIT | @@ -1333,8 +1299,7 @@ void VkPipelineObj::InitGraphicsPipelineCreateInfo(VkGraphicsPipelineCreateInfo } } -VkResult VkPipelineObj::CreateVKPipeline(VkPipelineLayout layout, VkRenderPass render_pass, - VkGraphicsPipelineCreateInfo *gp_ci) { +VkResult VkPipelineObj::CreateVKPipeline(VkPipelineLayout layout, VkRenderPass render_pass, VkGraphicsPipelineCreateInfo *gp_ci) { VkGraphicsPipelineCreateInfo info = {}; // if not given a CreateInfo, create and initialize a local one. @@ -1631,9 +1596,9 @@ void VkDepthStencilObj::Init(VkDeviceObj *device, int32_t width, int32_t height, init(width, height, m_depth_stencil_fmt, usage, VK_IMAGE_TILING_OPTIMAL); VkImageAspectFlags aspect = VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; - if (vk_format_is_depth_only(format)) + if (VkFormatIsDepthOnly(format)) aspect = VK_IMAGE_ASPECT_DEPTH_BIT; - else if (vk_format_is_stencil_only(format)) + else if (VkFormatIsStencilOnly(format)) aspect = VK_IMAGE_ASPECT_STENCIL_BIT; SetLayout(aspect, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); diff --git a/tests/vkrenderframework.h b/tests/vkrenderframework.h index a693038a..f15d19b1 100644 --- a/tests/vkrenderframework.h +++ b/tests/vkrenderframework.h @@ -445,5 +445,7 @@ class VkPipelineObj : public vk_testing::Pipeline { vector<VkPipelineColorBlendAttachmentState> m_colorAttachments; int m_vertexBufferCount; }; -VkFormat find_depth_stencil_format(VkDeviceObj *device); + +VkFormat FindDepthStencilFormat(VkPhysicalDevice); + #endif // VKRENDERFRAMEWORK_H |