Pass VA while constructing BlitProperties instead of allocation + offset

Change-Id: Id6f88ff5252cab650ecf103e1e465bf454e6ba4c
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2019-12-12 10:47:28 +01:00
committed by sys_ocldev
parent fb8df1a328
commit 9a1133615e
6 changed files with 157 additions and 68 deletions

View File

@@ -428,7 +428,8 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC
csr.taskCount = newTaskCount - 1;
EXPECT_EQ(0u, csr.recursiveLockCounter.load());
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer->getGraphicsAllocation(), 0, nullptr, hostPtr,
csr, buffer->getGraphicsAllocation(), nullptr, hostPtr,
buffer->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, bltSize);
blitBuffer(&csr, blitProperties, true);
@@ -484,7 +485,8 @@ HWTEST_F(BcsTests, givenCsrDependenciesWhenProgrammingCommandStreamThenAddSemaph
size_t numberNodesPerContainer = 5;
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer->getGraphicsAllocation(), 0, nullptr, hostPtr,
csr, buffer->getGraphicsAllocation(), nullptr, hostPtr,
buffer->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, 1);
MockTimestampPacketContainer timestamp0(*csr.getTimestampPacketAllocator(), numberNodesPerContainer);
@@ -532,10 +534,12 @@ HWTEST_F(BcsTests, givenMultipleBlitPropertiesWhenDispatchingThenProgramCommands
void *hostPtr2 = reinterpret_cast<void *>(0x12340000);
auto blitProperties1 = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer1->getGraphicsAllocation(), 0, nullptr, hostPtr1,
csr, buffer1->getGraphicsAllocation(), nullptr, hostPtr1,
buffer1->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, 1);
auto blitProperties2 = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer2->getGraphicsAllocation(), 0, nullptr, hostPtr2,
csr, buffer2->getGraphicsAllocation(), nullptr, hostPtr2,
buffer2->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, 1);
MockTimestampPacketContainer timestamp1(*csr.getTimestampPacketAllocator(), 1);
@@ -586,11 +590,13 @@ HWTEST_F(BcsTests, givenInputAllocationsWhenBlitDispatchedThenMakeAllAllocations
EXPECT_EQ(0u, csr.makeSurfacePackNonResidentCalled);
auto blitProperties1 = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer1->getGraphicsAllocation(), 0, nullptr, hostPtr1,
csr, buffer1->getGraphicsAllocation(), nullptr, hostPtr1,
buffer1->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, 1);
auto blitProperties2 = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer2->getGraphicsAllocation(), 0, nullptr, hostPtr2,
csr, buffer2->getGraphicsAllocation(), nullptr, hostPtr2,
buffer2->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, 1);
BlitPropertiesContainer blitPropertiesContainer;
@@ -623,7 +629,8 @@ HWTEST_F(BcsTests, givenBufferWhenBlitCalledThenFlushCommandBuffer) {
csr.taskCount = newTaskCount - 1;
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer->getGraphicsAllocation(), 0, nullptr, hostPtr,
csr, buffer->getGraphicsAllocation(), nullptr, hostPtr,
buffer->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, 1);
blitBuffer(&csr, blitProperties, true);
@@ -672,8 +679,10 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) {
void *hostPtr = reinterpret_cast<void *>(0x12340000);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
*myMockCsr, buffer->getGraphicsAllocation(), 0, nullptr,
hostPtr, 0, 0, 1);
*myMockCsr, buffer->getGraphicsAllocation(), nullptr,
hostPtr,
buffer->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, 1);
blitBuffer(myMockCsr.get(), blitProperties, false);
@@ -702,7 +711,8 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCleanTemporaryAllocations) {
EXPECT_EQ(0u, mockInternalAllocationsStorage->cleanAllocationsCalled);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
bcsCsr, buffer->getGraphicsAllocation(), 0, nullptr, hostPtr,
bcsCsr, buffer->getGraphicsAllocation(), nullptr, hostPtr,
buffer->getGraphicsAllocation()->getGpuAddress(), 0,
0, 0, 1);
blitBuffer(&bcsCsr, blitProperties, false);
@@ -734,8 +744,11 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
// from hostPtr
HardwareParse hwParser;
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, subBuffer1->getGraphicsAllocation(), subBuffer1Offset,
nullptr, hostPtr, hostPtrOffset, 0, 1);
csr, subBuffer1->getGraphicsAllocation(),
nullptr, hostPtr,
subBuffer1->getGraphicsAllocation()->getGpuAddress() +
subBuffer1->getOffset(),
0, hostPtrOffset, 0, 1);
blitBuffer(&csr, blitProperties, true);
@@ -753,8 +766,11 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr,
csr, subBuffer1->getGraphicsAllocation(), subBuffer1Offset,
nullptr, hostPtr, hostPtrOffset, 0, 1);
csr, subBuffer1->getGraphicsAllocation(),
nullptr, hostPtr,
subBuffer1->getGraphicsAllocation()->getGpuAddress() +
subBuffer1->getOffset(),
0, hostPtrOffset, 0, 1);
blitBuffer(&csr, blitProperties, true);
@@ -829,8 +845,11 @@ HWTEST_F(BcsTests, givenMapAllocationWhenDispatchReadWriteOperationThenSetValidG
// from hostPtr
HardwareParse hwParser;
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer->getGraphicsAllocation(), 0,
mapAllocation, mapPtr, hostPtrOffset, 0, 1);
csr, buffer->getGraphicsAllocation(),
mapAllocation, mapPtr,
buffer->getGraphicsAllocation()->getGpuAddress(),
castToUint64(mapPtr),
hostPtrOffset, 0, 1);
blitBuffer(&csr, blitProperties, true);
@@ -849,8 +868,10 @@ HWTEST_F(BcsTests, givenMapAllocationWhenDispatchReadWriteOperationThenSetValidG
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr,
csr, buffer->getGraphicsAllocation(), 0,
mapAllocation, mapPtr, hostPtrOffset, 0, 1);
csr, buffer->getGraphicsAllocation(),
mapAllocation, mapPtr,
buffer->getGraphicsAllocation()->getGpuAddress(),
castToUint64(mapPtr), hostPtrOffset, 0, 1);
blitBuffer(&csr, blitProperties, true);
@@ -951,7 +972,7 @@ HWTEST_F(BcsTests, givenNonZeroCopySvmAllocationWhenConstructingBlitPropertiesFo
svmAllocsManager.freeSVMAlloc(svmAlloc);
}
HWTEST_F(BcsTests, givenSvmAllocationWhenBlitCalledThenUseOnlySvmAllocationsWithoutHostPtr) {
HWTEST_F(BcsTests, givenSvmAllocationWhenBlitCalledThenUsePassedPointers) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
MockMemoryManager mockMemoryManager(true, true);
SVMAllocsManager svmAllocsManager(&mockMemoryManager);
@@ -964,13 +985,16 @@ HWTEST_F(BcsTests, givenSvmAllocationWhenBlitCalledThenUseOnlySvmAllocationsWith
EXPECT_NE(nullptr, svmData->cpuAllocation);
EXPECT_NE(svmData->gpuAllocation, svmData->cpuAllocation);
uint64_t srcOffset = 2;
uint64_t dstOffset = 3;
{
// from hostPtr
BuiltinOpParams builtinOpParams = {};
builtinOpParams.dstSvmAlloc = svmData->cpuAllocation;
builtinOpParams.srcSvmAlloc = svmData->gpuAllocation;
builtinOpParams.srcPtr = reinterpret_cast<void *>(0x1234567);
builtinOpParams.dstPtr = reinterpret_cast<void *>(0x7654321);
builtinOpParams.srcPtr = reinterpret_cast<void *>(svmData->cpuAllocation->getGpuAddress() + srcOffset);
builtinOpParams.dstPtr = reinterpret_cast<void *>(svmData->cpuAllocation->getGpuAddress() + dstOffset);
builtinOpParams.size.x = 1;
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
@@ -985,16 +1009,16 @@ HWTEST_F(BcsTests, givenSvmAllocationWhenBlitCalledThenUseOnlySvmAllocationsWith
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
EXPECT_EQ(builtinOpParams.dstSvmAlloc->getGpuAddress(), bltCmd->getDestinationBaseAddress());
EXPECT_EQ(builtinOpParams.srcSvmAlloc->getGpuAddress(), bltCmd->getSourceBaseAddress());
EXPECT_EQ(castToUint64(builtinOpParams.dstPtr), bltCmd->getDestinationBaseAddress());
EXPECT_EQ(castToUint64(builtinOpParams.srcPtr), bltCmd->getSourceBaseAddress());
}
{
// to hostPtr
BuiltinOpParams builtinOpParams = {};
builtinOpParams.srcSvmAlloc = svmData->gpuAllocation;
builtinOpParams.dstSvmAlloc = svmData->cpuAllocation;
builtinOpParams.dstPtr = reinterpret_cast<void *>(0x1234567);
builtinOpParams.srcPtr = reinterpret_cast<void *>(0x7654321);
builtinOpParams.dstPtr = reinterpret_cast<void *>(svmData->cpuAllocation + dstOffset);
builtinOpParams.srcPtr = reinterpret_cast<void *>(svmData->gpuAllocation + srcOffset);
builtinOpParams.size.x = 1;
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
@@ -1008,8 +1032,8 @@ HWTEST_F(BcsTests, givenSvmAllocationWhenBlitCalledThenUseOnlySvmAllocationsWith
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
EXPECT_EQ(builtinOpParams.dstSvmAlloc->getGpuAddress(), bltCmd->getDestinationBaseAddress());
EXPECT_EQ(builtinOpParams.srcSvmAlloc->getGpuAddress(), bltCmd->getSourceBaseAddress());
EXPECT_EQ(castToUint64(builtinOpParams.dstPtr), bltCmd->getDestinationBaseAddress());
EXPECT_EQ(castToUint64(builtinOpParams.srcPtr), bltCmd->getSourceBaseAddress());
}
svmAllocsManager.freeSVMAlloc(svmAlloc);
@@ -1031,8 +1055,10 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, buffer1->getGraphicsAllocation(), 0, nullptr,
hostPtr, 0, buffer1Offset, 1);
csr, buffer1->getGraphicsAllocation(),
nullptr, hostPtr,
buffer1->getGraphicsAllocation()->getGpuAddress(),
0, 0, buffer1Offset, 1);
blitBuffer(&csr, blitProperties, true);
@@ -1050,8 +1076,10 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::BufferToHostPtr,
csr, buffer1->getGraphicsAllocation(), 0, nullptr,
hostPtr, 0, buffer1Offset, 1);
csr, buffer1->getGraphicsAllocation(), nullptr,
hostPtr,
buffer1->getGraphicsAllocation()->getGpuAddress(),
0, 0, buffer1Offset, 1);
blitBuffer(&csr, blitProperties, true);