mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 10:26:29 +08:00
Tracking the internal allocation when creating a buffer
This fix prevents the creation of a buffer from the pointer obtained from clEnqueueMapBuffer Change-Id: I203f2d5263eeb02fe0d73bc9db159438af3cf1fc
This commit is contained in:
committed by
sys_ocldev
parent
c46f716d6c
commit
fe56c57318
@@ -183,6 +183,43 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDefaultDrmMemoryManger
|
||||
EXPECT_NE(nullptr, memoryManager->getDrmInternal32BitAllocator());
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationToHostPtrManagerThenfragmentHasCorrectValues) {
|
||||
void *cpuPtr = (void *)0x30000;
|
||||
size_t size = 0x1000;
|
||||
|
||||
DrmAllocation gfxAllocation(nullptr, cpuPtr, size);
|
||||
memoryManager->addAllocationToHostPtrManager(&gfxAllocation);
|
||||
auto fragment = memoryManager->hostPtrManager.getFragment(gfxAllocation.getUnderlyingBuffer());
|
||||
EXPECT_NE(fragment, nullptr);
|
||||
EXPECT_TRUE(fragment->driverAllocation);
|
||||
EXPECT_EQ(fragment->refCount, 1);
|
||||
EXPECT_EQ(fragment->refCount, 1);
|
||||
EXPECT_EQ(fragment->fragmentCpuPointer, cpuPtr);
|
||||
EXPECT_EQ(fragment->fragmentSize, size);
|
||||
EXPECT_NE(fragment->osInternalStorage, nullptr);
|
||||
EXPECT_EQ(fragment->osInternalStorage->bo, gfxAllocation.getBO());
|
||||
|
||||
FragmentStorage fragmentStorage = {};
|
||||
fragmentStorage.fragmentCpuPointer = cpuPtr;
|
||||
memoryManager->hostPtrManager.storeFragment(fragmentStorage);
|
||||
fragment = memoryManager->hostPtrManager.getFragment(gfxAllocation.getUnderlyingBuffer());
|
||||
EXPECT_EQ(fragment->refCount, 2);
|
||||
|
||||
fragment->driverAllocation = false;
|
||||
memoryManager->removeAllocationFromHostPtrManager(&gfxAllocation);
|
||||
fragment = memoryManager->hostPtrManager.getFragment(gfxAllocation.getUnderlyingBuffer());
|
||||
EXPECT_EQ(fragment->refCount, 2);
|
||||
fragment->driverAllocation = true;
|
||||
|
||||
memoryManager->removeAllocationFromHostPtrManager(&gfxAllocation);
|
||||
fragment = memoryManager->hostPtrManager.getFragment(gfxAllocation.getUnderlyingBuffer());
|
||||
EXPECT_EQ(fragment->refCount, 1);
|
||||
|
||||
memoryManager->removeAllocationFromHostPtrManager(&gfxAllocation);
|
||||
fragment = memoryManager->hostPtrManager.getFragment(gfxAllocation.getUnderlyingBuffer());
|
||||
EXPECT_EQ(fragment, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenforcePinAllowedWhenMemoryManagerIsCreatedThenPinBbIsCreated) {
|
||||
auto memoryManager = new (std::nothrow) TestedDrmMemoryManager(this->mock, true, false);
|
||||
EXPECT_NE(nullptr, memoryManager->getPinBB());
|
||||
|
||||
Reference in New Issue
Block a user