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;