mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +00:00
Preliminary changes to Vulkan memory suballocation
This mostly makes the MemoryAllocator not owned by the BuddyResourceAllocator so that we don't need an extra class for the dependency injection in the Vulkan backend. (the container for the BuddyMemoryAllocator can be it's MemoryAllocator at the same time). Also renames methods of MemoryAllocator to be more explicit. Also renames the constructor parameter of BuddyMemoryAllocator to be (subjectively) closer to what the represent. BUG=dawn:27 Change-Id: I37355ad5b3cded143956f0adc4742fa1b717e9bc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12661 Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
60a04dd18c
commit
ca35435716
@@ -15,22 +15,23 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "dawn_native/BuddyMemoryAllocator.h"
|
||||
#include "dawn_native/ResourceHeapAllocator.h"
|
||||
|
||||
using namespace dawn_native;
|
||||
|
||||
class DummyMemoryAllocator : public MemoryAllocator {
|
||||
class DummyResourceHeapAllocator : public ResourceHeapAllocator {
|
||||
public:
|
||||
ResultOrError<std::unique_ptr<ResourceHeapBase>> Allocate(uint64_t size) override {
|
||||
ResultOrError<std::unique_ptr<ResourceHeapBase>> AllocateResourceHeap(uint64_t size) override {
|
||||
return std::make_unique<ResourceHeapBase>();
|
||||
}
|
||||
void Deallocate(std::unique_ptr<ResourceHeapBase> allocation) override {
|
||||
void DeallocateResourceHeap(std::unique_ptr<ResourceHeapBase> allocation) override {
|
||||
}
|
||||
};
|
||||
|
||||
class DummyBuddyResourceAllocator {
|
||||
public:
|
||||
DummyBuddyResourceAllocator(uint64_t maxBlockSize, uint64_t memorySize)
|
||||
: mAllocator(maxBlockSize, memorySize, std::make_unique<DummyMemoryAllocator>()) {
|
||||
: mAllocator(maxBlockSize, memorySize, &mHeapAllocator) {
|
||||
}
|
||||
|
||||
ResourceMemoryAllocation Allocate(uint64_t allocationSize, uint64_t alignment = 1) {
|
||||
@@ -48,6 +49,7 @@ class DummyBuddyResourceAllocator {
|
||||
}
|
||||
|
||||
private:
|
||||
DummyResourceHeapAllocator mHeapAllocator;
|
||||
BuddyMemoryAllocator mAllocator;
|
||||
};
|
||||
|
||||
@@ -342,4 +344,4 @@ TEST(BuddyMemoryAllocatorTests, VariousSizeSameAlignment) {
|
||||
ASSERT_EQ(allocation4.GetInfo().mMethod, AllocationMethod::kSubAllocated);
|
||||
|
||||
ASSERT_EQ(allocator.ComputeTotalNumOfHeapsForTesting(), 3u);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user