Cleanup d3d12::Device::ExecuteCommandLists

- All callers were passing either 0 or 1 commandlist to this
function. Removing the initializer list means we can save an
std::vector heap allocation.
- Checking the number of lists before calling ExecuteCommandLists
eliminates superfluous entries in PIX logs.

Bug:dawn:222
Change-Id: Ic50b9293c3f31bf8f52e7de10161fd284ef2e0f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11060
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
This commit is contained in:
Rafael Cintron 2019-09-11 00:09:40 +00:00 committed by Commit Bot service account
parent f35dcfe60a
commit 03e31edd98
4 changed files with 16 additions and 15 deletions

View File

@ -224,7 +224,7 @@ namespace dawn_native { namespace d3d12 {
mDescriptorHeapAllocator->Tick(mCompletedSerial); mDescriptorHeapAllocator->Tick(mCompletedSerial);
mMapRequestTracker->Tick(mCompletedSerial); mMapRequestTracker->Tick(mCompletedSerial);
mUsedComObjectRefs.ClearUpTo(mCompletedSerial); mUsedComObjectRefs.ClearUpTo(mCompletedSerial);
ExecuteCommandLists({}); ExecuteCommandList(nullptr);
NextSerial(); NextSerial();
} }
@ -245,21 +245,22 @@ namespace dawn_native { namespace d3d12 {
mUsedComObjectRefs.Enqueue(object, GetPendingCommandSerial()); mUsedComObjectRefs.Enqueue(object, GetPendingCommandSerial());
} }
void Device::ExecuteCommandLists(std::initializer_list<ID3D12CommandList*> commandLists) { void Device::ExecuteCommandList(ID3D12CommandList* d3d12CommandList) {
UINT numLists = 0;
std::array<ID3D12CommandList*, 2> d3d12CommandLists;
// If there are pending commands, prepend them to ExecuteCommandLists // If there are pending commands, prepend them to ExecuteCommandLists
if (mPendingCommands.open) { if (mPendingCommands.open) {
std::vector<ID3D12CommandList*> lists(commandLists.size() + 1);
mPendingCommands.commandList->Close(); mPendingCommands.commandList->Close();
mPendingCommands.open = false; mPendingCommands.open = false;
lists[0] = mPendingCommands.commandList.Get(); d3d12CommandLists[numLists++] = mPendingCommands.commandList.Get();
std::copy(commandLists.begin(), commandLists.end(), lists.begin() + 1); }
mCommandQueue->ExecuteCommandLists(static_cast<UINT>(commandLists.size() + 1), if (d3d12CommandList != nullptr) {
lists.data()); d3d12CommandLists[numLists++] = d3d12CommandList;
mPendingCommands.commandList = nullptr; }
} else { if (numLists > 0) {
std::vector<ID3D12CommandList*> lists(commandLists); mCommandQueue->ExecuteCommandLists(numLists, d3d12CommandLists.data());
mCommandQueue->ExecuteCommandLists(static_cast<UINT>(commandLists.size()), mPendingCommands.commandList.Reset();
lists.data());
} }
} }

View File

@ -73,7 +73,7 @@ namespace dawn_native { namespace d3d12 {
void ReferenceUntilUnused(ComPtr<IUnknown> object); void ReferenceUntilUnused(ComPtr<IUnknown> object);
void ExecuteCommandLists(std::initializer_list<ID3D12CommandList*> commandLists); void ExecuteCommandList(ID3D12CommandList* d3d12CommandList);
ResultOrError<std::unique_ptr<StagingBufferBase>> CreateStagingBuffer(size_t size) override; ResultOrError<std::unique_ptr<StagingBufferBase>> CreateStagingBuffer(size_t size) override;
MaybeError CopyFromStagingToBuffer(StagingBufferBase* source, MaybeError CopyFromStagingToBuffer(StagingBufferBase* source,

View File

@ -33,7 +33,7 @@ namespace dawn_native { namespace d3d12 {
} }
ASSERT_SUCCESS(mCommandList->Close()); ASSERT_SUCCESS(mCommandList->Close());
device->ExecuteCommandLists({mCommandList.Get()}); device->ExecuteCommandList(mCommandList.Get());
device->NextSerial(); device->NextSerial();
} }

View File

@ -54,7 +54,7 @@ namespace dawn_native { namespace d3d12 {
// Perform the necessary transition for the texture to be presented. // Perform the necessary transition for the texture to be presented.
ToBackend(texture)->TransitionUsageNow(device->GetPendingCommandList(), mTextureUsage); ToBackend(texture)->TransitionUsageNow(device->GetPendingCommandList(), mTextureUsage);
device->ExecuteCommandLists({}); device->ExecuteCommandList(nullptr);
} }
}} // namespace dawn_native::d3d12 }} // namespace dawn_native::d3d12