I have a program with no depth buffering which runs fine. Now, I want to add depth buffering. Following a tutorial I completed the steps:
-
Create depth image, view, bind memory.
-
Rewrite VkPipelineDepthStencilStateCreateInfo to enable depth test and depth write and set the depth compare op.
-
Modify the clear values vector for VkRenderPassBeginInfo to include {1.0f, 0} for depthStencil.
-
Add depthImageView as an attachment to each framebuffer.
-
In the createRenderPass() routine: create a “VkAttachmentDescription depthAttachment”, add it to vector<VkAttachmentDescription>, create a “VkAttachmentReference depthAttachmentRef” and, finally,
subpass.pDepthStencilAttachment = &depthAttachmentRef;
Here’s the problem. Up till step 5 all the way till that last statement everything runs ok (with no depth buffering apparent obviously). However, the moment I add that last statement all I see is blank screen cleared to the background clear color. Comment out that statement and it’s fine again.
I know it might be hard to say much without seeing all of the code. But I was hoping someone might see the problem and go, Oh yeah I know …
Thanks.