diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index 3ca3532d87..0b55f1b0d7 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -257,7 +257,6 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo switch (properties.allocationType) { case GraphicsAllocation::AllocationType::UNDECIDED: - case GraphicsAllocation::AllocationType::LINEAR_STREAM: case GraphicsAllocation::AllocationType::FILL_PATTERN: case GraphicsAllocation::AllocationType::TIMESTAMP_TAG_BUFFER: allocationData.flags.useSystemMemory = true; @@ -275,6 +274,16 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo break; } + switch (properties.allocationType) { + case GraphicsAllocation::AllocationType::LINEAR_STREAM: + case GraphicsAllocation::AllocationType::KERNEL_ISA: + case GraphicsAllocation::AllocationType::INTERNAL_HEAP: + allocationData.flags.requiresCpuAccess = true; + break; + default: + break; + } + allocationData.flags.mustBeZeroCopy = mustBeZeroCopy; allocationData.flags.allocateMemory = properties.flags.allocateMemory; allocationData.flags.allow32Bit = allow32Bit; diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index 18bee173f2..544aed27f2 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -199,7 +199,8 @@ class MemoryManager { uint32_t flushL3 : 1; uint32_t preferRenderCompressed : 1; uint32_t multiOsContextCapable : 1; - uint32_t reserved : 22; + uint32_t requiresCpuAccess : 1; + uint32_t reserved : 21; } flags; uint32_t allFlags = 0; }; diff --git a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl index b5d16604f2..6826e0c58b 100644 --- a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl +++ b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl @@ -373,10 +373,11 @@ TEST(MemoryManagerTest, givenFillPatternTypeWhenGetAllocationDataIsCalledThenSys EXPECT_TRUE(allocData.flags.useSystemMemory); } -TEST(MemoryManagerTest, givenLinearStreamTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) { +TEST(MemoryManagerTest, givenLinearStreamTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) { AllocationData allocData; MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::LINEAR_STREAM}, 0, nullptr); - EXPECT_TRUE(allocData.flags.useSystemMemory); + EXPECT_FALSE(allocData.flags.useSystemMemory); + EXPECT_TRUE(allocData.flags.requiresCpuAccess); } TEST(MemoryManagerTest, givenTimestampTagBufferTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) { @@ -422,14 +423,24 @@ TEST(MemoryManagerTest, givenInternalHeapTypeWhenGetAllocationDataIsCalledThenSy AllocationData allocData; MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::INTERNAL_HEAP}, 0, nullptr); EXPECT_FALSE(allocData.flags.useSystemMemory); + EXPECT_TRUE(allocData.flags.requiresCpuAccess); } TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) { AllocationData allocData; MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr); EXPECT_FALSE(allocData.flags.useSystemMemory); + EXPECT_TRUE(allocData.flags.requiresCpuAccess); } + +TEST(MemoryManagerTest, givenLinearStreamWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) { + AllocationData allocData; + MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::LINEAR_STREAM}, 0, nullptr); + EXPECT_FALSE(allocData.flags.useSystemMemory); + EXPECT_TRUE(allocData.flags.requiresCpuAccess); +} + TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenInternalAllocationIsRequested) { AllocationData allocData; MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr); EXPECT_EQ(AllocationOrigin::INTERNAL_ALLOCATION, allocData.allocationOrigin); -} \ No newline at end of file +}