Set depth clear value to 0 if it is unused (load op load)
VVL complains if it is NaN (the default value)
Fixed: dawn:1718
Include-Ci-Only-Tests: true
Change-Id: I397ad15dc7d5c142d7bd29f4301de27331aa7141
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124820
Kokoro: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp
index 86c95b5..a696c41 100644
--- a/src/dawn/native/CommandEncoder.cpp
+++ b/src/dawn/native/CommandEncoder.cpp
@@ -890,8 +890,18 @@
cmd->depthStencilAttachment.view = view;
- cmd->depthStencilAttachment.clearDepth =
- descriptor->depthStencilAttachment->depthClearValue;
+ switch (descriptor->depthStencilAttachment->depthLoadOp) {
+ case wgpu::LoadOp::Clear:
+ cmd->depthStencilAttachment.clearDepth =
+ descriptor->depthStencilAttachment->depthClearValue;
+ break;
+ case wgpu::LoadOp::Load:
+ case wgpu::LoadOp::Undefined:
+ // Set depthClearValue to 0 if it is the load op is not clear.
+ // The default value NaN may be invalid in the backend.
+ cmd->depthStencilAttachment.clearDepth = 0.f;
+ break;
+ }
cmd->depthStencilAttachment.clearStencil =
descriptor->depthStencilAttachment->stencilClearValue;