1 // Copyright 2019 The Dawn Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "dawn_native/d3d12/ResourceHeapAllocationD3D12.h" 16 17 #include "dawn_native/d3d12/D3D12Error.h" 18 #include "dawn_native/d3d12/HeapD3D12.h" 19 20 #include <utility> 21 22 namespace dawn_native { namespace d3d12 { ResourceHeapAllocation(const AllocationInfo & info,uint64_t offset,ComPtr<ID3D12Resource> resource,Heap * heap)23 ResourceHeapAllocation::ResourceHeapAllocation(const AllocationInfo& info, 24 uint64_t offset, 25 ComPtr<ID3D12Resource> resource, 26 Heap* heap) 27 : ResourceMemoryAllocation(info, offset, heap), mResource(std::move(resource)) { 28 ASSERT((info.mMethod == AllocationMethod::kExternal) == (heap == nullptr)); 29 } 30 Invalidate()31 void ResourceHeapAllocation::Invalidate() { 32 ResourceMemoryAllocation::Invalidate(); 33 mResource.Reset(); 34 } 35 GetD3D12Resource() const36 ID3D12Resource* ResourceHeapAllocation::GetD3D12Resource() const { 37 return mResource.Get(); 38 } 39 GetGPUPointer() const40 D3D12_GPU_VIRTUAL_ADDRESS ResourceHeapAllocation::GetGPUPointer() const { 41 return mResource->GetGPUVirtualAddress(); 42 } 43 }} // namespace dawn_native::d3d12 44