From 9fef899e42a16d0650bd8684ed30cf645d562932 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 30 Jun 2022 09:38:25 +0200 Subject: [PATCH] Fix various cases of image views with incorrect stencil aspect --- examples/deferred/deferred.cpp | 4 +++- examples/hdr/hdr.cpp | 4 +++- examples/multisampling/multisampling.cpp | 4 +++- examples/multiview/multiview.cpp | 4 +++- examples/offscreen/offscreen.cpp | 4 +++- examples/radialblur/radialblur.cpp | 4 +++- examples/renderheadless/renderheadless.cpp | 4 +++- examples/shadowmappingomni/shadowmappingomni.cpp | 4 +++- examples/ssao/ssao.cpp | 4 +++- 9 files changed, 27 insertions(+), 9 deletions(-) diff --git a/examples/deferred/deferred.cpp b/examples/deferred/deferred.cpp index 0994e2f9..7672a46a 100644 --- a/examples/deferred/deferred.cpp +++ b/examples/deferred/deferred.cpp @@ -190,7 +190,9 @@ public: } if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { - aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (format >= VK_FORMAT_D16_UNORM_S8_UINT) + aspectMask |=VK_IMAGE_ASPECT_STENCIL_BIT; imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; } diff --git a/examples/hdr/hdr.cpp b/examples/hdr/hdr.cpp index cda5b452..a43180bf 100644 --- a/examples/hdr/hdr.cpp +++ b/examples/hdr/hdr.cpp @@ -314,7 +314,9 @@ public: } if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { - aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (format >= VK_FORMAT_D16_UNORM_S8_UINT) + aspectMask |=VK_IMAGE_ASPECT_STENCIL_BIT; imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; } diff --git a/examples/multisampling/multisampling.cpp b/examples/multisampling/multisampling.cpp index 408e18f7..e4e01819 100644 --- a/examples/multisampling/multisampling.cpp +++ b/examples/multisampling/multisampling.cpp @@ -186,7 +186,9 @@ public: viewInfo.components.g = VK_COMPONENT_SWIZZLE_G; viewInfo.components.b = VK_COMPONENT_SWIZZLE_B; viewInfo.components.a = VK_COMPONENT_SWIZZLE_A; - viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (depthFormat >= VK_FORMAT_D16_UNORM_S8_UINT) + viewInfo.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; viewInfo.subresourceRange.levelCount = 1; viewInfo.subresourceRange.layerCount = 1; diff --git a/examples/multiview/multiview.cpp b/examples/multiview/multiview.cpp index a73992f3..13845f59 100644 --- a/examples/multiview/multiview.cpp +++ b/examples/multiview/multiview.cpp @@ -150,7 +150,9 @@ public: depthStencilView.format = depthFormat; depthStencilView.flags = 0; depthStencilView.subresourceRange = {}; - depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (depthFormat >= VK_FORMAT_D16_UNORM_S8_UINT) + depthStencilView.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; depthStencilView.subresourceRange.baseMipLevel = 0; depthStencilView.subresourceRange.levelCount = 1; depthStencilView.subresourceRange.baseArrayLayer = 0; diff --git a/examples/offscreen/offscreen.cpp b/examples/offscreen/offscreen.cpp index 4ae6cbe7..8c39f7ec 100644 --- a/examples/offscreen/offscreen.cpp +++ b/examples/offscreen/offscreen.cpp @@ -209,7 +209,9 @@ public: depthStencilView.format = fbDepthFormat; depthStencilView.flags = 0; depthStencilView.subresourceRange = {}; - depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (fbDepthFormat >= VK_FORMAT_D16_UNORM_S8_UINT) + depthStencilView.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; depthStencilView.subresourceRange.baseMipLevel = 0; depthStencilView.subresourceRange.levelCount = 1; depthStencilView.subresourceRange.baseArrayLayer = 0; diff --git a/examples/radialblur/radialblur.cpp b/examples/radialblur/radialblur.cpp index 22daed60..9b54883e 100644 --- a/examples/radialblur/radialblur.cpp +++ b/examples/radialblur/radialblur.cpp @@ -208,7 +208,9 @@ public: depthStencilView.format = fbDepthFormat; depthStencilView.flags = 0; depthStencilView.subresourceRange = {}; - depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (fbDepthFormat >= VK_FORMAT_D16_UNORM_S8_UINT) + depthStencilView.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; depthStencilView.subresourceRange.baseMipLevel = 0; depthStencilView.subresourceRange.levelCount = 1; depthStencilView.subresourceRange.baseArrayLayer = 0; diff --git a/examples/renderheadless/renderheadless.cpp b/examples/renderheadless/renderheadless.cpp index ba41bf8a..5f56987a 100644 --- a/examples/renderheadless/renderheadless.cpp +++ b/examples/renderheadless/renderheadless.cpp @@ -418,7 +418,9 @@ public: depthStencilView.format = depthFormat; depthStencilView.flags = 0; depthStencilView.subresourceRange = {}; - depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (depthFormat >= VK_FORMAT_D16_UNORM_S8_UINT) + depthStencilView.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; depthStencilView.subresourceRange.baseMipLevel = 0; depthStencilView.subresourceRange.levelCount = 1; depthStencilView.subresourceRange.baseArrayLayer = 0; diff --git a/examples/shadowmappingomni/shadowmappingomni.cpp b/examples/shadowmappingomni/shadowmappingomni.cpp index 72e82bd5..3835ac01 100644 --- a/examples/shadowmappingomni/shadowmappingomni.cpp +++ b/examples/shadowmappingomni/shadowmappingomni.cpp @@ -291,7 +291,9 @@ public: depthStencilView.format = fbDepthFormat; depthStencilView.flags = 0; depthStencilView.subresourceRange = {}; - depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (fbDepthFormat >= VK_FORMAT_D16_UNORM_S8_UINT) + depthStencilView.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; depthStencilView.subresourceRange.baseMipLevel = 0; depthStencilView.subresourceRange.levelCount = 1; depthStencilView.subresourceRange.baseArrayLayer = 0; diff --git a/examples/ssao/ssao.cpp b/examples/ssao/ssao.cpp index 92558908..29e73016 100644 --- a/examples/ssao/ssao.cpp +++ b/examples/ssao/ssao.cpp @@ -196,7 +196,9 @@ public: } if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { - aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (format >= VK_FORMAT_D16_UNORM_S8_UINT) + aspectMask |=VK_IMAGE_ASPECT_STENCIL_BIT; } assert(aspectMask > 0);