[9/n] Internal 4GB allocator

- Add new function to compute offset from the heap base.

Change-Id: I1eda6e989675b767e17979181446c62444c12f9b
This commit is contained in:
Mrozek, Michal
2018-03-05 16:30:25 +01:00
committed by sys_ocldev
parent c4c35955d1
commit 8f0789bd3e
2 changed files with 23 additions and 0 deletions

View File

@ -144,3 +144,20 @@ TEST_F(LinearStreamTest, givenGraphicsAllocationWithGpuBaseAddressWhenItIsQuerie
EXPECT_EQ(gpuHeapBase, linearStream.getGpuBase());
}
TEST_F(LinearStreamTest, given32BitHeapWhenItIsAskedForGpuoffsetThenOffsetFromBaseIsReturned) {
auto allocationSize = 4096;
std::unique_ptr<char> memoryPtr(new char[allocationSize]);
uint64_t gpuHeapBase = 0x1000000;
uint64_t gpuAddress = 0x1000017;
auto currentOffset = gpuAddress - gpuHeapBase;
GraphicsAllocation newGraphicsAllocation(memoryPtr.get(), gpuAddress, gpuHeapBase, allocationSize);
linearStream.replaceGraphicsAllocation(&newGraphicsAllocation);
EXPECT_EQ(linearStream.getCurrentGpuOffsetFromHeapBase(), currentOffset);
linearStream.getSpace(10);
currentOffset += 10;
EXPECT_EQ(linearStream.getCurrentGpuOffsetFromHeapBase(), currentOffset);
}