File: cm_device.h

package info (click to toggle)
intel-media-driver 25.2.3%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 151,588 kB
  • sloc: cpp: 1,609,549; ansic: 215,001; asm: 39,161; python: 555; sh: 177; makefile: 16
file content (235 lines) | stat: -rw-r--r-- 11,970 bytes parent folder | download | duplicates (8)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef CMRTLIB_LINUX_HARDWARE_CM_DEVICE_H_
#define CMRTLIB_LINUX_HARDWARE_CM_DEVICE_H_

#include "cm_device_base.h"
#include "cm_def_hw.h"
#include "cm_kernel_debugger.h"
#include <vector>

class CmQueue_RT;
class CmSurfaceManager;

class CmDevice_RT : public CmDevice
{
public:
    static int32_t GetSupportedAdapters(uint32_t& count);
    static int32_t CreateCmDeviceFromAdapter(CmDevice_RT*& pCmDev, int32_t adapterIndex, uint32_t createOption = 0);
    static int32_t GetPlatformInfo(uint32_t adapterIndex);
    static int32_t QueryAdapterInfo(uint32_t adapterIndex, AdapterInfoType infoName, void* info, uint32_t infoSize, uint32_t* outInfoSize);

    static int32_t Create( CmDevice_RT* &device, uint32_t createOption );
    static int32_t Destroy( CmDevice_RT* &device );
    static int32_t Create(VADisplay &vaDisplay, CmDevice_RT* &device,uint32_t createOption );

    CM_RT_API int32_t CreateBuffer(uint32_t size, CmBuffer* &buffer);

    CM_RT_API int32_t CreateSurface2D(uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, CmSurface2D* &surface );
    CM_RT_API int32_t CreateSurface3D(uint32_t width, uint32_t height, uint32_t depth, CM_SURFACE_FORMAT format, CmSurface3D* &surface );

    CM_RT_API int32_t CreateSurface2D( VASurfaceID vaSurface, CmSurface2D* &surface );
    CM_RT_API int32_t CreateSurface2D( VASurfaceID* vaSurfaceArray, const uint32_t surfaceCount, CmSurface2D **surfaceArray);

    CM_RT_API int32_t DestroySurface( CmBuffer* &buffer);
    CM_RT_API int32_t DestroySurface( CmSurface2D* &surface2d);
    CM_RT_API int32_t DestroySurface( CmSurface3D* &surface3d);

    CM_RT_API int32_t CreateQueue( CmQueue* & queue);

    CM_RT_API int32_t LoadProgram( void* commonISACode, const uint32_t size, CmProgram*& program,  const char* options = nullptr );

    CM_RT_API int32_t CreateKernel( CmProgram* program, const char* kernelName, CmKernel* & kernel, const char* options = nullptr);
    CM_RT_API int32_t CreateKernel( CmProgram* program, const char* kernelName, const void * fncPnt, CmKernel* & kernel, const char* options = nullptr) {return CM_FAILURE;}
    CM_RT_API int32_t CreateSampler( const CM_SAMPLER_STATE & sampleState, CmSampler* &sampler );

    CM_RT_API int32_t CreateTask(CmTask *& task);
    CM_RT_API int32_t GetCaps(CM_DEVICE_CAP_NAME capName, size_t& capValueSize, void* capValue );
    CM_RT_API int32_t CreateThreadSpace( uint32_t width, uint32_t height, CmThreadSpace* &threadSpace);

    CM_RT_API int32_t DestroyKernel( CmKernel*& kernel);
    CM_RT_API int32_t DestroySampler( CmSampler*& sampler );
    CM_RT_API int32_t DestroyProgram( CmProgram*& program );
    CM_RT_API int32_t DestroySampler8x8( CmSampler8x8 *& sampler );
    CM_RT_API int32_t DestroyThreadSpace( CmThreadSpace* &threadSpace);
    CM_RT_API int32_t DestroyTask(CmTask *& task);

    CM_RT_API int32_t CreateVmeSurfaceG7_5 (CmSurface2D* currentSurface, CmSurface2D** forwardSurfaceArray, CmSurface2D** backwardSurfaceArray, const uint32_t surfaceCountForward, const uint32_t surfaceCountBackward, SurfaceIndex* & vmeSurfaceIndex );
    CM_RT_API int32_t DestroyVmeSurfaceG7_5(SurfaceIndex* & vmeSurfaceIndex);
    CM_RT_API int32_t SetVmeSurfaceStateParam(SurfaceIndex* vmeSurfaceIndex, CM_VME_SURFACE_STATE_PARAM *newState);

    CM_RT_API int32_t CreateBufferUP(uint32_t size, void *sysMem, CmBufferUP* &buffer);
    CM_RT_API int32_t DestroyBufferUP( CmBufferUP* &buffer);

