diff options
| author | Mark Lobodzinski <mark@lunarg.com> | 2015-07-29 09:21:22 -0600 |
|---|---|---|
| committer | Mark Lobodzinski <mark@lunarg.com> | 2015-07-29 09:29:18 -0600 |
| commit | e3a40c7806c694c1e8d4d58e2186c30100173ff8 (patch) | |
| tree | aa174416ffc80623f93e6c858af2432f3e00b2c9 /layers/image.cpp | |
| parent | 3883d8b7a85fd004a139a4ee92189ea73b8043fb (diff) | |
| download | usermoji-e3a40c7806c694c1e8d4d58e2186c30100173ff8.tar.xz | |
layers: Add validation case for mismatched renderpass attachements and subpasses
Added to the Image validation layer.
Diffstat (limited to 'layers/image.cpp')
| -rw-r--r-- | layers/image.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/layers/image.cpp b/layers/image.cpp index 4520fa14..bd5f9d81 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -246,6 +246,28 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceLayerProperties( pCount, pProperties); } +// Start of the Image layer proper + +// Returns TRUE if a format is a depth-compatible format +bool is_depth_format(VkFormat format) +{ + bool result = VK_FALSE; + switch (format) { + case VK_FORMAT_D16_UNORM: + case VK_FORMAT_D24_UNORM: + case VK_FORMAT_D32_SFLOAT: + case VK_FORMAT_S8_UINT: + case VK_FORMAT_D16_UNORM_S8_UINT: + case VK_FORMAT_D24_UNORM_S8_UINT: + case VK_FORMAT_D32_SFLOAT_S8_UINT: + result = VK_TRUE; + break; + default: + break; + } + return result; +} + VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage) { if(pCreateInfo->format != VK_FORMAT_UNDEFINED) @@ -330,6 +352,24 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRende } } + // Any depth buffers specified as attachments? + bool depthFormatPresent = VK_FALSE; + for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) + { + depthFormatPresent |= is_depth_format(pCreateInfo->pAttachments[i].format); + } + + if (depthFormatPresent == VK_FALSE) { + // No depth attachment is present, validate that subpasses set depthStencilAttachment to VK_ATTACHMENT_UNUSED; + for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) { + if (pCreateInfo->pSubpasses[i].depthStencilAttachment.attachment != VK_ATTACHMENT_UNUSED) { + std::stringstream ss; + ss << "vkCreateRenderPass has no depth/stencil attachment, yet subpass[" << i << "] has VkSubpassDescription::depthStencilAttachment value that is not VK_ATTACHMENT_UNUSED"; + log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, 1, "IMAGE", ss.str().c_str()); + } + } + } + VkResult result = get_dispatch_table(image_device_table_map, device)->CreateRenderPass(device, pCreateInfo, pRenderPass); return result; |
