From ecc2a6b1155c36dbdef5bedd4974c4e9aaaba67b Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Thu, 4 Jul 2019 14:22:28 +0200 Subject: [PATCH] AuxTranslation support in BlitProperties Change-Id: I52b136dd2a14e8b2c614c54dc695eca141b87a99 Signed-off-by: Dunajski, Bartosz Related-To: NEO-3020 --- runtime/helpers/blit_commands_helper.cpp | 12 +++++-- runtime/helpers/blit_commands_helper.h | 5 +++ .../command_stream_receiver_hw_tests.cpp | 35 +++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/runtime/helpers/blit_commands_helper.cpp b/runtime/helpers/blit_commands_helper.cpp index b5c8e34269..0c7f5e43a2 100644 --- a/runtime/helpers/blit_commands_helper.cpp +++ b/runtime/helpers/blit_commands_helper.cpp @@ -24,16 +24,22 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons auto hostPtrAllocation = hostPtrSurface.getAllocation(); if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) { - return {nullptr, blitDirection, {}, memObjAllocation, hostPtrAllocation, hostPtr, blocking, offset, 0, copySize}; + return {nullptr, blitDirection, {}, AuxTranslationDirection::None, memObjAllocation, hostPtrAllocation, hostPtr, blocking, offset, 0, copySize}; } else { - return {nullptr, blitDirection, {}, hostPtrAllocation, memObjAllocation, hostPtr, blocking, 0, offset, copySize}; + return {nullptr, blitDirection, {}, AuxTranslationDirection::None, hostPtrAllocation, memObjAllocation, hostPtr, blocking, 0, offset, copySize}; } } BlitProperties BlitProperties::constructPropertiesForCopyBuffer(GraphicsAllocation *dstAllocation, GraphicsAllocation *srcAllocation, bool blocking, size_t dstOffset, size_t srcOffset, uint64_t copySize) { - return {nullptr, BlitterConstants::BlitDirection::BufferToBuffer, {}, dstAllocation, srcAllocation, nullptr, blocking, dstOffset, srcOffset, copySize}; + return {nullptr, BlitterConstants::BlitDirection::BufferToBuffer, {}, AuxTranslationDirection::None, dstAllocation, srcAllocation, nullptr, blocking, dstOffset, srcOffset, copySize}; +} + +BlitProperties BlitProperties::constructPropertiesForAuxTranslation(AuxTranslationDirection auxTranslationDirection, + GraphicsAllocation *allocation) { + auto allocationSize = allocation->getUnderlyingBufferSize(); + return {nullptr, BlitterConstants::BlitDirection::BufferToBuffer, {}, auxTranslationDirection, allocation, allocation, nullptr, false, 0, 0, allocationSize}; } } // namespace NEO diff --git a/runtime/helpers/blit_commands_helper.h b/runtime/helpers/blit_commands_helper.h index a4c2dcae1a..2e42335929 100644 --- a/runtime/helpers/blit_commands_helper.h +++ b/runtime/helpers/blit_commands_helper.h @@ -7,6 +7,7 @@ #pragma once #include "runtime/helpers/csr_deps.h" +#include "runtime/helpers/properties_helper.h" #include "runtime/memory_manager/memory_constants.h" #include @@ -28,9 +29,13 @@ struct BlitProperties { static BlitProperties constructPropertiesForCopyBuffer(GraphicsAllocation *dstAllocation, GraphicsAllocation *srcAllocation, bool blocking, size_t dstOffset, size_t srcOffset, uint64_t copySize); + static BlitProperties constructPropertiesForAuxTranslation(AuxTranslationDirection auxTranslationDirection, + GraphicsAllocation *allocation); + TimestampPacketContainer *outputTimestampPacket = nullptr; BlitterConstants::BlitDirection blitDirection; CsrDependencies csrDependencies; + AuxTranslationDirection auxTranslationDirection = AuxTranslationDirection::None; GraphicsAllocation *dstAllocation = nullptr; GraphicsAllocation *srcAllocation = nullptr; diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index 171ca4c02e..19cd9ec43b 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -723,6 +723,41 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec } } +HWTEST_F(BcsTests, givenAuxTranslationRequestWhenBlitCalledThenProgramCommandCorrectly) { + auto &csr = pDevice->getUltCommandStreamReceiver(); + + cl_int retVal = CL_SUCCESS; + auto buffer = clUniquePtr(Buffer::create(context.get(), CL_MEM_READ_WRITE, 123, nullptr, retVal)); + auto allocationGpuAddress = buffer->getGraphicsAllocation()->getGpuAddress(); + auto allocationSize = buffer->getGraphicsAllocation()->getUnderlyingBufferSize(); + + AuxTranslationDirection translationDirection[] = {AuxTranslationDirection::AuxToNonAux, AuxTranslationDirection::NonAuxToAux}; + + for (int i = 0; i < 2; i++) { + auto blitProperties = BlitProperties::constructPropertiesForAuxTranslation(translationDirection[i], + buffer->getGraphicsAllocation()); + + auto offset = csr.commandStream.getUsed(); + csr.blitBuffer(blitProperties); + + HardwareParse hwParser; + hwParser.parseCommands(csr.commandStream, offset); + uint32_t xyCopyBltCmdFound = 0; + + for (auto &cmd : hwParser.cmdList) { + if (auto bltCmd = genCmdCast(cmd)) { + xyCopyBltCmdFound++; + EXPECT_EQ(static_cast(allocationSize), bltCmd->getDestinationX2CoordinateRight()); + EXPECT_EQ(1u, bltCmd->getDestinationY2CoordinateBottom()); + + EXPECT_EQ(allocationGpuAddress, bltCmd->getDestinationBaseAddress()); + EXPECT_EQ(allocationGpuAddress, bltCmd->getSourceBaseAddress()); + } + } + EXPECT_EQ(1u, xyCopyBltCmdFound); + } +} + struct MockScratchSpaceController : ScratchSpaceControllerBase { using ScratchSpaceControllerBase::privateScratchAllocation; using ScratchSpaceControllerBase::ScratchSpaceControllerBase;