mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
feature: bindless addressing support for image views
Related-To: NEO-7063 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7f085af8a3
commit
fb211a921d
@@ -15,6 +15,7 @@ namespace NEO {
|
||||
struct ImageInfo;
|
||||
class GraphicsAllocation;
|
||||
struct ImageDescriptor;
|
||||
struct SurfaceStateInHeapInfo;
|
||||
} // namespace NEO
|
||||
|
||||
namespace L0 {
|
||||
@@ -42,6 +43,8 @@ struct Image : _ze_image_handle_t {
|
||||
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;
|
||||
virtual ze_result_t allocateBindlessSlot() = 0;
|
||||
virtual NEO::SurfaceStateInHeapInfo *getBindlessSlot() = 0;
|
||||
|
||||
static Image *fromHandle(ze_image_handle_t handle) { return static_cast<Image *>(handle); }
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#include "level_zero/core/source/image/image_imp.h"
|
||||
|
||||
#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/helpers/bindless_heaps_helper.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
|
||||
@@ -22,6 +26,11 @@ namespace L0 {
|
||||
ImageAllocatorFn imageFactory[IGFX_MAX_PRODUCT] = {};
|
||||
|
||||
ImageImp::~ImageImp() {
|
||||
if (isImageView() && this->device != nullptr && this->allocation) {
|
||||
if (bindlessInfo.get() && this->device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[this->allocation->getRootDeviceIndex()]->getBindlessHeapsHelper() != nullptr) {
|
||||
this->device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[this->allocation->getRootDeviceIndex()]->getBindlessHeapsHelper()->releaseSSToReusePool(*bindlessInfo);
|
||||
}
|
||||
}
|
||||
if (!isImageView() && this->device != nullptr) {
|
||||
this->device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(this->allocation);
|
||||
}
|
||||
@@ -77,6 +86,36 @@ ze_result_t ImageImp::createView(Device *device, const ze_image_desc_t *desc, ze
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t ImageImp::allocateBindlessSlot() {
|
||||
if (!isImageView()) {
|
||||
if (!this->device->getNEODevice()->getMemoryManager()->allocateBindlessSlot(allocation)) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
if (allocation->getBindlessOffset() != std::numeric_limits<uint64_t>::max()) {
|
||||
bindlessInfo = std::make_unique<NEO::SurfaceStateInHeapInfo>(allocation->getBindlessInfo());
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
auto bindlessHelper = this->device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[allocation->getRootDeviceIndex()]->getBindlessHeapsHelper();
|
||||
|
||||
if (bindlessHelper && !bindlessInfo) {
|
||||
auto &gfxCoreHelper = this->device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[allocation->getRootDeviceIndex()]->getHelper<NEO::GfxCoreHelper>();
|
||||
const auto surfStateCount = 2;
|
||||
auto surfaceStateSize = surfStateCount * gfxCoreHelper.getRenderSurfaceStateSize();
|
||||
|
||||
auto surfaceStateInfo = bindlessHelper->allocateSSInHeap(surfaceStateSize, allocation, NEO::BindlessHeapsHelper::GLOBAL_SSH);
|
||||
if (surfaceStateInfo.heapAllocation == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
bindlessInfo = std::make_unique<NEO::SurfaceStateInHeapInfo>(surfaceStateInfo);
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
NEO::SurfaceStateInHeapInfo *ImageImp::getBindlessSlot() {
|
||||
return bindlessInfo.get();
|
||||
}
|
||||
|
||||
ze_result_t Image::create(uint32_t productFamily, Device *device, const ze_image_desc_t *desc, Image **pImage) {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
ImageAllocatorFn allocator = nullptr;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "level_zero/core/source/image/image.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace L0 {
|
||||
@@ -43,11 +44,15 @@ struct ImageImp : public Image {
|
||||
return sourceImageFormatDesc.has_value();
|
||||
}
|
||||
|
||||
ze_result_t allocateBindlessSlot() override;
|
||||
NEO::SurfaceStateInHeapInfo *getBindlessSlot() override;
|
||||
|
||||
protected:
|
||||
Device *device = nullptr;
|
||||
NEO::ImageInfo imgInfo = {};
|
||||
NEO::GraphicsAllocation *allocation = nullptr;
|
||||
ze_image_desc_t imageFormatDesc = {};
|
||||
std::optional<ze_image_desc_t> sourceImageFormatDesc = {};
|
||||
std::unique_ptr<NEO::SurfaceStateInHeapInfo> bindlessInfo;
|
||||
};
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user