1bf215546Sopenharmony_ci
2bf215546Sopenharmony_ci#ifndef _WINSYS_HANDLE_H_
3bf215546Sopenharmony_ci#define _WINSYS_HANDLE_H_
4bf215546Sopenharmony_ci
5bf215546Sopenharmony_ci#ifdef _WIN32
6bf215546Sopenharmony_ci#include <windows.h>
7bf215546Sopenharmony_ci#endif
8bf215546Sopenharmony_ci
9bf215546Sopenharmony_ci#ifdef __cplusplus
10bf215546Sopenharmony_ciextern "C" {
11bf215546Sopenharmony_ci#endif
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci#define WINSYS_HANDLE_TYPE_SHARED 0
14bf215546Sopenharmony_ci#define WINSYS_HANDLE_TYPE_KMS    1
15bf215546Sopenharmony_ci#define WINSYS_HANDLE_TYPE_FD     2
16bf215546Sopenharmony_ci/* Win32 handles serve the same purpose as FD, just on Windows, so alias the value */
17bf215546Sopenharmony_ci#define WINSYS_HANDLE_TYPE_WIN32_HANDLE WINSYS_HANDLE_TYPE_FD
18bf215546Sopenharmony_ci#define WINSYS_HANDLE_TYPE_SHMID   3
19bf215546Sopenharmony_ci#define WINSYS_HANDLE_TYPE_D3D12_RES 4
20bf215546Sopenharmony_ci#define WINSYS_HANDLE_TYPE_WIN32_NAME 5
21bf215546Sopenharmony_ci
22bf215546Sopenharmony_ci/**
23bf215546Sopenharmony_ci * For use with pipe_screen::{resource_from_handle|resource_get_handle}.
24bf215546Sopenharmony_ci */
25bf215546Sopenharmony_cistruct winsys_handle
26bf215546Sopenharmony_ci{
27bf215546Sopenharmony_ci   /**
28bf215546Sopenharmony_ci    * Input for resource_from_handle, valid values are
29bf215546Sopenharmony_ci    * WINSYS_HANDLE_TYPE_SHARED or WINSYS_HANDLE_TYPE_FD.
30bf215546Sopenharmony_ci    * Input to resource_get_handle,
31bf215546Sopenharmony_ci    * to select handle for kms, flink, or prime.
32bf215546Sopenharmony_ci    */
33bf215546Sopenharmony_ci   unsigned type;
34bf215546Sopenharmony_ci   /**
35bf215546Sopenharmony_ci    * Input for resource_get_handle, allows to export the offset
36bf215546Sopenharmony_ci    * of a specific layer of an array texture.
37bf215546Sopenharmony_ci    */
38bf215546Sopenharmony_ci   unsigned layer;
39bf215546Sopenharmony_ci   /**
40bf215546Sopenharmony_ci    * Input for resource_get_handle, allows to export of a specific plane of a
41bf215546Sopenharmony_ci    * texture.
42bf215546Sopenharmony_ci    */
43bf215546Sopenharmony_ci   unsigned plane;
44bf215546Sopenharmony_ci   /**
45bf215546Sopenharmony_ci    * Input to resource_from_handle.
46bf215546Sopenharmony_ci    * Output for resource_get_handle.
47bf215546Sopenharmony_ci    */
48bf215546Sopenharmony_ci#ifdef _WIN32
49bf215546Sopenharmony_ci   HANDLE handle;
50bf215546Sopenharmony_ci#else
51bf215546Sopenharmony_ci   unsigned handle;
52bf215546Sopenharmony_ci#endif
53bf215546Sopenharmony_ci   /**
54bf215546Sopenharmony_ci    * Input to resource_from_handle.
55bf215546Sopenharmony_ci    * Output for resource_get_handle.
56bf215546Sopenharmony_ci    */
57bf215546Sopenharmony_ci   unsigned stride;
58bf215546Sopenharmony_ci   /**
59bf215546Sopenharmony_ci    * Input to resource_from_handle.
60bf215546Sopenharmony_ci    * Output for resource_get_handle.
61bf215546Sopenharmony_ci    */
62bf215546Sopenharmony_ci   unsigned offset;
63bf215546Sopenharmony_ci
64bf215546Sopenharmony_ci   /**
65bf215546Sopenharmony_ci    * Input to resource_from_handle.
66bf215546Sopenharmony_ci    * Output from resource_get_handle.
67bf215546Sopenharmony_ci    */
68bf215546Sopenharmony_ci   uint64_t format;
69bf215546Sopenharmony_ci
70bf215546Sopenharmony_ci   /**
71bf215546Sopenharmony_ci    * Input to resource_from_handle.
72bf215546Sopenharmony_ci    * Output from resource_get_handle.
73bf215546Sopenharmony_ci    */
74bf215546Sopenharmony_ci   uint64_t modifier;
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci   union
77bf215546Sopenharmony_ci   {
78bf215546Sopenharmony_ci      /**
79bf215546Sopenharmony_ci       * Input to resource_from_handle.
80bf215546Sopenharmony_ci       * Output for resource_get_handle.
81bf215546Sopenharmony_ci       */
82bf215546Sopenharmony_ci      void *com_obj;
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ci      /**
85bf215546Sopenharmony_ci       * String name for an object.
86bf215546Sopenharmony_ci       * Input to resource_from_handle.
87bf215546Sopenharmony_ci       */
88bf215546Sopenharmony_ci      const void *name;
89bf215546Sopenharmony_ci   };
90bf215546Sopenharmony_ci
91bf215546Sopenharmony_ci   /**
92bf215546Sopenharmony_ci    * Total size of the object.
93bf215546Sopenharmony_ci    * Output for resource_get_handle.
94bf215546Sopenharmony_ci    */
95bf215546Sopenharmony_ci   uint64_t size;
96bf215546Sopenharmony_ci};
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_ci#ifdef __cplusplus
99bf215546Sopenharmony_ci}
100bf215546Sopenharmony_ci#endif
101bf215546Sopenharmony_ci
102bf215546Sopenharmony_ci#endif /* _WINSYS_HANDLE_H_ */
103