From 319672791e8e46421e9fac35aa36131970b04857 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Thu, 16 Apr 2020 18:59:53 +0000 Subject: [PATCH] D3D12: Remove ComPtr from d3d12::Device::GetD3D12Device() Accessing the d3d device using COM needlessly refcounts. This is a particular issue in areas that frequently access the d3d device like Populate(). BUG=dawn:155 Change-Id: I24e83093623afd02fa592d8ec0c404b4571c374b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19703 Reviewed-by: Rafael Cintron Reviewed-by: Austin Eng Commit-Queue: Bryan Bernhart --- src/dawn_native/d3d12/BindGroupD3D12.cpp | 4 ++-- src/dawn_native/d3d12/CommandBufferD3D12.cpp | 2 +- src/dawn_native/d3d12/DeviceD3D12.cpp | 4 ++-- src/dawn_native/d3d12/DeviceD3D12.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dawn_native/d3d12/BindGroupD3D12.cpp b/src/dawn_native/d3d12/BindGroupD3D12.cpp index 950279eb5b..ee48625a36 100644 --- a/src/dawn_native/d3d12/BindGroupD3D12.cpp +++ b/src/dawn_native/d3d12/BindGroupD3D12.cpp @@ -44,7 +44,7 @@ namespace dawn_native { namespace d3d12 { const auto& bindingOffsets = bgl->GetBindingOffsets(); - ID3D12Device* d3d12Device = device->GetD3D12Device().Get(); + ID3D12Device* d3d12Device = device->GetD3D12Device(); // It's not necessary to create descriptors in the descriptor heap for dynamic resources. // This is because they are created as root descriptors which are never heap allocated. @@ -162,7 +162,7 @@ namespace dawn_native { namespace d3d12 { const BindGroupLayout* bgl = ToBackend(GetLayout()); const Serial pendingSerial = device->GetPendingCommandSerial(); - ID3D12Device* d3d12Device = device->GetD3D12Device().Get(); + ID3D12Device* d3d12Device = device->GetD3D12Device(); // CPU bindgroups are sparsely allocated across CPU heaps. Instead of doing // simple copies per bindgroup, a single non-simple copy could be issued. diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp index 104e5b1487..088480e6d6 100644 --- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp @@ -309,7 +309,7 @@ namespace dawn_native { namespace d3d12 { DAWN_TRY_ASSIGN(rtvHeap, allocator->AllocateCPUHeap(D3D12_DESCRIPTOR_HEAP_TYPE_RTV, rtvCount)); ASSERT(rtvHeap.Get() != nullptr); - ID3D12Device* d3dDevice = device->GetD3D12Device().Get(); + ID3D12Device* d3dDevice = device->GetD3D12Device(); unsigned int rtvIndex = 0; for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) { diff --git a/src/dawn_native/d3d12/DeviceD3D12.cpp b/src/dawn_native/d3d12/DeviceD3D12.cpp index 9dce6e38e7..755c4be4e5 100644 --- a/src/dawn_native/d3d12/DeviceD3D12.cpp +++ b/src/dawn_native/d3d12/DeviceD3D12.cpp @@ -135,8 +135,8 @@ namespace dawn_native { namespace d3d12 { ShutDownBase(); } - ComPtr Device::GetD3D12Device() const { - return mD3d12Device; + ID3D12Device* Device::GetD3D12Device() const { + return mD3d12Device.Get(); } ComPtr Device::GetCommandQueue() const { diff --git a/src/dawn_native/d3d12/DeviceD3D12.h b/src/dawn_native/d3d12/DeviceD3D12.h index 38334d5d24..1f3a95827b 100644 --- a/src/dawn_native/d3d12/DeviceD3D12.h +++ b/src/dawn_native/d3d12/DeviceD3D12.h @@ -59,7 +59,7 @@ namespace dawn_native { namespace d3d12 { Serial GetLastSubmittedCommandSerial() const final override; MaybeError TickImpl() override; - ComPtr GetD3D12Device() const; + ID3D12Device* GetD3D12Device() const; ComPtr GetCommandQueue() const; ID3D12SharingContract* GetSharingContract() const;