fix: Allow free of zero sized allocation
Related-To: NEO-9236 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
parent
d514c675df
commit
5717a726ff
|
@ -811,11 +811,10 @@ bool WddmMemoryManager::isMemoryBudgetExhausted() const {
|
|||
bool WddmMemoryManager::validateAllocation(WddmAllocation *alloc) {
|
||||
if (alloc == nullptr)
|
||||
return false;
|
||||
auto size = alloc->getUnderlyingBufferSize();
|
||||
if (alloc->physicalMemoryReservation && !alloc->mappedPhysicalMemoryReservation) {
|
||||
return true;
|
||||
}
|
||||
if (alloc->getGpuAddress() == 0u || size == 0 || (alloc->getDefaultHandle() == 0 && alloc->fragmentsStorage.fragmentCount == 0))
|
||||
if (alloc->getGpuAddress() == 0u || (alloc->getDefaultHandle() == 0 && alloc->fragmentsStorage.fragmentCount == 0))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3372,6 +3372,17 @@ TEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledW
|
|||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledWithZeroSizedAllocationThenSuccessIsReturned) {
|
||||
wddm->init();
|
||||
MockWddmMemoryManager memoryManager(executionEnvironment);
|
||||
|
||||
auto ptr = reinterpret_cast<void *>(0x1234);
|
||||
WddmAllocation allocation{0, AllocationType::commandBuffer, ptr, castToUint64(ptr), 0, nullptr, MemoryPool::system64KBPages, 0u, 1u};
|
||||
allocation.getHandleToModify(0u) = 1;
|
||||
|
||||
EXPECT_TRUE(memoryManager.validateAllocationMock(&allocation));
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCreateOrReleaseDeviceSpecificMemResourcesWhenCreatingMemoryManagerObjectThenTheseMethodsAreEmpty) {
|
||||
wddm->init();
|
||||
MockWddmMemoryManager memoryManager(executionEnvironment);
|
||||
|
|
Loading…
Reference in New Issue