Files
compute-runtime/level_zero/core/source/image/image.h
Mateusz Jablonski 14fd9f3f24 fix: correct using L0 loader functions
use zelLoaderTranslateHandle for translating handle to internal handle
get pointer to zelSetDriverTeardown during global ctor
don't load loader library by name
get loader function pointers directly from current process

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
2024-09-04 17:30:25 +02:00

76 lines
2.6 KiB
C++

/*
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "level_zero/core/source/helpers/api_handle_helper.h"
#include <level_zero/ze_api.h>
struct _ze_image_handle_t {
const uint64_t objMagic = objMagicValue;
static const zel_handle_type_t handleType = ZEL_HANDLE_IMAGE;
};
namespace NEO {
struct ImageInfo;
class GraphicsAllocation;
struct ImageDescriptor;
struct SurfaceStateInHeapInfo;
} // namespace NEO
namespace L0 {
struct Device;
struct Image : _ze_image_handle_t {
template <typename Type>
struct Allocator {
static Image *allocate() { return new Type(); }
};
virtual ~Image() = default;
virtual ze_result_t destroy() = 0;
virtual ze_result_t destroyPeerImages(const void *ptr, Device *device) = 0;
static ze_result_t create(uint32_t productFamily, Device *device, const ze_image_desc_t *desc, Image **pImage);
virtual ze_result_t createView(Device *device, const ze_image_desc_t *desc, ze_image_handle_t *pImage) = 0;
virtual NEO::GraphicsAllocation *getAllocation() = 0;
virtual NEO::GraphicsAllocation *getImplicitArgsAllocation() = 0;
virtual void copySurfaceStateToSSH(void *surfaceStateHeap,
const uint32_t surfaceStateOffset,
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;
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; }
};
using ImageAllocatorFn = Image *(*)();
extern ImageAllocatorFn imageFactory[];
template <uint32_t productFamily, typename ImageType>
struct ImagePopulateFactory {
ImagePopulateFactory() { imageFactory[productFamily] = Image::Allocator<ImageType>::allocate; }
};
} // namespace L0