From 52b785552b8112730f2c30c46b929d648362490b Mon Sep 17 00:00:00 2001 From: Maciej Plewka Date: Mon, 28 Sep 2020 17:24:59 +0200 Subject: [PATCH] Fix memory fill using bliter Change-Id: Idf2463361c19f80e11a920aebf7ad1194cd3c2bb Signed-off-by: Maciej Plewka --- .../helpers/blit_commands_helper_base.inl | 6 ++--- .../helpers/blit_commands_helper_tests.cpp | 24 ++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/shared/source/helpers/blit_commands_helper_base.inl b/shared/source/helpers/blit_commands_helper_base.inl index fd0445a372..99641bf71e 100644 --- a/shared/source/helpers/blit_commands_helper_base.inl +++ b/shared/source/helpers/blit_commands_helper_base.inl @@ -185,7 +185,7 @@ void BlitCommandsHelper::dispatchBlitMemoryFill(NEO::GraphicsAllocati blitCmd.setColorDepth(depth); uint64_t offset = 0; - uint64_t sizeToFill = size; + uint64_t sizeToFill = size / patternSize; while (sizeToFill != 0) { auto tmpCmd = blitCmd; tmpCmd.setDestinationBaseAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast(offset))); @@ -203,14 +203,14 @@ void BlitCommandsHelper::dispatchBlitMemoryFill(NEO::GraphicsAllocati } tmpCmd.setTransferWidth(static_cast(width)); tmpCmd.setTransferHeight(static_cast(height)); - tmpCmd.setDestinationPitch(static_cast(width)); + tmpCmd.setDestinationPitch(static_cast(width * patternSize)); appendBlitCommandsForFillBuffer(dstAlloc, tmpCmd, rootDeviceEnvironment); auto cmd = linearStream.getSpaceForCmd(); *cmd = tmpCmd; auto blitSize = width * height; - offset += (blitSize); + offset += (blitSize * patternSize); sizeToFill -= blitSize; } } diff --git a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp index 7a166859e7..caacff0be9 100644 --- a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp +++ b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp @@ -168,7 +168,7 @@ HWTEST_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBli uint32_t streamBuffer[100] = {}; LinearStream stream(streamBuffer, sizeof(streamBuffer)); MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitWidth), + reinterpret_cast(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitWidth * sizeof(uint32_t)), MemoryPool::System4KBPages, mockMaxOsContextCount); BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]); GenCmdList cmdList; @@ -179,6 +179,28 @@ HWTEST_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBli { auto cmd = genCmdCast(*itor); EXPECT_EQ(cmd->getTransferHeight(), 2u); + EXPECT_EQ(cmd->getDestinationPitch(), BlitterConstants::maxBlitWidth * sizeof(uint32_t)); + } +} + +HWTEST_F(BlitTests, givenMemorySizeIsLessThanTwicenMaxWidthWhenFillPatternWithBlitThenHeightIsOne) { + using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT; + using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH; + uint32_t pattern[4] = {1, 0, 0, 0}; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, + reinterpret_cast(0x1234), 0x1000, 0, ((BlitterConstants::maxBlitWidth + 1) * sizeof(uint32_t)), + MemoryPool::System4KBPages, mockMaxOsContextCount); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, pattern, sizeof(uint32_t), stream, mockAllocation.getUnderlyingBufferSize(), *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + { + auto cmd = genCmdCast(*itor); + EXPECT_EQ(cmd->getTransferHeight(), 1u); } }