From 918f7be8add9995e3ce5779222b823dabb662b45 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Fri, 5 Aug 2022 13:14:14 -0700 Subject: [PATCH] Reland "Remove depreciated APIs. (#564)" This reverts commit 12650353cb859453d1cd26b39af92e03beee770b. --- .github/workflows/.patches/dawn.diff | 37 ++++++++------- scripts/webnn.deps | 2 +- src/gpgmm/d3d12/HeapD3D12.h | 7 --- src/gpgmm/d3d12/ResidencyListD3D12.cpp | 35 -------------- src/gpgmm/d3d12/ResidencyListD3D12.h | 56 ++--------------------- src/gpgmm/d3d12/ResidencyManagerD3D12.cpp | 24 ---------- src/gpgmm/d3d12/ResidencyManagerD3D12.h | 17 ------- 7 files changed, 22 insertions(+), 156 deletions(-) diff --git a/.github/workflows/.patches/dawn.diff b/.github/workflows/.patches/dawn.diff index 1f8172f46..db4dbf19b 100644 --- a/.github/workflows/.patches/dawn.diff +++ b/.github/workflows/.patches/dawn.diff @@ -1,4 +1,4 @@ -From be80c6e52d951647f7f501ad665ab6506acae698 Mon Sep 17 00:00:00 2001 +From 8ef270d881c9f8d91a3acbaa7f8fbc572baa3d57 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Tue, 15 Feb 2022 17:25:29 -0800 Subject: [PATCH] Use GPGMM for D3D12 backend. @@ -22,7 +22,7 @@ Change-Id: I47708462a1d9dd0166120c3a6af93451aae54a07 src/dawn/native/d3d12/D3D12Backend.cpp | 17 ++- src/dawn/native/d3d12/DeviceD3D12.cpp | 114 +++++++++++++++--- src/dawn/native/d3d12/DeviceD3D12.h | 20 +-- - .../ShaderVisibleDescriptorAllocatorD3D12.cpp | 80 +++++++----- + .../ShaderVisibleDescriptorAllocatorD3D12.cpp | 79 +++++++----- .../ShaderVisibleDescriptorAllocatorD3D12.h | 11 +- src/dawn/native/d3d12/StagingBufferD3D12.cpp | 22 +--- src/dawn/native/d3d12/StagingBufferD3D12.h | 4 +- @@ -31,7 +31,7 @@ Change-Id: I47708462a1d9dd0166120c3a6af93451aae54a07 src/dawn/native/d3d12/UtilsD3D12.cpp | 11 ++ src/dawn/native/d3d12/UtilsD3D12.h | 2 + .../tests/white_box/D3D12ResidencyTests.cpp | 17 +-- - 26 files changed, 326 insertions(+), 162 deletions(-) + 26 files changed, 325 insertions(+), 162 deletions(-) create mode 100644 build_overrides/gpgmm.gni diff --git a/.gitignore b/.gitignore @@ -725,7 +725,7 @@ index 99b03e396..b1cf46fd0 100644 static constexpr uint32_t kMaxSamplerDescriptorsPerBindGroup = 3 * kMaxSamplersPerShaderStage; static constexpr uint32_t kMaxViewDescriptorsPerBindGroup = diff --git a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp -index fe99a63ac..40ce7b4a7 100644 +index fe99a63ac..e169435f9 100644 --- a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp +++ b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp @@ -93,7 +93,8 @@ ShaderVisibleDescriptorAllocator::ShaderVisibleDescriptorAllocator( @@ -738,7 +738,7 @@ index fe99a63ac..40ce7b4a7 100644 ASSERT(heapType == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV || heapType == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); } -@@ -140,31 +141,41 @@ void ShaderVisibleDescriptorAllocator::Tick(ExecutionSerial completedSerial) { +@@ -140,31 +141,40 @@ void ShaderVisibleDescriptorAllocator::Tick(ExecutionSerial completedSerial) { ResultOrError> ShaderVisibleDescriptorAllocator::AllocateHeap(uint32_t descriptorCount) const { @@ -787,19 +787,18 @@ index fe99a63ac..40ce7b4a7 100644 - // We must track the allocation in the LRU when it is created, otherwise the residency - // manager will see the allocation as non-resident in the later call to LockAllocation. - mDevice->GetResidencyManager()->TrackResidentAllocation(descriptorHeap.get()); -+ gpgmm::d3d12::Heap* descriptorHeapPtr = nullptr; ++ ComPtr descriptorHeap; + DAWN_TRY(CheckOutOfMemoryHRESULT( + gpgmm::d3d12::Heap::CreateHeap(heapDesc, mDevice->GetResidencyManager(), createHeapFn, -+ &descriptorHeapPtr), ++ &descriptorHeap), + "Unable to create descriptor heap")); - return std::move(descriptorHeap); -+ return std::make_unique( -+ std::unique_ptr(descriptorHeapPtr)); ++ return std::make_unique(std::move(descriptorHeap)); } // Creates a GPU descriptor heap that manages descriptors in a FIFO queue. -@@ -174,7 +185,9 @@ MaybeError ShaderVisibleDescriptorAllocator::AllocateAndSwitchShaderVisibleHeap( +@@ -174,7 +184,9 @@ MaybeError ShaderVisibleDescriptorAllocator::AllocateAndSwitchShaderVisibleHeap( // The first phase increasingly grows a small heap in binary sizes for light users while the // second phase pool-allocates largest sized heaps for heavy users. if (mHeap != nullptr) { @@ -810,7 +809,7 @@ index fe99a63ac..40ce7b4a7 100644 const uint32_t maxDescriptorCount = GetD3D12ShaderVisibleHeapMaxSize( mHeapType, mDevice->IsToggleEnabled(Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); -@@ -200,7 +213,10 @@ MaybeError ShaderVisibleDescriptorAllocator::AllocateAndSwitchShaderVisibleHeap( +@@ -200,7 +212,10 @@ MaybeError ShaderVisibleDescriptorAllocator::AllocateAndSwitchShaderVisibleHeap( DAWN_TRY_ASSIGN(descriptorHeap, AllocateHeap(mDescriptorCount)); } @@ -822,7 +821,7 @@ index fe99a63ac..40ce7b4a7 100644 // Create a FIFO buffer from the recently created heap. mHeap = std::move(descriptorHeap); -@@ -227,12 +243,12 @@ uint64_t ShaderVisibleDescriptorAllocator::GetShaderVisiblePoolSizeForTesting() +@@ -227,12 +242,12 @@ uint64_t ShaderVisibleDescriptorAllocator::GetShaderVisiblePoolSizeForTesting() } bool ShaderVisibleDescriptorAllocator::IsShaderVisibleHeapLockedResidentForTesting() const { @@ -837,7 +836,7 @@ index fe99a63ac..40ce7b4a7 100644 } bool ShaderVisibleDescriptorAllocator::IsAllocationStillValid( -@@ -244,12 +260,18 @@ bool ShaderVisibleDescriptorAllocator::IsAllocationStillValid( +@@ -244,12 +259,18 @@ bool ShaderVisibleDescriptorAllocator::IsAllocationStillValid( } ShaderVisibleDescriptorHeap::ShaderVisibleDescriptorHeap( @@ -845,24 +844,24 @@ index fe99a63ac..40ce7b4a7 100644 - uint64_t size) - : Pageable(d3d12DescriptorHeap, MemorySegment::Local, size), - mD3d12DescriptorHeap(std::move(d3d12DescriptorHeap)) {} -+ std::unique_ptr descriptorHeap) ++ ComPtr descriptorHeap) + : mDescriptorHeap(std::move(descriptorHeap)) {} ID3D12DescriptorHeap* ShaderVisibleDescriptorHeap::GetD3D12DescriptorHeap() const { - return mD3d12DescriptorHeap.Get(); + ComPtr descriptorHeap; -+ HRESULT hr = mDescriptorHeap->As(&descriptorHeap); ++ HRESULT hr = mDescriptorHeap.As(&descriptorHeap); + ASSERT(SUCCEEDED(hr)); + return descriptorHeap.Get(); +} + +gpgmm::d3d12::Heap* ShaderVisibleDescriptorHeap::GetHeap() const { -+ return mDescriptorHeap.get(); ++ return mDescriptorHeap.Get(); } + } // namespace dawn::native::d3d12 diff --git a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.h b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.h -index cf09f9d50..008b54818 100644 +index cf09f9d50..86a661c4a 100644 --- a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.h +++ b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.h @@ -24,6 +24,8 @@ @@ -882,13 +881,13 @@ index cf09f9d50..008b54818 100644 +class ShaderVisibleDescriptorHeap { public: - ShaderVisibleDescriptorHeap(ComPtr d3d12DescriptorHeap, uint64_t size); -+ ShaderVisibleDescriptorHeap(std::unique_ptr descriptorHeap); ++ ShaderVisibleDescriptorHeap(ComPtr descriptorHeap); ID3D12DescriptorHeap* GetD3D12DescriptorHeap() const; + gpgmm::d3d12::Heap* GetHeap() const; private: - ComPtr mD3d12DescriptorHeap; -+ std::unique_ptr mDescriptorHeap; ++ ComPtr mDescriptorHeap; }; class ShaderVisibleDescriptorAllocator { diff --git a/scripts/webnn.deps b/scripts/webnn.deps index a68b675bb..ac370e080 100644 --- a/scripts/webnn.deps +++ b/scripts/webnn.deps @@ -34,7 +34,7 @@ deps = { }, 'third_party/webnn_native': { - 'url': '{github_git}/webmachinelearning/webnn-native.git@bcbc5217cc92d7a0cc1c18f0809a16d6d0722e96', + 'url': '{github_git}/webmachinelearning/webnn-native.git@294de6bca89094ede3f7693bb7d0c7edf44e5141', 'condition': 'checkout_webnn', }, diff --git a/src/gpgmm/d3d12/HeapD3D12.h b/src/gpgmm/d3d12/HeapD3D12.h index 1943182ca..4c78eb847 100644 --- a/src/gpgmm/d3d12/HeapD3D12.h +++ b/src/gpgmm/d3d12/HeapD3D12.h @@ -166,14 +166,7 @@ namespace gpgmm::d3d12 { \return Error HRESULT if the specified interface was not represented by the heap. - - \deprecated Use ComPtr - HRESULT As(Microsoft::WRL::Details::ComPtrRef> ptr) const { - return mPageable.As(ptr); - } - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override; /** \brief Determine if the heap is resident or not. diff --git a/src/gpgmm/d3d12/ResidencyListD3D12.cpp b/src/gpgmm/d3d12/ResidencyListD3D12.cpp index c2ca8f74a..15028ab88 100644 --- a/src/gpgmm/d3d12/ResidencyListD3D12.cpp +++ b/src/gpgmm/d3d12/ResidencyListD3D12.cpp @@ -52,39 +52,4 @@ namespace gpgmm::d3d12 { return "ResidencyList"; } - ResidencySet::ResidencySet() { - GPGMM_TRACE_EVENT_OBJECT_NEW(this); - } - - ResidencySet::~ResidencySet() { - GPGMM_TRACE_EVENT_OBJECT_DESTROY(this); - } - - HRESULT ResidencySet::Insert(Heap* pHeap) { - if (pHeap == nullptr) { - return E_INVALIDARG; - } - if (mSet.insert(pHeap).second) { - return S_OK; - } - return S_FALSE; - } - - HRESULT ResidencySet::Reset() { - mSet.clear(); - return S_OK; - } - - ResidencySet::UnderlyingType::iterator ResidencySet::begin() const { - return mSet.begin(); - } - - ResidencySet::UnderlyingType::iterator ResidencySet::end() const { - return mSet.end(); - } - - const char* ResidencySet::GetTypename() const { - return "ResidencySet"; - } - } // namespace gpgmm::d3d12 diff --git a/src/gpgmm/d3d12/ResidencyListD3D12.h b/src/gpgmm/d3d12/ResidencyListD3D12.h index f41bffa64..30a46fdc7 100644 --- a/src/gpgmm/d3d12/ResidencyListD3D12.h +++ b/src/gpgmm/d3d12/ResidencyListD3D12.h @@ -18,7 +18,6 @@ #include "gpgmm/d3d12/d3d12_platform.h" #include "include/gpgmm_export.h" -#include #include namespace gpgmm::d3d12 { @@ -28,7 +27,7 @@ namespace gpgmm::d3d12 { /** \brief Represents a list of heaps which will be "made resident" when executing a command-list. - A residency set helps track heaps for residency which will be referenced together by a + A residency list helps track heaps for residency which will be referenced together by a command-list. The application uses a ResidencyList by inserting heaps, by calling ResourceAllocation::GetMemory, into the list. Once ResidencyManager::ExecuteCommandLists is called, the list can be reset or cleared for the next frame. @@ -55,9 +54,9 @@ namespace gpgmm::d3d12 { */ HRESULT Add(Heap* pHeap); - /** \brief Reset this residency set. + /** \brief Reset this residency list. - Removes all heaps from the set so the set can be re-used. + Removes all heaps from the list so the list can be re-used. */ HRESULT Reset(); @@ -72,55 +71,6 @@ namespace gpgmm::d3d12 { UnderlyingType mList; }; - /** \brief Represents a set of heaps which will be "made resident" when executing a - command-list. - - A residency set helps track heaps for residency which will be referenced together by a - command-list. The application uses a ResidencySet by inserting heaps, by calling - ResourceAllocation::GetMemory, into the set. Once ResidencyManager::ExecuteCommandLists is - called, the set can be reset or cleared for the next frame. - - Without a ResidencySet, the application would need to manually ResidencyManager::LockHeap and - ResidencyManager::UnlockHeap each heap before and after ResidencyManager::ExecuteCommandLists, - respectively. - - \deprecated Use ResidencyList instead of ResidencySet. - */ - class GPGMM_EXPORT ResidencySet final { - public: - /** \brief Create a residency set or collection of heaps to manage together for residency. - */ - ResidencySet(); - ~ResidencySet(); - - ResidencySet(const ResidencySet&) = default; - ResidencySet& operator=(const ResidencySet&) = default; - - /** \brief Insert heap into this residency set. - - @param pHeap A pointer to Heap about to be inserted. - - \return S_OK if heap was inserted or S_FALSE if heap was already inserted, else error. - */ - HRESULT Insert(Heap* pHeap); - - /** \brief Reset this residency set. - - Removes all heaps from the set so the set can be re-used. - */ - HRESULT Reset(); - - using UnderlyingType = std::set; - - UnderlyingType::iterator begin() const; - UnderlyingType::iterator end() const; - - private: - const char* GetTypename() const; - - UnderlyingType mSet; - }; - } // namespace gpgmm::d3d12 #endif diff --git a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp index 7bb297451..01238a32e 100644 --- a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp +++ b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp @@ -565,30 +565,6 @@ namespace gpgmm::d3d12 { return S_OK; } - /** \brief Execute command lists using residency managed heaps. - * - \deprecated use ResidencyList instead of ResidencySet - */ - HRESULT ResidencyManager::ExecuteCommandLists(ID3D12CommandQueue* pQueue, - ID3D12CommandList* const* ppCommandLists, - ResidencySet* const* ppResidencySets, - uint32_t count) { - ResidencyList residencyList; - - // TODO: support multiple command lists. - if (count > 1) { - return E_NOTIMPL; - } - - for (Heap* heap : *ppResidencySets[0]) { - residencyList.Add(heap); - } - - ResidencyList* residencyListPtr = &residencyList; - - return ExecuteCommandLists(pQueue, ppCommandLists, &residencyListPtr, count); - } - // Given a list of heaps that are pending usage, this function will estimate memory needed, // evict resources until enough space is available, then make resident any heaps scheduled for // usage. diff --git a/src/gpgmm/d3d12/ResidencyManagerD3D12.h b/src/gpgmm/d3d12/ResidencyManagerD3D12.h index 4d91073cb..ec079a93a 100644 --- a/src/gpgmm/d3d12/ResidencyManagerD3D12.h +++ b/src/gpgmm/d3d12/ResidencyManagerD3D12.h @@ -33,7 +33,6 @@ namespace gpgmm::d3d12 { class Fence; class Heap; class ResidencyList; - class ResidencySet; class ResourceAllocator; /** \struct RESIDENCY_DESC @@ -193,22 +192,6 @@ namespace gpgmm::d3d12 { ResidencyList* const* ppResidencyLists, uint32_t count); - /** \brief Execute command lists using residency managed heaps. - - Submits an array of command lists and residency sets for the specified command queue. - - @param pQueue The command queue to submit to. - @param ppCommandLists The array of ID3D12CommandList command lists to be executed. - @param ppResidencySets The array of ResidencySet residency sets to make resident. - @param count The size of commandLists and residencyLists arrays. - - \deprecated Use ResidencyList instead of ResidencySet. - */ - HRESULT ExecuteCommandLists(ID3D12CommandQueue* pQueue, - ID3D12CommandList* const* ppCommandLists, - ResidencySet* const* ppResidencySets, - uint32_t count); - /** \brief Sets video memory reservation. A reservation is the lowest amount of physical memory the application need to continue