|
1 | 1 | /* |
2 | | - * Copyright (C) 2020-2021 Intel Corporation |
| 2 | + * Copyright (C) 2020-2022 Intel Corporation |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: MIT |
5 | 5 | * |
|
9 | 9 | #include "shared/test/common/helpers/unit_test_helper.h" |
10 | 10 | #include "shared/test/common/test_macros/test.h" |
11 | 11 |
|
| 12 | +#include "level_zero/core/source/image/image_hw.h" |
12 | 13 | #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" |
13 | 14 | #include "level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h" |
14 | 15 | #include "level_zero/core/test/unit_tests/fixtures/module_fixture.h" |
@@ -122,6 +123,115 @@ HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenAppendWriteGlobalTimes |
122 | 123 | ASSERT_EQ(ZE_RESULT_SUCCESS, result); |
123 | 124 | } |
124 | 125 |
|
| 126 | +HWTEST2_F(CommandListCreate, givenUseCsrImmediateSubmissionEnabledForCopyImmediateCommandListThenAppendImageCopyRegionReturnsSuccess, IsAtLeastXeHpCore) { |
| 127 | + DebugManagerStateRestore restorer; |
| 128 | + NEO::DebugManager.flags.EnableFlushTaskSubmission.set(true); |
| 129 | + const ze_command_queue_desc_t queueDesc = {}; |
| 130 | + void *srcPtr = reinterpret_cast<void *>(0x1234); |
| 131 | + void *dstPtr = reinterpret_cast<void *>(0x2345); |
| 132 | + |
| 133 | + neoDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; |
| 134 | + ze_result_t returnValue; |
| 135 | + std::unique_ptr<L0::CommandList> commandList0(CommandList::createImmediate(productFamily, |
| 136 | + device, |
| 137 | + &queueDesc, |
| 138 | + false, |
| 139 | + NEO::EngineGroupType::Copy, |
| 140 | + returnValue)); |
| 141 | + ASSERT_NE(nullptr, commandList0); |
| 142 | + |
| 143 | + ze_image_desc_t desc = {}; |
| 144 | + desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC; |
| 145 | + desc.type = ZE_IMAGE_TYPE_3D; |
| 146 | + desc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8; |
| 147 | + desc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT; |
| 148 | + desc.width = 11; |
| 149 | + desc.height = 13; |
| 150 | + desc.depth = 17; |
| 151 | + |
| 152 | + desc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_A; |
| 153 | + desc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_0; |
| 154 | + desc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1; |
| 155 | + desc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X; |
| 156 | + auto imageHWSrc = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>(); |
| 157 | + auto imageHWDst = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>(); |
| 158 | + imageHWSrc->initialize(device, &desc); |
| 159 | + imageHWDst->initialize(device, &desc); |
| 160 | + |
| 161 | + returnValue = commandList0->appendImageCopy(imageHWDst->toHandle(), imageHWSrc->toHandle(), nullptr, 0, nullptr); |
| 162 | + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); |
| 163 | + returnValue = commandList0->appendImageCopyFromMemory(imageHWDst->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr); |
| 164 | + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); |
| 165 | + returnValue = commandList0->appendImageCopyToMemory(dstPtr, imageHWSrc->toHandle(), nullptr, nullptr, 0, nullptr); |
| 166 | + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); |
| 167 | +} |
| 168 | + |
| 169 | +HWTEST2_F(CommandListCreate, givenUseCsrImmediateSubmissionDisabledForCopyImmediateCommandListThenAppendImageCopyRegionReturnsSuccess, IsAtLeastXeHpCore) { |
| 170 | + DebugManagerStateRestore restorer; |
| 171 | + NEO::DebugManager.flags.EnableFlushTaskSubmission.set(false); |
| 172 | + |
| 173 | + const ze_command_queue_desc_t queueDesc = {}; |
| 174 | + |
| 175 | + void *srcPtr = reinterpret_cast<void *>(0x1234); |
| 176 | + void *dstPtr = reinterpret_cast<void *>(0x2345); |
| 177 | + |
| 178 | + neoDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; |
| 179 | + ze_result_t returnValue; |
| 180 | + std::unique_ptr<L0::CommandList> commandList0(CommandList::createImmediate(productFamily, |
| 181 | + device, |
| 182 | + &queueDesc, |
| 183 | + false, |
| 184 | + NEO::EngineGroupType::Copy, |
| 185 | + returnValue)); |
| 186 | + ASSERT_NE(nullptr, commandList0); |
| 187 | + |
| 188 | + ze_image_desc_t desc = {}; |
| 189 | + desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC; |
| 190 | + desc.type = ZE_IMAGE_TYPE_3D; |
| 191 | + desc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8; |
| 192 | + desc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT; |
| 193 | + desc.width = 11; |
| 194 | + desc.height = 13; |
| 195 | + desc.depth = 17; |
| 196 | + |
| 197 | + desc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_A; |
| 198 | + desc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_0; |
| 199 | + desc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1; |
| 200 | + desc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X; |
| 201 | + auto imageHWSrc = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>(); |
| 202 | + auto imageHWDst = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>(); |
| 203 | + imageHWSrc->initialize(device, &desc); |
| 204 | + imageHWDst->initialize(device, &desc); |
| 205 | + |
| 206 | + returnValue = commandList0->appendImageCopy(imageHWDst->toHandle(), imageHWSrc->toHandle(), nullptr, 0, nullptr); |
| 207 | + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); |
| 208 | + returnValue = commandList0->appendImageCopyFromMemory(imageHWDst->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr); |
| 209 | + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); |
| 210 | + returnValue = commandList0->appendImageCopyToMemory(dstPtr, imageHWSrc->toHandle(), nullptr, nullptr, 0, nullptr); |
| 211 | + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); |
| 212 | +} |
| 213 | + |
| 214 | +HWTEST_F(CommandListCreate, givenUseCsrImmediateSubmissionEnabledForCopyImmediateCommandListthenAppendMemoryCopyRegionReturnsSuccess) { |
| 215 | + DebugManagerStateRestore restorer; |
| 216 | + NEO::DebugManager.flags.EnableFlushTaskSubmission.set(true); |
| 217 | + |
| 218 | + void *srcPtr = reinterpret_cast<void *>(0x1234); |
| 219 | + void *dstPtr = reinterpret_cast<void *>(0x2345); |
| 220 | + uint32_t width = 16; |
| 221 | + uint32_t height = 16; |
| 222 | + ze_copy_region_t sr = {0U, 0U, 0U, width, height, 0U}; |
| 223 | + ze_copy_region_t dr = {0U, 0U, 0U, width, height, 0U}; |
| 224 | + |
| 225 | + ze_command_queue_desc_t queueDesc = {}; |
| 226 | + ze_result_t returnValue = ZE_RESULT_SUCCESS; |
| 227 | + auto commandList = CommandList::createImmediate(productFamily, device, &queueDesc, false, NEO::EngineGroupType::Copy, returnValue); |
| 228 | + |
| 229 | + auto result = commandList->appendMemoryCopyRegion(dstPtr, &dr, 0, 0, srcPtr, &sr, 0, 0, nullptr, 0, nullptr); |
| 230 | + ASSERT_EQ(ZE_RESULT_SUCCESS, result); |
| 231 | + |
| 232 | + commandList->destroy(); |
| 233 | +} |
| 234 | + |
125 | 235 | HWTEST_F(CommandListCreate, GivenCommandListWhenUnalignedPtrThenLeftMiddleAndRightCopyAdded) { |
126 | 236 | using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; |
127 | 237 | ze_result_t returnValue; |
|
0 commit comments