diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 4627b8c151..f433690b7c 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -22,6 +22,7 @@ #include "shared/source/helpers/definitions/command_encoder_args.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/hw_info.h" +#include "shared/source/helpers/image_helper.h" #include "shared/source/helpers/in_order_cmd_helpers.h" #include "shared/source/helpers/kernel_helpers.h" #include "shared/source/helpers/pipe_control_args.h" @@ -908,7 +909,7 @@ ze_result_t CommandListCoreFamily::appendImageCopyFromMemoryExt(z builtinKernel->setArgBufferWithAlloc(0u, allocationStruct.alignedAllocationPtr, allocationStruct.alloc, nullptr); - builtinKernel->setArgRedescribedImage(1u, image->toHandle()); + builtinKernel->setArgRedescribedImage(1u, image->toHandle(), false); builtinKernel->setArgumentValue(2u, sizeof(size_t), &allocationStruct.offset); uint32_t origin[] = {pDstRegion->originX, @@ -1113,7 +1114,7 @@ ze_result_t CommandListCoreFamily::appendImageCopyToMemoryExt(voi auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership(); Kernel *builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(builtInType); - builtinKernel->setArgRedescribedImage(0u, image->toHandle()); + builtinKernel->setArgRedescribedImage(0u, image->toHandle(), false); builtinKernel->setArgBufferWithAlloc(1u, allocationStruct.alignedAllocationPtr, allocationStruct.alloc, nullptr); @@ -1315,8 +1316,11 @@ ze_result_t CommandListCoreFamily::appendImageCopyRegion(ze_image ze_group_count_t kernelArgs{srcRegion.width / groupSizeX, srcRegion.height / groupSizeY, srcRegion.depth / groupSizeZ}; - kernel->setArgRedescribedImage(0, srcImage->toHandle()); - kernel->setArgRedescribedImage(1, dstImage->toHandle()); + const bool isPackedFormat = NEO::ImageHelper::areImagesCompatibleWithPackedFormat(device->getProductHelper(), srcImage->getImageInfo(), dstImage->getImageInfo(), srcImage->getAllocation(), dstImage->getAllocation(), srcRegion.width); + + kernel->setArgRedescribedImage(0, srcImage->toHandle(), isPackedFormat); + kernel->setArgRedescribedImage(1, dstImage->toHandle(), isPackedFormat); + kernel->setArgumentValue(2, sizeof(srcOffset), &srcOffset); kernel->setArgumentValue(3, sizeof(dstOffset), &dstOffset); diff --git a/level_zero/core/source/image/image.h b/level_zero/core/source/image/image.h index b1001ee0c5..f59c7e94f9 100644 --- a/level_zero/core/source/image/image.h +++ b/level_zero/core/source/image/image.h @@ -39,10 +39,9 @@ struct Image : _ze_image_handle_t { virtual NEO::GraphicsAllocation *getAllocation() = 0; virtual NEO::GraphicsAllocation *getImplicitArgsAllocation() = 0; virtual void copySurfaceStateToSSH(void *surfaceStateHeap, - const uint32_t surfaceStateOffset, + uint32_t surfaceStateOffset, + uint32_t bindlessSlot, bool isMediaBlockArg) = 0; - virtual void copyRedescribedSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) = 0; - virtual void copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) = 0; virtual NEO::ImageInfo getImageInfo() = 0; virtual ze_image_desc_t getImageDesc() = 0; virtual ze_result_t getMemoryProperties(ze_image_memory_properties_exp_t *pMemoryProperties) = 0; diff --git a/level_zero/core/source/image/image_hw.h b/level_zero/core/source/image/image_hw.h index 8cb87b44a6..b7db5a31a0 100644 --- a/level_zero/core/source/image/image_hw.h +++ b/level_zero/core/source/image/image_hw.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -21,9 +21,10 @@ struct ImageCoreFamily : public ImageImp { using ImageImp::bindlessImage; ze_result_t initialize(Device *device, const ze_image_desc_t *desc) override; - void copySurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset, bool isMediaBlockArg) override; - void copyRedescribedSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) override; - void copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) override; + void copySurfaceStateToSSH(void *surfaceStateHeap, + uint32_t surfaceStateOffset, + uint32_t bindlessSlot, + bool isMediaBlockArg) override; bool isMediaFormat(const ze_image_format_layout_t layout) { if (layout == ze_image_format_layout_t::ZE_IMAGE_FORMAT_LAYOUT_NV12 || layout == ze_image_format_layout_t::ZE_IMAGE_FORMAT_LAYOUT_P010 || @@ -53,6 +54,7 @@ struct ImageCoreFamily : public ImageImp { RENDER_SURFACE_STATE surfaceState; RENDER_SURFACE_STATE implicitArgsSurfaceState; RENDER_SURFACE_STATE redescribedSurfaceState; + RENDER_SURFACE_STATE packedSurfaceState; }; template diff --git a/level_zero/core/source/image/image_hw.inl b/level_zero/core/source/image/image_hw.inl index 9c0d54995a..84043d289d 100644 --- a/level_zero/core/source/image/image_hw.inl +++ b/level_zero/core/source/image/image_hw.inl @@ -13,6 +13,7 @@ #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/bindless_heaps_helper.h" #include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/helpers/image_helper.h" #include "shared/source/helpers/surface_format_info.h" #include "shared/source/image/image_surface_state.h" #include "shared/source/memory_manager/allocation_properties.h" @@ -244,7 +245,7 @@ ze_result_t ImageCoreFamily::initialize(Device *device, const ze_ if (this->bindlessImage) { auto ssInHeap = getBindlessSlot(); - copySurfaceStateToSSH(ssInHeap->ssPtr, 0u, false); + copySurfaceStateToSSH(ssInHeap->ssPtr, 0u, NEO::BindlessImageSlot::image, false); if (this->sampledImage) { auto productFamily = this->device->getNEODevice()->getHardwareInfo().platform.eProductFamily; @@ -261,6 +262,7 @@ ze_result_t ImageCoreFamily::initialize(Device *device, const ze_ } } + const auto &productHelper = rootDeviceEnvironment.getHelper(); if (this->bindlessImage && implicitArgsAllocation) { implicitArgsSurfaceState = GfxFamily::cmdInitRenderSurfaceState; @@ -285,7 +287,6 @@ ze_result_t ImageCoreFamily::initialize(Device *device, const ze_ imageImplicitArgs.flagHeight = (imgInfo.imgDesc.imageHeight * pixelSize) - 1u; imageImplicitArgs.flatPitch = imgInfo.imgDesc.imageRowPitch - 1u; - const auto &productHelper = rootDeviceEnvironment.getHelper(); NEO::MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *implicitArgsAllocation), *this->device->getNEODevice(), implicitArgsAllocation, 0u, &imageImplicitArgs, NEO::ImageImplicitArgs::getSize()); { @@ -362,50 +363,51 @@ ze_result_t ImageCoreFamily::initialize(Device *device, const ze_ } } + if (productHelper.isPackedCopyFormatSupported()) { + packedSurfaceState = redescribedSurfaceState; + + NEO::EncodeSurfaceState::convertSurfaceStateToPacked(&packedSurfaceState, imgInfo); + } + return ZE_RESULT_SUCCESS; } template void ImageCoreFamily::copySurfaceStateToSSH(void *surfaceStateHeap, - const uint32_t surfaceStateOffset, + uint32_t surfaceStateOffset, + uint32_t bindlessSlot, bool isMediaBlockArg) { using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE; - // Copy the image's surface state into position in the provided surface state heap - auto destSurfaceState = ptrOffset(surfaceStateHeap, surfaceStateOffset); - memcpy_s(destSurfaceState, sizeof(RENDER_SURFACE_STATE), - &surfaceState, sizeof(RENDER_SURFACE_STATE)); + const RENDER_SURFACE_STATE *src = nullptr; + + switch (bindlessSlot) { + case NEO::BindlessImageSlot::image: + src = &surfaceState; + break; + case NEO::BindlessImageSlot::redescribedImage: + src = &redescribedSurfaceState; + break; + case NEO::BindlessImageSlot::implicitArgs: + src = &implicitArgsSurfaceState; + break; + case NEO::BindlessImageSlot::packedImage: + src = &packedSurfaceState; + break; + default: + UNRECOVERABLE_IF(true); + } + + auto dst = ptrOffset(surfaceStateHeap, surfaceStateOffset); + memcpy_s(dst, sizeof(RENDER_SURFACE_STATE), src, sizeof(RENDER_SURFACE_STATE)); + if (isMediaBlockArg) { - RENDER_SURFACE_STATE *dstRss = static_cast(destSurfaceState); + RENDER_SURFACE_STATE *dstRss = static_cast(dst); NEO::ImageSurfaceStateHelper::setWidthForMediaBlockSurfaceState(dstRss, imgInfo); } } -template -void ImageCoreFamily::copyRedescribedSurfaceStateToSSH(void *surfaceStateHeap, - const uint32_t surfaceStateOffset) { - using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; - using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE; - - // Copy the image's surface state into position in the provided surface state heap - auto destSurfaceState = ptrOffset(surfaceStateHeap, surfaceStateOffset); - memcpy_s(destSurfaceState, sizeof(RENDER_SURFACE_STATE), - &redescribedSurfaceState, sizeof(RENDER_SURFACE_STATE)); -} - -template -void ImageCoreFamily::copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap, - const uint32_t surfaceStateOffset) { - using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; - using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE; - - // Copy the image's surface state into position in the provided surface state heap - auto destSurfaceState = ptrOffset(surfaceStateHeap, surfaceStateOffset); - memcpy_s(destSurfaceState, sizeof(RENDER_SURFACE_STATE), - &implicitArgsSurfaceState, sizeof(RENDER_SURFACE_STATE)); -} - template bool ImageCoreFamily::isSuitableForCompression(const StructuresLookupTable &structuresLookupTable, const NEO::ImageInfo &imgInfo) { auto &hwInfo = device->getHwInfo(); diff --git a/level_zero/core/source/kernel/kernel.h b/level_zero/core/source/kernel/kernel.h index 69f049d3f5..1f6c8ba871 100644 --- a/level_zero/core/source/kernel/kernel.h +++ b/level_zero/core/source/kernel/kernel.h @@ -128,7 +128,7 @@ struct Kernel : _ze_kernel_handle_t, virtual NEO::DispatchKernelEncoderI, NEO::N virtual void setGroupCount(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) = 0; virtual ze_result_t setArgBufferWithAlloc(uint32_t argIndex, uintptr_t argVal, NEO::GraphicsAllocation *allocation, NEO::SvmAllocationData *peerAllocData) = 0; - virtual ze_result_t setArgRedescribedImage(uint32_t argIndex, ze_image_handle_t argVal) = 0; + virtual ze_result_t setArgRedescribedImage(uint32_t argIndex, ze_image_handle_t argVal, bool isPacked) = 0; virtual ze_result_t setGroupSize(uint32_t groupSizeX, uint32_t groupSizeY, uint32_t groupSizeZ) = 0; virtual ze_result_t suggestGroupSize(uint32_t globalSizeX, uint32_t globalSizeY, diff --git a/level_zero/core/source/kernel/kernel_imp.cpp b/level_zero/core/source/kernel/kernel_imp.cpp index fa18f462c1..8aca0c6689 100644 --- a/level_zero/core/source/kernel/kernel_imp.cpp +++ b/level_zero/core/source/kernel/kernel_imp.cpp @@ -599,7 +599,9 @@ ze_result_t KernelImp::setArgImmediate(uint32_t argIndex, size_t argSize, const return ZE_RESULT_SUCCESS; } -ze_result_t KernelImp::setArgRedescribedImage(uint32_t argIndex, ze_image_handle_t argVal) { +ze_result_t KernelImp::setArgRedescribedImage(uint32_t argIndex, ze_image_handle_t argVal, bool isPacked) { + const uint32_t bindlessSlot = isPacked ? NEO::BindlessImageSlot::packedImage : NEO::BindlessImageSlot::redescribedImage; + const auto &arg = kernelImmData->getDescriptor().payloadMappings.explicitArgs[argIndex].as(); if (argVal == nullptr) { argumentsResidencyContainer[argIndex] = nullptr; @@ -622,7 +624,7 @@ ze_result_t KernelImp::setArgRedescribedImage(uint32_t argIndex, ze_image_handle auto ssInHeap = image->getBindlessSlot(); auto patchLocation = ptrOffset(getCrossThreadData(), arg.bindless); // redescribed image's surface state is after image's implicit args and sampler - uint64_t bindlessSlotOffset = ssInHeap->surfaceStateOffset + surfaceStateSize * NEO::BindlessImageSlot::redescribedImage; + uint64_t bindlessSlotOffset = ssInHeap->surfaceStateOffset + surfaceStateSize * bindlessSlot; uint32_t patchSize = this->heaplessEnabled ? 8u : 4u; uint64_t patchValue = this->heaplessEnabled ? bindlessSlotOffset + bindlessHeapsHelper->getGlobalHeapsBase() @@ -630,15 +632,15 @@ ze_result_t KernelImp::setArgRedescribedImage(uint32_t argIndex, ze_image_handle patchWithRequiredSize(const_cast(patchLocation), patchSize, patchValue); - image->copyRedescribedSurfaceStateToSSH(ptrOffset(ssInHeap->ssPtr, surfaceStateSize * NEO::BindlessImageSlot::redescribedImage), 0u); + image->copySurfaceStateToSSH(ptrOffset(ssInHeap->ssPtr, surfaceStateSize * bindlessSlot), 0u, bindlessSlot, false); isBindlessOffsetSet[argIndex] = true; } else { usingSurfaceStateHeap[argIndex] = true; auto ssPtr = ptrOffset(surfaceStateHeapData.get(), getSurfaceStateIndexForBindlessOffset(arg.bindless) * surfaceStateSize); - image->copyRedescribedSurfaceStateToSSH(ssPtr, 0u); + image->copySurfaceStateToSSH(ssPtr, 0u, bindlessSlot, false); } } else { - image->copyRedescribedSurfaceStateToSSH(surfaceStateHeapData.get(), arg.bindful); + image->copySurfaceStateToSSH(surfaceStateHeapData.get(), arg.bindful, bindlessSlot, false); } argumentsResidencyContainer[argIndex] = image->getAllocation(); @@ -832,17 +834,17 @@ ze_result_t KernelImp::setArgImage(uint32_t argIndex, size_t argSize, const void patchWithRequiredSize(const_cast(patchLocation), patchSize, patchValue); - image->copySurfaceStateToSSH(ssInHeap->ssPtr, 0u, isMediaBlockImage); - image->copyImplicitArgsSurfaceStateToSSH(ptrOffset(ssInHeap->ssPtr, surfaceStateSize), 0u); + image->copySurfaceStateToSSH(ssInHeap->ssPtr, 0u, NEO::BindlessImageSlot::image, isMediaBlockImage); + image->copySurfaceStateToSSH(ptrOffset(ssInHeap->ssPtr, surfaceStateSize), 0u, NEO::BindlessImageSlot::implicitArgs, false); isBindlessOffsetSet[argIndex] = true; } else { usingSurfaceStateHeap[argIndex] = true; auto ssPtr = ptrOffset(surfaceStateHeapData.get(), getSurfaceStateIndexForBindlessOffset(arg.bindless) * surfaceStateSize); - image->copySurfaceStateToSSH(ssPtr, 0u, isMediaBlockImage); + image->copySurfaceStateToSSH(ssPtr, 0u, NEO::BindlessImageSlot::image, isMediaBlockImage); } } else { - image->copySurfaceStateToSSH(surfaceStateHeapData.get(), arg.bindful, isMediaBlockImage); + image->copySurfaceStateToSSH(surfaceStateHeapData.get(), arg.bindful, NEO::BindlessImageSlot::image, isMediaBlockImage); } argumentsResidencyContainer[argIndex] = image->getAllocation(); diff --git a/level_zero/core/source/kernel/kernel_imp.h b/level_zero/core/source/kernel/kernel_imp.h index fcaa78a9f7..5762ebc6d2 100644 --- a/level_zero/core/source/kernel/kernel_imp.h +++ b/level_zero/core/source/kernel/kernel_imp.h @@ -99,7 +99,7 @@ struct KernelImp : Kernel { ze_result_t setArgUnknown(uint32_t argIndex, size_t argSize, const void *argVal); - ze_result_t setArgRedescribedImage(uint32_t argIndex, ze_image_handle_t argVal) override; + ze_result_t setArgRedescribedImage(uint32_t argIndex, ze_image_handle_t argVal, bool isPacked) override; ze_result_t setArgBufferWithAlloc(uint32_t argIndex, uintptr_t argVal, NEO::GraphicsAllocation *allocation, NEO::SvmAllocationData *peerAllocData) override; diff --git a/level_zero/core/test/unit_tests/mocks/mock_image.h b/level_zero/core/test/unit_tests/mocks/mock_image.h index 1ca67c48ec..109abcaac4 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_image.h +++ b/level_zero/core/test/unit_tests/mocks/mock_image.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2024 Intel Corporation + * Copyright (C) 2022-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -26,6 +26,7 @@ struct WhiteBox<::L0::ImageCoreFamily> ~WhiteBox() override {} using BaseClass::implicitArgsSurfaceState; + using BaseClass::packedSurfaceState; using BaseClass::redescribedSurfaceState; using BaseClass::surfaceState; using BaseClass::ImageImp::imageFromBuffer; diff --git a/level_zero/core/test/unit_tests/mocks/mock_kernel.h b/level_zero/core/test/unit_tests/mocks/mock_kernel.h index aec9bb744e..dc4c10704e 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_kernel.h +++ b/level_zero/core/test/unit_tests/mocks/mock_kernel.h @@ -98,8 +98,8 @@ struct Mock<::L0::KernelImp> : public WhiteBox<::L0::KernelImp> { ADDMETHOD_NOBASE(getProperties, ze_result_t, ZE_RESULT_SUCCESS, (ze_kernel_properties_t * pKernelProperties)) ADDMETHOD(setArgRedescribedImage, ze_result_t, true, ZE_RESULT_SUCCESS, - (uint32_t argIndex, ze_image_handle_t argVal), - (argIndex, argVal)); + (uint32_t argIndex, ze_image_handle_t argVal, bool isPacked), + (argIndex, argVal, isPacked)); Mock(); ~Mock() override; diff --git a/level_zero/core/test/unit_tests/sources/helper/CMakeLists.txt b/level_zero/core/test/unit_tests/sources/helper/CMakeLists.txt index 45cce8454b..40e60a8412 100644 --- a/level_zero/core/test/unit_tests/sources/helper/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/sources/helper/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2024 Intel Corporation +# Copyright (C) 2020-2025 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -13,5 +13,6 @@ target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/l0_gfx_core_helper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/properties_parser_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ze_object_utils.h + ${CMAKE_CURRENT_SOURCE_DIR}/image_helper_l0_tests.cpp ) add_subdirectories() diff --git a/level_zero/core/test/unit_tests/sources/helper/image_helper_l0_tests.cpp b/level_zero/core/test/unit_tests/sources/helper/image_helper_l0_tests.cpp new file mode 100644 index 0000000000..61beee3ec9 --- /dev/null +++ b/level_zero/core/test/unit_tests/sources/helper/image_helper_l0_tests.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/gmm.h" +#include "shared/source/helpers/image_helper.h" +#include "shared/test/common/mocks/mock_gmm_resource_info.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/source/builtin/builtin_functions_lib.h" +#include "level_zero/core/source/image/image_hw.h" +#include "level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.h" +#include "level_zero/core/test/unit_tests/fixtures/in_order_cmd_list_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_image.h" + +using namespace NEO; + +namespace L0 { +namespace ult { + +struct ImageHelperFixture : Test { + CmdListMemoryCopyParams copyParams = {}; +}; + +HWTEST_F(ImageHelperFixture, whenImagesCheckedForPackageFormatThenFalseIsReturned) { + auto imageHWSrc = std::make_unique>>(); + auto imageHWDst = std::make_unique>>(); + ze_image_desc_t zeDesc = {}; + zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC; + zeDesc.type = ZE_IMAGE_TYPE_2D; + zeDesc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8; + zeDesc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT; + zeDesc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_R; + zeDesc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_G; + zeDesc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_B; + zeDesc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_A; + zeDesc.width = 4; + zeDesc.height = 4; + zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC; + imageHWSrc->initialize(device, &zeDesc); + imageHWDst->initialize(device, &zeDesc); + EXPECT_FALSE(ImageHelper::areImagesCompatibleWithPackedFormat(device->getProductHelper(), imageHWSrc->getImageInfo(), imageHWDst->getImageInfo(), imageHWSrc->getAllocation(), imageHWDst->getAllocation(), 5)); +} + +HWTEST_F(ImageHelperFixture, givenPackedSurfaceStateWhenCopyingImageThenSurfaceStateIsNotModified) { + auto kernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyImageRegion); + auto mockBuiltinKernel = static_cast *>(kernel); + mockBuiltinKernel->setArgRedescribedImageCallBase = false; + + auto commandList = std::make_unique>>(); + commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + + auto imageHWSrc = std::make_unique>>(); + auto imageHWDst = std::make_unique>>(); + + ze_image_desc_t zeDesc = {}; + zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC; + zeDesc.type = ZE_IMAGE_TYPE_2D; + zeDesc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8; + zeDesc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT; + zeDesc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_R; + zeDesc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_G; + zeDesc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_B; + zeDesc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_A; + zeDesc.width = 4; + zeDesc.height = 4; + + imageHWSrc->initialize(device, &zeDesc); + imageHWDst->initialize(device, &zeDesc); + + EXPECT_EQ(imageHWSrc->packedSurfaceState.getSurfaceFormat(), 0u); + EXPECT_EQ(imageHWSrc->packedSurfaceState.getWidth(), 1u); + EXPECT_EQ(imageHWSrc->packedSurfaceState.getHeight(), 1u); + + EXPECT_EQ(imageHWDst->packedSurfaceState.getSurfaceFormat(), 0u); + EXPECT_EQ(imageHWDst->packedSurfaceState.getWidth(), 1u); + EXPECT_EQ(imageHWDst->packedSurfaceState.getHeight(), 1u); +} + +} // namespace ult +} // namespace L0 \ No newline at end of file diff --git a/level_zero/core/test/unit_tests/sources/image/test_image.cpp b/level_zero/core/test/unit_tests/sources/image/test_image.cpp index 8b5950b152..f8c31480a6 100644 --- a/level_zero/core/test/unit_tests/sources/image/test_image.cpp +++ b/level_zero/core/test/unit_tests/sources/image/test_image.cpp @@ -881,7 +881,7 @@ HWTEST_F(ImageCreate, givenMediaBlockOptionWhenCopySurfaceStateThenSurfaceStateI RENDER_SURFACE_STATE rss = {}; - imageHW->copySurfaceStateToSSH(&rss, 0u, true); + imageHW->copySurfaceStateToSSH(&rss, 0u, NEO::BindlessImageSlot::image, true); EXPECT_EQ(surfaceState->getWidth(), (static_cast(imageHW->getImageInfo().surfaceFormat->imageElementSizeInBytes) * static_cast(imageHW->getImageInfo().imgDesc.imageWidth)) / sizeof(uint32_t)); } @@ -1363,7 +1363,7 @@ HWTEST2_F(ImageCreate, givenImageSizeZeroThenDummyImageIsCreated, IsAtMostXeHpgC ASSERT_NE(nullptr, alloc); auto renderSurfaceState = FamilyType::cmdInitRenderSurfaceState; - image->copySurfaceStateToSSH(&renderSurfaceState, 0u, false); + image->copySurfaceStateToSSH(&renderSurfaceState, 0u, NEO::BindlessImageSlot::image, false); EXPECT_EQ(1u, renderSurfaceState.getWidth()); EXPECT_EQ(1u, renderSurfaceState.getHeight()); @@ -1634,8 +1634,8 @@ HWTEST2_F(ImageCreate, WhenCopyingToSshThenSurfacePropertiesAreRetained, IsAtMos ret = imageB->initialize(device, &desc); ASSERT_EQ(ZE_RESULT_SUCCESS, ret); - imageA->copySurfaceStateToSSH(mockSSH, 0, false); - imageB->copySurfaceStateToSSH(mockSSH, sizeof(RENDER_SURFACE_STATE), false); + imageA->copySurfaceStateToSSH(mockSSH, 0, NEO::BindlessImageSlot::image, false); + imageB->copySurfaceStateToSSH(mockSSH, sizeof(RENDER_SURFACE_STATE), NEO::BindlessImageSlot::image, false); auto surfaceStateA = reinterpret_cast(mockSSH); ASSERT_EQ(surfaceStateA->getSurfaceType(), RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_2D); diff --git a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp index 90bb4890b3..4be3509131 100644 --- a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp +++ b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp @@ -2950,19 +2950,27 @@ TEST_F(KernelBindlessUncachedMemoryTests, template struct MyMockImage : public WhiteBox<::L0::ImageCoreFamily> { - void copySurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset, bool isMediaBlockArg) override { - passedSurfaceStateHeap = surfaceStateHeap; - passedSurfaceStateOffset = surfaceStateOffset; - } + void copySurfaceStateToSSH(void *surfaceStateHeap, + uint32_t surfaceStateOffset, + uint32_t bindlessSlot, + bool isMediaBlockArg) override { - void copyImplicitArgsSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) override { - passedImplicitArgsSurfaceStateHeap = surfaceStateHeap; - passedImplicitArgsSurfaceStateOffset = surfaceStateOffset; - } - - void copyRedescribedSurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset) override { - passedRedescribedSurfaceStateHeap = surfaceStateHeap; - passedRedescribedSurfaceStateOffset = surfaceStateOffset; + switch (bindlessSlot) { + case NEO::BindlessImageSlot::implicitArgs: + passedImplicitArgsSurfaceStateHeap = surfaceStateHeap; + passedImplicitArgsSurfaceStateOffset = surfaceStateOffset; + break; + case BindlessImageSlot::redescribedImage: + passedRedescribedSurfaceStateHeap = surfaceStateHeap; + passedRedescribedSurfaceStateOffset = surfaceStateOffset; + break; + case BindlessImageSlot::packedImage: + case BindlessImageSlot::image: + default: + passedSurfaceStateHeap = surfaceStateHeap; + passedSurfaceStateOffset = surfaceStateOffset; + break; + } } void *passedSurfaceStateHeap = nullptr; @@ -2973,6 +2981,9 @@ struct MyMockImage : public WhiteBox<::L0::ImageCoreFamily> { void *passedRedescribedSurfaceStateHeap = nullptr; uint32_t passedRedescribedSurfaceStateOffset = 0; + + void *passedPackedSurfaceStateHeap = nullptr; + uint32_t passedPackedSurfaceStateOffset = 0; }; HWTEST2_F(SetKernelArg, givenImageAndBindlessKernelWhenSetArgImageThenCopySurfaceStateToSSHCalledWithCorrectArgs, ImageSupport) { @@ -3112,7 +3123,7 @@ HWTEST2_F(SetKernelArg, givenImageBindlessKernelAndGlobalBindlessHelperWhenSetAr auto handle = imageHW->toHandle(); ASSERT_EQ(ZE_RESULT_SUCCESS, ret); - ret = kernel->setArgRedescribedImage(3, handle); + ret = kernel->setArgRedescribedImage(3, handle, false); EXPECT_EQ(ZE_RESULT_SUCCESS, ret); auto &gfxCoreHelper = neoDevice->getGfxCoreHelper(); @@ -3151,7 +3162,7 @@ HWTEST2_F(SetKernelArg, givenHeaplessWhenPatchingImageWithBindlessEnabledCorrect auto handle = imageHW->toHandle(); ASSERT_EQ(ZE_RESULT_SUCCESS, ret); - ret = kernel->setArgRedescribedImage(3, handle); + ret = kernel->setArgRedescribedImage(3, handle, false); EXPECT_EQ(ZE_RESULT_SUCCESS, ret); auto &gfxCoreHelper = neoDevice->getGfxCoreHelper(); @@ -3325,7 +3336,7 @@ HWTEST2_F(SetKernelArg, givenImageAndBindlessKernelWhenSetArgRedescribedImageCal auto handle = imageHW->toHandle(); ASSERT_EQ(ZE_RESULT_SUCCESS, ret); - ret = mockKernel.setArgRedescribedImage(0, handle); + ret = mockKernel.setArgRedescribedImage(0, handle, false); EXPECT_EQ(ZE_RESULT_SUCCESS, ret); void *expectedSsInHeap = nullptr; @@ -3371,7 +3382,7 @@ HWTEST2_F(SetKernelArg, givenBindlessKernelAndNoAvailableSpaceOnSshWhenSetArgRed mockMemManager->failAllocate32Bit = true; bindlessHelper->globalSsh->getSpace(bindlessHelper->globalSsh->getAvailableSpace()); - ret = kernel->setArgRedescribedImage(3, handle); + ret = kernel->setArgRedescribedImage(3, handle, false); EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY, ret); auto &bindlessInfo = imageHW->getAllocation()->getBindlessInfo(); @@ -3486,7 +3497,7 @@ HWTEST2_F(SetKernelArg, givenImageAndBindfulKernelWhenSetArgImageThenCopySurface template struct MyMockImageMediaBlock : public WhiteBox<::L0::ImageCoreFamily> { - void copySurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset, bool isMediaBlockArg) override { + void copySurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset, uint32_t bindlessSlot, bool isMediaBlockArg) override { isMediaBlockPassedValue = isMediaBlockArg; } bool isMediaBlockPassedValue = false; diff --git a/opencl/source/built_ins/builtins_dispatch_builder.cpp b/opencl/source/built_ins/builtins_dispatch_builder.cpp index 16fd692c42..ce098062a4 100644 --- a/opencl/source/built_ins/builtins_dispatch_builder.cpp +++ b/opencl/source/built_ins/builtins_dispatch_builder.cpp @@ -11,6 +11,7 @@ #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/debug_helpers.h" +#include "shared/source/helpers/image_helper.h" #include "opencl/source/built_ins/aux_translation_builtin.h" #include "opencl/source/built_ins/built_ins.inl" @@ -874,6 +875,33 @@ class BuiltInOp : public BuiltinDispatchInfoBui // Redescribe images to be byte-copies auto srcImageRedescribed = srcImage->redescribe(); auto dstImageRedescribed = dstImage->redescribe(); + + auto srcImageDescriptor = Image::convertDescriptor(srcImage->getImageDesc()); + auto srcSurfaceFormatInfo = srcImage->getSurfaceFormatInfo(); + SurfaceOffsets srcSurfaceOffsets; + srcImage->getSurfaceOffsets(srcSurfaceOffsets); + ImageInfo srcImgInfo; + srcImgInfo.imgDesc = srcImageDescriptor; + srcImgInfo.surfaceFormat = &srcSurfaceFormatInfo.surfaceFormat; + srcImgInfo.xOffset = srcSurfaceOffsets.xOffset; + + auto dstImageDescriptor = Image::convertDescriptor(dstImage->getImageDesc()); + auto dstSurfaceFormatInfo = dstImage->getSurfaceFormatInfo(); + SurfaceOffsets dstSurfaceOffsets; + dstImage->getSurfaceOffsets(dstSurfaceOffsets); + ImageInfo dstImgInfo; + dstImgInfo.imgDesc = dstImageDescriptor; + dstImgInfo.surfaceFormat = &dstSurfaceFormatInfo.surfaceFormat; + dstImgInfo.xOffset = dstSurfaceOffsets.xOffset; + + const auto *srcAllocation = srcImage->getGraphicsAllocation(clDevice.getRootDeviceIndex()); + const auto *dstAllocation = dstImage->getGraphicsAllocation(clDevice.getRootDeviceIndex()); + + if (ImageHelper::areImagesCompatibleWithPackedFormat(clDevice.getProductHelper(), srcImgInfo, dstImgInfo, srcAllocation, dstAllocation, operationParams.size.x)) { + srcImageRedescribed->setIsPackedFormat(true); + dstImageRedescribed->setIsPackedFormat(true); + } + multiDispatchInfo.pushRedescribedMemObj(std::unique_ptr(srcImageRedescribed)); // life range same as mdi's multiDispatchInfo.pushRedescribedMemObj(std::unique_ptr(dstImageRedescribed)); // life range same as mdi's diff --git a/opencl/source/mem_obj/image.h b/opencl/source/mem_obj/image.h index cfcb428b2a..cd4432b4ae 100644 --- a/opencl/source/mem_obj/image.h +++ b/opencl/source/mem_obj/image.h @@ -209,6 +209,7 @@ class Image : public MemObj { static bool validateHandleType(MemoryProperties &memoryProperties, UnifiedSharingMemoryDescription &extMem); void setAs3DUavOrRtvImage(bool isUavOrRtv); + void setIsPackedFormat(bool isPackedFormat) { this->isPackedFormat = isPackedFormat; } protected: Image(Context *context, @@ -249,6 +250,7 @@ class Image : public MemObj { uint32_t mipCount = 1; GMM_YUV_PLANE_ENUM plane = GMM_NO_PLANE; bool is3DUAVOrRTV = false; + bool isPackedFormat = false; static bool isValidSingleChannelFormat(const cl_image_format *imageFormat); static bool isValidIntensityFormat(const cl_image_format *imageFormat); diff --git a/opencl/source/mem_obj/image.inl b/opencl/source/mem_obj/image.inl index 659c276689..4174eafd23 100644 --- a/opencl/source/mem_obj/image.inl +++ b/opencl/source/mem_obj/image.inl @@ -12,6 +12,7 @@ #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/resource_info.h" #include "shared/source/helpers/aligned_memory.h" +#include "shared/source/helpers/image_helper.h" #include "shared/source/helpers/populate_factory.h" #include "shared/source/image/image_surface_state.h" #include "shared/source/release_helper/release_helper.h" @@ -104,6 +105,10 @@ void ImageHw::setImageArg(void *memory, bool setAsMediaBlockImage, ui adjustDepthLimitations(surfaceState, minArrayElement, renderTargetViewExtent, depth, mipCount, is3DUAVOrRTV); appendSurfaceStateParams(surfaceState, rootDeviceIndex); appendSurfaceStateExt(surfaceState); + + if (isPackedFormat) { + NEO::EncodeSurfaceState::convertSurfaceStateToPacked(surfaceState, imgInfo); + } } template diff --git a/opencl/test/unit_test/helpers/CMakeLists.txt b/opencl/test/unit_test/helpers/CMakeLists.txt index dacfc07aee..9b1d4875c2 100644 --- a/opencl/test/unit_test/helpers/CMakeLists.txt +++ b/opencl/test/unit_test/helpers/CMakeLists.txt @@ -27,6 +27,7 @@ set(IGDRCL_SRCS_tests_helpers ${CMAKE_CURRENT_SOURCE_DIR}/timestamp_packet_tests.h ${CMAKE_CURRENT_SOURCE_DIR}/transfer_properties_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/validator_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/image_helper_ocl_tests.cpp ) if(TESTS_XEHP_AND_LATER) diff --git a/opencl/test/unit_test/helpers/image_helper_ocl_tests.cpp b/opencl/test/unit_test/helpers/image_helper_ocl_tests.cpp new file mode 100644 index 0000000000..58960683e7 --- /dev/null +++ b/opencl/test/unit_test/helpers/image_helper_ocl_tests.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/gmm.h" +#include "shared/source/helpers/image_helper.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_gmm_resource_info.h" + +#include "opencl/test/unit_test/command_queue/enqueue_copy_image_fixture.h" +#include "opencl/test/unit_test/fixtures/image_fixture.h" + +struct ImageHelperFixture : ::testing::Test { + using MockContext = NEO::MockContext; + + MockContext context; +}; + +HWTEST_F(ImageHelperFixture, whenImagesCheckedForPackageFormatThenFalseIsReturned) { + std::unique_ptr> srcImage1(static_cast *>(ImageHelperUlt::create(&context))); + std::unique_ptr> dstImage1(static_cast *>(ImageHelperUlt::create(&context))); + auto srcAllocation1 = srcImage1->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex()); + auto dstAllocation1 = dstImage1->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex()); + auto srcMockGmmResourceInfo1 = reinterpret_cast(srcAllocation1->getDefaultGmm()->gmmResourceInfo.get()); + auto dstMockGmmResourceInfo1 = reinterpret_cast(dstAllocation1->getDefaultGmm()->gmmResourceInfo.get()); + srcMockGmmResourceInfo1->getResourceFlags()->Info.Tile64 = 1; + dstMockGmmResourceInfo1->getResourceFlags()->Info.Tile64 = 1; + + auto srcImageDescriptor1 = Image::convertDescriptor(srcImage1->getImageDesc()); + ClSurfaceFormatInfo srcSurfaceFormatInfo1 = srcImage1->getSurfaceFormatInfo(); + SurfaceOffsets srcSurfaceOffsets1; + srcImage1->getSurfaceOffsets(srcSurfaceOffsets1); + + ImageInfo srcImgInfo1; + srcImgInfo1.imgDesc = srcImageDescriptor1; + srcImgInfo1.surfaceFormat = &srcSurfaceFormatInfo1.surfaceFormat; + srcImgInfo1.xOffset = srcSurfaceOffsets1.xOffset; + + auto dstImageDescriptor1 = Image::convertDescriptor(dstImage1->getImageDesc()); + ClSurfaceFormatInfo dstSurfaceFormatInfo1 = dstImage1->getSurfaceFormatInfo(); + SurfaceOffsets dstSurfaceOffsets1; + dstImage1->getSurfaceOffsets(dstSurfaceOffsets1); + + ImageInfo dstImgInfo1; + dstImgInfo1.imgDesc = dstImageDescriptor1; + dstImgInfo1.surfaceFormat = &dstSurfaceFormatInfo1.surfaceFormat; + dstImgInfo1.xOffset = dstSurfaceOffsets1.xOffset; + + EXPECT_FALSE(ImageHelper::areImagesCompatibleWithPackedFormat(context.getDevice(0)->getProductHelper(), srcImgInfo1, dstImgInfo1, srcAllocation1, dstAllocation1, 4)); +} + +HWTEST_F(EnqueueCopyImageTest, givenPackedSurfaceStateWhenCopyingImageThenSurfaceStateIsNotModified) { + typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; + typedef typename RENDER_SURFACE_STATE::SURFACE_FORMAT SURFACE_FORMAT; + + auto mockCmdQ = std::make_unique>(context, pClDevice, nullptr); + VariableBackup cmdQBackup(&pCmdQ, mockCmdQ.get()); + mockCmdQ->storeMultiDispatchInfo = true; + mockCmdQ->clearBcsEngines(); + + std::unique_ptr> srcImage(static_cast *>(Image2dHelperUlt<>::create(context))); + std::unique_ptr> dstImage(static_cast *>(Image2dHelperUlt<>::create(context))); + auto srcMockGmmResourceInfo = reinterpret_cast(srcImage->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->getDefaultGmm()->gmmResourceInfo.get()); + auto dstMockGmmResourceInfo = reinterpret_cast(dstImage->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->getDefaultGmm()->gmmResourceInfo.get()); + srcMockGmmResourceInfo->getResourceFlags()->Info.Tile64 = 1; + dstMockGmmResourceInfo->getResourceFlags()->Info.Tile64 = 1; + + auto retVal = EnqueueCopyImageHelper<>::enqueueCopyImage( + pCmdQ, + srcImage.get(), + dstImage.get()); + EXPECT_EQ(CL_SUCCESS, retVal); + parseCommands(*pCmdQ); + + for (uint32_t i = 0; i < 2; ++i) { + const auto surfaceState = SurfaceStateAccessor::getSurfaceState(mockCmdQ, i); + + EXPECT_EQ(SURFACE_FORMAT::SURFACE_FORMAT_R32_UINT, surfaceState->getSurfaceFormat()); + + const auto &imageDesc = dstImage->getImageDesc(); + + EXPECT_EQ(7u, surfaceState->getWidth()); + EXPECT_EQ(imageDesc.image_height, surfaceState->getHeight()); + } + + const auto srcSurfaceState = SurfaceStateAccessor::getSurfaceState(mockCmdQ, 0); + EXPECT_EQ(srcImage->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->getGpuAddress(), srcSurfaceState->getSurfaceBaseAddress()); + + const auto dstSurfaceState = SurfaceStateAccessor::getSurfaceState(mockCmdQ, 1); + EXPECT_EQ(dstImage->getGraphicsAllocation(pClDevice->getRootDeviceIndex())->getGpuAddress(), dstSurfaceState->getSurfaceBaseAddress()); +} diff --git a/shared/source/command_container/command_encoder_from_xe_hpg_core_to_xe3_core.inl b/shared/source/command_container/command_encoder_from_xe_hpg_core_to_xe3_core.inl index f960f4a407..03adc7f79a 100644 --- a/shared/source/command_container/command_encoder_from_xe_hpg_core_to_xe3_core.inl +++ b/shared/source/command_container/command_encoder_from_xe_hpg_core_to_xe3_core.inl @@ -26,6 +26,10 @@ uint32_t EncodeSurfaceState::getPitchForScratchInBytes(R_SURFACE_STATE * return surfaceState->getSurfacePitch(); } +template +void EncodeSurfaceState::convertSurfaceStateToPacked(R_SURFACE_STATE *surfaceState, ImageInfo &imgInfo) { +} + template void EncodeSemaphore::appendSemaphoreCommand(MI_SEMAPHORE_WAIT &cmd, uint64_t compareData, bool indirect, bool useQwordData, bool switchOnUnsuccessful) { constexpr uint64_t upper32b = static_cast(std::numeric_limits::max()) << 32; diff --git a/shared/source/command_container/encode_surface_state.h b/shared/source/command_container/encode_surface_state.h index 1df850a73f..7d24d47d0d 100644 --- a/shared/source/command_container/encode_surface_state.h +++ b/shared/source/command_container/encode_surface_state.h @@ -22,6 +22,7 @@ struct HardwareInfo; struct PipeControlArgs; struct PipelineSelectArgs; struct RootDeviceEnvironment; +struct ImageInfo; union SurfaceStateBufferLength { uint32_t length; @@ -72,6 +73,7 @@ struct EncodeSurfaceState { static void setPitchForScratch(R_SURFACE_STATE *surfaceState, uint32_t pitch, const ProductHelper &productHelper); static uint32_t getPitchForScratchInBytes(R_SURFACE_STATE *surfaceState, const ProductHelper &productHelper); static bool shouldProgramAuxForMcs(bool isAuxCapable, bool hasMcsSurface); + static void convertSurfaceStateToPacked(R_SURFACE_STATE *surfaceState, ImageInfo &imgInfo); }; } // namespace NEO diff --git a/shared/source/gen12lp/command_encoder_gen12lp.cpp b/shared/source/gen12lp/command_encoder_gen12lp.cpp index 19362fa157..82c504ea7e 100644 --- a/shared/source/gen12lp/command_encoder_gen12lp.cpp +++ b/shared/source/gen12lp/command_encoder_gen12lp.cpp @@ -688,6 +688,10 @@ uint32_t EncodeSurfaceState::getPitchForScratchInBytes(R_SURFACE_STATE * return surfaceState->getSurfacePitch(); } +template +void EncodeSurfaceState::convertSurfaceStateToPacked(R_SURFACE_STATE *surfaceState, ImageInfo &imgInfo) { +} + template void EncodeSemaphore::appendSemaphoreCommand(MI_SEMAPHORE_WAIT &cmd, uint64_t compareData, bool indirect, bool useQwordData, bool switchOnUnsuccessful) { constexpr uint64_t upper32b = static_cast(std::numeric_limits::max()) << 32; diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index 25f4f6a4cd..5a524b2161 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -167,6 +167,8 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/definitions/engine_group_types.h ${CMAKE_CURRENT_SOURCE_DIR}/definitions/command_encoder_args.h ${CMAKE_CURRENT_SOURCE_DIR}/definitions/indirect_detection_versions.h + ${CMAKE_CURRENT_SOURCE_DIR}/image_helper.h + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}image_helper.cpp ) if(WIN32) diff --git a/shared/source/helpers/bindless_heaps_helper.h b/shared/source/helpers/bindless_heaps_helper.h index 0590119c77..68df921b93 100644 --- a/shared/source/helpers/bindless_heaps_helper.h +++ b/shared/source/helpers/bindless_heaps_helper.h @@ -29,7 +29,8 @@ constexpr uint32_t image = 0; constexpr uint32_t implicitArgs = 1; constexpr uint32_t sampler = 2; constexpr uint32_t redescribedImage = 3; -constexpr uint32_t max = 4; +constexpr uint32_t packedImage = 4; +constexpr uint32_t max = 5; }; // namespace BindlessImageSlot class BindlessHeapsHelper : NEO::NonCopyableAndNonMovableClass { diff --git a/shared/source/helpers/image_helper.cpp b/shared/source/helpers/image_helper.cpp new file mode 100644 index 0000000000..5a66ecbdae --- /dev/null +++ b/shared/source/helpers/image_helper.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/image_helper.h" + +namespace NEO { + +bool ImageHelper::areImagesCompatibleWithPackedFormat(const ProductHelper &productHelper, const ImageInfo &srcImageInfo, const ImageInfo &dstImageInfo, const GraphicsAllocation *srcAllocation, const GraphicsAllocation *dstAllocation, size_t copyWidth) { + return false; +} + +} // namespace NEO \ No newline at end of file diff --git a/shared/source/helpers/image_helper.h b/shared/source/helpers/image_helper.h new file mode 100644 index 0000000000..bf92832976 --- /dev/null +++ b/shared/source/helpers/image_helper.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include +#include + +namespace NEO { +struct ImageInfo; +class GraphicsAllocation; +class ProductHelper; + +struct ImageHelper { + static bool areImagesCompatibleWithPackedFormat(const ProductHelper &productHelper, const ImageInfo &srcImageInfo, const ImageInfo &dstImageInfo, const GraphicsAllocation *srcAllocation, const GraphicsAllocation *dstAllocation, size_t copyWidth); +}; + +} // namespace NEO \ No newline at end of file diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 2257cb57e7..c6cd1f5841 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -270,6 +270,7 @@ class ProductHelper { virtual bool isExposingSubdevicesAllowed() const = 0; virtual bool useAdditionalBlitProperties() const = 0; virtual bool isNonCoherentTimestampsModeEnabled() const = 0; + virtual bool isPackedCopyFormatSupported() const = 0; virtual bool isPidFdOrSocketForIpcSupported() const = 0; virtual bool getStorageInfoLocalOnlyFlag(LocalMemAllocationMode usmDeviceAllocationMode, bool defaultValue) const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index a0a8cfb076..b739c801c6 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -1085,8 +1085,14 @@ bool ProductHelperHw::useAdditionalBlitProperties() const { return false; } +template +bool ProductHelperHw::isPackedCopyFormatSupported() const { + return false; +} + template bool ProductHelperHw::getStorageInfoLocalOnlyFlag(LocalMemAllocationMode usmDeviceAllocationMode, bool defaultValue) const { return defaultValue; } + } // namespace NEO diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 54c852a63c..03557aa210 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -134,6 +134,7 @@ class ProductHelperHw : public ProductHelper { bool overrideAllocationCpuCacheable(const AllocationData &allocationData) const override; bool is2MBLocalMemAlignmentEnabled() const override; bool isPostImageWriteFlushRequired() const override; + bool isPackedCopyFormatSupported() const override; bool getFrontEndPropertyScratchSizeSupport() const override; bool getFrontEndPropertyPrivateScratchSizeSupport() const override; diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index 19241e4159..dbf690e821 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -1181,6 +1181,10 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenCallingIsResourceUncachedForC } } +HWTEST2_F(ProductHelperTest, givenProductHelperWhenisPackedCopyFormatSupportedThenCorrectValueIsReturned, IsAtMostXe3Core) { + EXPECT_FALSE(productHelper->isPackedCopyFormatSupported()); +} + HWTEST_F(ProductHelperTest, givenProductHelperWhenGettingPreferredWorkgroupCountPerSubsliceThenZeroReturned) { EXPECT_EQ(0u, productHelper->getPreferredWorkgroupCountPerSubslice()); }