From dd7d78b2a67973c2bb9aeb9da0be7d4ddda51100 Mon Sep 17 00:00:00 2001 From: Juan Caldas Date: Mon, 23 Jun 2025 11:27:36 -0400 Subject: [PATCH] webgpu: Set Load and Store Ops (#8889) --- .../backend/src/webgpu/WebGPURenderTarget.cpp | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/filament/backend/src/webgpu/WebGPURenderTarget.cpp b/filament/backend/src/webgpu/WebGPURenderTarget.cpp index b3bc71fda3..c810f22d22 100644 --- a/filament/backend/src/webgpu/WebGPURenderTarget.cpp +++ b/filament/backend/src/webgpu/WebGPURenderTarget.cpp @@ -91,16 +91,20 @@ void WebGPURenderTarget::setUpRenderPassAttachments(wgpu::RenderPassDescriptor& .clearValue = { params.clearColor.r, params.clearColor.g, params.clearColor.b, params.clearColor.a } }); + bool const depthReadOnly = + (params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH) > 0; + if (defaultDepthStencilTextureView) { mDepthStencilAttachmentDescriptor = { .view = defaultDepthStencilTextureView, - .depthLoadOp = - WebGPURenderTarget::getLoadOperation(params, TargetBufferFlags::DEPTH), - .depthStoreOp = - WebGPURenderTarget::getStoreOperation(params, TargetBufferFlags::DEPTH), + .depthLoadOp = depthReadOnly ? wgpu::LoadOp::Undefined + : WebGPURenderTarget::getLoadOperation(params, + TargetBufferFlags::DEPTH), + .depthStoreOp = depthReadOnly ? wgpu::StoreOp::Undefined + : WebGPURenderTarget::getStoreOperation(params, + TargetBufferFlags::DEPTH), .depthClearValue = static_cast(params.clearDepth), - .depthReadOnly = - (params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH) > 0, + .depthReadOnly = depthReadOnly, .stencilLoadOp = wgpu::LoadOp::Undefined, .stencilStoreOp = wgpu::StoreOp::Undefined, .stencilClearValue = params.clearStencil, @@ -156,14 +160,17 @@ void WebGPURenderTarget::setUpRenderPassAttachments(wgpu::RenderPassDescriptor& customDepthTextureView ? customDepthTextureView : customStencilTextureView; if (hasDepth) { + bool const depthReadonly = + (params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH) > 0; mDepthStencilAttachmentDescriptor.depthLoadOp = + depthReadonly ? wgpu::LoadOp::Undefined : WebGPURenderTarget::getLoadOperation(params, TargetBufferFlags::DEPTH); mDepthStencilAttachmentDescriptor.depthStoreOp = + depthReadonly ? wgpu::StoreOp::Undefined : WebGPURenderTarget::getStoreOperation(params, TargetBufferFlags::DEPTH); mDepthStencilAttachmentDescriptor.depthClearValue = static_cast(params.clearDepth); - mDepthStencilAttachmentDescriptor.depthReadOnly = - (params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH) > 0; + mDepthStencilAttachmentDescriptor.depthReadOnly = depthReadonly; } else { mDepthStencilAttachmentDescriptor.depthLoadOp = wgpu::LoadOp::Undefined; mDepthStencilAttachmentDescriptor.depthStoreOp = wgpu::StoreOp::Undefined;