d3d11: support multisampled rendering and enable related tests

Bug: dawn:1804
Bug: dawn:1705
Change-Id: Ic90a42dab7149af261af790ca393d8a595e3ec4c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132021
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Peng Huang 2023-05-10 01:44:26 +00:00 committed by Dawn LUCI CQ
parent 9af5ceb553
commit b6e73aa50a
3 changed files with 39 additions and 1 deletions

View File

@ -627,7 +627,42 @@ MaybeError CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass,
switch (type) { switch (type) {
case Command::EndRenderPass: { case Command::EndRenderPass: {
mCommands.NextCommand<EndRenderPassCmd>(); mCommands.NextCommand<EndRenderPassCmd>();
// 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 {}; return {};
} }

View File

@ -955,6 +955,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithBlendState) {
} }
DAWN_INSTANTIATE_TEST(CreatePipelineAsyncTest, DAWN_INSTANTIATE_TEST(CreatePipelineAsyncTest,
D3D11Backend(),
D3D12Backend(), D3D12Backend(),
MetalBackend(), MetalBackend(),
OpenGLBackend(), OpenGLBackend(),

View File

@ -1189,6 +1189,7 @@ TEST_P(MultisampledRenderingWithTransientAttachmentTest, ResolveTransientAttachm
} }
DAWN_INSTANTIATE_TEST(MultisampledRenderingTest, DAWN_INSTANTIATE_TEST(MultisampledRenderingTest,
D3D11Backend(),
D3D12Backend(), D3D12Backend(),
D3D12Backend({}, {"use_d3d12_resource_heap_tier2"}), D3D12Backend({}, {"use_d3d12_resource_heap_tier2"}),
D3D12Backend({}, {"use_d3d12_render_pass"}), D3D12Backend({}, {"use_d3d12_render_pass"}),
@ -1203,6 +1204,7 @@ DAWN_INSTANTIATE_TEST(MultisampledRenderingTest,
"emulate_store_and_msaa_resolve"})); "emulate_store_and_msaa_resolve"}));
DAWN_INSTANTIATE_TEST(MultisampledRenderingWithTransientAttachmentTest, DAWN_INSTANTIATE_TEST(MultisampledRenderingWithTransientAttachmentTest,
D3D11Backend(),
D3D12Backend(), D3D12Backend(),
D3D12Backend({}, {"use_d3d12_resource_heap_tier2"}), D3D12Backend({}, {"use_d3d12_resource_heap_tier2"}),
D3D12Backend({}, {"use_d3d12_render_pass"}), D3D12Backend({}, {"use_d3d12_render_pass"}),