File: null_driver.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 (218 lines) | stat: -rw-r--r-- 7,499 bytes parent folder | download
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
{{/*
 * Copyright 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */}}

{{Include "../api/templates/vulkan_common.tmpl"}}
{{Global "clang-format" (Strings "clang-format" "-style=file")}}
{{Macro "DefineGlobals" $}}
{{$ | Macro "null_driver_gen.h"   | Format (Global "clang-format") | Write "null_driver_gen.h"  }}
{{$ | Macro "null_driver_gen.cpp" | Format (Global "clang-format") | Write "null_driver_gen.cpp"}}


{{/*
-------------------------------------------------------------------------------
  null_driver_gen.h
-------------------------------------------------------------------------------
*/}}
{{define "null_driver_gen.h"}}
/*
•* Copyright 2015 The Android Open Source Project
•*
•* Licensed under the Apache License, Version 2.0 (the "License");
•* you may not use this file except in compliance with the License.
•* You may obtain a copy of the License at
•*
•*      http://www.apache.org/licenses/LICENSE-2.0
•*
•* Unless required by applicable law or agreed to in writing, software
•* distributed under the License is distributed on an "AS IS" BASIS,
•* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
•* See the License for the specific language governing permissions and
•* limitations under the License.
•*/
// WARNING: This file is generated. See ../README.md for instructions.
#ifndef NULLDRV_NULL_DRIVER_H
#define NULLDRV_NULL_DRIVER_H 1
#include <vulkan/vk_android_native_buffer.h>
#include <vulkan/vulkan.h>
namespace null_driver {«
PFN_vkVoidFunction GetGlobalProcAddr(const char* name);
PFN_vkVoidFunction GetInstanceProcAddr(const char* name);
// clang-format off
  {{range $f := AllCommands $}}
    {{if (Macro "IsDriverFunction" $f)}}
VKAPI_ATTR {{Node "Type" $f.Return}} {{Macro "BaseName" $f}}({{Macro "Parameters" $f}});
    {{end}}
  {{end}}
VKAPI_ATTR VkResult GetSwapchainGrallocUsageANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage);
VKAPI_ATTR VkResult AcquireImageANDROID(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence);
VKAPI_ATTR VkResult QueueSignalReleaseImageANDROID(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd);
// clang-format on
»}  // namespace null_driver
#endif  // NULLDRV_NULL_DRIVER_H
¶{{end}}


{{/*
-------------------------------------------------------------------------------
  null_driver_gen.cpp
-------------------------------------------------------------------------------
*/}}
{{define "null_driver_gen.cpp"}}
/*
•* Copyright 2015 The Android Open Source Project
•*
•* Licensed under the Apache License, Version 2.0 (the "License");
•* you may not use this file except in compliance with the License.
•* You may obtain a copy of the License at
•*
•*      http://www.apache.org/licenses/LICENSE-2.0
•*
•* Unless required by applicable law or agreed to in writing, software
•* distributed under the License is distributed on an "AS IS" BASIS,
•* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
•* See the License for the specific language governing permissions and
•* limitations under the License.
•*/
// WARNING: This file is generated. See ../README.md for instructions.
#include "null_driver_gen.h"
#include <algorithm>
using namespace null_driver;
namespace {
struct NameProc {
    const char* name;
    PFN_vkVoidFunction proc;
};
PFN_vkVoidFunction Lookup(const char* name,
                          const NameProc* begin,
                          const NameProc* end) {
    const auto& entry = std::lower_bound(
        begin, end, name,
        [](const NameProc& e, const char* n) { return strcmp(e.name, n) < 0; });
    if (entry == end || strcmp(entry->name, name) != 0)
        return nullptr;
    return entry->proc;
}
template <size_t N>
PFN_vkVoidFunction Lookup(const char* name, const NameProc (&procs)[N]) {
    return Lookup(name, procs, procs + N);
}
const NameProc kGlobalProcs[] = {«
  // clang-format off
  {{range $f := SortBy (AllCommands $) "FunctionName"}}
    {{if and (Macro "IsDriverFunction" $f) (eq (Macro "Vtbl" $f) "Global")}}
      {"{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
        static_cast<{{Macro "FunctionPtrName" $f}}>(§
          {{Macro "BaseName" $f}}))},
    {{end}}
  {{end}}
  // clang-format on
»};
const NameProc kInstanceProcs[] = {«
  // clang-format off
  {{range $f := SortBy (AllCommands $) "FunctionName"}}
    {{if (Macro "IsDriverFunction" $f)}}
      {"{{$f.Name}}", reinterpret_cast<PFN_vkVoidFunction>(§
        static_cast<{{Macro "FunctionPtrName" $f}}>(§
          {{Macro "BaseName" $f}}))},
    {{end}}
  {{end}}
  // clang-format on
»};
} // namespace
namespace null_driver {
PFN_vkVoidFunction GetGlobalProcAddr(const char* name) {
    return Lookup(name, kGlobalProcs);
}
PFN_vkVoidFunction GetInstanceProcAddr(const char* name) {«
    PFN_vkVoidFunction pfn;
    if ((pfn = Lookup(name, kInstanceProcs)))
        return pfn;
    if (strcmp(name, "vkGetSwapchainGrallocUsageANDROID") == 0)
        return reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkGetSwapchainGrallocUsageANDROID>(GetSwapchainGrallocUsageANDROID));
    if (strcmp(name, "vkAcquireImageANDROID") == 0)
        return reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkAcquireImageANDROID>(AcquireImageANDROID));
    if (strcmp(name, "vkQueueSignalReleaseImageANDROID") == 0)
        return reinterpret_cast<PFN_vkVoidFunction>(static_cast<PFN_vkQueueSignalReleaseImageANDROID>(QueueSignalReleaseImageANDROID));
    return nullptr;
»}
} // namespace null_driver
{{end}}


{{/*
-------------------------------------------------------------------------------
  Emits a function name without the "vk" prefix.
-------------------------------------------------------------------------------
*/}}
{{define "BaseName"}}
  {{AssertType $ "Function"}}
  {{TrimPrefix "vk" $.Name}}
{{end}}


{{/*
------------------------------------------------------------------------------
  Emits 'true' if the API function is implemented by the driver.
------------------------------------------------------------------------------
*/}}
{{define "IsDriverFunction"}}
  {{AssertType $ "Function"}}

  {{if not (GetAnnotation $ "pfn")}}
    {{$ext := GetAnnotation $ "extension"}}
    {{if $ext}}
      {{Macro "IsDriverExtension" $ext}}
    {{else}}
      true
    {{end}}
  {{end}}
{{end}}


{{/*
------------------------------------------------------------------------------
  Reports whether an extension is implemented by the driver.
------------------------------------------------------------------------------
*/}}
{{define "IsDriverExtension"}}
  {{$ext := index $.Arguments 0}}
  {{     if eq $ext "VK_ANDROID_native_buffer"}}true
  {{else if eq $ext "VK_EXT_debug_report"}}true
  {{end}}
{{end}}