File: image.h

package info (click to toggle)
intel-compute-runtime 25.44.36015.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 79,632 kB
  • sloc: cpp: 931,547; lisp: 2,074; sh: 719; makefile: 162; python: 21
file content (72 lines) | stat: -rw-r--r-- 2,471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright (C) 2020-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once

#include "level_zero/core/source/helpers/api_handle_helper.h"

struct _ze_image_handle_t : BaseHandleWithLoaderTranslation<ZEL_HANDLE_IMAGE> {};
static_assert(IsCompliantWithDdiHandlesExt<_ze_image_handle_t>);

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,
                                       uint32_t surfaceStateOffset,
                                       uint32_t bindlessSlot,
                                       bool isMediaBlockArg) = 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;
    virtual bool isMimickedImage() = 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