Corrected image layouts for shadow mapping depth reads (Fixes #253), fixed typo
This commit is contained in:
parent
34ca943ac5
commit
c7729f7634
1 changed files with 14 additions and 14 deletions
|
|
@ -191,24 +191,24 @@ public:
|
||||||
// This is necessary as the offscreen frame buffer attachments use formats different to those from the example render pass
|
// This is necessary as the offscreen frame buffer attachments use formats different to those from the example render pass
|
||||||
void prepareOffscreenRenderpass()
|
void prepareOffscreenRenderpass()
|
||||||
{
|
{
|
||||||
VkAttachmentDescription attchmentDescription{};
|
VkAttachmentDescription attachmentDescription{};
|
||||||
attchmentDescription.format = DEPTH_FORMAT;
|
attachmentDescription.format = DEPTH_FORMAT;
|
||||||
attchmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
|
attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
attchmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; // Clear depth at beginning of the render pass
|
attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; // Clear depth at beginning of the render pass
|
||||||
attchmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE; // We will read from depth, so it's important to store the depth attachment results
|
attachmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE; // We will read from depth, so it's important to store the depth attachment results
|
||||||
attchmentDescription.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
attachmentDescription.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
attchmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
attachmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||||
attchmentDescription.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; // We don't care about initial layout of the attachment
|
attachmentDescription.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; // We don't care about initial layout of the attachment
|
||||||
attchmentDescription.finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; // Attachment will be transitioned to shader read at render pass end
|
attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;// Attachment will be transitioned to shader read at render pass end
|
||||||
|
|
||||||
VkAttachmentReference depthReference = {};
|
VkAttachmentReference depthReference = {};
|
||||||
depthReference.attachment = 0;
|
depthReference.attachment = 0;
|
||||||
depthReference.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; // Attachment will be used as depth/stencil during render pass
|
depthReference.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; // Attachment will be used as depth/stencil during render pass
|
||||||
|
|
||||||
VkSubpassDescription subpass = {};
|
VkSubpassDescription subpass = {};
|
||||||
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||||
subpass.colorAttachmentCount = 0; // No color attachments
|
subpass.colorAttachmentCount = 0; // No color attachments
|
||||||
subpass.pDepthStencilAttachment = &depthReference; // Reference to our depth attachment
|
subpass.pDepthStencilAttachment = &depthReference; // Reference to our depth attachment
|
||||||
|
|
||||||
// Use subpass dependencies for layout transitions
|
// Use subpass dependencies for layout transitions
|
||||||
std::array<VkSubpassDependency, 2> dependencies;
|
std::array<VkSubpassDependency, 2> dependencies;
|
||||||
|
|
@ -231,7 +231,7 @@ public:
|
||||||
|
|
||||||
VkRenderPassCreateInfo renderPassCreateInfo = vkTools::initializers::renderPassCreateInfo();
|
VkRenderPassCreateInfo renderPassCreateInfo = vkTools::initializers::renderPassCreateInfo();
|
||||||
renderPassCreateInfo.attachmentCount = 1;
|
renderPassCreateInfo.attachmentCount = 1;
|
||||||
renderPassCreateInfo.pAttachments = &attchmentDescription;
|
renderPassCreateInfo.pAttachments = &attachmentDescription;
|
||||||
renderPassCreateInfo.subpassCount = 1;
|
renderPassCreateInfo.subpassCount = 1;
|
||||||
renderPassCreateInfo.pSubpasses = &subpass;
|
renderPassCreateInfo.pSubpasses = &subpass;
|
||||||
renderPassCreateInfo.dependencyCount = static_cast<uint32_t>(dependencies.size());
|
renderPassCreateInfo.dependencyCount = static_cast<uint32_t>(dependencies.size());
|
||||||
|
|
@ -594,7 +594,7 @@ public:
|
||||||
vkTools::initializers::descriptorImageInfo(
|
vkTools::initializers::descriptorImageInfo(
|
||||||
offscreenPass.depthSampler,
|
offscreenPass.depthSampler,
|
||||||
offscreenPass.depth.view,
|
offscreenPass.depth.view,
|
||||||
VK_IMAGE_LAYOUT_GENERAL);
|
VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL);
|
||||||
|
|
||||||
writeDescriptorSets = {
|
writeDescriptorSets = {
|
||||||
// Binding 0 : Vertex shader uniform buffer
|
// Binding 0 : Vertex shader uniform buffer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue