From 798c068ed15b012fc6b239eb7c8ce5d89171de5a Mon Sep 17 00:00:00 2001 From: "He, Wenju" Date: Mon, 26 Feb 2024 12:23:46 +0000 Subject: [PATCH] feature: copy surface state to ssh in bindless image initialization The surface state needs to be copied to global ssh either during image initialization for sycl bindless image that could be passed to kernel through memory. Privously the copy is done in KernelImp::setArgImage. However, the function won't be called for sycl bindless image. Related-To: NEO-10352 Signed-off-by: He, Wenju --- level_zero/core/source/image/image_hw.inl | 5 ++ .../unit_tests/sources/image/test_image.cpp | 46 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/level_zero/core/source/image/image_hw.inl b/level_zero/core/source/image/image_hw.inl index f9f2140d1d..650a78cfa1 100644 --- a/level_zero/core/source/image/image_hw.inl +++ b/level_zero/core/source/image/image_hw.inl @@ -212,6 +212,11 @@ ze_result_t ImageCoreFamily::initialize(Device *device, const ze_ } } + if (this->bindlessImage) { + auto ssInHeap = getBindlessSlot(); + copySurfaceStateToSSH(ssInHeap->ssPtr, 0u, false); + } + if (this->bindlessImage && implicitArgsAllocation) { implicitArgsSurfaceState = GfxFamily::cmdInitRenderSurfaceState; 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 a9d1169cbf..86fba35eca 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 @@ -1839,5 +1839,51 @@ HWTEST2_F(ImageCreate, GivenBindlessImageWhenImageViewCreatedWithDeviceUMSPitche ret = context->freeMem(ptr); } +HWTEST2_F(ImageCreate, GivenBindlessImageWhenInitializedThenSurfaceStateCopiedToSSH, IsAtLeastSkl) { + const size_t width = 32; + const size_t height = 32; + const size_t depth = 1; + + auto bindlessHelper = new MockBindlesHeapsHelper(neoDevice->getMemoryManager(), + neoDevice->getNumGenericSubDevices() > 1, + neoDevice->getRootDeviceIndex(), + neoDevice->getDeviceBitfield()); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHelper); + + ze_image_bindless_exp_desc_t bindlessExtDesc = {}; + bindlessExtDesc.stype = ZE_STRUCTURE_TYPE_BINDLESS_IMAGE_EXP_DESC; + bindlessExtDesc.pNext = nullptr; + bindlessExtDesc.flags = ZE_IMAGE_BINDLESS_EXP_FLAG_BINDLESS; + + ze_image_desc_t srcImgDesc = {ZE_STRUCTURE_TYPE_IMAGE_DESC, + &bindlessExtDesc, + ZE_IMAGE_FLAG_KERNEL_WRITE, + ZE_IMAGE_TYPE_2D, + {ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8, ZE_IMAGE_FORMAT_TYPE_UINT, + ZE_IMAGE_FORMAT_SWIZZLE_R, ZE_IMAGE_FORMAT_SWIZZLE_G, + ZE_IMAGE_FORMAT_SWIZZLE_B, ZE_IMAGE_FORMAT_SWIZZLE_A}, + width, + height, + depth, + 0, + 0}; + + auto imageHW = std::make_unique>>(); + auto ret = imageHW->initialize(device, &srcImgDesc); + ASSERT_EQ(ZE_RESULT_SUCCESS, ret); + + auto ssHeapInfo = imageHW->getBindlessSlot(); + ASSERT_NE(nullptr, ssHeapInfo); + + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + auto *surfaceState = static_cast(ssHeapInfo->ssPtr); + ASSERT_EQ(surfaceState->getSurfaceType(), RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_2D); + ASSERT_EQ(surfaceState->getSurfaceFormat(), + RENDER_SURFACE_STATE::SURFACE_FORMAT_R8G8B8A8_UINT); + ASSERT_EQ(surfaceState->getWidth(), width); + ASSERT_EQ(surfaceState->getHeight(), height); + ASSERT_EQ(surfaceState->getDepth(), depth); +} + } // namespace ult } // namespace L0