    CM_RT_API int32_t GetSurface2DInfo(uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, uint32_t & pitch, uint32_t & physicalSize );
    CM_RT_API int32_t CreateSurface2DUP( uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, void* sysMem, CmSurface2DUP* &surface );
    CM_RT_API int32_t DestroySurface2DUP( CmSurface2DUP* &surface) ;

    CM_RT_API int32_t CreateSampler8x8(const CM_SAMPLER_8X8_DESCR  &samplerDescriptor, CmSampler8x8* &sampler);
    CM_RT_API int32_t CreateSampler8x8Surface(CmSurface2D* surface2d, SurfaceIndex* &sampler8x8SurfaceIndex, CM_SAMPLER8x8_SURFACE surfaceType, CM_SURFACE_ADDRESS_CONTROL_MODE addressControl = CM_SURFACE_CLAMP);
    CM_RT_API int32_t DestroySampler8x8Surface(SurfaceIndex* &sampler8x8SurfaceIndex);

    CM_RT_API int32_t CreateThreadGroupSpace( uint32_t threadSpaceWidth, uint32_t threadSpaceHeight, uint32_t groupSpaceWidth, uint32_t groupSpaceHeight, CmThreadGroupSpace* &threadGroupSpace);
    CM_RT_API int32_t DestroyThreadGroupSpace(CmThreadGroupSpace* &threadGroupSpace);

    CM_RT_API int32_t SetL3Config(const L3ConfigRegisterValues *registerValues);
    CM_RT_API int32_t SetSuggestedL3Config( L3_SUGGEST_CONFIG configIndex);

    CM_RT_API int32_t SetCaps(CM_DEVICE_CAP_NAME capName, size_t capValueSize, void* capValue );

    CM_RT_API int32_t CreateSamplerSurface2D(CmSurface2D* surface2d, SurfaceIndex* & samplerSurface2dIndex);
    CM_RT_API int32_t CreateSamplerSurface3D(CmSurface3D* surface3d, SurfaceIndex* & samplerSurface3dIndex);
    CM_RT_API int32_t DestroySamplerSurface(SurfaceIndex* & samplerSurfaceIndex);

    CM_RT_API int32_t InitPrintBuffer(size_t size = CM_DEFAULT_PRINT_BUFFER_SIZE);

    CM_RT_API int32_t FlushPrintBuffer();

    CM_RT_API int32_t CreateVebox( CmVebox* & vebox );
    CM_RT_API int32_t DestroyVebox(CmVebox* & vebox);

    CM_RT_API int32_t CreateBufferSVM(uint32_t size, void* & sysMem, uint32_t accessFlag, CmBufferSVM* &buffer );
    CM_RT_API int32_t DestroyBufferSVM( CmBufferSVM* & buffer);

    CM_RT_API int32_t CloneKernel( CmKernel * &destKernel, CmKernel *srcKernel );

    CM_RT_API int32_t GetVaDpy(VADisplay* &vaDisplay);
    CM_RT_API int32_t CreateVaSurface2D( uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, VASurfaceID & vaSurface, CmSurface2D* & surface);

    CM_RT_API int32_t CreateSamplerSurface2DUP(CmSurface2DUP* surface2dUP, SurfaceIndex* & samplerSurface2dUPIndex);

    CM_RT_API int32_t CreateSurface2DAlias(CmSurface2D* originalSurface, SurfaceIndex* &aliasIndex);

    CM_RT_API int32_t CreateHevcVmeSurfaceG10(CmSurface2D* currentSurface, CmSurface2D** forwardSurfaceArray, CmSurface2D** backwardSurfaceArray, const uint32_t surfaceCountForward, const uint32_t surfaceCountBackward, SurfaceIndex* & vmeSurfaceIndex);
    CM_RT_API int32_t DestroyHevcVmeSurfaceG10(SurfaceIndex* & vmeSurfaceIndex);
    CM_RT_API int32_t CreateSamplerEx( const CM_SAMPLER_STATE_EX & samplerState, CmSampler* & sampler ) ;

    CM_RT_API int32_t FlushPrintBufferIntoFile(const char *filename);
    CM_RT_API int32_t CreateThreadGroupSpaceEx(uint32_t threadSpaceWidth, uint32_t threadSpaceHeight, uint32_t threadSpaceDepth, uint32_t groupSpaceWidth, uint32_t groupSpaceHeight, uint32_t groupSpaceDepth, CmThreadGroupSpace* &threadGroupSpace);
    CM_RT_API int32_t CreateSampler8x8SurfaceEx(CmSurface2D* surface2d, SurfaceIndex* &sampler8x8SurfaceIndex, CM_SAMPLER8x8_SURFACE surfaceType, CM_SURFACE_ADDRESS_CONTROL_MODE addressControl = CM_SURFACE_CLAMP, CM_FLAG* flag = nullptr);
    CM_RT_API int32_t CreateSamplerSurface2DEx(CmSurface2D* surface2d, SurfaceIndex* & samplerSurface2dIndex, CM_FLAG* flag);
    CM_RT_API int32_t CreateBufferAlias(CmBuffer *originalBuffer, SurfaceIndex* &aliasIndex);

