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
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.
From the extension specification's issues section, one can find a number of other things that have to happen. Since you didn't deign to show your code, here's a list:
The image format of the depth buffer has to be floating-point. If it is fixed-point, then values will still be clamped to that range. Note that hardware does not have to support floating-point depth buffers (though, if it doesn't, then odds are good it doesn't support this extension either).
Clipping may still apply. Primitives can be clipped to the [0, W c ] range, where "W c " is the fourth component of the clip-space vertex position. To stop this, you have to turn off depth clipping, via VkPipelineRasterizationStateCreateInfo::depthClampEnable = VK_TRUE
(or VkPipelineRasterizationDepthClipStateCreateInfoEXT::depthClipEnable = VK_FALSE
if you're using that extension).
With depth clipping disabled, the depth values will still be clamped to the VkViewport::minDepth/maxDepth
range. So you have to make sure that's big enough.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.