D3D12: Simplify lazy clear of render pass attachments
Bug: dawn:145 Change-Id: If4c83cdf4065acc9f68aa5d9a7e581e9f2e801a9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14982 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
5a2dd74450
commit
3d97384e16
src/dawn_native/d3d12
|
@ -675,6 +675,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
const bool passHasUAV =
|
const bool passHasUAV =
|
||||||
TransitionForPass(commandContext, passResourceUsages[nextPassNumber]);
|
TransitionForPass(commandContext, passResourceUsages[nextPassNumber]);
|
||||||
bindingTracker.SetInComputePass(false);
|
bindingTracker.SetInComputePass(false);
|
||||||
|
|
||||||
|
LazyClearRenderPassAttachments(beginRenderPassCmd);
|
||||||
RecordRenderPass(commandContext, &bindingTracker, &renderPassTracker,
|
RecordRenderPass(commandContext, &bindingTracker, &renderPassTracker,
|
||||||
beginRenderPassCmd, passHasUAV);
|
beginRenderPassCmd, passHasUAV);
|
||||||
|
|
||||||
|
@ -930,15 +932,6 @@ namespace dawn_native { namespace d3d12 {
|
||||||
for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||||
RenderPassColorAttachmentInfo& attachmentInfo = renderPass->colorAttachments[i];
|
RenderPassColorAttachmentInfo& attachmentInfo = renderPass->colorAttachments[i];
|
||||||
TextureView* view = ToBackend(attachmentInfo.view.Get());
|
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.
|
// Set color load operation.
|
||||||
renderPassBuilder->SetRenderTargetBeginningAccess(
|
renderPassBuilder->SetRenderTargetBeginningAccess(
|
||||||
|
@ -953,46 +946,21 @@ namespace dawn_native { namespace d3d12 {
|
||||||
resolveDestinationTexture->TransitionUsageNow(commandContext,
|
resolveDestinationTexture->TransitionUsageNow(commandContext,
|
||||||
D3D12_RESOURCE_STATE_RESOLVE_DEST);
|
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,
|
renderPassBuilder->SetRenderTargetEndingAccessResolve(i, attachmentInfo.storeOp,
|
||||||
view, resolveDestinationView);
|
view, resolveDestinationView);
|
||||||
} else {
|
} else {
|
||||||
renderPassBuilder->SetRenderTargetEndingAccess(i, attachmentInfo.storeOp);
|
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()) {
|
if (renderPass->attachmentState->HasDepthStencilAttachment()) {
|
||||||
RenderPassDepthStencilAttachmentInfo& attachmentInfo =
|
RenderPassDepthStencilAttachmentInfo& attachmentInfo =
|
||||||
renderPass->depthStencilAttachment;
|
renderPass->depthStencilAttachment;
|
||||||
TextureView* view = ToBackend(renderPass->depthStencilAttachment.view.Get());
|
TextureView* view = ToBackend(renderPass->depthStencilAttachment.view.Get());
|
||||||
Texture* texture = ToBackend(view->GetTexture());
|
|
||||||
|
|
||||||
const bool hasDepth = view->GetTexture()->GetFormat().HasDepth();
|
const bool hasDepth = view->GetTexture()->GetFormat().HasDepth();
|
||||||
const bool hasStencil = view->GetTexture()->GetFormat().HasStencil();
|
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.
|
// Set depth/stencil load operations.
|
||||||
if (hasDepth) {
|
if (hasDepth) {
|
||||||
renderPassBuilder->SetDepthAccess(
|
renderPassBuilder->SetDepthAccess(
|
||||||
|
@ -1010,12 +978,6 @@ namespace dawn_native { namespace d3d12 {
|
||||||
renderPassBuilder->SetStencilNoAccess();
|
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 {
|
} else {
|
||||||
renderPassBuilder->SetDepthStencilNoAccess();
|
renderPassBuilder->SetDepthStencilNoAccess();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue