@@ -4897,6 +4897,38 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenOversize
48974897 memoryManager->freeGraphicsMemory (allocation);
48984898}
48994899
4900+ TEST_F (DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenHeapExtendedWhenAllocationsAreMadeTheyAreAlignedToNextPowerOfTwo) {
4901+ if (!memoryManager->getGfxPartition (rootDeviceIndex)->getHeapLimit (HeapIndex::HEAP_EXTENDED)) {
4902+ GTEST_SKIP ();
4903+ }
4904+
4905+ auto size = 16 * MemoryConstants::megaByte;
4906+
4907+ auto status = MemoryManager::AllocationStatus::Error;
4908+ AllocationData allocData;
4909+ allocData.size = size;
4910+ allocData.type = AllocationType::BUFFER;
4911+ allocData.rootDeviceIndex = rootDeviceIndex;
4912+ auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool (allocData, status);
4913+ EXPECT_EQ (MemoryManager::AllocationStatus::Success, status);
4914+ ASSERT_NE (nullptr , allocation);
4915+ EXPECT_EQ (allocData.size , allocation->getUnderlyingBufferSize ());
4916+ EXPECT_EQ (allocData.size , static_cast <DrmAllocation *>(allocation)->getBO ()->peekSize ());
4917+ EXPECT_TRUE (allocation->getGpuAddress () % size == 0u );
4918+
4919+ size = 32 * MemoryConstants::megaByte;
4920+ allocData.size = size;
4921+ auto allocation2 = memoryManager->allocateGraphicsMemoryInDevicePool (allocData, status);
4922+ EXPECT_EQ (MemoryManager::AllocationStatus::Success, status);
4923+ ASSERT_NE (nullptr , allocation2);
4924+ EXPECT_EQ (allocData.size , allocation2->getUnderlyingBufferSize ());
4925+ EXPECT_EQ (allocData.size , static_cast <DrmAllocation *>(allocation2)->getBO ()->peekSize ());
4926+ EXPECT_TRUE (allocation2->getGpuAddress () % size == 0u );
4927+
4928+ memoryManager->freeGraphicsMemory (allocation);
4929+ memoryManager->freeGraphicsMemory (allocation2);
4930+ }
4931+
49004932struct DrmMemoryManagerToTestCopyMemoryToAllocationBanks : public DrmMemoryManager {
49014933 DrmMemoryManagerToTestCopyMemoryToAllocationBanks (ExecutionEnvironment &executionEnvironment, size_t lockableLocalMemorySize)
49024934 : DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive, false , false , executionEnvironment) {
0 commit comments