From 67198ea705b2781da95652d988f2df1e62d2311d Mon Sep 17 00:00:00 2001 From: Maciej Plewka Date: Tue, 28 Apr 2020 10:24:22 +0200 Subject: [PATCH] Use bliter for memoryFill Change-Id: I2e60d1b436cb2955952b62b1eb43d9efbe70d19b Signed-off-by: Maciej Plewka --- level_zero/core/source/cmdlist/cmdlist_hw.h | 5 + level_zero/core/source/cmdlist/cmdlist_hw.inl | 47 +++++ .../core/source/cmdlist/cmdlist_hw_base.inl | 5 + .../sources/cmdlist/test_cmdlist.cpp | 88 ++++++++- .../command_stream_receiver_hw_gen11.cpp | 1 + shared/source/gen11/hw_cmds_base.h | 1 + .../command_stream_receiver_hw_gen12lp.cpp | 1 + shared/source/gen12lp/hw_cmds_base.h | 1 + .../gen8/command_stream_receiver_hw_gen8.cpp | 1 + shared/source/gen8/hw_cmds_base.h | 1 + .../gen9/command_stream_receiver_hw_gen9.cpp | 1 + shared/source/gen9/hw_cmds_base.h | 1 + .../gen11/hw_cmds_generated_gen11.inl | 170 ++++++++++++++++++ .../gen12lp/hw_cmds_generated_gen12lp.inl | 170 ++++++++++++++++++ .../generated/gen8/hw_cmds_generated_gen8.inl | 170 ++++++++++++++++++ .../generated/gen9/hw_cmds_generated_gen9.inl | 170 ++++++++++++++++++ shared/source/helpers/blit_commands_helper.h | 6 + .../helpers/blit_commands_helper_base.inl | 38 ++++ .../helpers/blit_commands_helper_bdw_plus.inl | 28 +++ shared/source/helpers/constants.h | 6 +- .../unit_test/cmd_parse/cmd_parse_base.inl | 17 ++ shared/test/unit_test/helpers/CMakeLists.txt | 1 + .../helpers/blit_commands_helper_tests.cpp | 119 +++++++++++- .../helpers/blit_commands_helper_tests.inl | 53 ++++++ 24 files changed, 1095 insertions(+), 6 deletions(-) create mode 100644 shared/test/unit_test/helpers/blit_commands_helper_tests.inl diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.h b/level_zero/core/source/cmdlist/cmdlist_hw.h index 0c5ddcdffe..0acba282a7 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.h +++ b/level_zero/core/source/cmdlist/cmdlist_hw.h @@ -158,6 +158,10 @@ struct CommandListCoreFamily : CommandListImp { ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents); + MOCKABLE_VIRTUAL ze_result_t appendBlitFill(void *ptr, const void *pattern, + size_t patternSize, size_t size, + ze_event_handle_t hEvent); + ze_result_t appendLaunchKernelWithParams(ze_kernel_handle_t hKernel, const ze_group_count_t *pThreadGroupDimensions, ze_event_handle_t hEvent, uint32_t numWaitEvents, @@ -171,6 +175,7 @@ struct CommandListCoreFamily : CommandListImp { ze_result_t setGlobalWorkSizeIndirect(NEO::CrossThreadDataOffset offsets[3], void *crossThreadAddress, uint32_t lws[3]); void appendEventForProfiling(ze_event_handle_t hEvent, bool beforeWalker); void appendSignalEventPostWalker(ze_event_handle_t hEvent); + bool useMemCopyToBlitFill(size_t patternSize); uint64_t getInputBufferSize(NEO::ImageType imageType, uint64_t bytesPerPixel, const ze_image_region_t *region); virtual AlignedAllocationData getAlignedAllocation(Device *device, const void *buffer, uint64_t bufferSize); diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index b84b4a0513..9354eb423e 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -18,7 +18,9 @@ #include "shared/source/helpers/string.h" #include "shared/source/helpers/surface_format_info.h" #include "shared/source/indirect_heap/indirect_heap.h" +#include "shared/source/memory_manager/allocation_properties.h" #include "shared/source/memory_manager/graphics_allocation.h" +#include "shared/source/memory_manager/memory_manager.h" #include "opencl/source/helpers/hardware_commands_helper.h" @@ -969,6 +971,10 @@ ze_result_t CommandListCoreFamily::appendMemoryFill(void *ptr, size_t size, ze_event_handle_t hEvent) { + if (isCopyOnlyCmdList) { + return appendBlitFill(ptr, pattern, patternSize, size, hEvent); + } + using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; bool hostPointerNeedsFlush = false; @@ -1075,6 +1081,47 @@ ze_result_t CommandListCoreFamily::appendMemoryFill(void *ptr, return res; } +template +ze_result_t CommandListCoreFamily::appendBlitFill(void *ptr, + const void *pattern, + size_t patternSize, + size_t size, + ze_event_handle_t hEvent) { + if (useMemCopyToBlitFill(patternSize)) { + NEO::AllocationProperties properties = {device->getNEODevice()->getRootDeviceIndex(), + false, + size, + NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, + false, + device->getNEODevice()->getDeviceBitfield()}; + properties.flags.allocateMemory = 1; + auto internalAlloc = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); + size_t offset = 0; + for (uint32_t i = 0; i < size / patternSize; i++) { + memcpy(ptrOffset(internalAlloc->getDriverAllocatedCpuPtr(), offset), pattern, patternSize); + offset += patternSize; + } + auto ret = appendMemoryCopy(ptr, internalAlloc->getDriverAllocatedCpuPtr(), size, hEvent, 0, nullptr); + commandContainer.getDeallocationContainer().push_back(internalAlloc); + return ret; + } else { + appendEventForProfiling(hEvent, true); + NEO::SvmAllocationData *allocData = nullptr; + bool dstAllocFound = device->getDriverHandle()->findAllocationDataForRange(ptr, size, &allocData); + if (dstAllocFound == false) { + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + } + commandContainer.addToResidencyContainer(allocData->gpuAllocation); + uint32_t patternToCommand[4] = {}; + memcpy(&patternToCommand, pattern, patternSize); + NEO::BlitCommandsHelper::dispatchBlitMemoryColorFill(allocData->gpuAllocation, patternToCommand, patternSize, *commandContainer.getCommandStream(), size, *device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]); + if (hEvent) { + this->appendSignalEventPostWalker(hEvent); + } + } + return ZE_RESULT_SUCCESS; +} + template void CommandListCoreFamily::appendSignalEventPostWalker(ze_event_handle_t hEvent) { auto event = Event::fromHandle(hEvent); diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_base.inl b/level_zero/core/source/cmdlist/cmdlist_hw_base.inl index c12a89d254..366d38ba0a 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_base.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_base.inl @@ -124,4 +124,9 @@ void CommandListCoreFamily::appendEventForProfiling(ze_event_hand } } } + +template +bool CommandListCoreFamily::useMemCopyToBlitFill(size_t patternSize) { + return patternSize > sizeof(uint32_t); +} } // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp index d9672eec41..facc87feb2 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp @@ -241,14 +241,21 @@ class MockCommandList : public WhiteBox<::L0::CommandListCoreFamily; @@ -278,11 +285,16 @@ class MockDriverHandle : public L0::DriverHandleImp { bool findAllocationDataForRange(const void *buffer, size_t size, NEO::SvmAllocationData **allocData) override { + mockAllocation.reset(new NEO::MockGraphicsAllocation(0, NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::System4KBPages)); + data.gpuAllocation = mockAllocation.get(); if (allocData) { *allocData = &data; } return true; } + std::unique_ptr mockAllocation; NEO::SvmAllocationData data = {}; }; @@ -310,7 +322,7 @@ HWTEST2_F(CommandListCreate, givenCommandListAnd3DWhbufferenMemoryCopyRegionCall ze_copy_region_t srcRegion = {4, 4, 4, 2, 2, 2}; cmdList.appendMemoryCopyRegion(dstPtr, &dstRegion, 0, 0, srcPtr, &srcRegion, 0, 0, nullptr); EXPECT_EQ(cmdList.appendMemoryCopyBlitRegionCalledTimes, 0u); - EXPECT_GT(cmdList.appendMemoryCopyKernel3dalledTimes, 0u); + EXPECT_GT(cmdList.appendMemoryCopyKernel3dCalledTimes, 0u); } HWTEST2_F(CommandListCreate, givenCommandListAnd2DWhbufferenMemoryCopyRegionCalledThenCopyKernel2DCalled, Platforms) { @@ -327,6 +339,24 @@ HWTEST2_F(CommandListCreate, givenCommandListAnd2DWhbufferenMemoryCopyRegionCall EXPECT_GT(cmdList.appendMemoryCopyKernel2dCalledTimes, 0u); } +HWTEST2_F(CommandListCreate, givenCopyOnlyCommandListWhenAppendMemoryFillCalledThenAppendBlitFillCalled, Platforms) { + MockCommandList cmdList; + cmdList.initialize(device, true); + void *dstPtr = reinterpret_cast(0x1234); + int pattern = 1; + cmdList.appendMemoryFill(dstPtr, reinterpret_cast(&pattern), sizeof(pattern), 0, nullptr); + EXPECT_GT(cmdList.appendBlitFillCalledTimes, 0u); +} + +HWTEST2_F(CommandListCreate, givenCommandListWhenAppendMemoryFillCalledThenAppendBlitFillNotCalled, Platforms) { + MockCommandList cmdList; + cmdList.initialize(device, false); + void *dstPtr = reinterpret_cast(0x1234); + int pattern = 1; + cmdList.appendMemoryFill(dstPtr, reinterpret_cast(&pattern), sizeof(pattern), 0, nullptr); + EXPECT_EQ(cmdList.appendBlitFillCalledTimes, 0u); +} + class MockEvent : public Mock { public: MockEvent() { @@ -406,5 +436,57 @@ HWTEST_F(CommandListCreate, givenCommandListyWhenAppendWaitEventsWithDcFlushTheP EXPECT_NE(cmdList.end(), itor); } +template +class MockCommandListForMemFill : public WhiteBox<::L0::CommandListCoreFamily> { + public: + MockCommandListForMemFill() : WhiteBox<::L0::CommandListCoreFamily>(1) {} + + AlignedAllocationData getAlignedAllocation(L0::Device *device, const void *buffer, uint64_t bufferSize) override { + return {0, 0, nullptr, true}; + } + ze_result_t appendMemoryCopyBlit(NEO::GraphicsAllocation *dstPtrAlloc, + uint64_t dstOffset, + NEO::GraphicsAllocation *srcPtrAlloc, + uint64_t srcOffset, uint32_t size) override { + appendMemoryCopyBlitCalledTimes++; + return ZE_RESULT_SUCCESS; + } + uint32_t appendMemoryCopyBlitCalledTimes = 0; +}; + +HWTEST2_F(CommandListCreate, givenCopyOnlyCommandListWhenAppenBlitFillCalledWithLargePatternSizeThenMemCopyWasCalled, Platforms) { + MockCommandListForMemFill cmdList; + cmdList.initialize(device, true); + uint64_t pattern[4] = {1, 2, 3, 4}; + void *ptr = reinterpret_cast(0x1234); + cmdList.appendMemoryFill(ptr, reinterpret_cast(&pattern), sizeof(pattern), 0x1000, nullptr); + EXPECT_GT(cmdList.appendMemoryCopyBlitCalledTimes, 0u); +} + +HWTEST2_F(CommandListCreate, givenCopyOnlyCommandListWhenAppenBlitFillToNotDeviceMemThenInvalidArgumentReturned, Platforms) { + MockCommandListForMemFill cmdList; + cmdList.initialize(device, true); + uint8_t pattern = 1; + void *ptr = reinterpret_cast(0x1234); + auto ret = cmdList.appendMemoryFill(ptr, reinterpret_cast(&pattern), sizeof(pattern), 0x1000, nullptr); + EXPECT_EQ(ret, ZE_RESULT_ERROR_INVALID_ARGUMENT); +} + +HWTEST2_F(CommandListCreate, givenCopyOnlyCommandListWhenAppenBlitFillThenCopyBltIsProgrammed, Platforms) { + using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; + using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT; + MockCommandListForMemFill commandList; + MockDriverHandle driverHandle; + device->setDriverHandle(&driverHandle); + commandList.initialize(device, true); + uint16_t pattern = 1; + void *ptr = reinterpret_cast(0x1234); + commandList.appendMemoryFill(ptr, reinterpret_cast(&pattern), sizeof(pattern), 0x1000, nullptr); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(commandList.commandContainer.getCommandStream()->getCpuBase(), 0), commandList.commandContainer.getCommandStream()->getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); +} } // namespace ult } // namespace L0 diff --git a/shared/source/gen11/command_stream_receiver_hw_gen11.cpp b/shared/source/gen11/command_stream_receiver_hw_gen11.cpp index b10faf442f..8316974a84 100644 --- a/shared/source/gen11/command_stream_receiver_hw_gen11.cpp +++ b/shared/source/gen11/command_stream_receiver_hw_gen11.cpp @@ -187,4 +187,5 @@ const Family::BINDING_TABLE_STATE Family::cmdInitBindingTableState = Family::BIN const Family::MI_USER_INTERRUPT Family::cmdInitUserInterrupt = Family::MI_USER_INTERRUPT::sInit(); const Family::XY_SRC_COPY_BLT Family::cmdInitXyCopyBlt = Family::XY_SRC_COPY_BLT::sInit(); const Family::MI_FLUSH_DW Family::cmdInitMiFlushDw = Family::MI_FLUSH_DW::sInit(); +const Family::XY_COLOR_BLT Family::cmdInitXyColorBlt = Family::XY_COLOR_BLT::sInit(); } // namespace NEO diff --git a/shared/source/gen11/hw_cmds_base.h b/shared/source/gen11/hw_cmds_base.h index 4a9121f477..9a63759a31 100644 --- a/shared/source/gen11/hw_cmds_base.h +++ b/shared/source/gen11/hw_cmds_base.h @@ -82,6 +82,7 @@ struct ICLFamily : public GEN11 { static const MI_USER_INTERRUPT cmdInitUserInterrupt; static const XY_SRC_COPY_BLT cmdInitXyCopyBlt; static const MI_FLUSH_DW cmdInitMiFlushDw; + static const XY_COLOR_BLT cmdInitXyColorBlt; static constexpr bool supportsCmdSet(GFXCORE_FAMILY cmdSetBaseFamily) { return cmdSetBaseFamily == IGFX_GEN8_CORE; diff --git a/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp b/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp index 208802ec16..c53026a0a5 100644 --- a/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp +++ b/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp @@ -92,4 +92,5 @@ const Family::BINDING_TABLE_STATE Family::cmdInitBindingTableState = Family::BIN const Family::MI_USER_INTERRUPT Family::cmdInitUserInterrupt = Family::MI_USER_INTERRUPT::sInit(); const Family::XY_SRC_COPY_BLT Family::cmdInitXyCopyBlt = Family::XY_SRC_COPY_BLT::sInit(); const Family::MI_FLUSH_DW Family::cmdInitMiFlushDw = Family::MI_FLUSH_DW::sInit(); +const Family::XY_COLOR_BLT Family::cmdInitXyColorBlt = Family::XY_COLOR_BLT::sInit(); } // namespace NEO diff --git a/shared/source/gen12lp/hw_cmds_base.h b/shared/source/gen12lp/hw_cmds_base.h index 76a3fee803..595714e84a 100644 --- a/shared/source/gen12lp/hw_cmds_base.h +++ b/shared/source/gen12lp/hw_cmds_base.h @@ -85,6 +85,7 @@ struct TGLLPFamily : public GEN12LP { static const MI_USER_INTERRUPT cmdInitUserInterrupt; static const XY_SRC_COPY_BLT cmdInitXyCopyBlt; static const MI_FLUSH_DW cmdInitMiFlushDw; + static const XY_COLOR_BLT cmdInitXyColorBlt; static constexpr bool supportsCmdSet(GFXCORE_FAMILY cmdSetBaseFamily) { return cmdSetBaseFamily == IGFX_GEN8_CORE; diff --git a/shared/source/gen8/command_stream_receiver_hw_gen8.cpp b/shared/source/gen8/command_stream_receiver_hw_gen8.cpp index caa2e3eb5f..c79f57422b 100644 --- a/shared/source/gen8/command_stream_receiver_hw_gen8.cpp +++ b/shared/source/gen8/command_stream_receiver_hw_gen8.cpp @@ -66,4 +66,5 @@ const Family::BINDING_TABLE_STATE Family::cmdInitBindingTableState = Family::BIN const Family::MI_USER_INTERRUPT Family::cmdInitUserInterrupt = Family::MI_USER_INTERRUPT::sInit(); const Family::XY_SRC_COPY_BLT Family::cmdInitXyCopyBlt = Family::XY_SRC_COPY_BLT::sInit(); const Family::MI_FLUSH_DW Family::cmdInitMiFlushDw = Family::MI_FLUSH_DW::sInit(); +const Family::XY_COLOR_BLT Family::cmdInitXyColorBlt = Family::XY_COLOR_BLT::sInit(); } // namespace NEO diff --git a/shared/source/gen8/hw_cmds_base.h b/shared/source/gen8/hw_cmds_base.h index 5eb3f1ab5a..1602dce8e5 100644 --- a/shared/source/gen8/hw_cmds_base.h +++ b/shared/source/gen8/hw_cmds_base.h @@ -83,6 +83,7 @@ struct BDWFamily : public GEN8 { static const MI_USER_INTERRUPT cmdInitUserInterrupt; static const XY_SRC_COPY_BLT cmdInitXyCopyBlt; static const MI_FLUSH_DW cmdInitMiFlushDw; + static const XY_COLOR_BLT cmdInitXyColorBlt; static constexpr bool supportsCmdSet(GFXCORE_FAMILY cmdSetBaseFamily) { return cmdSetBaseFamily == IGFX_GEN8_CORE; diff --git a/shared/source/gen9/command_stream_receiver_hw_gen9.cpp b/shared/source/gen9/command_stream_receiver_hw_gen9.cpp index d50287f0f9..76f8070936 100644 --- a/shared/source/gen9/command_stream_receiver_hw_gen9.cpp +++ b/shared/source/gen9/command_stream_receiver_hw_gen9.cpp @@ -61,4 +61,5 @@ const Family::BINDING_TABLE_STATE Family::cmdInitBindingTableState = Family::BIN const Family::MI_USER_INTERRUPT Family::cmdInitUserInterrupt = Family::MI_USER_INTERRUPT::sInit(); const Family::XY_SRC_COPY_BLT Family::cmdInitXyCopyBlt = Family::XY_SRC_COPY_BLT::sInit(); const Family::MI_FLUSH_DW Family::cmdInitMiFlushDw = Family::MI_FLUSH_DW::sInit(); +const Family::XY_COLOR_BLT Family::cmdInitXyColorBlt = Family::XY_COLOR_BLT::sInit(); } // namespace NEO diff --git a/shared/source/gen9/hw_cmds_base.h b/shared/source/gen9/hw_cmds_base.h index 70f1036ba4..24bc29fa42 100644 --- a/shared/source/gen9/hw_cmds_base.h +++ b/shared/source/gen9/hw_cmds_base.h @@ -84,6 +84,7 @@ struct SKLFamily : public GEN9 { static const MI_USER_INTERRUPT cmdInitUserInterrupt; static const XY_SRC_COPY_BLT cmdInitXyCopyBlt; static const MI_FLUSH_DW cmdInitMiFlushDw; + static const XY_COLOR_BLT cmdInitXyColorBlt; static constexpr bool supportsCmdSet(GFXCORE_FAMILY cmdSetBaseFamily) { return cmdSetBaseFamily == IGFX_GEN8_CORE; diff --git a/shared/source/generated/gen11/hw_cmds_generated_gen11.inl b/shared/source/generated/gen11/hw_cmds_generated_gen11.inl index d24bb52ea4..4b737b91eb 100644 --- a/shared/source/generated/gen11/hw_cmds_generated_gen11.inl +++ b/shared/source/generated/gen11/hw_cmds_generated_gen11.inl @@ -4276,6 +4276,7 @@ typedef struct tagXY_SRC_COPY_BLT { TheStructure.Common.ClippingEnabled = CLIPPING_ENABLED_DISABLED; TheStructure.Common.InstructionTarget_Opcode = INSTRUCTIONTARGET_OPCODE_OPCODE; TheStructure.Common.DwordLength = DWORD_LENGTH_EXCLUDES_DWORD_0_1; + TheStructure.Common.RasterOperation = 0xCC; } static tagXY_SRC_COPY_BLT sInit(void) { XY_SRC_COPY_BLT state; @@ -4407,6 +4408,175 @@ typedef struct tagXY_SRC_COPY_BLT { } XY_SRC_COPY_BLT; STATIC_ASSERT(40 == sizeof(XY_SRC_COPY_BLT)); +typedef struct tagXY_COLOR_BLT { + union tagTheStructure { + struct tagCommon { + // DWORD 0 + uint32_t DwordLength : BITFIELD_RANGE(0, 7); + uint32_t Reserved_8 : BITFIELD_RANGE(8, 10); + uint32_t DestTilingEnable : BITFIELD_RANGE(11, 11); + uint32_t Reserved_12 : BITFIELD_RANGE(12, 19); + uint32_t _32BppByteMask : BITFIELD_RANGE(20, 21); + uint32_t InstructionTarget_Opcode : BITFIELD_RANGE(22, 28); + uint32_t Client : BITFIELD_RANGE(29, 31); + // DWORD 1 + uint32_t DestinationPitch : BITFIELD_RANGE(0, 15); + uint32_t RasterOperation : BITFIELD_RANGE(16, 23); + uint32_t ColorDepth : BITFIELD_RANGE(24, 25); + uint32_t Reserved_58 : BITFIELD_RANGE(26, 29); + uint32_t ClippingEnabled : BITFIELD_RANGE(30, 30); + uint32_t Reserved_63 : BITFIELD_RANGE(31, 31); + // DWORD 2 + uint32_t DestinationX1Coordinate_Left : BITFIELD_RANGE(0, 15); + uint32_t DestinationY1Coordinate_Top : BITFIELD_RANGE(16, 31); + // DWORD 3 + uint32_t DestinationX2Coordinate_Right : BITFIELD_RANGE(0, 15); + uint32_t DestinationY2Coordinate_Bottom : BITFIELD_RANGE(16, 31); + // DWORD 4-5 + uint64_t DestinationBaseAddress; + // DWORD 6 + uint32_t SolidPaternColor; + } Common; + uint32_t RawData[7]; + } TheStructure; + typedef enum tagDEST_TILING_ENABLE { + DEST_TILING_ENABLE_TILING_DISABLED_LINEAR_BLIT = 0x0, + DEST_TILING_ENABLE_TILING_ENABLED = 0x1, + } DEST_TILING_ENABLE; + typedef enum tag_32BPP_BYTE_MASK { + _32BPP_BYTE_MASK_WRITE_RGB_CHANNEL = 0x1, + _32BPP_BYTE_MASK_WRITE_ALPHA_CHANNEL = 0x2, + _32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL = 0x3 + } _32BPP_BYTE_MASK; + typedef enum tagCLIENT { + CLIENT_2D_PROCESSOR = 0x2, + } CLIENT; + typedef enum tagCOLOR_DEPTH { + COLOR_DEPTH_8_BIT_COLOR = 0x0, + COLOR_DEPTH_16_BIT_COLOR565 = 0x1, + COLOR_DEPTH_16_BIT_COLOR1555 = 0x2, + COLOR_DEPTH_32_BIT_COLOR = 0x3, + } COLOR_DEPTH; + typedef enum tagCLIPPING_ENABLED { + CLIPPING_ENABLED_DISABLED = 0x0, + CLIPPING_ENABLED_ENABLED = 0x1, + } CLIPPING_ENABLED; + typedef enum tagINSTRUCTIONTARGET_OPCODE { + INSTRUCTIONTARGET_OPCODE_OPCODE = 0x50, + } INSTRUCTIONTARGET_OPCODE; + typedef enum tagDWORD_LENGTH { + DWORD_LENGTH_EXCLUDES_DWORD_0_1 = 0x5, + } DWORD_LENGTH; + inline void init(void) { + memset(&TheStructure, 0, sizeof(TheStructure)); + TheStructure.Common.DestTilingEnable = DEST_TILING_ENABLE_TILING_DISABLED_LINEAR_BLIT; + TheStructure.Common.Client = CLIENT_2D_PROCESSOR; + TheStructure.Common.ColorDepth = COLOR_DEPTH_8_BIT_COLOR; + TheStructure.Common.ClippingEnabled = CLIPPING_ENABLED_DISABLED; + TheStructure.Common.InstructionTarget_Opcode = INSTRUCTIONTARGET_OPCODE_OPCODE; + TheStructure.Common.DwordLength = DWORD_LENGTH_EXCLUDES_DWORD_0_1; + TheStructure.Common.RasterOperation = 0xF0; + } + static tagXY_COLOR_BLT sInit(void) { + XY_COLOR_BLT state; + state.init(); + return state; + } + inline uint32_t &getRawData(const uint32_t index) { + UNRECOVERABLE_IF(index >= 10); + return TheStructure.RawData[index]; + } + inline void setDestTilingEnable(const DEST_TILING_ENABLE value) { + TheStructure.Common.DestTilingEnable = value; + } + inline DEST_TILING_ENABLE getDestTilingEnable(void) const { + return static_cast(TheStructure.Common.DestTilingEnable); + } + inline void set32BppByteMask(const _32BPP_BYTE_MASK value) { + TheStructure.Common._32BppByteMask = value; + } + inline _32BPP_BYTE_MASK get32BppByteMask(void) const { + return static_cast<_32BPP_BYTE_MASK>(TheStructure.Common._32BppByteMask); + } + inline void setInstructionTargetOpcode(const uint32_t value) { + UNRECOVERABLE_IF(value > 0x1fc00000); + TheStructure.Common.InstructionTarget_Opcode = value; + } + inline uint32_t getInstructionTargetOpcode(void) const { + return TheStructure.Common.InstructionTarget_Opcode; + } + inline void setClient(const CLIENT value) { + TheStructure.Common.Client = value; + } + inline CLIENT getClient(void) const { + return static_cast(TheStructure.Common.Client); + } + inline void setDestinationPitch(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationPitch = value; + } + inline uint32_t getDestinationPitch(void) const { + return TheStructure.Common.DestinationPitch; + } + inline void setRasterOperation(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xff0000); + TheStructure.Common.RasterOperation = value; + } + inline uint32_t getRasterOperation(void) const { + return TheStructure.Common.RasterOperation; + } + inline void setColorDepth(const COLOR_DEPTH value) { + TheStructure.Common.ColorDepth = value; + } + inline COLOR_DEPTH getColorDepth(void) const { + return static_cast(TheStructure.Common.ColorDepth); + } + inline void setClippingEnabled(const CLIPPING_ENABLED value) { + TheStructure.Common.ClippingEnabled = value; + } + inline CLIPPING_ENABLED getClippingEnabled(void) const { + return static_cast(TheStructure.Common.ClippingEnabled); + } + inline void setDestinationX1CoordinateLeft(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationX1Coordinate_Left = value; + } + inline uint32_t getDestinationX1CoordinateLeft(void) const { + return TheStructure.Common.DestinationX1Coordinate_Left; + } + inline void setDestinationY1CoordinateTop(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff0000); + TheStructure.Common.DestinationY1Coordinate_Top = value; + } + inline uint32_t getDestinationY1CoordinateTop(void) const { + return TheStructure.Common.DestinationY1Coordinate_Top; + } + inline void setTransferWidth(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationX2Coordinate_Right = value; + } + inline uint32_t getTransferWidth(void) const { + return TheStructure.Common.DestinationX2Coordinate_Right; + } + inline void setTransferHeight(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff0000); + TheStructure.Common.DestinationY2Coordinate_Bottom = value; + } + inline uint32_t getTransferHeight(void) const { + return TheStructure.Common.DestinationY2Coordinate_Bottom; + } + inline void setDestinationBaseAddress(const uint64_t value) { + TheStructure.Common.DestinationBaseAddress = value; + } + inline uint64_t getDestinationBaseAddress(void) const { + return TheStructure.Common.DestinationBaseAddress; + } + inline void setFillColor(const uint32_t *value) { + TheStructure.Common.SolidPaternColor = *value; + } +} XY_COLOR_BLT; +STATIC_ASSERT(28 == sizeof(XY_COLOR_BLT)); + typedef struct tagGRF { union tagTheStructure { float fRegs[8]; diff --git a/shared/source/generated/gen12lp/hw_cmds_generated_gen12lp.inl b/shared/source/generated/gen12lp/hw_cmds_generated_gen12lp.inl index c02e664d21..238cd786c5 100644 --- a/shared/source/generated/gen12lp/hw_cmds_generated_gen12lp.inl +++ b/shared/source/generated/gen12lp/hw_cmds_generated_gen12lp.inl @@ -3939,6 +3939,7 @@ typedef struct tagXY_SRC_COPY_BLT { TheStructure.Common.ClippingEnabled = CLIPPING_ENABLED_DISABLED; TheStructure.Common.InstructionTarget_Opcode = INSTRUCTIONTARGET_OPCODE_OPCODE; TheStructure.Common.DwordLength = DWORD_LENGTH_EXCLUDES_DWORD_0_1; + TheStructure.Common.RasterOperation = 0xCC; } static tagXY_SRC_COPY_BLT sInit(void) { XY_SRC_COPY_BLT state; @@ -4070,6 +4071,175 @@ typedef struct tagXY_SRC_COPY_BLT { } XY_SRC_COPY_BLT; STATIC_ASSERT(40 == sizeof(XY_SRC_COPY_BLT)); +typedef struct tagXY_COLOR_BLT { + union tagTheStructure { + struct tagCommon { + // DWORD 0 + uint32_t DwordLength : BITFIELD_RANGE(0, 7); + uint32_t Reserved_8 : BITFIELD_RANGE(8, 10); + uint32_t DestTilingEnable : BITFIELD_RANGE(11, 11); + uint32_t Reserved_12 : BITFIELD_RANGE(12, 19); + uint32_t _32BppByteMask : BITFIELD_RANGE(20, 21); + uint32_t InstructionTarget_Opcode : BITFIELD_RANGE(22, 28); + uint32_t Client : BITFIELD_RANGE(29, 31); + // DWORD 1 + uint32_t DestinationPitch : BITFIELD_RANGE(0, 15); + uint32_t RasterOperation : BITFIELD_RANGE(16, 23); + uint32_t ColorDepth : BITFIELD_RANGE(24, 25); + uint32_t Reserved_58 : BITFIELD_RANGE(26, 29); + uint32_t ClippingEnabled : BITFIELD_RANGE(30, 30); + uint32_t Reserved_63 : BITFIELD_RANGE(31, 31); + // DWORD 2 + uint32_t DestinationX1Coordinate_Left : BITFIELD_RANGE(0, 15); + uint32_t DestinationY1Coordinate_Top : BITFIELD_RANGE(16, 31); + // DWORD 3 + uint32_t DestinationX2Coordinate_Right : BITFIELD_RANGE(0, 15); + uint32_t DestinationY2Coordinate_Bottom : BITFIELD_RANGE(16, 31); + // DWORD 4-5 + uint64_t DestinationBaseAddress; + // DWORD 6 + uint32_t SolidPaternColor; + } Common; + uint32_t RawData[7]; + } TheStructure; + typedef enum tagDEST_TILING_ENABLE { + DEST_TILING_ENABLE_TILING_DISABLED_LINEAR_BLIT = 0x0, + DEST_TILING_ENABLE_TILING_ENABLED = 0x1, + } DEST_TILING_ENABLE; + typedef enum tag_32BPP_BYTE_MASK { + _32BPP_BYTE_MASK_WRITE_RGB_CHANNEL = 0x1, + _32BPP_BYTE_MASK_WRITE_ALPHA_CHANNEL = 0x2, + _32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL = 0x3 + } _32BPP_BYTE_MASK; + typedef enum tagCLIENT { + CLIENT_2D_PROCESSOR = 0x2, + } CLIENT; + typedef enum tagCOLOR_DEPTH { + COLOR_DEPTH_8_BIT_COLOR = 0x0, + COLOR_DEPTH_16_BIT_COLOR565 = 0x1, + COLOR_DEPTH_16_BIT_COLOR1555 = 0x2, + COLOR_DEPTH_32_BIT_COLOR = 0x3, + } COLOR_DEPTH; + typedef enum tagCLIPPING_ENABLED { + CLIPPING_ENABLED_DISABLED = 0x0, + CLIPPING_ENABLED_ENABLED = 0x1, + } CLIPPING_ENABLED; + typedef enum tagINSTRUCTIONTARGET_OPCODE { + INSTRUCTIONTARGET_OPCODE_OPCODE = 0x50, + } INSTRUCTIONTARGET_OPCODE; + typedef enum tagDWORD_LENGTH { + DWORD_LENGTH_EXCLUDES_DWORD_0_1 = 0x5, + } DWORD_LENGTH; + inline void init(void) { + memset(&TheStructure, 0, sizeof(TheStructure)); + TheStructure.Common.DestTilingEnable = DEST_TILING_ENABLE_TILING_DISABLED_LINEAR_BLIT; + TheStructure.Common.Client = CLIENT_2D_PROCESSOR; + TheStructure.Common.ColorDepth = COLOR_DEPTH_8_BIT_COLOR; + TheStructure.Common.ClippingEnabled = CLIPPING_ENABLED_DISABLED; + TheStructure.Common.InstructionTarget_Opcode = INSTRUCTIONTARGET_OPCODE_OPCODE; + TheStructure.Common.DwordLength = DWORD_LENGTH_EXCLUDES_DWORD_0_1; + TheStructure.Common.RasterOperation = 0xF0; + } + static tagXY_COLOR_BLT sInit(void) { + XY_COLOR_BLT state; + state.init(); + return state; + } + inline uint32_t &getRawData(const uint32_t index) { + UNRECOVERABLE_IF(index >= 10); + return TheStructure.RawData[index]; + } + inline void setDestTilingEnable(const DEST_TILING_ENABLE value) { + TheStructure.Common.DestTilingEnable = value; + } + inline DEST_TILING_ENABLE getDestTilingEnable(void) const { + return static_cast(TheStructure.Common.DestTilingEnable); + } + inline void set32BppByteMask(const _32BPP_BYTE_MASK value) { + TheStructure.Common._32BppByteMask = value; + } + inline _32BPP_BYTE_MASK get32BppByteMask(void) const { + return static_cast<_32BPP_BYTE_MASK>(TheStructure.Common._32BppByteMask); + } + inline void setInstructionTargetOpcode(const uint32_t value) { + UNRECOVERABLE_IF(value > 0x1fc00000); + TheStructure.Common.InstructionTarget_Opcode = value; + } + inline uint32_t getInstructionTargetOpcode(void) const { + return TheStructure.Common.InstructionTarget_Opcode; + } + inline void setClient(const CLIENT value) { + TheStructure.Common.Client = value; + } + inline CLIENT getClient(void) const { + return static_cast(TheStructure.Common.Client); + } + inline void setDestinationPitch(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationPitch = value; + } + inline uint32_t getDestinationPitch(void) const { + return TheStructure.Common.DestinationPitch; + } + inline void setRasterOperation(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xff0000); + TheStructure.Common.RasterOperation = value; + } + inline uint32_t getRasterOperation(void) const { + return TheStructure.Common.RasterOperation; + } + inline void setColorDepth(const COLOR_DEPTH value) { + TheStructure.Common.ColorDepth = value; + } + inline COLOR_DEPTH getColorDepth(void) const { + return static_cast(TheStructure.Common.ColorDepth); + } + inline void setClippingEnabled(const CLIPPING_ENABLED value) { + TheStructure.Common.ClippingEnabled = value; + } + inline CLIPPING_ENABLED getClippingEnabled(void) const { + return static_cast(TheStructure.Common.ClippingEnabled); + } + inline void setDestinationX1CoordinateLeft(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationX1Coordinate_Left = value; + } + inline uint32_t getDestinationX1CoordinateLeft(void) const { + return TheStructure.Common.DestinationX1Coordinate_Left; + } + inline void setDestinationY1CoordinateTop(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff0000); + TheStructure.Common.DestinationY1Coordinate_Top = value; + } + inline uint32_t getDestinationY1CoordinateTop(void) const { + return TheStructure.Common.DestinationY1Coordinate_Top; + } + inline void setTransferWidth(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationX2Coordinate_Right = value; + } + inline uint32_t getTransferWidth(void) const { + return TheStructure.Common.DestinationX2Coordinate_Right; + } + inline void setTransferHeight(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff0000); + TheStructure.Common.DestinationY2Coordinate_Bottom = value; + } + inline uint32_t getTransferHeight(void) const { + return TheStructure.Common.DestinationY2Coordinate_Bottom; + } + inline void setDestinationBaseAddress(const uint64_t value) { + TheStructure.Common.DestinationBaseAddress = value; + } + inline uint64_t getDestinationBaseAddress(void) const { + return TheStructure.Common.DestinationBaseAddress; + } + inline void setFillColor(const uint32_t *value) { + TheStructure.Common.SolidPaternColor = *value; + } +} XY_COLOR_BLT; +STATIC_ASSERT(28 == sizeof(XY_COLOR_BLT)); + typedef struct tagMI_FLUSH_DW { union tagTheStructure { struct tagCommon { diff --git a/shared/source/generated/gen8/hw_cmds_generated_gen8.inl b/shared/source/generated/gen8/hw_cmds_generated_gen8.inl index 1705bf408b..a962bb201a 100644 --- a/shared/source/generated/gen8/hw_cmds_generated_gen8.inl +++ b/shared/source/generated/gen8/hw_cmds_generated_gen8.inl @@ -3960,6 +3960,7 @@ typedef struct tagXY_SRC_COPY_BLT { TheStructure.Common.ClippingEnabled = CLIPPING_ENABLED_DISABLED; TheStructure.Common.InstructionTarget_Opcode = INSTRUCTIONTARGET_OPCODE_OPCODE; TheStructure.Common.DwordLength = DWORD_LENGTH_EXCLUDES_DWORD_0_1; + TheStructure.Common.RasterOperation = 0xCC; } static tagXY_SRC_COPY_BLT sInit(void) { XY_SRC_COPY_BLT state; @@ -4091,6 +4092,175 @@ typedef struct tagXY_SRC_COPY_BLT { } XY_SRC_COPY_BLT; STATIC_ASSERT(40 == sizeof(XY_SRC_COPY_BLT)); +typedef struct tagXY_COLOR_BLT { + union tagTheStructure { + struct tagCommon { + // DWORD 0 + uint32_t DwordLength : BITFIELD_RANGE(0, 7); + uint32_t Reserved_8 : BITFIELD_RANGE(8, 10); + uint32_t DestTilingEnable : BITFIELD_RANGE(11, 11); + uint32_t Reserved_12 : BITFIELD_RANGE(12, 19); + uint32_t _32BppByteMask : BITFIELD_RANGE(20, 21); + uint32_t InstructionTarget_Opcode : BITFIELD_RANGE(22, 28); + uint32_t Client : BITFIELD_RANGE(29, 31); + // DWORD 1 + uint32_t DestinationPitch : BITFIELD_RANGE(0, 15); + uint32_t RasterOperation : BITFIELD_RANGE(16, 23); + uint32_t ColorDepth : BITFIELD_RANGE(24, 25); + uint32_t Reserved_58 : BITFIELD_RANGE(26, 29); + uint32_t ClippingEnabled : BITFIELD_RANGE(30, 30); + uint32_t Reserved_63 : BITFIELD_RANGE(31, 31); + // DWORD 2 + uint32_t DestinationX1Coordinate_Left : BITFIELD_RANGE(0, 15); + uint32_t DestinationY1Coordinate_Top : BITFIELD_RANGE(16, 31); + // DWORD 3 + uint32_t DestinationX2Coordinate_Right : BITFIELD_RANGE(0, 15); + uint32_t DestinationY2Coordinate_Bottom : BITFIELD_RANGE(16, 31); + // DWORD 4-5 + uint64_t DestinationBaseAddress; + // DWORD 6 + uint32_t SolidPaternColor; + } Common; + uint32_t RawData[7]; + } TheStructure; + typedef enum tagDEST_TILING_ENABLE { + DEST_TILING_ENABLE_TILING_DISABLED_LINEAR_BLIT = 0x0, + DEST_TILING_ENABLE_TILING_ENABLED = 0x1, + } DEST_TILING_ENABLE; + typedef enum tag_32BPP_BYTE_MASK { + _32BPP_BYTE_MASK_WRITE_RGB_CHANNEL = 0x1, + _32BPP_BYTE_MASK_WRITE_ALPHA_CHANNEL = 0x2, + _32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL = 0x3 + } _32BPP_BYTE_MASK; + typedef enum tagCLIENT { + CLIENT_2D_PROCESSOR = 0x2, + } CLIENT; + typedef enum tagCOLOR_DEPTH { + COLOR_DEPTH_8_BIT_COLOR = 0x0, + COLOR_DEPTH_16_BIT_COLOR565 = 0x1, + COLOR_DEPTH_16_BIT_COLOR1555 = 0x2, + COLOR_DEPTH_32_BIT_COLOR = 0x3, + } COLOR_DEPTH; + typedef enum tagCLIPPING_ENABLED { + CLIPPING_ENABLED_DISABLED = 0x0, + CLIPPING_ENABLED_ENABLED = 0x1, + } CLIPPING_ENABLED; + typedef enum tagINSTRUCTIONTARGET_OPCODE { + INSTRUCTIONTARGET_OPCODE_OPCODE = 0x50, + } INSTRUCTIONTARGET_OPCODE; + typedef enum tagDWORD_LENGTH { + DWORD_LENGTH_EXCLUDES_DWORD_0_1 = 0x5, + } DWORD_LENGTH; + inline void init(void) { + memset(&TheStructure, 0, sizeof(TheStructure)); + TheStructure.Common.DestTilingEnable = DEST_TILING_ENABLE_TILING_DISABLED_LINEAR_BLIT; + TheStructure.Common.Client = CLIENT_2D_PROCESSOR; + TheStructure.Common.ColorDepth = COLOR_DEPTH_8_BIT_COLOR; + TheStructure.Common.ClippingEnabled = CLIPPING_ENABLED_DISABLED; + TheStructure.Common.InstructionTarget_Opcode = INSTRUCTIONTARGET_OPCODE_OPCODE; + TheStructure.Common.DwordLength = DWORD_LENGTH_EXCLUDES_DWORD_0_1; + TheStructure.Common.RasterOperation = 0xF0; + } + static tagXY_COLOR_BLT sInit(void) { + XY_COLOR_BLT state; + state.init(); + return state; + } + inline uint32_t &getRawData(const uint32_t index) { + UNRECOVERABLE_IF(index >= 10); + return TheStructure.RawData[index]; + } + inline void setDestTilingEnable(const DEST_TILING_ENABLE value) { + TheStructure.Common.DestTilingEnable = value; + } + inline DEST_TILING_ENABLE getDestTilingEnable(void) const { + return static_cast(TheStructure.Common.DestTilingEnable); + } + inline void set32BppByteMask(const _32BPP_BYTE_MASK value) { + TheStructure.Common._32BppByteMask = value; + } + inline _32BPP_BYTE_MASK get32BppByteMask(void) const { + return static_cast<_32BPP_BYTE_MASK>(TheStructure.Common._32BppByteMask); + } + inline void setInstructionTargetOpcode(const uint32_t value) { + UNRECOVERABLE_IF(value > 0x1fc00000); + TheStructure.Common.InstructionTarget_Opcode = value; + } + inline uint32_t getInstructionTargetOpcode(void) const { + return TheStructure.Common.InstructionTarget_Opcode; + } + inline void setClient(const CLIENT value) { + TheStructure.Common.Client = value; + } + inline CLIENT getClient(void) const { + return static_cast(TheStructure.Common.Client); + } + inline void setDestinationPitch(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationPitch = value; + } + inline uint32_t getDestinationPitch(void) const { + return TheStructure.Common.DestinationPitch; + } + inline void setRasterOperation(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xff0000); + TheStructure.Common.RasterOperation = value; + } + inline uint32_t getRasterOperation(void) const { + return TheStructure.Common.RasterOperation; + } + inline void setColorDepth(const COLOR_DEPTH value) { + TheStructure.Common.ColorDepth = value; + } + inline COLOR_DEPTH getColorDepth(void) const { + return static_cast(TheStructure.Common.ColorDepth); + } + inline void setClippingEnabled(const CLIPPING_ENABLED value) { + TheStructure.Common.ClippingEnabled = value; + } + inline CLIPPING_ENABLED getClippingEnabled(void) const { + return static_cast(TheStructure.Common.ClippingEnabled); + } + inline void setDestinationX1CoordinateLeft(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationX1Coordinate_Left = value; + } + inline uint32_t getDestinationX1CoordinateLeft(void) const { + return TheStructure.Common.DestinationX1Coordinate_Left; + } + inline void setDestinationY1CoordinateTop(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff0000); + TheStructure.Common.DestinationY1Coordinate_Top = value; + } + inline uint32_t getDestinationY1CoordinateTop(void) const { + return TheStructure.Common.DestinationY1Coordinate_Top; + } + inline void setTransferWidth(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationX2Coordinate_Right = value; + } + inline uint32_t getTransferWidth(void) const { + return TheStructure.Common.DestinationX2Coordinate_Right; + } + inline void setTransferHeight(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff0000); + TheStructure.Common.DestinationY2Coordinate_Bottom = value; + } + inline uint32_t getTransferHeight(void) const { + return TheStructure.Common.DestinationY2Coordinate_Bottom; + } + inline void setDestinationBaseAddress(const uint64_t value) { + TheStructure.Common.DestinationBaseAddress = value; + } + inline uint64_t getDestinationBaseAddress(void) const { + return TheStructure.Common.DestinationBaseAddress; + } + inline void setFillColor(const uint32_t *value) { + TheStructure.Common.SolidPaternColor = *value; + } +} XY_COLOR_BLT; +STATIC_ASSERT(28 == sizeof(XY_COLOR_BLT)); + typedef struct tagGRF { union tagTheStructure { float fRegs[8]; diff --git a/shared/source/generated/gen9/hw_cmds_generated_gen9.inl b/shared/source/generated/gen9/hw_cmds_generated_gen9.inl index 39db696866..4edf910e83 100644 --- a/shared/source/generated/gen9/hw_cmds_generated_gen9.inl +++ b/shared/source/generated/gen9/hw_cmds_generated_gen9.inl @@ -4155,6 +4155,7 @@ typedef struct tagXY_SRC_COPY_BLT { TheStructure.Common.ClippingEnabled = CLIPPING_ENABLED_DISABLED; TheStructure.Common.InstructionTarget_Opcode = INSTRUCTIONTARGET_OPCODE_OPCODE; TheStructure.Common.DwordLength = DWORD_LENGTH_EXCLUDES_DWORD_0_1; + TheStructure.Common.RasterOperation = 0xCC; } static tagXY_SRC_COPY_BLT sInit(void) { XY_SRC_COPY_BLT state; @@ -4286,6 +4287,175 @@ typedef struct tagXY_SRC_COPY_BLT { } XY_SRC_COPY_BLT; STATIC_ASSERT(40 == sizeof(XY_SRC_COPY_BLT)); +typedef struct tagXY_COLOR_BLT { + union tagTheStructure { + struct tagCommon { + // DWORD 0 + uint32_t DwordLength : BITFIELD_RANGE(0, 7); + uint32_t Reserved_8 : BITFIELD_RANGE(8, 10); + uint32_t DestTilingEnable : BITFIELD_RANGE(11, 11); + uint32_t Reserved_12 : BITFIELD_RANGE(12, 19); + uint32_t _32BppByteMask : BITFIELD_RANGE(20, 21); + uint32_t InstructionTarget_Opcode : BITFIELD_RANGE(22, 28); + uint32_t Client : BITFIELD_RANGE(29, 31); + // DWORD 1 + uint32_t DestinationPitch : BITFIELD_RANGE(0, 15); + uint32_t RasterOperation : BITFIELD_RANGE(16, 23); + uint32_t ColorDepth : BITFIELD_RANGE(24, 25); + uint32_t Reserved_58 : BITFIELD_RANGE(26, 29); + uint32_t ClippingEnabled : BITFIELD_RANGE(30, 30); + uint32_t Reserved_63 : BITFIELD_RANGE(31, 31); + // DWORD 2 + uint32_t DestinationX1Coordinate_Left : BITFIELD_RANGE(0, 15); + uint32_t DestinationY1Coordinate_Top : BITFIELD_RANGE(16, 31); + // DWORD 3 + uint32_t DestinationX2Coordinate_Right : BITFIELD_RANGE(0, 15); + uint32_t DestinationY2Coordinate_Bottom : BITFIELD_RANGE(16, 31); + // DWORD 4-5 + uint64_t DestinationBaseAddress; + // DWORD 6 + uint32_t SolidPaternColor; + } Common; + uint32_t RawData[7]; + } TheStructure; + typedef enum tagDEST_TILING_ENABLE { + DEST_TILING_ENABLE_TILING_DISABLED_LINEAR_BLIT = 0x0, + DEST_TILING_ENABLE_TILING_ENABLED = 0x1, + } DEST_TILING_ENABLE; + typedef enum tag_32BPP_BYTE_MASK { + _32BPP_BYTE_MASK_WRITE_RGB_CHANNEL = 0x1, + _32BPP_BYTE_MASK_WRITE_ALPHA_CHANNEL = 0x2, + _32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL = 0x3 + } _32BPP_BYTE_MASK; + typedef enum tagCLIENT { + CLIENT_2D_PROCESSOR = 0x2, + } CLIENT; + typedef enum tagCOLOR_DEPTH { + COLOR_DEPTH_8_BIT_COLOR = 0x0, + COLOR_DEPTH_16_BIT_COLOR565 = 0x1, + COLOR_DEPTH_16_BIT_COLOR1555 = 0x2, + COLOR_DEPTH_32_BIT_COLOR = 0x3, + } COLOR_DEPTH; + typedef enum tagCLIPPING_ENABLED { + CLIPPING_ENABLED_DISABLED = 0x0, + CLIPPING_ENABLED_ENABLED = 0x1, + } CLIPPING_ENABLED; + typedef enum tagINSTRUCTIONTARGET_OPCODE { + INSTRUCTIONTARGET_OPCODE_OPCODE = 0x50, + } INSTRUCTIONTARGET_OPCODE; + typedef enum tagDWORD_LENGTH { + DWORD_LENGTH_EXCLUDES_DWORD_0_1 = 0x5, + } DWORD_LENGTH; + inline void init(void) { + memset(&TheStructure, 0, sizeof(TheStructure)); + TheStructure.Common.DestTilingEnable = DEST_TILING_ENABLE_TILING_DISABLED_LINEAR_BLIT; + TheStructure.Common.Client = CLIENT_2D_PROCESSOR; + TheStructure.Common.ColorDepth = COLOR_DEPTH_8_BIT_COLOR; + TheStructure.Common.ClippingEnabled = CLIPPING_ENABLED_DISABLED; + TheStructure.Common.InstructionTarget_Opcode = INSTRUCTIONTARGET_OPCODE_OPCODE; + TheStructure.Common.DwordLength = DWORD_LENGTH_EXCLUDES_DWORD_0_1; + TheStructure.Common.RasterOperation = 0xF0; + } + static tagXY_COLOR_BLT sInit(void) { + XY_COLOR_BLT state; + state.init(); + return state; + } + inline uint32_t &getRawData(const uint32_t index) { + UNRECOVERABLE_IF(index >= 10); + return TheStructure.RawData[index]; + } + inline void setDestTilingEnable(const DEST_TILING_ENABLE value) { + TheStructure.Common.DestTilingEnable = value; + } + inline DEST_TILING_ENABLE getDestTilingEnable(void) const { + return static_cast(TheStructure.Common.DestTilingEnable); + } + inline void set32BppByteMask(const _32BPP_BYTE_MASK value) { + TheStructure.Common._32BppByteMask = value; + } + inline _32BPP_BYTE_MASK get32BppByteMask(void) const { + return static_cast<_32BPP_BYTE_MASK>(TheStructure.Common._32BppByteMask); + } + inline void setInstructionTargetOpcode(const uint32_t value) { + UNRECOVERABLE_IF(value > 0x1fc00000); + TheStructure.Common.InstructionTarget_Opcode = value; + } + inline uint32_t getInstructionTargetOpcode(void) const { + return TheStructure.Common.InstructionTarget_Opcode; + } + inline void setClient(const CLIENT value) { + TheStructure.Common.Client = value; + } + inline CLIENT getClient(void) const { + return static_cast(TheStructure.Common.Client); + } + inline void setDestinationPitch(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationPitch = value; + } + inline uint32_t getDestinationPitch(void) const { + return TheStructure.Common.DestinationPitch; + } + inline void setRasterOperation(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xff0000); + TheStructure.Common.RasterOperation = value; + } + inline uint32_t getRasterOperation(void) const { + return TheStructure.Common.RasterOperation; + } + inline void setColorDepth(const COLOR_DEPTH value) { + TheStructure.Common.ColorDepth = value; + } + inline COLOR_DEPTH getColorDepth(void) const { + return static_cast(TheStructure.Common.ColorDepth); + } + inline void setClippingEnabled(const CLIPPING_ENABLED value) { + TheStructure.Common.ClippingEnabled = value; + } + inline CLIPPING_ENABLED getClippingEnabled(void) const { + return static_cast(TheStructure.Common.ClippingEnabled); + } + inline void setDestinationX1CoordinateLeft(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationX1Coordinate_Left = value; + } + inline uint32_t getDestinationX1CoordinateLeft(void) const { + return TheStructure.Common.DestinationX1Coordinate_Left; + } + inline void setDestinationY1CoordinateTop(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff0000); + TheStructure.Common.DestinationY1Coordinate_Top = value; + } + inline uint32_t getDestinationY1CoordinateTop(void) const { + return TheStructure.Common.DestinationY1Coordinate_Top; + } + inline void setTransferWidth(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff); + TheStructure.Common.DestinationX2Coordinate_Right = value; + } + inline uint32_t getTransferWidth(void) const { + return TheStructure.Common.DestinationX2Coordinate_Right; + } + inline void setTransferHeight(const uint32_t value) { + UNRECOVERABLE_IF(value > 0xffff0000); + TheStructure.Common.DestinationY2Coordinate_Bottom = value; + } + inline uint32_t getTransferHeight(void) const { + return TheStructure.Common.DestinationY2Coordinate_Bottom; + } + inline void setDestinationBaseAddress(const uint64_t value) { + TheStructure.Common.DestinationBaseAddress = value; + } + inline uint64_t getDestinationBaseAddress(void) const { + return TheStructure.Common.DestinationBaseAddress; + } + inline void setFillColor(const uint32_t *value) { + TheStructure.Common.SolidPaternColor = *value; + } +} XY_COLOR_BLT; +STATIC_ASSERT(28 == sizeof(XY_COLOR_BLT)); + typedef struct tagGRF { union tagTheStructure { float fRegs[8]; diff --git a/shared/source/helpers/blit_commands_helper.h b/shared/source/helpers/blit_commands_helper.h index 4c60f26481..8e756665ea 100644 --- a/shared/source/helpers/blit_commands_helper.h +++ b/shared/source/helpers/blit_commands_helper.h @@ -74,11 +74,17 @@ struct BlitProperties { template struct BlitCommandsHelper { + using COLOR_DEPTH = typename GfxFamily::XY_COLOR_BLT::COLOR_DEPTH; static size_t estimateBlitCommandsSize(Vec3 copySize, const CsrDependencies &csrDependencies, bool updateTimestampPacket); static size_t estimateBlitCommandsSize(const BlitPropertiesContainer &blitPropertiesContainer, const HardwareInfo &hwInfo); static uint64_t calculateBlitCommandDestinationBaseAddress(const BlitProperties &blitProperties, uint64_t offset, uint64_t row, uint64_t slice); static uint64_t calculateBlitCommandSourceBaseAddress(const BlitProperties &blitProperties, uint64_t offset, uint64_t row, uint64_t slice); static void dispatchBlitCommandsForBuffer(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment); + static void dispatchBlitMemoryColorFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, size_t patternSize, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment); + template + static void dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth); static void appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment); + static void appendBlitCommandsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment); + static void appendTilingEnable(typename GfxFamily::XY_COLOR_BLT &blitCmd); }; } // namespace NEO diff --git a/shared/source/helpers/blit_commands_helper_base.inl b/shared/source/helpers/blit_commands_helper_base.inl index 04032d3e17..7b71a9efb0 100644 --- a/shared/source/helpers/blit_commands_helper_base.inl +++ b/shared/source/helpers/blit_commands_helper_base.inl @@ -128,5 +128,43 @@ void BlitCommandsHelper::dispatchBlitCommandsForBuffer(const BlitProp } } } +template +template +void BlitCommandsHelper::dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) { + using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT; + auto blitCmd = GfxFamily::cmdInitXyColorBlt; + + blitCmd.setFillColor(pattern); + blitCmd.setColorDepth(depth); + + appendBlitCommandsForFillBuffer(dstAlloc, blitCmd, rootDeviceEnvironment); + + uint64_t offset = 0; + uint64_t sizeToFill = size; + while (sizeToFill != 0) { + auto tmpCmd = blitCmd; + tmpCmd.setDestinationBaseAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast(offset))); + uint64_t height = 0; + uint64_t width = 0; + if (sizeToFill <= BlitterConstants::maxBlitWidth) { + width = sizeToFill; + height = 1; + } else { + width = BlitterConstants::maxBlitWidth; + height = std::min((sizeToFill / width), BlitterConstants::maxBlitHeight); + if (height > 1) { + appendTilingEnable(tmpCmd); + } + } + tmpCmd.setTransferWidth(static_cast(width)); + tmpCmd.setTransferHeight(static_cast(height)); + tmpCmd.setDestinationPitch(static_cast(width)); + auto cmd = linearStream.getSpaceForCmd(); + *cmd = tmpCmd; + auto blitSize = width * height; + offset += (blitSize); + sizeToFill -= blitSize; + } +} } // namespace NEO diff --git a/shared/source/helpers/blit_commands_helper_bdw_plus.inl b/shared/source/helpers/blit_commands_helper_bdw_plus.inl index b869158282..7b916afddf 100644 --- a/shared/source/helpers/blit_commands_helper_bdw_plus.inl +++ b/shared/source/helpers/blit_commands_helper_bdw_plus.inl @@ -12,4 +12,32 @@ namespace NEO { template void BlitCommandsHelper::appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {} +template +void BlitCommandsHelper::appendBlitCommandsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) { + using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT; + if (blitCmd.getColorDepth() == XY_COLOR_BLT::COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR) { + blitCmd.set32BppByteMask(XY_COLOR_BLT::_32BPP_BYTE_MASK::_32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL); + } +} + +template +void BlitCommandsHelper::dispatchBlitMemoryColorFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, size_t patternSize, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment) { + switch (patternSize) { + case 1: + NEO::BlitCommandsHelper::dispatchBlitMemoryFill<1>(dstAlloc, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR); + break; + case 2: + NEO::BlitCommandsHelper::dispatchBlitMemoryFill<2>(dstAlloc, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR1555); + break; + default: + NEO::BlitCommandsHelper::dispatchBlitMemoryFill<4>(dstAlloc, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR); + } +} + +template +void BlitCommandsHelper::appendTilingEnable(typename GfxFamily::XY_COLOR_BLT &blitCmd) { + using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT; + blitCmd.setDestTilingEnable(XY_COLOR_BLT::DEST_TILING_ENABLE::DEST_TILING_ENABLE_TILING_ENABLED); +} + } // namespace NEO diff --git a/shared/source/helpers/constants.h b/shared/source/helpers/constants.h index 13481e2575..950cd6207d 100644 --- a/shared/source/helpers/constants.h +++ b/shared/source/helpers/constants.h @@ -56,8 +56,10 @@ constexpr uint64_t MB = MemoryConstants::megaByte; constexpr uint64_t GB = MemoryConstants::gigaByte; namespace BlitterConstants { -constexpr uint64_t maxBlitWidth = 0x7FC0; // 0x7FFF aligned to cacheline size -constexpr uint64_t maxBlitHeight = 0x3FC0; // 0x4000 aligned to cacheline size +constexpr uint64_t maxBlitWidth = 0x7FC0; // 0x7FFF aligned to cacheline size +constexpr uint64_t maxBlitHeight = 0x3FC0; // 0x4000 aligned to cacheline size +constexpr uint64_t maxBlitSetWidth = 0x1FFC0; // 0x20000 aligned to cacheline size +constexpr uint64_t maxBlitSetHeight = 0x1FFC0; // 0x20000 aligned to cacheline size enum class BlitDirection : uint32_t { BufferToHostPtr, HostPtrToBuffer, diff --git a/shared/test/unit_test/cmd_parse/cmd_parse_base.inl b/shared/test/unit_test/cmd_parse/cmd_parse_base.inl index 0042216176..f2c9b5d60c 100644 --- a/shared/test/unit_test/cmd_parse/cmd_parse_base.inl +++ b/shared/test/unit_test/cmd_parse/cmd_parse_base.inl @@ -27,6 +27,7 @@ using MI_SEMAPHORE_WAIT = GenStruct::MI_SEMAPHORE_WAIT; using MI_STORE_DATA_IMM = GenStruct::MI_STORE_DATA_IMM; using MI_FLUSH_DW = GenStruct::MI_FLUSH_DW; using XY_COPY_BLT = GenGfxFamily::XY_COPY_BLT; +using XY_COLOR_BLT = GenGfxFamily::XY_COLOR_BLT; // clang-format on template <> @@ -205,6 +206,16 @@ XY_COPY_BLT *genCmdCast(void *buffer) { : nullptr; } +template <> +XY_COLOR_BLT *genCmdCast(void *buffer) { + auto pCmd = reinterpret_cast(buffer); + + return XY_COLOR_BLT::INSTRUCTIONTARGET_OPCODE_OPCODE == pCmd->TheStructure.Common.InstructionTarget_Opcode && + XY_COLOR_BLT::CLIENT_2D_PROCESSOR == pCmd->TheStructure.Common.Client + ? pCmd + : nullptr; +} + template size_t CmdParse::getCommandLength(void *cmd) { { @@ -297,6 +308,11 @@ size_t CmdParse::getCommandLength(void *cmd) { if (pCmd) return pCmd->TheStructure.Common.DwordLength + 2; } + { + auto pCmd = genCmdCast(cmd); + if (pCmd) + return pCmd->TheStructure.Common.DwordLength + 2; + } auto commandLengthHwSpecific = getCommandLengthHwSpecific(cmd); @@ -330,6 +346,7 @@ const char *CmdParse::getCommandName(void *cmd) { RETURN_NAME_IF(MI_STORE_DATA_IMM); RETURN_NAME_IF(MI_FLUSH_DW); RETURN_NAME_IF(XY_COPY_BLT); + RETURN_NAME_IF(XY_COLOR_BLT); #undef RETURN_NAME_IF diff --git a/shared/test/unit_test/helpers/CMakeLists.txt b/shared/test/unit_test/helpers/CMakeLists.txt index ee1be17ee5..bf18387806 100644 --- a/shared/test/unit_test/helpers/CMakeLists.txt +++ b/shared/test/unit_test/helpers/CMakeLists.txt @@ -6,6 +6,7 @@ set(NEO_CORE_HELPERS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_tests.inl ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/debug_manager_state_restore.h ${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.h 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 3cac3fda22..fa465e419a 100644 --- a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp +++ b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp @@ -5,6 +5,8 @@ * */ +#include "shared/test/unit_test/helpers/blit_commands_helper_tests.inl" + #include "shared/source/helpers/blit_commands_helper.h" #include "opencl/test/unit_test/mocks/mock_graphics_allocation.h" @@ -70,4 +72,119 @@ TEST(BlitCommandsHelperTest, GivenCopySizeYAndZEqual0WhenConstructingPropertiesF dstRowPitch, dstSlicePitch); Vec3 expectedSize{copySize.x, 1, 1}; EXPECT_EQ(blitProperties.copySize, expectedSize); -} \ No newline at end of file +} + +using BlitTests = Test; + +HWTEST_F(BlitTests, givenMemoryWhenFillPatternWithBlitThenCommandIsProgrammed) { + 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, sizeof(uint32_t), + MemoryPool::System4KBPages); + 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); +} + +HWTEST_F(BlitTests, givenMemorySizeBiggerThanMaxWidthButLessThanTwiceMaxWidthWhenFillPatternWithBlitThenHeightIsOne) { + 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, (2 * BlitterConstants::maxBlitWidth) - 1, + MemoryPool::System4KBPages); + 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); + } +} + +HWTEST_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBlitThenHeightIsTwo) { + 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, (2 * BlitterConstants::maxBlitWidth), + MemoryPool::System4KBPages); + 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(), 2u); + } +} + +using BlitPlatforms = IsWithinProducts; + +HWTEST2_F(BlitTests, givenMemoryWhenFillPatternSizeIs4BytesThen32BitMaskISSetCorrectly, BlitPlatforms) { + using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT; + using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH; + uint32_t pattern = 1; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::System4KBPages); + 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(XY_COLOR_BLT::_32BPP_BYTE_MASK::_32BPP_BYTE_MASK_WRITE_RGBA_CHANNEL, cmd->get32BppByteMask()); + } +} + +template +typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH getColorDepth(size_t patternSize) { + using COLOR_DEPTH = typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH; + COLOR_DEPTH depth = {}; + switch (patternSize) { + case 1: + depth = COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR; + break; + case 2: + depth = COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR1555; + break; + case 4: + depth = COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR; + break; + } + return depth; +} + +HWTEST2_P(BlitColorTests, givenCommandStreamWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, BlitPlatforms) { + auto patternSize = GetParam(); + auto expecttedDepth = getColorDepth(patternSize); + GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed test(pDevice); + test.TestBodyImpl(patternSize, expecttedDepth); +} + +INSTANTIATE_TEST_CASE_P(size_t, + BlitColorTests, + testing::Values(1, + 2, + 4)); diff --git a/shared/test/unit_test/helpers/blit_commands_helper_tests.inl b/shared/test/unit_test/helpers/blit_commands_helper_tests.inl new file mode 100644 index 0000000000..b10820a881 --- /dev/null +++ b/shared/test/unit_test/helpers/blit_commands_helper_tests.inl @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2017-2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/blit_commands_helper.h" +#include "shared/test/unit_test/cmd_parse/gen_cmd_parse.h" + +#include "opencl/test/unit_test/fixtures/device_fixture.h" +#include "opencl/test/unit_test/mocks/mock_graphics_allocation.h" +#include "test.h" + +using namespace NEO; + +struct BlitColorTests : public DeviceFixture, public testing::TestWithParam { + void SetUp() override { + DeviceFixture::SetUp(); + } + + void TearDown() override { + DeviceFixture::TearDown(); + } +}; + +template +class GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed { + public: + using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT; + using COLOR_DEPTH = typename XY_COLOR_BLT::COLOR_DEPTH; + GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed(Device *device) : device(device) {} + void TestBodyImpl(size_t patternSize, COLOR_DEPTH expectedDepth) { + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::System4KBPages); + uint32_t patternToCommand[4]; + memset(patternToCommand, 4, patternSize); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, patternToCommand, patternSize, stream, mockAllocation.getUnderlyingBufferSize(), *device->getExecutionEnvironment()->rootDeviceEnvironments[device->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(expectedDepth, cmd->getColorDepth()); + } + } + Device *device; +};