diff --git a/src/dawn/native/d3d11/BufferD3D11.cpp b/src/dawn/native/d3d11/BufferD3D11.cpp index e6bf540137..82e1758f01 100644 --- a/src/dawn/native/d3d11/BufferD3D11.cpp +++ b/src/dawn/native/d3d11/BufferD3D11.cpp @@ -407,6 +407,7 @@ MaybeError Buffer::Write(CommandRecordingContext* commandContext, return {}; } + MarkUsedInPendingCommands(); // Map the buffer if it is possible, so EnsureDataInitializedAsDestination() and WriteInternal() // can write the mapped memory directly. ScopedMap scopedMap; diff --git a/src/dawn/native/d3d11/CommandBufferD3D11.cpp b/src/dawn/native/d3d11/CommandBufferD3D11.cpp index 365ebd87c4..5b9eda7f8f 100644 --- a/src/dawn/native/d3d11/CommandBufferD3D11.cpp +++ b/src/dawn/native/d3d11/CommandBufferD3D11.cpp @@ -296,6 +296,8 @@ MaybeError CommandBuffer::Execute() { // Buffer::Copy() will ensure the source and destination buffers are initialized. DAWN_TRY(Buffer::Copy(commandContext, source, copy->sourceOffset, copy->size, destination, copy->destinationOffset)); + source->MarkUsedInPendingCommands(); + destination->MarkUsedInPendingCommands(); break; } @@ -326,6 +328,7 @@ MaybeError CommandBuffer::Execute() { DAWN_TRY(texture->Write(commandContext, subresources, copy->destination.origin, copy->copySize, data, copy->source.bytesPerRow, copy->source.rowsPerImage)); + buffer->MarkUsedInPendingCommands(); break; } @@ -423,6 +426,7 @@ MaybeError CommandBuffer::Execute() { d3d11DeviceContext1->Unmap(stagingTexture.Get(), z); } + dst.buffer->MarkUsedInPendingCommands(); break; } @@ -446,6 +450,7 @@ MaybeError CommandBuffer::Execute() { } Buffer* buffer = ToBackend(cmd->buffer.Get()); DAWN_TRY(buffer->Clear(commandContext, 0, cmd->offset, cmd->size)); + buffer->MarkUsedInPendingCommands(); break; } @@ -467,6 +472,7 @@ MaybeError CommandBuffer::Execute() { Buffer* dstBuffer = ToBackend(cmd->buffer.Get()); uint8_t* data = mCommands.NextData(cmd->size); DAWN_TRY(dstBuffer->Write(commandContext, cmd->offset, data, cmd->size)); + dstBuffer->MarkUsedInPendingCommands(); break; } diff --git a/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp b/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp index 7025f2e736..e7add5ca82 100644 --- a/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp +++ b/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp @@ -76,6 +76,7 @@ MaybeError CommandRecordingContext::Open(Device* device) { MaybeError CommandRecordingContext::ExecuteCommandList(Device* device) { // Consider using deferred DeviceContext. + mNeedsSubmit = false; return {}; } diff --git a/src/dawn/native/d3d11/DeviceD3D11.cpp b/src/dawn/native/d3d11/DeviceD3D11.cpp index 72be4a488a..c2bea8a1d5 100644 --- a/src/dawn/native/d3d11/DeviceD3D11.cpp +++ b/src/dawn/native/d3d11/DeviceD3D11.cpp @@ -183,7 +183,8 @@ MaybeError Device::NextSerial() { TRACE_EVENT1(GetPlatform(), General, "D3D11Device::SignalFence", "serial", uint64_t(GetLastSubmittedCommandSerial())); - CommandRecordingContext* commandContext = GetPendingCommandContext(); + CommandRecordingContext* commandContext = + GetPendingCommandContext(DeviceBase::SubmitMode::Passive); DAWN_TRY(CheckHRESULT(commandContext->GetD3D11DeviceContext4()->Signal( mFence.Get(), uint64_t(GetLastSubmittedCommandSerial())), "D3D11 command queue signal fence")); @@ -228,14 +229,10 @@ bool Device::HasPendingCommands() const { return mPendingCommands.NeedsSubmit(); } -void Device::ForceEventualFlushOfCommands() { - if (mPendingCommands.IsOpen()) { - mPendingCommands.SetNeedsSubmit(); - } -} +void Device::ForceEventualFlushOfCommands() {} MaybeError Device::ExecutePendingCommandContext() { - return {}; + return mPendingCommands.ExecuteCommandList(this); } ResultOrError> Device::CreateBindGroupImpl( diff --git a/src/dawn/native/d3d11/QueueD3D11.cpp b/src/dawn/native/d3d11/QueueD3D11.cpp index 24d3945013..5bfaef0dc3 100644 --- a/src/dawn/native/d3d11/QueueD3D11.cpp +++ b/src/dawn/native/d3d11/QueueD3D11.cpp @@ -38,6 +38,7 @@ MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* co for (uint32_t i = 0; i < commandCount; ++i) { DAWN_TRY(ToBackend(commands[i])->Execute()); } + DAWN_TRY(device->ExecutePendingCommandContext()); TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferD3D11::Execute"); DAWN_TRY(device->NextSerial()); diff --git a/src/dawn/tests/end2end/BufferTests.cpp b/src/dawn/tests/end2end/BufferTests.cpp index db1d8427a7..eb7e61812f 100644 --- a/src/dawn/tests/end2end/BufferTests.cpp +++ b/src/dawn/tests/end2end/BufferTests.cpp @@ -634,11 +634,6 @@ TEST_P(BufferMappingCallbackTests, EmptySubmissionAndThenMap) { } TEST_P(BufferMappingCallbackTests, UseTheBufferAndThenMap) { - // TODO(dawn:1705): enable this test for D3D11. D3D11 MapAsync() calls - // ID3D11DeviceContext::Map() which will synchronize with GPU. so the callback will always be - // called earlier comparing to other backends. - DAWN_SUPPRESS_TEST_IF(IsD3D11()); - wgpu::Buffer buffer = CreateMapWriteBuffer(4); MapAsyncAndWait(buffer, wgpu::MapMode::Write, 0, wgpu::kWholeMapSize); buffer.Unmap(); @@ -678,11 +673,6 @@ TEST_P(BufferMappingCallbackTests, UseTheBufferAndThenMap) { } TEST_P(BufferMappingCallbackTests, EmptySubmissionWriteAndThenMap) { - // TODO(dawn:1705): enable this test for D3D11. D3D11 MapAsync() calls - // ID3D11DeviceContext::Map() which will synchronize with GPU. so the callback will always be - // called earlier comparing to other backends. - DAWN_SUPPRESS_TEST_IF(IsD3D11()); - wgpu::Buffer buffer = CreateMapReadBuffer(4); MapAsyncAndWait(buffer, wgpu::MapMode::Read, 0, wgpu::kWholeMapSize); buffer.Unmap();