File: vulkan_h.tmpl

package info (click to toggle)
android-platform-frameworks-native 1%3A7.0.0%2Br33-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 15,036 kB
  • sloc: cpp: 126,962; xml: 48,615; ansic: 18,880; java: 4,991; python: 1,324; sh: 187; asm: 105; perl: 74; makefile: 28
file content (295 lines) | stat: -rw-r--r-- 10,085 bytes parent folder | download | duplicates (5)
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
{{Include "vulkan_common.tmpl"}}
{{Macro "DefineGlobals" $}}
{{$ | Macro "vulkan.h" | Format (Global "clang-format") | Write "../include/vulkan.h"}}


{{/*
-------------------------------------------------------------------------------
  Entry point
-------------------------------------------------------------------------------
*/}}
{{define "vulkan.h"}}
#ifndef __vulkan_h_
#define __vulkan_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2016 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are 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 Materials.
**
** THE MATERIALS ARE 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/*
** This header is generated from the Khronos Vulkan API Registry.
**
*/
#define VK_VERSION_1_0 1
#include "vk_platform.h"
#define VK_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch))
// Vulkan API version supported by this file
#define VK_API_VERSION \
    VK_MAKE_VERSION({{Global "VERSION_MAJOR"}}, {{Global "VERSION_MINOR"}}, {{Global "VERSION_PATCH"}})
#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff)
#if defined(__cplusplus) && ((defined(_MSC_VER) && _MSC_VER >= 1800 || __cplusplus >= 201103L)
    #define VK_NULL_HANDLE nullptr
#else
    #define VK_NULL_HANDLE 0
#endif
#define VK_DEFINE_HANDLE(obj) typedef struct obj##_T* obj;
#if defined(__cplusplus)
#if ((defined(_MSC_VER) && _MSC_VER >= 1800 || __cplusplus >= 201103L)
// The bool operator only works if there are no implicit conversions from an obj to
// a bool-compatible type, which can then be used to unintentionally violate type safety.
// C++11 and above supports the "explicit" keyword on conversion operators to stop this
// from happening. Otherwise users of C++ below C++11 won't get direct access to evaluating
// the object handle as a bool in expressions like:
//     if (obj) vkDestroy(obj);
#define VK_NONDISP_HANDLE_OPERATOR_BOOL() \
    explicit operator bool() const { return handle != 0; }
#define VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj) \
    explicit obj(uint64_t x) : handle(x) { } \
    obj(decltype(nullptr)) : handle(0) { }
#else
#define VK_NONDISP_HANDLE_OPERATOR_BOOL()
#define VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj) \
    obj(uint64_t x) : handle(x) { }
#endif
#define VK_DEFINE_NONDISP_HANDLE(obj)                                              \
    struct obj {                                                                   \
        obj() : handle(0) { }                                                      \
        VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj)                             \
        obj& operator=(uint64_t x) {                                               \
            handle = x;                                                            \
            return *this;                                                          \
        }                                                                          \
        bool operator==(const obj& other) const { return handle == other.handle; } \
        bool operator!=(const obj& other) const { return handle != other.handle; } \
        bool operator!() const { return !handle; }                                 \
        VK_NONDISP_HANDLE_OPERATOR_BOOL()                                          \
        uint64_t handle;                                                           \
    };
#else
#define VK_DEFINE_NONDISP_HANDLE(obj) \
    typedef struct obj##_T { uint64_t handle; } obj;
#endif
#define VK_LOD_CLAMP_NONE         1000.0f
#define VK_REMAINING_MIP_LEVELS   (~0U)
#define VK_REMAINING_ARRAY_LAYERS (~0U)
#define VK_WHOLE_SIZE             (~0ULL)
#define VK_ATTACHMENT_UNUSED      (~0U)
define VK_QUEUE_FAMILY_IGNORED    (~0U)
define VK_SUBPASS_EXTERNAL        (~0U)
{{range $d := $.Definitions}}
  {{if HasPrefix $d.Name "VK_"}}#define {{$d.Name}}  {{$d.Expression}}{{end}}
{{end}}
{{range $i, $p := $.Pseudonyms}}
  {{if GetAnnotation $p "dispatchHandle"}}VK_DEFINE_HANDLE({{$p.Name}})
  {{else if GetAnnotation $p "nonDispatchHandle"}}VK_DEFINE_NONDISP_HANDLE({{$p.Name}})
  {{end}}
{{end}}
// ------------------------------------------------------------------------------------------------
// Enumerations
  {{range $e := $.Enums}}
    {{if not $e.IsBitfield}}
      {{Macro "Enum" $e}}
    {{end}}
  {{end}}
// ------------------------------------------------------------------------------------------------
// Flags
  {{range $e := $.Enums}}
    {{if $e.IsBitfield}}
      {{Macro "Bitfield" $e}}
    {{end}}
  {{end}}
