summaryrefslogtreecommitdiff
path: root/src/gallium/include/frontend/winsys_handle.h
blob: 98d383cffa0379a3d28108d6368223f73b5045d5 (plain)
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

#ifndef _WINSYS_HANDLE_H_
#define _WINSYS_HANDLE_H_

#ifdef _WIN32
typedef void *HANDLE;
#endif

#ifdef __cplusplus
extern "C" {
#endif

#define WINSYS_HANDLE_TYPE_SHARED 0
#define WINSYS_HANDLE_TYPE_KMS    1
#define WINSYS_HANDLE_TYPE_FD     2
/* Win32 handles serve the same purpose as FD, just on Windows, so alias the value */
#define WINSYS_HANDLE_TYPE_WIN32_HANDLE WINSYS_HANDLE_TYPE_FD
#define WINSYS_HANDLE_TYPE_SHMID   3
#define WINSYS_HANDLE_TYPE_D3D12_RES 4
#define WINSYS_HANDLE_TYPE_WIN32_NAME 5

/**
 * For use with pipe_screen::{resource_from_handle|resource_get_handle}.
 */
struct winsys_handle
{
   /**
    * Input for resource_from_handle, valid values are
    * WINSYS_HANDLE_TYPE_SHARED or WINSYS_HANDLE_TYPE_FD.
    * Input to resource_get_handle,
    * to select handle for kms, flink, or prime.
    */
   unsigned type;
   /**
    * Input for resource_get_handle, allows to export the offset
    * of a specific layer of an array texture.
    */
   unsigned layer;
   /**
    * Input for resource_get_handle, allows to export of a specific plane of a
    * texture.
    */
   unsigned plane;
   /**
    * Input to resource_from_handle.
    * Output for resource_get_handle.
    */
#ifdef _WIN32
   HANDLE handle;
#else
   unsigned handle;
#endif
   /**
    * Input to resource_from_handle.
    * Output for resource_get_handle.
    */
   unsigned stride;
   /**
    * Input to resource_from_handle.
    * Output for resource_get_handle.
    */
   unsigned offset;

   /**
    * Input to resource_from_handle.
    * Output from resource_get_handle.
    */
   uint64_t format;

   /**
    * Input to resource_from_handle.
    * Output from resource_get_handle.
    */
   uint64_t modifier;

   union
   {
      /**
       * Input to resource_from_handle.
       * Output for resource_get_handle.
       */
      void *com_obj;

      /**
       * String name for an object.
       * Input to resource_from_handle.
       */
      const void *name;
   };

   /**
    * Total size of the object.
    * Output for resource_get_handle.
    */
   uint64_t size;
};

#ifdef __cplusplus
}
#endif

#endif /* _WINSYS_HANDLE_H_ */