LWJGL Forum

Programming => Bug Reports / RFE => Topic started by: ctl on December 15, 2017, 17:49:22

Title: [BUG] Vulkan depth buffer clear appears to have no effect
Post by: ctl on December 15, 2017, 17:49:22
I really hope that I'm not just screwing something up, but I've checked my code both against vulkan-tutorial.com and the InstancedSpheres lwjgl3 demo, and I'm doing the exact same thing. The symptom I'm having is that no triangles render if I use the depth compare op VK_COMPARE_OP_LESS but they do if I use VK_COMPARE_OP_GREATER (or _ALWAYS). But there is no difference when using _GREATER if I set the clear buffer to 0.0f or 1.0f or any other value; if the clear value was working setting the depth clear value to 1.0f really should result in no triangles being drawn. I ran the triangle demo (that doesn't use depth testing) which works and the instanced sphere demo (which doesn't work).

Here's the code i'm using:
VkClearValue.Buffer clearValue = VkClearValue.calloc(2);
try {
commandBeginInfo.sType(VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO);
commandBeginInfo.flags(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT);
commandBeginInfo.pInheritanceInfo(null);
int ret = vkBeginCommandBuffer(cb, commandBeginInfo);
errorIfNecessary(ret, "Unable to begin recording in command buffers: ");

beginRenderPassInfo.sType(VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO);
beginRenderPassInfo.renderPass(renderPass);
beginRenderPassInfo.framebuffer(framebuffers[index]);
offset.x(0).y(0);
beginRenderPassInfo.renderArea().offset(offset);
beginRenderPassInfo.renderArea().extent(swapchainExtent);
clearValue.get(0).color().float32(0, 0).float32(1, 0f).float32(2, 0).float32(3, 1);
clearValue.get(1).depthStencil().depth(1.0f).stencil(0);
beginRenderPassInfo.pClearValues(clearValue);
vkCmdBeginRenderPass(cb, beginRenderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
...

(I omitted the part which finishes recording the command buffers and frees the buffers.)

If I can do anything to help debug this (or to find out that it's somehow my fault), I'll be more than happy to run tests, etc. Thanks!
Title: Re: [BUG] Vulkan depth buffer clear appears to have no effect
Post by: spasi on December 16, 2017, 11:09:52
Can't see anything wrong with the above code. Could you prepare an MCVE (https://stackoverflow.com/help/mcve)?