// ------------------------------------------------------------------------------------------------
// Vulkan structures
  {{/* Function pointers */}}
  {{range $f := AllCommands $}}
    {{if GetAnnotation $f "pfn"}}
      {{Macro "FunctionTypedef" $f}}
    {{end}}
  {{end}}
  {{range $c := $.Classes}}
    {{if not (GetAnnotation $c "internal")}}
      {{Macro "Struct" $c}}
    {{end}}
  {{end}}
// ------------------------------------------------------------------------------------------------
// API functions
  {{range $f := AllCommands $}}
    {{if not (GetAnnotation $f "pfn")}}
      {{Macro "FunctionTypedef" $f}}
    {{end}}
  {{end}}
#ifdef VK_NO_PROTOTYPES
  {{range $f := AllCommands $}}
    {{if not (GetAnnotation $f "pfn")}}
      {{Macro "FunctionDecl" $f}}
    {{end}}
  {{end}}
#endif
#ifdef __cplusplus
}
#endif
#endif
{{end}}

{{/*
-------------------------------------------------------------------------------
  Emits the C declaration for the specified bitfield.
-------------------------------------------------------------------------------
*/}}
{{define "Bitfield"}}
  {{AssertType $ "Enum"}}

  {{Macro "Docs" $.Docs}}
  typedef VkFlags {{Macro "EnumName" $}};
  {{if $.Entries}}
  typedef enum {
  {{range $b := $.Entries}}
    {{Macro "BitfieldEntryName" $b}} = {{printf "0x%.8X" $b.Value}}, {{Macro "Docs" $b.Docs}}
  {{end}}
  } {{Macro "EnumName" $ | TrimRight "s"}}Bits;
  {{end}}
{{end}}


{{/*
-------------------------------------------------------------------------------
  Emits the C declaration for the specified enum.
-------------------------------------------------------------------------------
*/}}
{{define "Enum"}}
  {{AssertType $ "Enum"}}

  {{Macro "Docs" $.Docs}}
  typedef enum {
    {{range $i, $e := $.Entries}}
      {{Macro "EnumEntry" $e}} = {{printf "0x%.8X" $e.Value}}, {{Macro "Docs" $e.Docs}}
    {{end}}
    {{$name  := Macro "EnumName" $ | TrimRight "ABCDEFGHIJKLMNOQRSTUVWXYZ" | SplitPascalCase | Upper | JoinWith "_"}}
    {{if GetAnnotation $ "enumMaxOnly"}}
      VK_MAX_ENUM({{$name | SplitOn "VK_"}})
    {{else}}
      {{$first := Macro "EnumFirstEntry" $ | SplitOn $name | TrimLeft "_"}}
      {{$last  := Macro "EnumLastEntry" $  | SplitOn $name | TrimLeft "_"}}
      VK_ENUM_RANGE({{$name | SplitOn "VK_"}}, {{$first}}, {{$last}})
    {{end}}
  } {{Macro "EnumName" $}};
{{end}}


{{/*
-------------------------------------------------------------------------------
  Emits the C declaration for the specified class.
-------------------------------------------------------------------------------
*/}}
{{define "Struct"}}
  {{AssertType $ "Class"}}

  {{Macro "Docs" $.Docs}}
  typedef {{Macro "StructType" $}} {
    {{ForEach $.Fields "Field" | JoinWith "\n"}}
  } {{Macro "StructName" $}};
{{end}}


{{/*
-------------------------------------------------------------------------------
  Emits the C declaration for the specified class field.
-------------------------------------------------------------------------------
*/}}
{{define "Field"}}
  {{AssertType $ "Field"}}

  {{Node "Type" $}} {{$.Name}}§
  {{Macro "ArrayPostfix" (TypeOf $)}}; {{Macro "Docs" $.Docs}}
{{end}}


{{/*
-------------------------------------------------------------------------------
  Emits either 'struct' or 'union' for the specified class.
-------------------------------------------------------------------------------
*/}}
{{define "StructType"}}
  {{AssertType $ "Class"}}

  {{if GetAnnotation $ "union"}}union{{else}}struct{{end}}
{{end}}


{{/*
-------------------------------------------------------------------------------
  Emits the C function pointer typedef declaration for the specified command.
-------------------------------------------------------------------------------
*/}}
{{define "FunctionTypedef"}}
  {{AssertType $ "Function"}}

  typedef {{Node "Type" $.Return}} (VKAPI* {{Macro "FunctionPtrName" $}})({{Macro "Parameters" $}});
{{end}}


{{/*
-------------------------------------------------------------------------------
  Emits the C function declaration for the specified command.
-------------------------------------------------------------------------------
*/}}
{{define "FunctionDecl"}}
  {{AssertType $ "Function"}}

  {{if not (GetAnnotation $ "fptr")}}
    {{Macro "Docs" $.Docs}}
    {{Node "Type" $.Return}} VKAPI {{Macro "FunctionName" $}}({{Macro "Parameters" $}});
  {{end}}
{{end}}