mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Resource Management 7: Device memory sub-allocation using buddy allocator.
Uses a large buddy system to allocate binary sized heaps on-demand. BUG=dawn:27 Change-Id: I72e425c23e601da6ee53827423bef7ff13be049c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10880 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
This commit is contained in:
committed by
Commit Bot service account
parent
277d2e15d5
commit
21dfc91954
@@ -35,25 +35,36 @@ namespace dawn_native {
|
||||
kInvalid
|
||||
};
|
||||
|
||||
// Metadata that describes how the allocation was allocated.
|
||||
struct AllocationInfo {
|
||||
// AllocationInfo contains a separate offset to not confuse block vs memory offsets.
|
||||
// The block offset is within the entire allocator memory range and only required by the
|
||||
// buddy sub-allocator to get the corresponding memory. Unlike the block offset, the
|
||||
// allocation offset is always local to the memory.
|
||||
uint64_t mBlockOffset = 0;
|
||||
|
||||
AllocationMethod mMethod = AllocationMethod::kInvalid;
|
||||
};
|
||||
|
||||
// Handle into a resource heap pool.
|
||||
class ResourceMemoryAllocation {
|
||||
public:
|
||||
ResourceMemoryAllocation();
|
||||
ResourceMemoryAllocation(uint64_t offset,
|
||||
ResourceMemoryAllocation(const AllocationInfo& info,
|
||||
uint64_t offset,
|
||||
ResourceHeapBase* resourceHeap,
|
||||
AllocationMethod method,
|
||||
uint8_t* mappedPointer = nullptr);
|
||||
~ResourceMemoryAllocation() = default;
|
||||
|
||||
ResourceHeapBase* GetResourceHeap() const;
|
||||
uint64_t GetOffset() const;
|
||||
AllocationMethod GetAllocationMethod() const;
|
||||
uint8_t* GetMappedPointer() const;
|
||||
AllocationInfo GetInfo() const;
|
||||
|
||||
void Invalidate();
|
||||
|
||||
private:
|
||||
AllocationMethod mMethod;
|
||||
AllocationInfo mInfo;
|
||||
uint64_t mOffset;
|
||||
ResourceHeapBase* mResourceHeap;
|
||||
uint8_t* mMappedPointer;
|
||||
|
||||
Reference in New Issue
Block a user