Depth buffering problem

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:

  1. Create depth image, view, bind memory.

  2. Rewrite VkPipelineDepthStencilStateCreateInfo to enable depth test and depth write and set the depth compare op.

  3. Modify the clear values vector for VkRenderPassBeginInfo to include {1.0f, 0} for depthStencil.

  4. Add depthImageView as an attachment to each framebuffer.

  5. 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.