From 9a73375dddfd10ab54e016e65c6ad06f273cf500 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Mon, 20 Mar 2023 22:37:17 +0000 Subject: [PATCH] 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 Commit-Queue: Austin Eng Reviewed-by: Shrek Shao --- src/dawn/native/CommandEncoder.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp index 86c95b5bb9..a696c41ee2 100644 --- a/src/dawn/native/CommandEncoder.cpp +++ b/src/dawn/native/CommandEncoder.cpp @@ -890,8 +890,18 @@ Ref CommandEncoder::BeginRenderPass(const RenderPassDescripto 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;