feature: bindless image extension

- support for zeMemGetPitchFor2dImage() and
zeImageGetDeviceOffsetExp()

Related-To: NEO-10352

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2024-02-14 11:07:01 +00:00
committed by Compute-Runtime-Automation
parent 88c5872682
commit 3051c5ef2b
14 changed files with 297 additions and 13 deletions

View File

@@ -191,13 +191,13 @@ ze_result_t ZE_APICALL zeMemGetPitchFor2dImage(
size_t imageHeight,
unsigned int elementSizeInBytes,
size_t *rowPitch) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
return L0::Context::fromHandle(hContext)->getPitchFor2dImage(hDevice, imageWidth, imageHeight, elementSizeInBytes, rowPitch);
}
ze_result_t ZE_APICALL zeImageGetDeviceOffsetExp(
ze_image_handle_t hImage,
uint64_t *pDeviceOffset) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
return L0::Image::fromHandle(hImage)->getDeviceOffset(pDeviceOffset);
}
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -166,6 +166,13 @@ struct Context : _ze_context_handle_t {
virtual bool isShareableMemory(const void *exportDesc, bool exportableMemory, NEO::Device *neoDevice) = 0;
virtual void *getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, NEO::AllocationType allocationType, ze_ipc_memory_flags_t flags) = 0;
virtual ze_result_t getPitchFor2dImage(
ze_device_handle_t hDevice,
size_t imageWidth,
size_t imageHeight,
unsigned int elementSizeInBytes,
size_t *rowPitch) = 0;
static Context *fromHandle(ze_context_handle_t handle) { return static_cast<Context *>(handle); }
inline ze_context_handle_t toHandle() { return this; }
};

View File

