diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp index ac3f9cbb40..a6dcbc572c 100644 --- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp @@ -675,6 +675,8 @@ namespace dawn_native { namespace d3d12 { const bool passHasUAV = TransitionForPass(commandContext, passResourceUsages[nextPassNumber]); bindingTracker.SetInComputePass(false); + + LazyClearRenderPassAttachments(beginRenderPassCmd); RecordRenderPass(commandContext, &bindingTracker, &renderPassTracker, beginRenderPassCmd, passHasUAV); @@ -930,15 +932,6 @@ namespace dawn_native { namespace d3d12 { for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) { RenderPassColorAttachmentInfo& attachmentInfo = renderPass->colorAttachments[i]; TextureView* view = ToBackend(attachmentInfo.view.Get()); - Texture* texture = ToBackend(view->GetTexture()); - - // Load operation is changed to clear when the texture is uninitialized. - if (!texture->IsSubresourceContentInitialized(view->GetBaseMipLevel(), 1, - view->GetBaseArrayLayer(), 1) && - attachmentInfo.loadOp == wgpu::LoadOp::Load) { - attachmentInfo.loadOp = wgpu::LoadOp::Clear; - attachmentInfo.clearColor = {0.0f, 0.0f, 0.0f, 0.0f}; - } // Set color load operation. renderPassBuilder->SetRenderTargetBeginningAccess( @@ -953,46 +946,21 @@ namespace dawn_native { namespace d3d12 { resolveDestinationTexture->TransitionUsageNow(commandContext, D3D12_RESOURCE_STATE_RESOLVE_DEST); - // Mark resolve target as initialized to prevent clearing later. - resolveDestinationTexture->SetIsSubresourceContentInitialized( - true, resolveDestinationView->GetBaseMipLevel(), 1, - resolveDestinationView->GetBaseArrayLayer(), 1); - renderPassBuilder->SetRenderTargetEndingAccessResolve(i, attachmentInfo.storeOp, view, resolveDestinationView); } else { renderPassBuilder->SetRenderTargetEndingAccess(i, attachmentInfo.storeOp); } - - // Set whether or not the texture requires initialization after the pass. - bool isInitialized = attachmentInfo.storeOp == wgpu::StoreOp::Store; - texture->SetIsSubresourceContentInitialized(isInitialized, view->GetBaseMipLevel(), 1, - view->GetBaseArrayLayer(), 1); } if (renderPass->attachmentState->HasDepthStencilAttachment()) { RenderPassDepthStencilAttachmentInfo& attachmentInfo = renderPass->depthStencilAttachment; TextureView* view = ToBackend(renderPass->depthStencilAttachment.view.Get()); - Texture* texture = ToBackend(view->GetTexture()); const bool hasDepth = view->GetTexture()->GetFormat().HasDepth(); const bool hasStencil = view->GetTexture()->GetFormat().HasStencil(); - // Load operations are changed to clear when the texture is uninitialized. - if (!view->GetTexture()->IsSubresourceContentInitialized( - view->GetBaseMipLevel(), view->GetLevelCount(), view->GetBaseArrayLayer(), - view->GetLayerCount())) { - if (hasDepth && attachmentInfo.depthLoadOp == wgpu::LoadOp::Load) { - attachmentInfo.clearDepth = 0.0f; - attachmentInfo.depthLoadOp = wgpu::LoadOp::Clear; - } - if (hasStencil && attachmentInfo.stencilLoadOp == wgpu::LoadOp::Load) { - attachmentInfo.clearStencil = 0u; - attachmentInfo.stencilLoadOp = wgpu::LoadOp::Clear; - } - } - // Set depth/stencil load operations. if (hasDepth) { renderPassBuilder->SetDepthAccess( @@ -1010,12 +978,6 @@ namespace dawn_native { namespace d3d12 { renderPassBuilder->SetStencilNoAccess(); } - // Set whether or not the texture requires initialization. - ASSERT(!hasDepth || !hasStencil || - attachmentInfo.depthStoreOp == attachmentInfo.stencilStoreOp); - bool isInitialized = attachmentInfo.depthStoreOp == wgpu::StoreOp::Store; - texture->SetIsSubresourceContentInitialized(isInitialized, view->GetBaseMipLevel(), 1, - view->GetBaseArrayLayer(), 1); } else { renderPassBuilder->SetDepthStencilNoAccess(); }