mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-07 05:36:04 +00:00
d3d11: Fix the failing BufferMapping cases.
This adds buffer usage tracking and corrects the usage of pending command context. Bug: dawn:1705 Change-Id: If327169429d4e0909bbcaa87a14bac9ef01ac2ad Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128180 Reviewed-by: Peng Huang <penghuang@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Jie A Chen <jie.a.chen@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
9b726858ff
commit
2fd411f7fe
@ -407,6 +407,7 @@ MaybeError Buffer::Write(CommandRecordingContext* commandContext,
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MarkUsedInPendingCommands();
|
||||||
// Map the buffer if it is possible, so EnsureDataInitializedAsDestination() and WriteInternal()
|
// Map the buffer if it is possible, so EnsureDataInitializedAsDestination() and WriteInternal()
|
||||||
// can write the mapped memory directly.
|
// can write the mapped memory directly.
|
||||||
ScopedMap scopedMap;
|
ScopedMap scopedMap;
|
||||||
|
@ -296,6 +296,8 @@ MaybeError CommandBuffer::Execute() {
|
|||||||
// Buffer::Copy() will ensure the source and destination buffers are initialized.
|
// Buffer::Copy() will ensure the source and destination buffers are initialized.
|
||||||
DAWN_TRY(Buffer::Copy(commandContext, source, copy->sourceOffset, copy->size,
|
DAWN_TRY(Buffer::Copy(commandContext, source, copy->sourceOffset, copy->size,
|
||||||
destination, copy->destinationOffset));
|
destination, copy->destinationOffset));
|
||||||
|
source->MarkUsedInPendingCommands();
|
||||||
|
destination->MarkUsedInPendingCommands();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,6 +328,7 @@ MaybeError CommandBuffer::Execute() {
|
|||||||
DAWN_TRY(texture->Write(commandContext, subresources, copy->destination.origin,
|
DAWN_TRY(texture->Write(commandContext, subresources, copy->destination.origin,
|
||||||
copy->copySize, data, copy->source.bytesPerRow,
|
copy->copySize, data, copy->source.bytesPerRow,
|
||||||
copy->source.rowsPerImage));
|
copy->source.rowsPerImage));
|
||||||
|
buffer->MarkUsedInPendingCommands();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,6 +426,7 @@ MaybeError CommandBuffer::Execute() {
|
|||||||
d3d11DeviceContext1->Unmap(stagingTexture.Get(), z);
|
d3d11DeviceContext1->Unmap(stagingTexture.Get(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dst.buffer->MarkUsedInPendingCommands();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,6 +450,7 @@ MaybeError CommandBuffer::Execute() {
|
|||||||
}
|
}
|
||||||
Buffer* buffer = ToBackend(cmd->buffer.Get());
|
Buffer* buffer = ToBackend(cmd->buffer.Get());
|
||||||
DAWN_TRY(buffer->Clear(commandContext, 0, cmd->offset, cmd->size));
|
DAWN_TRY(buffer->Clear(commandContext, 0, cmd->offset, cmd->size));
|
||||||
|
buffer->MarkUsedInPendingCommands();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,6 +472,7 @@ MaybeError CommandBuffer::Execute() {
|
|||||||
Buffer* dstBuffer = ToBackend(cmd->buffer.Get());
|
Buffer* dstBuffer = ToBackend(cmd->buffer.Get());
|
||||||
uint8_t* data = mCommands.NextData<uint8_t>(cmd->size);
|
uint8_t* data = mCommands.NextData<uint8_t>(cmd->size);
|
||||||
DAWN_TRY(dstBuffer->Write(commandContext, cmd->offset, data, cmd->size));
|
DAWN_TRY(dstBuffer->Write(commandContext, cmd->offset, data, cmd->size));
|
||||||
|
dstBuffer->MarkUsedInPendingCommands();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ MaybeError CommandRecordingContext::Open(Device* device) {
|
|||||||
|
|
||||||
MaybeError CommandRecordingContext::ExecuteCommandList(Device* device) {
|
MaybeError CommandRecordingContext::ExecuteCommandList(Device* device) {
|
||||||
// Consider using deferred DeviceContext.
|
// Consider using deferred DeviceContext.
|
||||||
|
mNeedsSubmit = false;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,8 @@ MaybeError Device::NextSerial() {
|
|||||||
TRACE_EVENT1(GetPlatform(), General, "D3D11Device::SignalFence", "serial",
|
TRACE_EVENT1(GetPlatform(), General, "D3D11Device::SignalFence", "serial",
|
||||||
uint64_t(GetLastSubmittedCommandSerial()));
|
uint64_t(GetLastSubmittedCommandSerial()));
|
||||||
|
|
||||||
CommandRecordingContext* commandContext = GetPendingCommandContext();
|
CommandRecordingContext* commandContext =
|
||||||
|
GetPendingCommandContext(DeviceBase::SubmitMode::Passive);
|
||||||
DAWN_TRY(CheckHRESULT(commandContext->GetD3D11DeviceContext4()->Signal(
|
DAWN_TRY(CheckHRESULT(commandContext->GetD3D11DeviceContext4()->Signal(
|
||||||
mFence.Get(), uint64_t(GetLastSubmittedCommandSerial())),
|
mFence.Get(), uint64_t(GetLastSubmittedCommandSerial())),
|
||||||
"D3D11 command queue signal fence"));
|
"D3D11 command queue signal fence"));
|
||||||
@ -228,14 +229,10 @@ bool Device::HasPendingCommands() const {
|
|||||||
return mPendingCommands.NeedsSubmit();
|
return mPendingCommands.NeedsSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::ForceEventualFlushOfCommands() {
|
void Device::ForceEventualFlushOfCommands() {}
|
||||||
if (mPendingCommands.IsOpen()) {
|
|
||||||
mPendingCommands.SetNeedsSubmit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MaybeError Device::ExecutePendingCommandContext() {
|
MaybeError Device::ExecutePendingCommandContext() {
|
||||||
return {};
|
return mPendingCommands.ExecuteCommandList(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<Ref<BindGroupBase>> Device::CreateBindGroupImpl(
|
ResultOrError<Ref<BindGroupBase>> Device::CreateBindGroupImpl(
|
||||||
|
@ -38,6 +38,7 @@ MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* co
|
|||||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||||
DAWN_TRY(ToBackend(commands[i])->Execute());
|
DAWN_TRY(ToBackend(commands[i])->Execute());
|
||||||
}
|
}
|
||||||
|
DAWN_TRY(device->ExecutePendingCommandContext());
|
||||||
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferD3D11::Execute");
|
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferD3D11::Execute");
|
||||||
|
|
||||||
DAWN_TRY(device->NextSerial());
|
DAWN_TRY(device->NextSerial());
|
||||||
|
@ -634,11 +634,6 @@ TEST_P(BufferMappingCallbackTests, EmptySubmissionAndThenMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BufferMappingCallbackTests, UseTheBufferAndThenMap) {
|
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);
|
wgpu::Buffer buffer = CreateMapWriteBuffer(4);
|
||||||
MapAsyncAndWait(buffer, wgpu::MapMode::Write, 0, wgpu::kWholeMapSize);
|
MapAsyncAndWait(buffer, wgpu::MapMode::Write, 0, wgpu::kWholeMapSize);
|
||||||
buffer.Unmap();
|
buffer.Unmap();
|
||||||
@ -678,11 +673,6 @@ TEST_P(BufferMappingCallbackTests, UseTheBufferAndThenMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BufferMappingCallbackTests, EmptySubmissionWriteAndThenMap) {
|
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);
|
wgpu::Buffer buffer = CreateMapReadBuffer(4);
|
||||||
MapAsyncAndWait(buffer, wgpu::MapMode::Read, 0, wgpu::kWholeMapSize);
|
MapAsyncAndWait(buffer, wgpu::MapMode::Read, 0, wgpu::kWholeMapSize);
|
||||||
buffer.Unmap();
|
buffer.Unmap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user