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:
parent
5a0f8d32a2
commit
85e6337027
|
@ -123,8 +123,6 @@ MaybeError CommandRecordingContext::ExecuteCommandList(Device* device) {
|
|||
ID3D12CommandList* d3d12CommandList = GetCommandList();
|
||||
device->GetCommandQueue()->ExecuteCommandLists(1, &d3d12CommandList);
|
||||
|
||||
DAWN_TRY(device->NextSerial());
|
||||
|
||||
for (Texture* texture : mSharedTextures) {
|
||||
DAWN_TRY(texture->SynchronizeImportedTextureAfterUse());
|
||||
}
|
||||
|
|
|
@ -338,8 +338,8 @@ MaybeError Device::TickImpl() {
|
|||
mUsedComObjectRefs.ClearUpTo(completedSerial);
|
||||
|
||||
if (mPendingCommands.IsOpen()) {
|
||||
// CommandRecordingContext::ExecuteCommandList() calls NextSerial().
|
||||
DAWN_TRY(ExecutePendingCommandContext());
|
||||
DAWN_TRY(NextSerial());
|
||||
}
|
||||
|
||||
DAWN_TRY(CheckDebugLayerAndGenerateErrors());
|
||||
|
|
|
@ -91,7 +91,6 @@ class Device final : public DeviceBase {
|
|||
|
||||
void ReferenceUntilUnused(ComPtr<IUnknown> object);
|
||||
|
||||
// Execute pending CommandRecordingContext, and increment last submitted serial if needed.
|
||||
MaybeError ExecutePendingCommandContext();
|
||||
|
||||
ResultOrError<std::unique_ptr<StagingBufferBase>> CreateStagingBuffer(size_t size) override;
|
||||
|
|
|
@ -691,19 +691,19 @@ ResultOrError<ExecutionSerial> Texture::EndAccess() {
|
|||
// 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.
|
||||
DAWN_TRY(ToBackend(GetDevice())->ExecutePendingCommandContext());
|
||||
|
||||
// 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.
|
||||
if (!mSignalFenceValue.has_value()) {
|
||||
DAWN_TRY(SynchronizeImportedTextureBeforeUse());
|
||||
DAWN_TRY(ToBackend(GetDevice())->NextSerial());
|
||||
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();
|
||||
ASSERT(ret <= GetDevice()->GetLastSubmittedCommandSerial());
|
||||
// Explicitly call reset() since std::move() on optional doesn't make it std::nullopt.
|
||||
mSignalFenceValue.reset();
|
||||
return ret;
|
||||
}
|
||||
|
@ -760,8 +760,8 @@ MaybeError Texture::SynchronizeImportedTextureAfterUse() {
|
|||
if (mD3D11on12Resource != nullptr) {
|
||||
DAWN_TRY(mD3D11on12Resource->ReleaseKeyedMutex());
|
||||
} else {
|
||||
// CommandRecordingContext will call NextSerial() to increment the fence before this call.
|
||||
mSignalFenceValue = ToBackend(GetDevice())->GetLastSubmittedCommandSerial();
|
||||
// NextSerial() will be called after this - this is also checked in EndAccess().
|
||||
mSignalFenceValue = ToBackend(GetDevice())->GetPendingCommandSerial();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue