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/ResourceMemoryAllocation.h" 16 #include "common/Assert.h" 17 18 namespace dawn_native { 19 ResourceMemoryAllocation()20 ResourceMemoryAllocation::ResourceMemoryAllocation() 21 : mOffset(0), mResourceHeap(nullptr), mMappedPointer(nullptr) { 22 } 23 ResourceMemoryAllocation(const AllocationInfo & info,uint64_t offset,ResourceHeapBase * resourceHeap,uint8_t * mappedPointer)24 ResourceMemoryAllocation::ResourceMemoryAllocation(const AllocationInfo& info, 25 uint64_t offset, 26 ResourceHeapBase* resourceHeap, 27 uint8_t* mappedPointer) 28 : mInfo(info), mOffset(offset), mResourceHeap(resourceHeap), mMappedPointer(mappedPointer) { 29 } 30 GetResourceHeap() const31 ResourceHeapBase* ResourceMemoryAllocation::GetResourceHeap() const { 32 ASSERT(mInfo.mMethod != AllocationMethod::kInvalid); 33 return mResourceHeap; 34 } 35 GetOffset() const36 uint64_t ResourceMemoryAllocation::GetOffset() const { 37 ASSERT(mInfo.mMethod != AllocationMethod::kInvalid); 38 return mOffset; 39 } 40 GetInfo() const41 AllocationInfo ResourceMemoryAllocation::GetInfo() const { 42 return mInfo; 43 } 44 GetMappedPointer() const45 uint8_t* ResourceMemoryAllocation::GetMappedPointer() const { 46 return mMappedPointer; 47 } 48 Invalidate()49 void ResourceMemoryAllocation::Invalidate() { 50 mResourceHeap = nullptr; 51 mInfo = {}; 52 } 53 } // namespace dawn_native 54