diff --git a/src/dawn/native/d3d11/CommandBufferD3D11.cpp b/src/dawn/native/d3d11/CommandBufferD3D11.cpp index 4db4f9bc7c..48aee390cf 100644 --- a/src/dawn/native/d3d11/CommandBufferD3D11.cpp +++ b/src/dawn/native/d3d11/CommandBufferD3D11.cpp @@ -627,7 +627,42 @@ MaybeError CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass, switch (type) { case Command::EndRenderPass: { mCommands.NextCommand(); - // TODO(dawn:1705): resolve MSAA + ID3D11DeviceContext* d3d11DeviceContext = commandContext->GetD3D11DeviceContext(); + d3d11DeviceContext->OMSetRenderTargets(0, nullptr, nullptr); + + if (renderPass->attachmentState->GetSampleCount() <= 1) { + return {}; + } + + // Resolve multisampled textures. + for (ColorAttachmentIndex i : + IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) { + const auto& attachment = renderPass->colorAttachments[i]; + if (!attachment.resolveTarget.Get()) { + continue; + } + + if (attachment.storeOp != wgpu::StoreOp::Store) { + continue; + } + + ASSERT(attachment.view->GetAspects() == Aspect::Color); + ASSERT(attachment.resolveTarget->GetAspects() == Aspect::Color); + + Texture* resolveTexture = ToBackend(attachment.resolveTarget->GetTexture()); + Texture* colorTexture = ToBackend(attachment.view->GetTexture()); + uint32_t dstSubresource = resolveTexture->GetSubresourceIndex( + attachment.resolveTarget->GetBaseMipLevel(), + attachment.resolveTarget->GetBaseArrayLayer(), Aspect::Color); + uint32_t srcSubresource = colorTexture->GetSubresourceIndex( + attachment.view->GetBaseMipLevel(), attachment.view->GetBaseArrayLayer(), + Aspect::Color); + d3d11DeviceContext->ResolveSubresource( + resolveTexture->GetD3D11Resource(), dstSubresource, + colorTexture->GetD3D11Resource(), srcSubresource, + resolveTexture->GetD3D11Format()); + } + return {}; } diff --git a/src/dawn/tests/end2end/CreatePipelineAsyncTests.cpp b/src/dawn/tests/end2end/CreatePipelineAsyncTests.cpp index 627d3b28d4..5d945be8a2 100644 --- a/src/dawn/tests/end2end/CreatePipelineAsyncTests.cpp +++ b/src/dawn/tests/end2end/CreatePipelineAsyncTests.cpp @@ -955,6 +955,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithBlendState) { } DAWN_INSTANTIATE_TEST(CreatePipelineAsyncTest, + D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), diff --git a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp index 50a50f1abb..72d95c3f99 100644 --- a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp @@ -1189,6 +1189,7 @@ TEST_P(MultisampledRenderingWithTransientAttachmentTest, ResolveTransientAttachm } DAWN_INSTANTIATE_TEST(MultisampledRenderingTest, + D3D11Backend(), D3D12Backend(), D3D12Backend({}, {"use_d3d12_resource_heap_tier2"}), D3D12Backend({}, {"use_d3d12_render_pass"}), @@ -1203,6 +1204,7 @@ DAWN_INSTANTIATE_TEST(MultisampledRenderingTest, "emulate_store_and_msaa_resolve"})); DAWN_INSTANTIATE_TEST(MultisampledRenderingWithTransientAttachmentTest, + D3D11Backend(), D3D12Backend(), D3D12Backend({}, {"use_d3d12_resource_heap_tier2"}), D3D12Backend({}, {"use_d3d12_render_pass"}),