Do not allocate Linear Stream in system memory.

Change-Id: I2d9abaab3358907037265214cec80cc84d6b9c0a
This commit is contained in:
Mrozek, Michal 2019-02-04 14:13:51 +01:00 committed by sys_ocldev
parent 16c3117b09
commit fe85c1d974
3 changed files with 26 additions and 5 deletions

View File

@ -257,7 +257,6 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
switch (properties.allocationType) { switch (properties.allocationType) {
case GraphicsAllocation::AllocationType::UNDECIDED: case GraphicsAllocation::AllocationType::UNDECIDED:
case GraphicsAllocation::AllocationType::LINEAR_STREAM:
case GraphicsAllocation::AllocationType::FILL_PATTERN: case GraphicsAllocation::AllocationType::FILL_PATTERN:
case GraphicsAllocation::AllocationType::TIMESTAMP_TAG_BUFFER: case GraphicsAllocation::AllocationType::TIMESTAMP_TAG_BUFFER:
allocationData.flags.useSystemMemory = true; allocationData.flags.useSystemMemory = true;
@ -275,6 +274,16 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
break; 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.mustBeZeroCopy = mustBeZeroCopy;
allocationData.flags.allocateMemory = properties.flags.allocateMemory; allocationData.flags.allocateMemory = properties.flags.allocateMemory;
allocationData.flags.allow32Bit = allow32Bit; allocationData.flags.allow32Bit = allow32Bit;

View File

@ -199,7 +199,8 @@ class MemoryManager {
uint32_t flushL3 : 1; uint32_t flushL3 : 1;
uint32_t preferRenderCompressed : 1; uint32_t preferRenderCompressed : 1;
uint32_t multiOsContextCapable : 1; uint32_t multiOsContextCapable : 1;
uint32_t reserved : 22; uint32_t requiresCpuAccess : 1;
uint32_t reserved : 21;
} flags; } flags;
uint32_t allFlags = 0; uint32_t allFlags = 0;
}; };

View File

@ -373,10 +373,11 @@ TEST(MemoryManagerTest, givenFillPatternTypeWhenGetAllocationDataIsCalledThenSys
EXPECT_TRUE(allocData.flags.useSystemMemory); EXPECT_TRUE(allocData.flags.useSystemMemory);
} }
TEST(MemoryManagerTest, givenLinearStreamTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) { TEST(MemoryManagerTest, givenLinearStreamTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) {
AllocationData allocData; AllocationData allocData;
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::LINEAR_STREAM}, 0, nullptr); 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) { TEST(MemoryManagerTest, givenTimestampTagBufferTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
@ -422,12 +423,22 @@ TEST(MemoryManagerTest, givenInternalHeapTypeWhenGetAllocationDataIsCalledThenSy
AllocationData allocData; AllocationData allocData;
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::INTERNAL_HEAP}, 0, nullptr); MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::INTERNAL_HEAP}, 0, nullptr);
EXPECT_FALSE(allocData.flags.useSystemMemory); EXPECT_FALSE(allocData.flags.useSystemMemory);
EXPECT_TRUE(allocData.flags.requiresCpuAccess);
} }
TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) { TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) {
AllocationData allocData; AllocationData allocData;
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr); MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr);
EXPECT_FALSE(allocData.flags.useSystemMemory); 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) { TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenInternalAllocationIsRequested) {
AllocationData allocData; AllocationData allocData;
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr); MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr);