1 /*
2 * Copyright � 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Wei Lin<wei.w.lin@intel.com>
26 * Yuting Yang<yuting.yang@intel.com>
27 */
28 #ifndef __GENOS_OS_H__
29 #define __GENOS_OS_H__
30
31 #include "os_utilities.h"
32 #include "hw_info.h"
33 #include "os_resource_defs.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #include <i915_drm.h>
40 #include <intel_bufmgr.h>
41 #include <xf86drm.h>
42
43 #ifdef __cplusplus
44 }
45 #endif
46 #define CMD_BUFFER_SIZE_IN_BYTES (8 * 1024)
47 #define CM_MAX_KERNELS_PER_TASK 16
48 typedef struct tagKdll_CacheEntry {
49 BYTE *pBinary;
50 int iSize;
51
52 int iKUID;
53
54 int iKCID;
55 DWORD dwLoaded;
56 } Kdll_CacheEntry;
57
58 typedef struct _GENHW_BB_CM_ARGS {
59 UINT64 uiKernelIds[CM_MAX_KERNELS_PER_TASK];
60 UINT64 uiRefCount;
61 BOOL bLatest;
62 } GENHW_BB_CM_ARGS, *PGENHW_BB_CM_ARGS;
63
64 typedef struct _GENHW_BATCH_BUFFER_PARAMS {
65 BOOL bMatch;
66 INT iCallID;
67 INT iSize;
68 union {
69 GENHW_BB_CM_ARGS BbCmArgs;
70 } BbArgs;
71 } GENHW_BATCH_BUFFER_PARAMS;
72
73 typedef unsigned int GENOS_OS_FORMAT;
74
75 #define MAKEFOURCC(ch0, ch1, ch2, ch3) \
76 ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
77 ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))
78
79 typedef enum _GFX_FORMAT {
80 GFX_FMT_UNKNOWN = 0,
81
82 GFX_FMT_R8G8B8 = 20,
83 GFX_FMT_A8R8G8B8 = 21,
84 GFX_FMT_X8R8G8B8 = 22,
85 GFX_FMT_R5G6B5 = 23,
86 GFX_FMT_X1R5G5B5 = 24,
87 GFX_FMT_A1R5G5B5 = 25,
88 GFX_FMT_A4R4G4B4 = 26,
89 GFX_FMT_R3G3B2 = 27,
90 GFX_FMT_A8 = 28,
91 GFX_FMT_A8R3G3B2 = 29,
92 GFX_FMT_X4R4G4B4 = 30,
93 GFX_FMT_A2B10G10R10 = 31,
94 GFX_FMT_A8B8G8R8 = 32,
95 GFX_FMT_X8B8G8R8 = 33,
96 GFX_FMT_G16R16 = 34,
97 GFX_FMT_A2R10G10B10 = 35,
98 GFX_FMT_A16B16G16R16 = 36,
99
100 GFX_FMT_A8P8 = 40,
101 GFX_FMT_P8 = 41,
102
103 GFX_FMT_L8 = 50,
104 GFX_FMT_A8L8 = 51,
105 GFX_FMT_A4L4 = 52,
106
107 GFX_FMT_V8U8 = 60,
108 GFX_FMT_L6V5U5 = 61,
109 GFX_FMT_X8L8V8U8 = 62,
110 GFX_FMT_Q8W8V8U8 = 63,
111 GFX_FMT_V16U16 = 64,
112 GFX_FMT_A2W10V10U10 = 67,
113
114 GFX_FMT_NV12 = MAKEFOURCC('N', 'V', '1', '2'),
115 GFX_FMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'),
116 GFX_FMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'),
117 GFX_FMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
118 GFX_FMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'),
119 GFX_FMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'),
120 GFX_FMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'),
121 GFX_FMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'),
122 GFX_FMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'),
123 GFX_FMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'),
124
125 GFX_FMT_D16_LOCKABLE = 70,
126 GFX_FMT_D32 = 71,
127 GFX_FMT_D15S1 = 73,
128 GFX_FMT_D24S8 = 75,
129 GFX_FMT_D24X8 = 77,
130 GFX_FMT_D24X4S4 = 79,
131 GFX_FMT_D16 = 80,
132
133 GFX_FMT_D32F_LOCKABLE = 82,
134 GFX_FMT_D24FS8 = 83,
135
136 GFX_FMT_L16 = 81,
137
138 GFX_FMT_VERTEXDATA = 100,
139 GFX_FMT_INDEX16 = 101,
140 GFX_FMT_INDEX32 = 102,
141
142 GFX_FMT_Q16W16V16U16 = 110,
143
144 GFX_FMT_MULTI2_ARGB8 = MAKEFOURCC('M', 'E', 'T', '1'),
145
146 GFX_FMT_R32U = MAKEFOURCC('R', '3', '2', 'U'),
147 GFX_FMT_R32S = MAKEFOURCC('R', '3', '2', 'S'),
148 GFX_FMT_R8U = MAKEFOURCC('R', '8', 'U', 'I'),
149 GFX_FMT_R8G8U = MAKEFOURCC('R', 'G', '8', 'U'),
150 GFX_FMT_R8G8S = MAKEFOURCC('R', 'G', '8', 'S'),
151
152 GFX_FMT_R16F = 111,
153 GFX_FMT_G16R16F = 112,
154 GFX_FMT_A16B16G16R16F = 113,
155
156 GFX_FMT_R32F = 114,
157 GFX_FMT_G32R32F = 115,
158 GFX_FMT_A32B32G32R32F = 116,
159
160 GFX_FMT_CxV8U8 = 117,
161
162 GFX_FMT_FORCE_DWORD = 0x7fffffff
163 } GFX_FORMAT;
164
165 #define GFX_DDIFMT_UNKNOWN GFX_FMT_UNKNOWN
166 #define GFX_DDIFMT_A8B8G8R8 GFX_FMT_A8B8G8R8
167 #define GFX_DDIFMT_X8B8G8R8 GFX_FMT_X8B8G8R8
168 #define GFX_DDIFMT_A8R8G8B8 GFX_FMT_A8R8G8B8
169 #define GFX_DDIFMT_X8R8G8B8 GFX_FMT_X8R8G8B8
170 #define GFX_DDIFMT_R5G6B5 GFX_FMT_R5G6B5
171 #define GFX_DDIFMT_YUY2 GFX_FMT_YUY2
172 #define GFX_DDIFMT_P8 GFX_FMT_P8
173 #define GFX_DDIFMT_A8P8 GFX_FMT_A8P8
174 #define GFX_DDIFMT_A8 GFX_FMT_A8
175 #define GFX_DDIFMT_L8 GFX_FMT_L8
176 #define GFX_DDIFMT_A4L4 GFX_FMT_A4L4
177 #define GFX_DDIFMT_A8L8 GFX_FMT_A8L8
178 #define GFX_DDIFMT_R32F GFX_FMT_R32F
179 #define GFX_DDIFMT_V8U8 GFX_FMT_V8U8
180 #define GFX_DDIFMT_UYVY GFX_FMT_UYVY
181 #define GFX_DDIFMT_NV12 GFX_FMT_NV12
182
183 #define GFX_DDITEXF_NONE GFX_TEXF_NONE
184 #define GFX_DDITEXF_POINT GFX_TEXF_POINT
185 #define GFX_DDITEXF_LINEAR GFX_TEXF_LINEAR
186 #define GFX_DDITEXF_ANISOTROPIC GFX_TEXF_ANISOTROPIC
187 #define GFX_DDITEXF_PYRAMIDALQUAD GFX_TEXF_PYRAMIDALQUAD
188 #define GFX_DDITEXF_GAUSSIANQUAD GFX_TEXF_GAUSSIANQUAD
189
190 typedef enum _GFX_TEXTUREADDRESS {
191 GFX_TADDRESS_WRAP = 1,
192 GFX_TADDRESS_MIRROR = 2,
193 GFX_TADDRESS_CLAMP = 3,
194 GFX_TADDRESS_BORDER = 4,
195 GFX_TADDRESS_MIRRORONCE = 5,
196 GFX_TADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
197 } GFX_TEXTUREADDRESS;
198
199 typedef enum _GFX_TEXTUREFILTERTYPE {
200 GFX_TEXF_NONE = 0,
201 GFX_TEXF_POINT = 1,
202 GFX_TEXF_LINEAR = 2,
203 GFX_TEXF_ANISOTROPIC = 3,
204 GFX_TEXF_PYRAMIDALQUAD = 6,
205 GFX_TEXF_GAUSSIANQUAD = 7,
206 GFX_TEXF_FORCE_DWORD = 0x7fffffff,
207 } GFX_TEXTUREFILTERTYPE;
208
209 typedef GFX_TEXTUREFILTERTYPE GFX_DDITEXTUREFILTERTYPE;
210
211 #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
212
213 #define COMMAND_BUFFER_SIZE 32768
214
215 #define MAX_CMD_BUF_NUM 30
216
217 #define GENOS_LOCKFLAG_WRITEONLY USERMODE_WRITEONLY_LOCKFLAG
218 #define GENOS_LOCKFLAG_READONLY USERMODE_READONLY_LOCKFLAG
219 #define GENOS_LOCKFLAG_NOOVERWRITE USERMODE_NOOVERWRITE_LOCKFLAG
220
221 #define GENOS_DIR_SEPERATOR '/'
222
223 #define GENOS_INVALID_ALLOC_INDEX -1
224 #define GENOS_MAX_REGS 128
225 #define GENOS_STATUS_REPORT_DEFAULT 0
226
227 #define OSKM_LOCKFLAG_WRITEONLY 0x00000001
228 #define OSKM_LOCKFLAG_READONLY 0x00000002
229 #define OSKM_LOCKFLAG_NOOVERWRITE 0x00000004
230
231 #define I915_EXEC_VCS2 (5<<0)
232
233 typedef struct _GENOS_RESOURCE_LINUX GENOS_RESOURCE, *PGENOS_RESOURCE;
234 #define GFX_DDIFORMAT GFX_FORMAT
235 typedef struct _GENOS_INTERFACE *PGENOS_INTERFACE;
236 typedef struct _GENOS_COMMAND_BUFFER *PGENOS_COMMAND_BUFFER;
237
238 typedef enum _GENOS_MEDIA_OPERATION {
239 GENOS_MEDIA_OPERATION_NONE = 0,
240 GENOS_MEDIA_OPERATION_DECODE,
241 GENOS_MEDIA_OPERATION_ENCODE,
242 GENOS_MEDIA_OPERATION_MAX
243 } GENOS_MEDIA_OPERATION, *PGENOS_MEDIA_OPERATION;
244
245 typedef enum _GENOS_GPU_NODE {
246 GENOS_GPU_NODE_3D = I915_EXEC_RENDER,
247 GENOS_GPU_NODE_VIDEO = I915_EXEC_BSD,
248 GENOS_GPU_NODE_VIDEO2 = I915_EXEC_VCS2,
249 GENOS_GPU_NODE_VXD = I915_EXEC_BSD,
250 GENOS_GPU_NODE_MAX = 6
251 } GENOS_GPU_NODE, *PGENOS_GPU_NODE;
252
OSKMGetGpuNode(GENOS_GPU_CONTEXT uiGpuContext)253 static inline GENOS_GPU_NODE OSKMGetGpuNode(GENOS_GPU_CONTEXT uiGpuContext)
254 {
255 switch (uiGpuContext) {
256 case GENOS_GPU_CONTEXT_RENDER:
257 case GENOS_GPU_CONTEXT_RENDER3:
258 case GENOS_GPU_CONTEXT_RENDER4:
259 return GENOS_GPU_NODE_3D;
260 break;
261
262 default:
263 return GENOS_GPU_NODE_MAX;
264 break;
265 }
266 }
267
268 struct _GENOS_RESOURCE_LINUX {
269 GENOS_FORMAT Format;
270 INT iWidth;
271 INT iHeight;
272 INT iPitch;
273 INT iDepth;
274 INT iCount;
275 INT iAllocationIndex[GENOS_GPU_CONTEXT_MAX];
276 DWORD dwGfxAddress;
277 PBYTE pData;
278 CONST CHAR *bufname;
279 UINT isTiled;
280 GENOS_TILE_TYPE TileType;
281 UINT bMapped;
282 drm_intel_bo *bo;
283 UINT name;
284
285 struct {
286 BOOL bSemInitialized;
287 PGENOS_SEMAPHORE **ppSyncSem;
288 PUINT puiSemIndex;
289 };
290 };
291
292 typedef struct _PATCHLOCATIONLIST {
293 UINT AllocationIndex;
294 UINT AllocationOffset;
295 UINT PatchOffset;
296 BOOL uiRelocFlag;
297 } PATCHLOCATIONLIST, *PPATCHLOCATIONLIST;
298
299 #define CODECHAL_MAX_REGS 128
300 #define PATCHLOCATIONLIST_SIZE CODECHAL_MAX_REGS
301
302 typedef struct _ALLOCATION_LIST {
303 PVOID hAllocation;
304 UINT WriteOperation;
305 } ALLOCATION_LIST, *PALLOCATION_LIST;
306
307 #define ALLOCATIONLIST_SIZE CODECHAL_MAX_REGS
308
309 typedef struct _COMMAND_BUFFER {
310 struct _COMMAND_BUFFER *pNext;
311 struct _COMMAND_BUFFER *pPrev;
312
313 LONGLONG *pSyncTag;
314 LONGLONG qSyncTag;
315
316 BOOL bActive;
317 BOOL bRunning;
318 LARGE_INTEGER TimeStart;
319 LARGE_INTEGER TimeEnd;
320
321 PBYTE pCmdBase;
322 PBYTE pCmdCurrent;
323 INT iSize;
324 INT iCurrent;
325 INT iRemaining;
326 } COMMAND_BUFFER, *PCOMMAND_BUFFER;
327
328 typedef struct _CODECHAL_OS_GPU_CONTEXT {
329 volatile BOOL bCBFlushed;
330 PGENOS_COMMAND_BUFFER pCB;
331 UINT uiCommandBufferSize;
332
333 ALLOCATION_LIST *pAllocationList;
334 UINT uiNumAllocations;
335 UINT uiMaxPatchLocationsize;
336
337 PATCHLOCATIONLIST *pPatchLocationList;
338 UINT uiCurrentNumPatchLocations;
339 UINT uiMaxNumAllocations;
340
341 PCOMMAND_BUFFER pStartCB;
342 PCOMMAND_BUFFER pCurrentCB;
343
344 UINT uiResCount;
345 INT iResIndex[CODECHAL_MAX_REGS];
346 GENOS_RESOURCE *pResources;
347 BOOL *pbWriteMode;
348 } GENOS_OS_GPU_CONTEXT, *PGENOS_OS_GPU_CONTEXT;
349
350 typedef struct _CMD_BUFFER_BO_POOL {
351 INT iFetch;
352 drm_intel_bo *pCmd_bo[MAX_CMD_BUF_NUM];
353 } CMD_BUFFER_BO_POOL;
354
355 typedef struct _GENOS_OS_CONTEXT GENOS_CONTEXT, *PGENOS_CONTEXT,
356 GENOS_OS_CONTEXT, *PGENOS_OS_CONTEXT, GENOS_DRIVER_CONTEXT,
357 *PGENOS_DRIVER_CONTEXT;
358
359 struct _GENOS_OS_CONTEXT {
360 BOOL bFreeContext;
361
362 UINT uIndirectStateSize;
363
364 GENOS_OS_GPU_CONTEXT OsGpuContext[GENOS_GPU_CONTEXT_MAX];
365
366 LARGE_INTEGER Frequency;
367 LARGE_INTEGER LastCB;
368
369 CMD_BUFFER_BO_POOL CmdBufferPool;
370
371 PLATFORM platform;
372
373 dri_bufmgr *bufmgr;
374
375 int wDeviceID;
376 int wRevision;
377 int fd;
378
379 VOID(*pfnDestroy) (struct _GENOS_OS_CONTEXT * pOsContext);
380
381 BOOL(*pfnRefresh) (struct _GENOS_OS_CONTEXT * pOsContext);
382
383 BOOL(*pfnGetCommandBuffer) (struct _GENOS_OS_CONTEXT * pOsContext,
384 PGENOS_COMMAND_BUFFER pCmdBuffer,
385 INT iSize);
386
387 VOID(*pfnReturnCommandBuffer) (struct _GENOS_OS_CONTEXT * pOsContext,
388 GENOS_GPU_CONTEXT GpuContext,
389 PGENOS_COMMAND_BUFFER pCmdBuffer);
390
391 BOOL(*pfnFlushCommandBuffer) (struct _GENOS_OS_CONTEXT * pOsContext,
392 GENOS_GPU_CONTEXT GpuContext);
393
394 HRESULT(*pfnInsertCmdBufferToPool) (struct _GENOS_OS_CONTEXT *
395 pOsContext, drm_intel_bo * bo);
396
397 };
398
399 typedef enum _GENOS_RESOURCE_TYPE_LINUX {
400 TYPE_INVALID_LINUX,
401 TYPE_RESOURCE_LINUX,
402 TYPE_RESOURCE_UP_LINUX,
403 TYPE_BUFFER_LINUX,
404 TYPE_BUFFER_UP_LINUX
405 } GENOS_RESOURCE_TYPE_LINUX;
406
407 typedef struct _GENOS_OS_ALLOCATION {
408 PGENOS_RESOURCE pOsResource;
409 BOOL bWriteMode;
410 } GENOS_OS_ALLOCATION, *PGENOS_OS_ALLOCATION;
411
412 #ifdef __cplusplus
413 extern "C" {
414 #endif
415 BOOL IntelGen_OsResourceIsNull(PGENOS_RESOURCE pOsResource);
416
417 VOID IntelGen_OsResetResource(PGENOS_RESOURCE pOsResource);
418
419 GENOS_TILE_TYPE OsToGenTileType(UINT type);
420
421 HRESULT IntelGen_OsInitInterface_Linux(PGENOS_INTERFACE pOsInterface,
422 PGENOS_CONTEXT pOsDriverContext);
423
424 #define WAIT_OBJECT_0 0
425
426 #ifdef __cplusplus
427 }
428 #endif
429 #define GENOS_NAL_UNIT_LENGTH 4
430 #define GENOS_NAL_UNIT_STARTCODE_LENGTH 3
431 #define GENOS_MAX_PATH_LENGTH 256
432 #define GENOS_MAX_SEMAPHORE_COUNT 3
433 #define GENOS_MAX_OBJECT_SIGNALED 32
434 #ifndef E_NOTIMPL
435 #define E_NOTIMPL 0x80004001L
436 #endif
437 #ifndef E_UNEXPECTED
438 #define E_UNEXPECTED 0x8000FFFFL
439 #endif
440 typedef enum _GENOS_OS {
441 GENOS_OS_NONE = 0,
442 GENOS_OS_LINUX = 4,
443 GENOS_OS_NEXT = 5
444 } GENOS_OS, *PGENOS_OS;
445
446 typedef enum _GENOS_COMPONENT {
447 COMPONENT_UNKNOWN = 0,
448 COMPONENT_CM,
449 } GENOS_COMPONENT;
450 C_ASSERT(COMPONENT_CM == 1);
451
452 typedef struct _GENOS_PLANE_OFFSET {
453 int iSurfaceOffset;
454 int iXOffset;
455 int iYOffset;
456 } GENOS_PLANE_OFFSET, *PGENOS_PLANE_OFFSET;
457
458 typedef struct _GENOS_COMMAND_BUFFER {
459 GENOS_RESOURCE OsResource;
460
461 PDWORD pCmdBase;
462 PDWORD pCmdPtr;
463 INT iOffset;
464 INT iRemaining;
465 INT iTokenOffsetInCmdBuf;
466 } GENOS_COMMAND_BUFFER, *PGENOS_COMMAND_BUFFER;
467
468 typedef struct _GENOS_LOCK_PARAMS {
469 union {
470 struct {
471 UINT ReadOnly:1;
472 UINT WriteOnly:1;
473 UINT TiledAsTiled:1;
474 UINT NoOverWrite:1;
475 UINT NoDecompress:1;
476 UINT Reserved:27;
477 };
478 UINT Value;
479 };
480 } GENOS_LOCK_PARAMS, *PGENOS_LOCK_PARAMS;
481
482 typedef struct _GENOS_GFXRES_FLAGS {
483 BOOL bNotLockable;
484 BOOL bFlipChain;
485 } GENOS_GFXRES_FLAGS, *PGENOS_GFXRES_FLAGS;
486
487 typedef struct _GENOS_ALLOC_GFXRES_PARAMS {
488 GENOS_GFXRES_TYPE Type;
489 GENOS_GFXRES_FLAGS Flags;
490 union {
491 DWORD dwWidth;
492 DWORD dwBytes;
493 };
494 DWORD dwHeight;
495 DWORD dwDepth;
496 DWORD dwArraySize;
497 GENOS_TILE_TYPE TileType;
498 GENOS_FORMAT Format;
499 PVOID pSystemMemory;
500 PCCHAR pBufName;
501 BOOL bIsCompressed;
502 } GENOS_ALLOC_GFXRES_PARAMS, *PGENOS_ALLOC_GFXRES_PARAMS;
503
504 typedef enum _GENOS_MEMCOMP_STATE {
505 GENOS_MEMCOMP_DISABLED = 0,
506 GENOS_MEMCOMP_HORIZONTAL,
507 GENOS_MEMCOMP_VERTICAL
508 } GENOS_MEMCOMP_STATE, *PGENOS_MEMCOMP_STATE;
509
510 typedef struct _GENOS_RESOURCE_OFFSETS {
511 DWORD BaseOffset;
512 DWORD XOffset;
513 DWORD YOffset;
514 } GENOS_RESOURCE_OFFSETS;
515
516 typedef struct _GENOS_SURFACE {
517 GENOS_RESOURCE OsResource;
518
519 UINT dwArraySlice;
520 UINT dwMipSlice;
521
522 GENOS_GFXRES_TYPE Type;
523 BOOL bFlipChain;
524
525 DWORD dwSubResourceIndex;
526
527 DWORD dwWidth;
528 DWORD dwHeight;
529 DWORD dwSize;
530 DWORD dwDepth;
531 DWORD dwArraySize;
532 DWORD dwLockPitch;
533 DWORD dwPitch;
534 GENOS_TILE_TYPE TileType;
535 GENOS_FORMAT Format;
536 BOOL bArraySpacing;
537 BOOL bCompressible;
538
539 DWORD dwOffset;
540 GENOS_PLANE_OFFSET UPlaneOffset;
541 GENOS_PLANE_OFFSET VPlaneOffset;
542
543 union {
544 struct {
545 GENOS_RESOURCE_OFFSETS Y;
546 GENOS_RESOURCE_OFFSETS U;
547 GENOS_RESOURCE_OFFSETS V;
548 } YUV;
549
550 GENOS_RESOURCE_OFFSETS RGB;
551 } RenderOffset;
552
553 union {
554 struct {
555 DWORD Y;
556 DWORD U;
557 DWORD V;
558 } YUV;
559
560 DWORD RGB;
561 } LockOffset;
562
563 BOOL bIsCompressed;
564 } GENOS_SURFACE, *PGENOS_SURFACE;
565
566 typedef struct _GENOS_INTERFACE {
567 PGENOS_CONTEXT pOsContext;
568 GENOS_GPU_CONTEXT CurrentGpuContextOrdinal;
569 UINT CurrentGpuContextHandle;
570 HANDLE CurrentGpuContextRuntimeHandle;
571
572 GENOS_OS OS;
573 BOOL b64bit;
574 BOOL bDeallocateOnExit;
575
576 BOOL bUsesCmdBufHeader;
577 BOOL bUsesCmdBufHeaderInResize;
578 BOOL bNoParsingAssistanceInKmd;
579 DWORD dwCommandBufferReservedSpace;
580 DWORD dwNumNalUnitBytesIncluded;
581
582 BOOL bUsesPatchList;
583 BOOL bUsesGfxAddress;
584
585 BOOL bMapOnCreate;
586
587 BOOL bTagEngineSync;
588 BOOL bTagResourceSync;
589 BOOL bOsEngineSync;
590 BOOL bOsResourceSync;
591
592 VOID(*pfnDestroy) (PGENOS_INTERFACE pOsInterface,
593 BOOL bDestroyVscVppDeviceTag);
594
595 VOID(*pfnGetPlatform) (PGENOS_INTERFACE pOsInterface,
596 PLATFORM * pPlatform);
597
598 VOID(*pfnResetOsStates) (PGENOS_INTERFACE pOsInterface);
599
600 HRESULT(*pfnAllocateResource) (PGENOS_INTERFACE pOsInterface,
601 PGENOS_ALLOC_GFXRES_PARAMS pParams,
602 PGENOS_RESOURCE pOsResource);
603
604 VOID(*pfnFreeResource) (PGENOS_INTERFACE pOsInterface,
605 PGENOS_RESOURCE pResource);
606
607 PVOID(*pfnLockResource) (PGENOS_INTERFACE pOsInterface,
608 PGENOS_RESOURCE pResource,
609 PGENOS_LOCK_PARAMS pFlags);
610
611 HRESULT(*pfnUnlockResource) (PGENOS_INTERFACE pOsInterface,
612 PGENOS_RESOURCE pResource);
613
614 HRESULT(*pfnRegisterResource) (PGENOS_INTERFACE pOsInterface,
615 PGENOS_RESOURCE pResource,
616 BOOL bWrite,
617 BOOL bWritebSetResourceSyncTag);
618
619 VOID(*pfnResetResourceAllocationIndex) (PGENOS_INTERFACE pOsInterface,
620 PGENOS_RESOURCE pResource);
621
622 INT(*pfnGetResourceAllocationIndex) (PGENOS_INTERFACE pOsInterface,
623 PGENOS_RESOURCE pResource);
624
625 HRESULT(*pfnSetPatchEntry) (PGENOS_INTERFACE pOsInterface,
626 const UINT iAllocationIndex,
627 const UINT ResourceOffset,
628 const UINT PatchOffset);
629
630 HRESULT(*pfnWaitOnResource) (PGENOS_INTERFACE pOsInterface,
631 PGENOS_RESOURCE pResource);
632
633 HRESULT(*pfnVerifyCommandBufferSize) (PGENOS_INTERFACE pOsInterface,
634 DWORD dwRequestedSize);
635
636 HRESULT(*pfnResizeCommandBufferAndPatchList) (PGENOS_INTERFACE
637 pOsInterface,
638 DWORD
639 dwRequestedCommandBufferSize,
640 DWORD
641 dwRequestedPatchListSize);
642
643 HRESULT(*pfnGetCommandBuffer) (PGENOS_INTERFACE pOsInterface,
644 PGENOS_COMMAND_BUFFER pCmdBuffer);
645
646 HRESULT(*pfnSetIndirectStateSize) (PGENOS_INTERFACE pOsInterface,
647 UINT uSize);
648
649 HRESULT(*pfnGetIndirectState) (PGENOS_INTERFACE pOsInterface,
650 UINT * puOffset, UINT * puSize);
651
652 HRESULT(*pfnGetIndirectStatePointer) (PGENOS_INTERFACE pOsInterface,
653 PBYTE * pIndirectState);
654
655 VOID(*pfnReturnCommandBuffer) (PGENOS_INTERFACE pOsInterface,
656 PGENOS_COMMAND_BUFFER pCmdBuffer);
657
658 HRESULT(*pfnSubmitCommandBuffer) (PGENOS_INTERFACE pOsInterface,
659 PGENOS_COMMAND_BUFFER pCmdBuffer,
660 BOOL bNullRendering);
661
662 VOID(*pfnSleepMs) (PGENOS_INTERFACE pOsInterface, DWORD dwWaitMs);
663
664 GENOS_FORMAT(*pfnFmt_OsToGen) (GENOS_OS_FORMAT format);
665
666 GENOS_OS_FORMAT(*pfnFmt_GenToOs) (GENOS_FORMAT format);
667
668 VOID(*pfnQueryPerformanceFrequency) (PLONGLONG pFrequency);
669
670 VOID(*pfnQueryPerformanceCounter) (PLONGLONG pCount);
671
672 HINSTANCE(*pfnLoadLibrary) (CONST PCHAR pFileName);
673
674 HRESULT(*pfnFreeLibrary) (HINSTANCE hInstance);
675
676 PVOID(*pfnGetProcAddress) (HINSTANCE hInstance, PCHAR pModuleName);
677
678 HRESULT(*pfnResetCommandBuffer) (PGENOS_INTERFACE pOsInterface,
679 PGENOS_COMMAND_BUFFER pCmdBuffer);
680
681 PVOID (*pfnAllocUserptr) (PGENOS_CONTEXT pOsContext,
682 const char *name,
683 void *addr,
684 uint32_t tilingMode,
685 uint32_t stride,
686 unsigned long size,
687 unsigned long flags);
688
689 } GENOS_INTERFACE;
690
691 #ifdef __cplusplus
692 extern "C" {
693 #endif
694
695 HRESULT IntelGen_OsInitInterfaceComp(PGENOS_INTERFACE pOsInterface,
696 PGENOS_CONTEXT pOsDriverContext,
697 GENOS_COMPONENT component);
698
699 GENOS_STATUS IntelGen_OsAddCommand(PGENOS_COMMAND_BUFFER pCmdBuffer,
700 PCVOID pCmd, DWORD dwCmdSize);
701
702 PVOID IntelGen_OsGetCmdBufferSpace(PGENOS_COMMAND_BUFFER pCmdBuffer,
703 DWORD dwCmdSize);
704
705 VOID IntelGen_OsAdjustCmdBufferFreeSpace(PGENOS_COMMAND_BUFFER
706 pCmdBuffer, DWORD dwCmdSize);
707
708 #ifdef __cplusplus
709 }
710 #endif
711 #endif
712