mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
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:
committed by
Compute-Runtime-Automation
parent
88c5872682
commit
3051c5ef2b
@@ -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; }
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user