@@ -1308,4 +1308,14 @@ bool ContextImp::isAllocationSuitableForCompression(const StructuresLookupTable
return structuresLookupTable.compressedHint;
}
ze_result_t ContextImp::getPitchFor2dImage(
ze_device_handle_t hDevice,
size_t imageWidth,
size_t imageHeight,
unsigned int elementSizeInBytes,
size_t *rowPitch) {
return Image::getPitchFor2dImage(hDevice, imageWidth, imageHeight, elementSizeInBytes, rowPitch);
}
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -175,6 +175,13 @@ struct ContextImp : Context {
NEO::VirtualMemoryReservation *findSupportedVirtualReservation(const void *ptr, size_t size);
ze_result_t checkMemSizeLimit(Device *inDevice, size_t size, bool relaxedSizeAllowed, void **ptr);
ze_result_t getPitchFor2dImage(
ze_device_handle_t hDevice,
size_t imageWidth,
size_t imageHeight,
unsigned int elementSizeInBytes,
size_t *rowPitch) override;
protected:
ze_result_t getIpcMemHandlesImpl(const void *ptr, uint32_t *numIpcHandles, ze_ipc_mem_handle_t *pIpcHandles);
void setIPCHandleData(NEO::GraphicsAllocation *graphicsAllocation, uint64_t handle, IpcMemoryData &ipcData, uint64_t ptrAddress, uint8_t type);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Intel Corporation
* Copyright (C) 2021-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -9,6 +9,7 @@
#include "shared/source/helpers/surface_format_info.h"
#include "level_zero/api/driver_experimental/public/ze_bindless_image_exp.h"
#include <level_zero/ze_api.h>
#include <cstdint>
@@ -71,6 +72,7 @@ struct StructuresLookupTable {
bool compressedHint;
bool uncompressedHint;
bool rayTracingMemory;
bool bindlessImage;
};
inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupTable, const void *desc) {
@@ -112,6 +114,11 @@ inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupT
lookupTable.areImageProperties = true;
lookupTable.imageProperties.isPlanarExtension = true;
lookupTable.imageProperties.planeIndex = imageViewDesc->planeIndex;
} else if (extendedDesc->stype == ZE_STRUCTURE_TYPE_BINDLESS_IMAGE_EXP_DESC) {
const ze_image_bindless_exp_desc_t *imageBindlessDesc =
reinterpret_cast<const ze_image_bindless_exp_desc_t *>(extendedDesc);
lookupTable.bindlessImage = imageBindlessDesc->flags & ZE_IMAGE_BINDLESS_EXP_FLAG_BINDLESS;
} else if (extendedDesc->stype == ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC) {
const ze_relaxed_allocation_limits_exp_desc_t *relaxedLimitsDesc =
reinterpret_cast<const ze_relaxed_allocation_limits_exp_desc_t *>(extendedDesc);

View File

@@ -47,7 +47,14 @@ struct Image : _ze_image_handle_t {
virtual ze_result_t getMemoryProperties(ze_image_memory_properties_exp_t *pMemoryProperties) = 0;
virtual ze_result_t allocateBindlessSlot() = 0;
virtual NEO::SurfaceStateInHeapInfo *getBindlessSlot() = 0;
virtual ze_result_t getDeviceOffset(uint64_t *deviceOffset) = 0;
static ze_result_t getPitchFor2dImage(
ze_device_handle_t hDevice,
size_t imageWidth,
size_t imageHeight,
unsigned int elementSizeInByte,
size_t *rowPitch);
static Image *fromHandle(ze_image_handle_t handle) { return static_cast<Image *>(handle); }
inline ze_image_handle_t toHandle() { return this; }

View File

@@ -18,6 +18,7 @@ template <GFXCORE_FAMILY gfxCoreFamily>
struct ImageCoreFamily : public ImageImp {
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
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;

View File

@@ -36,8 +36,6 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
const auto &rootDeviceEnvironment = device->getNEODevice()->getRootDeviceEnvironment();
const bool isBindlessMode = rootDeviceEnvironment.getReleaseHelper() ? NEO::ApiSpecificConfig::getBindlessMode(rootDeviceEnvironment.getReleaseHelper()) : false;
StructuresLookupTable lookupTable = {};
lookupTable.areImageProperties = true;
@@ -84,6 +82,11 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
imgInfo.plane = lookupTable.imageProperties.isPlanarExtension ? static_cast<GMM_YUV_PLANE>(lookupTable.imageProperties.planeIndex + 1u) : GMM_NO_PLANE;
imgInfo.useLocalMemory = false;
if (lookupTable.bindlessImage && this->device->getNEODevice()->getBindlessHeapsHelper() == nullptr) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
this->bindlessImage = lookupTable.bindlessImage;
if (!isImageView()) {
if (lookupTable.isSharedHandle) {
if (!lookupTable.sharedHandleType.isSupportedHandle) {
@@ -113,7 +116,11 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
}
}
if (isBindlessMode) {
if (this->bindlessImage) {
auto result = allocateBindlessSlot();
if (result != ZE_RESULT_SUCCESS) {
return result;
}
NEO::AllocationProperties imgImplicitArgsAllocProperties(device->getRootDeviceIndex(), NEO::ImageImplicitArgs::getSize(), NEO::AllocationType::buffer, device->getNEODevice()->getDeviceBitfield());
implicitArgsAllocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(imgImplicitArgsAllocProperties);
}
@@ -172,7 +179,7 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
}
}
if (isBindlessMode && implicitArgsAllocation) {
if (this->bindlessImage && implicitArgsAllocation) {
implicitArgsSurfaceState = GfxFamily::cmdInitRenderSurfaceState;
auto clChannelType = getClChannelDataType(imageFormatDesc.format);

View File

@@ -10,6 +10,8 @@
#include "shared/source/device/device.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/gmm.h"
#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/hw_info.h"
@@ -18,6 +20,7 @@
#include "level_zero/core/source/device/device.h"
#include "level_zero/core/source/device/device_imp.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/core/source/image/image_formats.h"
#include "igfxfmid.h"
@@ -143,4 +146,55 @@ ze_result_t Image::create(uint32_t productFamily, Device *device, const ze_image
return result;
}
ze_result_t Image::getPitchFor2dImage(
ze_device_handle_t hDevice,
size_t imageWidth,
size_t imageHeight,
unsigned int elementSizeInByte,
size_t *rowPitch) {
NEO::StorageInfo storageInfo = {};
NEO::GmmRequirements gmmRequirements{};
gmmRequirements.allowLargePages = true;
NEO::ImageInfo imgInfo = {};
imgInfo.imgDesc.imageType = NEO::ImageType::image2D;
imgInfo.imgDesc.imageWidth = imageWidth;
imgInfo.imgDesc.imageHeight = imageHeight;
imgInfo.linearStorage = true;
const uint32_t exponent = Math::log2(elementSizeInByte);
if (exponent >= 5u) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
imgInfo.surfaceFormat = &ImageFormats::surfaceFormatsForRedescribe[exponent % 5];
DeviceImp *deviceImp = static_cast<DeviceImp *>(Device::fromHandle(hDevice));
NEO::Gmm gmm(deviceImp->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[deviceImp->getRootDeviceIndex()]->getGmmHelper(),
imgInfo,
storageInfo,
false);
*rowPitch = imgInfo.rowPitch;
return ZE_RESULT_SUCCESS;
}
ze_result_t ImageImp::getDeviceOffset(uint64_t *deviceOffset) {
if (!this->bindlessImage) {
return ZE_RESULT_ERROR_NOT_AVAILABLE;
}
auto result = allocateBindlessSlot();
if (result == ZE_RESULT_SUCCESS) {
DEBUG_BREAK_IF(this->getBindlessSlot() == nullptr);
*deviceOffset = this->getBindlessSlot()->surfaceStateOffset;
}
return result;
}
} // namespace L0

View File

@@ -48,6 +48,7 @@ struct ImageImp : public Image, NEO::NonCopyableOrMovableClass {
ze_result_t allocateBindlessSlot() override;
NEO::SurfaceStateInHeapInfo *getBindlessSlot() override;
ze_result_t getDeviceOffset(uint64_t *deviceOffset) override;
protected:
Device *device = nullptr;
@@ -57,5 +58,6 @@ struct ImageImp : public Image, NEO::NonCopyableOrMovableClass {
ze_image_desc_t imageFormatDesc = {};
std::optional<ze_image_desc_t> sourceImageFormatDesc = {};
std::unique_ptr<NEO::SurfaceStateInHeapInfo> bindlessInfo;
bool bindlessImage = false;
};
} // namespace L0

View File

@@ -98,6 +98,7 @@ void testAppendImageFunction(ze_context_handle_t &context,
gpuDepth,
0,
0};
ze_image_handle_t dstImg;
ze_image_region_t dstRegion = {outOffsetX, outOffsetY, outOffsetZ, hostWidth, hostHeight, hostDepth};

View File

@@ -10,6 +10,7 @@
#include "shared/source/helpers/blit_properties.h"
#include "shared/source/memory_manager/gfx_partition.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/test/common/mocks/mock_bindless_heaps_helper.h"
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_compilers.h"
#include "shared/test/common/mocks/mock_cpu_page_fault_manager.h"
@@ -1953,7 +1954,7 @@ HWTEST2_F(ContextTest, givenBindlessModeDisabledWhenMakeImageResidentAndEvictThe
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
}
HWTEST2_F(ContextTest, givenBindlessModeEnabledWhenMakeImageResidentAndEvictThenImageImplicitArgsAllocationIsMadeResidentAndEvicted, IsAtLeastSkl) {
HWTEST2_F(ContextTest, givenBindlessImageWhenMakeImageResidentAndEvictThenImageImplicitArgsAllocationIsMadeResidentAndEvicted, IsAtLeastSkl) {
if (!device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper() ||
!device->getNEODevice()->getDeviceInfo().imageSupport) {
GTEST_SKIP();
@@ -1970,12 +1971,23 @@ HWTEST2_F(ContextTest, givenBindlessModeEnabledWhenMakeImageResidentAndEvictThen
auto mockMemoryOperationsInterface = new NEO::MockMemoryOperations();
mockMemoryOperationsInterface->captureGfxAllocationsForMakeResident = true;
device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[0]->memoryOperationsInterface.reset(mockMemoryOperationsInterface);
auto bindlessHelper = new MockBindlesHeapsHelper(device->getNEODevice()->getMemoryManager(),
device->getNEODevice()->getNumGenericSubDevices() > 1,
device->getNEODevice()->getRootDeviceIndex(),
device->getNEODevice()->getDeviceBitfield());
device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getNEODevice()->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHelper);
ContextImp *contextImp = static_cast<ContextImp *>(L0::Context::fromHandle(hContext));
ze_image_handle_t image = {};
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 imageDesc = {};
imageDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
imageDesc.pNext = &bindlessExtDesc;
res = contextImp->createImage(device, &imageDesc, &image);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);

View File

@@ -9,12 +9,15 @@
#include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/surface_format_info.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "shared/source/memory_manager/memory_allocation.h"
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/mocks/mock_bindless_heaps_helper.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_gmm_client_context.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/mocks/mock_sip.h"
#include "shared/test/common/test_macros/hw_test.h"
@@ -140,17 +143,26 @@ HWTEST2_F(ImageCreate, givenDifferentSwizzleFormatWhenImageInitializeThenCorrect
RENDER_SURFACE_STATE::SHADER_CHANNEL_SELECT_ZERO);
}
HWTEST2_F(ImageCreate, givenBindlessModeWhenImageInitializeThenImageImplicitArgsAreCorrectlyStoredInNewSeparateAllocation, IsAtLeastSkl) {
HWTEST2_F(ImageCreate, givenBindlessImageWhenImageInitializeThenImageImplicitArgsAreCorrectlyStoredInNewSeparateAllocation, IsAtLeastSkl) {
if (!device->getNEODevice()->getRootDeviceEnvironment().getReleaseHelper()) {
GTEST_SKIP();
}
DebugManagerStateRestore restore;
NEO::debugManager.flags.UseBindlessMode.set(1);
auto bindlessHelper = new MockBindlesHeapsHelper(neoDevice->getMemoryManager(),
neoDevice->getNumGenericSubDevices() > 1,
neoDevice->getRootDeviceIndex(),
neoDevice->getDeviceBitfield());
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHelper);
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
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 desc = {};
desc.pNext = &bindlessExtDesc;
desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
desc.type = ZE_IMAGE_TYPE_3D;
@@ -1529,5 +1541,146 @@ HWTEST2_F(ImageCreate, WhenImageViewCreateExtThenSuccessIsReturned, IsAtLeastSkl
zeImageDestroy(planeY);
}
HWTEST2_F(ImageCreate, GivenNonBindlessImageWhenGettingDeviceOffsetThenErrorIsReturned, IsAtLeastSkl) {
const size_t width = 32;
const size_t height = 32;
const size_t depth = 1;
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(nullptr);
ze_image_desc_t srcImgDesc = {ZE_STRUCTURE_TYPE_IMAGE_DESC,
nullptr,
ZE_IMAGE_FLAG_KERNEL_WRITE,
ZE_IMAGE_TYPE_2D,
{ZE_IMAGE_FORMAT_LAYOUT_NV12, 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<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
auto ret = imageHW->initialize(device, &srcImgDesc);
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
EXPECT_EQ(nullptr, imageHW->getBindlessSlot());
uint64_t deviceOffset = 0;
ret = imageHW->getDeviceOffset(&deviceOffset);
ASSERT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, ret);
}
HWTEST2_F(ImageCreate, GivenNoBindlessHelperAndBindlessImageFlagWhenCreatingImageThenErrorIsReturned, IsAtLeastSkl) {
const size_t width = 32;
const size_t height = 32;
const size_t depth = 1;
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_NV12, 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<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
auto ret = imageHW->initialize(device, &srcImgDesc);
ASSERT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, ret);
}
HWTEST2_F(ImageCreate, GivenBindlessImageWhenGettingDeviceOffsetThenBindlessSlotIsReturned, 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_NV12, 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<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
auto ret = imageHW->initialize(device, &srcImgDesc);
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
EXPECT_NE(nullptr, imageHW->getBindlessSlot());
uint64_t deviceOffset = 0;
ret = imageHW->getDeviceOffset(&deviceOffset);
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
auto ssHeapInfo = imageHW->getBindlessSlot();
ASSERT_NE(nullptr, ssHeapInfo);
EXPECT_EQ(ssHeapInfo->surfaceStateOffset, deviceOffset);
}
HWTEST2_F(ImageCreate, GivenBindlessImageWhenBindlessSlotAllocationFailsThenImageInitializationFails, 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_NV12, 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};
bindlessHelper->failAllocateSS = true;
bindlessHelper->globalSsh->getSpace(bindlessHelper->globalSsh->getAvailableSpace());
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
auto ret = imageHW->initialize(device, &srcImgDesc);
ASSERT_EQ(ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY, ret);
}
} // namespace ult
} // namespace L0

View File

@@ -1593,6 +1593,22 @@ TEST_F(MemoryTest, givenProductWithNon48bForRTWhenAllocatingDeviceMemoryAsRayTra
std::swap(rootDeviceEnvironment.productHelper, productHelper);
}
TEST_F(MemoryTest, givenContextWhenGettingPitchFor2dImageThenCorrectRowPitchIsReturned) {
size_t rowPitch = 0;
ze_result_t result = context->getPitchFor2dImage(device->toHandle(),
4, 4,
4, &rowPitch);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(0u, rowPitch);
rowPitch = 0;
result = context->getPitchFor2dImage(device->toHandle(),
4, 4,
1024, &rowPitch);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result);
EXPECT_EQ(0u, rowPitch);
}
struct SVMAllocsManagerSharedAllocZexPointerMock : public NEO::SVMAllocsManager {
SVMAllocsManagerSharedAllocZexPointerMock(MemoryManager *memoryManager) : NEO::SVMAllocsManager(memoryManager, false) {}
void *createHostUnifiedMemoryAllocation(size_t size,