Primarily for debugging purpose I wish to store and reuse in future render calls depth buffer, which is not clamped to [0.0, 1.0] range, as bound by the Vulkan specification. The VK_EXT_depth_range_unrestricted seems to be exactly what I need, so I had
- Enabled VK_EXT_depth_range_unrestricted,
- Set depth range in viewport to [0.0, 10.0],
- Set VkPipelineDepthStencilStateCreateInfo's depth bounds to [0.0, 10.0], depthTestEnable and depthWriteEnable to VK_TRUE,
- Set depth clear value for renderpass to be equal to 10,
- Rasterized some triangles, depth of each vertex is equal to 3.0,
and found that all pixels of the depth map are equal to 1.0. But I expected rasterized pixels to have depth 3.0, and not rasterized to have 10.0 (checked both in renderdoc and by dumping the depth buffer to host memory).
Hence my question: is it possible to actually store the unnormalized depth in the depth buffer in Vulkan? If it is, how do I do it?
UPDATE: I crafted the reproducer from Sascha Willems' triangle drawing example. It's in the fork When running the example, validation does not report anything. What I see is the blank image (every pixel is cleared), however I expected a single triangle to be drawn (because each vertex of it has the depth 3, and the cleared depth is 5). Just in case, device is Vega RX, driver 18.50-ubuntu16.04.