Fix a bug for depth test on Vulkan backend
The default value for maxDepthBound should be 1.0.
BUG=dawn:81
Change-Id: I337aac884456c739222bc31f8003267aa6de96af
Reviewed-on: https://dawn-review.googlesource.com/c/3580
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
diff --git a/src/dawn_native/vulkan/DepthStencilStateVk.cpp b/src/dawn_native/vulkan/DepthStencilStateVk.cpp
index c2f29a4..2f6472c 100644
--- a/src/dawn_native/vulkan/DepthStencilStateVk.cpp
+++ b/src/dawn_native/vulkan/DepthStencilStateVk.cpp
@@ -74,12 +74,16 @@
mCreateInfo.flags = 0;
const auto& depth = GetDepth();
- mCreateInfo.depthTestEnable = VK_TRUE;
+ // Depth writes only occur if depth is enabled
+ mCreateInfo.depthTestEnable =
+ (depth.compareFunction == dawn::CompareFunction::Always && !depth.depthWriteEnabled)
+ ? VK_FALSE
+ : VK_TRUE;
mCreateInfo.depthWriteEnable = depth.depthWriteEnabled ? VK_TRUE : VK_FALSE;
mCreateInfo.depthCompareOp = VulkanCompareOp(depth.compareFunction);
mCreateInfo.depthBoundsTestEnable = false;
mCreateInfo.minDepthBounds = 0.0f;
- mCreateInfo.maxDepthBounds = 0.0f;
+ mCreateInfo.maxDepthBounds = 1.0f;
const auto& stencil = GetStencil();
mCreateInfo.stencilTestEnable = StencilTestEnabled() ? VK_TRUE : VK_FALSE;