    CM_RT_API int32_t GetVISAVersion(uint32_t& majorVersion, uint32_t& minorVersion);
    CM_RT_API int32_t CreateQueueEx(CmQueue *&queue, CM_QUEUE_CREATE_OPTION queueCreateOption = CM_DEFAULT_QUEUE_CREATE_OPTION);

    CM_RT_API int32_t CreateBufferStateless(size_t size,
                                            uint32_t option,
                                            void *sysMem,
                                            CmBufferStateless *&pBufferStateless);
    CM_RT_API int32_t DestroyBufferStateless(CmBufferStateless *&buffer);

    CM_RT_API int32_t DispatchTask() { return CM_SUCCESS; }

    CM_RT_API int32_t CreateSurface2DStateless(uint32_t width,
                                               uint32_t height,
                                               uint32_t &pitch,
                                               CmSurface2DStateless *&pSurface);

    CM_RT_API int32_t DestroySurface2DStateless(CmSurface2DStateless *&pSurface);

    int32_t CheckDdiVersionSupported(const uint32_t ddiVersion);

    int32_t OSALExtensionExecute(uint32_t functionId,
                                 void *inputData,
                                 uint32_t inputDataLength,
                                 void **resourceList = nullptr,
                                 uint32_t resourceCount = 0);

protected:
    CmDevice_RT(
        VADisplay vaDisplay,
        uint32_t createOption
    );

    ~CmDevice_RT( void );

    int32_t SetCapsInternal(CM_DEVICE_CAP_NAME capName, size_t capValueSize, void* capValue);

    int32_t CreateProgram(void* commonISACode,
                          const uint32_t size,
                          CmProgram*& program,
                          const char* options );

    int32_t CreateDeviceInUmd();

    int32_t FlushPrintBufferInternal(const char *filename);

    CmSurfaceManager *         m_surfaceManager;

    uint32_t m_cmVersion;
    void    *m_deviceInUmd;    //CmDevice pointer in UMD
    bool    m_cmCreated;

    int32_t Initialize(bool isCmCreated, uint32_t Index = 0);
    int32_t FreeResources();
#if USE_EXTENSION_CODE
    int32_t EnableGtpin( void );
    int32_t RegisterGtpinMarkerFunctions();
#endif
    int32_t CreateVmeSurface( CmSurface2D* currentSurface, CmSurface2D** forwardSurfaceArray, CmSurface2D** backwardSurfaceArray, const uint32_t surfaceCountForward, const uint32_t surfaceCountBackward, SurfaceIndex* & vmeSurfaceIndex, CM_FUNCTION_ID functionName);
    int32_t DestroyVmeSurface( SurfaceIndex* & vmeSurfaceIndex );

#ifndef ANDROID
    int32_t FreeLibvaDrm();
    int32_t GetLibvaDisplayDrm(VADisplay & vaDisplay);
#endif

    int32_t InitializeLibvaDisplay(uint32_t Index = 0);
    VADisplay m_vaDisplay;
    uint32_t m_drmIndex;
    pvaCmExtSendReqMsg    m_fvaCmExtSendReqMsg;

#if !defined(ANDROID)
    static uint32_t m_vaReferenceCount;
    static CSync m_vaReferenceCountCriticalSection;
    int32_t m_driFileDescriptor;
    static void  *m_vaDrm;
    static pfVAGetDisplayDRM m_vaGetDisplayDrm;
#else
    Display*  m_display;
#endif

    L3ConfigRegisterValues m_l3Config;

    // Variables used in GTPIN
    bool            m_gtpinEnabled;
    CmBufferUP*     m_gtpinBufferUP0;
    CmBufferUP*     m_gtpinBufferUP1;
    CmBufferUP*     m_gtpinBufferUP2;

    uint32_t       m_createOption;
    uint32_t       m_driverStoreEnabled;

    // Kernel debugger
    CmKernelDebugger *m_kernelDebugger;

    // Queue list and Queue critical section
    CSync          m_criticalSectionQueue;
    std::vector<CmQueue_RT *> m_queue;

private:
    CmDevice_RT(const CmDevice_RT &other);
    CmDevice_RT &operator=(const CmDevice_RT &other);
};

#endif  // #ifndef CMRTLIB_LINUX_HARDWARE_CM_DEVICE_H_