d3d12: Move NextSerial out of ExecuteCommandList

Reverts to the code flow before fences were implemented. NextSerial is
now the reponsibility of the caller of ExecutePendingCommandContext like
it was before. We now use GetPendingCommandSerial to store the signal
fence value instead of GetLastSubmittedCommandSerial and check that the
signal fence value was submitted in EndAccess.

Bug: dawn:576
Change-Id: I616840a0932ec17f77fcab38058773006dfae32f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103501
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Sunny Sachanandani 2022-09-23 00:52:56 +00:00 committed by Dawn LUCI CQ
parent 5a0f8d32a2
commit 85e6337027
4 changed files with 7 additions and 10 deletions

View File

@ -123,8 +123,6 @@ MaybeError CommandRecordingContext::ExecuteCommandList(Device* device) {
ID3D12CommandList* d3d12CommandList = GetCommandList(); ID3D12CommandList* d3d12CommandList = GetCommandList();
device->GetCommandQueue()->ExecuteCommandLists(1, &d3d12CommandList); device->GetCommandQueue()->ExecuteCommandLists(1, &d3d12CommandList);
DAWN_TRY(device->NextSerial());
for (Texture* texture : mSharedTextures) { for (Texture* texture : mSharedTextures) {
DAWN_TRY(texture->SynchronizeImportedTextureAfterUse()); DAWN_TRY(texture->SynchronizeImportedTextureAfterUse());
} }

View File

@ -338,8 +338,8 @@ MaybeError Device::TickImpl() {
mUsedComObjectRefs.ClearUpTo(completedSerial); mUsedComObjectRefs.ClearUpTo(completedSerial);
if (mPendingCommands.IsOpen()) { if (mPendingCommands.IsOpen()) {
// CommandRecordingContext::ExecuteCommandList() calls NextSerial().
DAWN_TRY(ExecutePendingCommandContext()); DAWN_TRY(ExecutePendingCommandContext());
DAWN_TRY(NextSerial());
} }
DAWN_TRY(CheckDebugLayerAndGenerateErrors()); DAWN_TRY(CheckDebugLayerAndGenerateErrors());

View File

@ -91,7 +91,6 @@ class Device final : public DeviceBase {
void ReferenceUntilUnused(ComPtr<IUnknown> object); void ReferenceUntilUnused(ComPtr<IUnknown> object);
// Execute pending CommandRecordingContext, and increment last submitted serial if needed.
MaybeError ExecutePendingCommandContext(); MaybeError ExecutePendingCommandContext();
ResultOrError<std::unique_ptr<StagingBufferBase>> CreateStagingBuffer(size_t size) override; ResultOrError<std::unique_ptr<StagingBufferBase>> CreateStagingBuffer(size_t size) override;

View File

@ -691,19 +691,19 @@ ResultOrError<ExecutionSerial> Texture::EndAccess() {
// Needed to ensure that command allocator doesn't get destroyed before pending commands // Needed to ensure that command allocator doesn't get destroyed before pending commands
// are submitted due to calling NextSerial(). No-op if there are no pending commands. // are submitted due to calling NextSerial(). No-op if there are no pending commands.
DAWN_TRY(ToBackend(GetDevice())->ExecutePendingCommandContext()); DAWN_TRY(ToBackend(GetDevice())->ExecutePendingCommandContext());
// If there were pending commands that used this texture mSignalFenceValue will be set, // If there were pending commands that used this texture mSignalFenceValue will be set,
// but if it's still not set, generate a signal fence after waiting on wait fences. // but if it's still not set, generate a signal fence after waiting on wait fences.
if (!mSignalFenceValue.has_value()) { if (!mSignalFenceValue.has_value()) {
DAWN_TRY(SynchronizeImportedTextureBeforeUse()); DAWN_TRY(SynchronizeImportedTextureBeforeUse());
DAWN_TRY(ToBackend(GetDevice())->NextSerial());
DAWN_TRY(SynchronizeImportedTextureAfterUse()); DAWN_TRY(SynchronizeImportedTextureAfterUse());
ASSERT(mSignalFenceValue.has_value());
} }
DAWN_TRY(ToBackend(GetDevice())->NextSerial());
ASSERT(mSignalFenceValue.has_value());
} }
// Explicitly call reset() since std::move() on optional doesn't make it std::nullopt.
ExecutionSerial ret = mSignalFenceValue.value(); ExecutionSerial ret = mSignalFenceValue.value();
ASSERT(ret <= GetDevice()->GetLastSubmittedCommandSerial());
// Explicitly call reset() since std::move() on optional doesn't make it std::nullopt.
mSignalFenceValue.reset(); mSignalFenceValue.reset();
return ret; return ret;
} }
@ -760,8 +760,8 @@ MaybeError Texture::SynchronizeImportedTextureAfterUse() {
if (mD3D11on12Resource != nullptr) { if (mD3D11on12Resource != nullptr) {
DAWN_TRY(mD3D11on12Resource->ReleaseKeyedMutex()); DAWN_TRY(mD3D11on12Resource->ReleaseKeyedMutex());
} else { } else {
// CommandRecordingContext will call NextSerial() to increment the fence before this call. // NextSerial() will be called after this - this is also checked in EndAccess().
mSignalFenceValue = ToBackend(GetDevice())->GetLastSubmittedCommandSerial(); mSignalFenceValue = ToBackend(GetDevice())->GetPendingCommandSerial();
} }
return {}; return {};
} }