Skip to content

Commit fe85c1d

Browse files
Do not allocate Linear Stream in system memory.
Change-Id: I2d9abaab3358907037265214cec80cc84d6b9c0a
1 parent 16c3117 commit fe85c1d

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

runtime/memory_manager/memory_manager.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
257257

258258
switch (properties.allocationType) {
259259
case GraphicsAllocation::AllocationType::UNDECIDED:
260-
case GraphicsAllocation::AllocationType::LINEAR_STREAM:
261260
case GraphicsAllocation::AllocationType::FILL_PATTERN:
262261
case GraphicsAllocation::AllocationType::TIMESTAMP_TAG_BUFFER:
263262
allocationData.flags.useSystemMemory = true;
@@ -275,6 +274,16 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
275274
break;
276275
}
277276

277+
switch (properties.allocationType) {
278+
case GraphicsAllocation::AllocationType::LINEAR_STREAM:
279+
case GraphicsAllocation::AllocationType::KERNEL_ISA:
280+
case GraphicsAllocation::AllocationType::INTERNAL_HEAP:
281+
allocationData.flags.requiresCpuAccess = true;
282+
break;
283+
default:
284+
break;
285+
}
286+
278287
allocationData.flags.mustBeZeroCopy = mustBeZeroCopy;
279288
allocationData.flags.allocateMemory = properties.flags.allocateMemory;
280289
allocationData.flags.allow32Bit = allow32Bit;

runtime/memory_manager/memory_manager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ class MemoryManager {
199199
uint32_t flushL3 : 1;
200200
uint32_t preferRenderCompressed : 1;
201201
uint32_t multiOsContextCapable : 1;
202-
uint32_t reserved : 22;
202+
uint32_t requiresCpuAccess : 1;
203+
uint32_t reserved : 21;
203204
} flags;
204205
uint32_t allFlags = 0;
205206
};

unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,11 @@ TEST(MemoryManagerTest, givenFillPatternTypeWhenGetAllocationDataIsCalledThenSys
373373
EXPECT_TRUE(allocData.flags.useSystemMemory);
374374
}
375375

376-
TEST(MemoryManagerTest, givenLinearStreamTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
376+
TEST(MemoryManagerTest, givenLinearStreamTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) {
377377
AllocationData allocData;
378378
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::LINEAR_STREAM}, 0, nullptr);
379-
EXPECT_TRUE(allocData.flags.useSystemMemory);
379+
EXPECT_FALSE(allocData.flags.useSystemMemory);
380+
EXPECT_TRUE(allocData.flags.requiresCpuAccess);
380381
}
381382

382383
TEST(MemoryManagerTest, givenTimestampTagBufferTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
@@ -422,14 +423,24 @@ TEST(MemoryManagerTest, givenInternalHeapTypeWhenGetAllocationDataIsCalledThenSy
422423
AllocationData allocData;
423424
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::INTERNAL_HEAP}, 0, nullptr);
424425
EXPECT_FALSE(allocData.flags.useSystemMemory);
426+
EXPECT_TRUE(allocData.flags.requiresCpuAccess);
425427
}
426428
TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) {
427429
AllocationData allocData;
428430
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr);
429431
EXPECT_FALSE(allocData.flags.useSystemMemory);
432+
EXPECT_TRUE(allocData.flags.requiresCpuAccess);
430433
}
434+
435+
TEST(MemoryManagerTest, givenLinearStreamWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) {
436+
AllocationData allocData;
437+
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::LINEAR_STREAM}, 0, nullptr);
438+
EXPECT_FALSE(allocData.flags.useSystemMemory);
439+
EXPECT_TRUE(allocData.flags.requiresCpuAccess);
440+
}
441+
431442
TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenInternalAllocationIsRequested) {
432443
AllocationData allocData;
433444
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr);
434445
EXPECT_EQ(AllocationOrigin::INTERNAL_ALLOCATION, allocData.allocationOrigin);
435-
}
446+
}

0 commit comments

Comments
 (0)