OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "vk/GrVkExtensions.h" | 8 #include "vk/GrVkExtensions.h" |
9 #include "vk/GrVkUtil.h" | 9 #include "vk/GrVkUtil.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 return -1; | 23 return -1; |
24 } | 24 } |
25 SkString extensionStr(ext); | 25 SkString extensionStr(ext); |
26 int idx = SkTSearch<SkString, extension_compare>(&strings.front(), | 26 int idx = SkTSearch<SkString, extension_compare>(&strings.front(), |
27 strings.count(), | 27 strings.count(), |
28 extensionStr, | 28 extensionStr, |
29 sizeof(SkString)); | 29 sizeof(SkString)); |
30 return idx; | 30 return idx; |
31 } | 31 } |
32 | 32 |
33 GrVkExtensions::GrVkExtensions(const GrVkExtensions& that) | 33 #define GET_PROC_LOCAL(inst, F) PFN_vk ## F F = (PFN_vk ## F) vkGetInstanceProcA
ddr(inst, "vk" #F) |
34 : fInstanceExtensionStrings(new SkTArray<SkString>) | |
35 , fDeviceExtensionStrings(new SkTArray<SkString>) | |
36 , fInstanceLayerStrings(new SkTArray<SkString>) | |
37 , fDeviceLayerStrings(new SkTArray<SkString>) { | |
38 *this = that; | |
39 } | |
40 | 34 |
41 GrVkExtensions& GrVkExtensions::operator=(const GrVkExtensions& that) { | 35 bool GrVkExtensions::initInstance(uint32_t specVersion) { |
42 *fInstanceExtensionStrings = *that.fInstanceExtensionStrings; | |
43 *fDeviceExtensionStrings = *that.fDeviceExtensionStrings; | |
44 *fInstanceLayerStrings = *that.fInstanceLayerStrings; | |
45 *fDeviceLayerStrings = *that.fDeviceLayerStrings; | |
46 | 36 |
47 fInitialized = that.fInitialized; | 37 GET_PROC_LOCAL(nullptr, EnumerateInstanceExtensionProperties); |
48 return *this; | 38 GET_PROC_LOCAL(nullptr, EnumerateInstanceLayerProperties); |
49 } | |
50 | 39 |
51 bool GrVkExtensions::init( | |
52 uint32_t specVersion, | |
53 VkPhysicalDevice physDev, | |
54 PFN_vkEnumerateInstanceExtensionProperties enumerateInstanceExtensionPropert
ies, | |
55 PFN_vkEnumerateDeviceExtensionProperties enumerateDeviceExtensionProperties, | |
56 PFN_vkEnumerateInstanceLayerProperties enumerateInstanceLayerProperties, | |
57 PFN_vkEnumerateDeviceLayerProperties enumerateDeviceLayerProperties) { | |
58 fInitialized = false; | |
59 this->reset(); | |
60 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | 40 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; |
61 | 41 |
62 if (!enumerateInstanceExtensionProperties || | 42 if (!EnumerateInstanceExtensionProperties || |
63 !enumerateDeviceExtensionProperties || | 43 !EnumerateInstanceLayerProperties) { |
64 !enumerateInstanceLayerProperties || | |
65 !enumerateDeviceLayerProperties) { | |
66 return false; | 44 return false; |
67 } | 45 } |
68 | 46 |
69 // instance layers | 47 // instance layers |
70 uint32_t layerCount = 0; | 48 uint32_t layerCount = 0; |
71 VkResult res = enumerateInstanceLayerProperties(&layerCount, nullptr); | 49 VkResult res = EnumerateInstanceLayerProperties(&layerCount, nullptr); |
72 if (VK_SUCCESS != res) { | 50 if (VK_SUCCESS != res) { |
73 return false; | 51 return false; |
74 } | 52 } |
75 VkLayerProperties* layers = new VkLayerProperties[layerCount]; | 53 VkLayerProperties* layers = new VkLayerProperties[layerCount]; |
76 res = enumerateInstanceLayerProperties(&layerCount, layers); | 54 res = EnumerateInstanceLayerProperties(&layerCount, layers); |
77 if (VK_SUCCESS != res) { | 55 if (VK_SUCCESS != res) { |
78 return false; | 56 return false; |
79 } | 57 } |
80 for (uint32_t i = 0; i < layerCount; ++i) { | 58 for (uint32_t i = 0; i < layerCount; ++i) { |
81 if (specVersion >= layers[i].specVersion) { | 59 if (specVersion >= layers[i].specVersion) { |
82 fInstanceLayerStrings->push_back() = layers[i].layerName; | 60 fInstanceLayerStrings->push_back() = layers[i].layerName; |
83 } | 61 } |
84 } | 62 } |
85 delete[] layers; | 63 delete[] layers; |
86 if (!fInstanceLayerStrings->empty()) { | 64 if (!fInstanceLayerStrings->empty()) { |
87 SkTQSort(&fInstanceLayerStrings->front(), &fInstanceLayerStrings->back()
, cmp); | 65 SkTQSort(&fInstanceLayerStrings->front(), &fInstanceLayerStrings->back()
, cmp); |
88 } | 66 } |
89 | 67 |
90 // instance extensions | 68 // instance extensions |
91 // via Vulkan implementation and implicitly enabled layers | 69 // via Vulkan implementation and implicitly enabled layers |
92 uint32_t extensionCount = 0; | 70 uint32_t extensionCount = 0; |
93 res = enumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr
); | 71 res = EnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr
); |
94 if (VK_SUCCESS != res) { | 72 if (VK_SUCCESS != res) { |
95 return false; | 73 return false; |
96 } | 74 } |
97 VkExtensionProperties* extensions = new VkExtensionProperties[extensionCount
]; | 75 VkExtensionProperties* extensions = new VkExtensionProperties[extensionCount
]; |
98 res = enumerateInstanceExtensionProperties(nullptr, &extensionCount, extensi
ons); | 76 res = EnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensi
ons); |
99 if (VK_SUCCESS != res) { | 77 if (VK_SUCCESS != res) { |
100 return false; | 78 return false; |
101 } | 79 } |
102 for (uint32_t i = 0; i < extensionCount; ++i) { | 80 for (uint32_t i = 0; i < extensionCount; ++i) { |
103 if (specVersion >= extensions[i].specVersion) { | 81 if (specVersion >= extensions[i].specVersion) { |
104 fInstanceExtensionStrings->push_back() = extensions[i].extensionName
; | 82 fInstanceExtensionStrings->push_back() = extensions[i].extensionName
; |
105 } | 83 } |
106 } | 84 } |
107 delete [] extensions; | 85 delete [] extensions; |
108 // sort so we can search | 86 // sort so we can search |
109 if (!fInstanceExtensionStrings->empty()) { | 87 if (!fInstanceExtensionStrings->empty()) { |
110 SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensionStrings
->back(), cmp); | 88 SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensionStrings
->back(), cmp); |
111 } | 89 } |
112 // via explicitly enabled layers | 90 // via explicitly enabled layers |
113 layerCount = fInstanceLayerStrings->count(); | 91 layerCount = fInstanceLayerStrings->count(); |
114 for (uint32_t layerIndex = 0; layerIndex < layerCount; ++layerIndex) { | 92 for (uint32_t layerIndex = 0; layerIndex < layerCount; ++layerIndex) { |
115 uint32_t extensionCount = 0; | 93 uint32_t extensionCount = 0; |
116 res = enumerateInstanceExtensionProperties((*fInstanceLayerStrings)[laye
rIndex].c_str(), | 94 res = EnumerateInstanceExtensionProperties((*fInstanceLayerStrings)[laye
rIndex].c_str(), |
117 &extensionCount, nullptr); | 95 &extensionCount, nullptr); |
118 if (VK_SUCCESS != res) { | 96 if (VK_SUCCESS != res) { |
119 return false; | 97 return false; |
120 } | 98 } |
121 VkExtensionProperties* extensions = new VkExtensionProperties[extensionC
ount]; | 99 VkExtensionProperties* extensions = new VkExtensionProperties[extensionC
ount]; |
122 res = enumerateInstanceExtensionProperties((*fInstanceLayerStrings)[laye
rIndex].c_str(), | 100 res = EnumerateInstanceExtensionProperties((*fInstanceLayerStrings)[laye
rIndex].c_str(), |
123 &extensionCount, extensions); | 101 &extensionCount, extensions); |
124 if (VK_SUCCESS != res) { | 102 if (VK_SUCCESS != res) { |
125 return false; | 103 return false; |
126 } | 104 } |
127 for (uint32_t i = 0; i < extensionCount; ++i) { | 105 for (uint32_t i = 0; i < extensionCount; ++i) { |
128 // if not already in the list, add it | 106 // if not already in the list, add it |
129 if (specVersion >= extensions[i].specVersion && | 107 if (specVersion >= extensions[i].specVersion && |
130 find_string(*fInstanceExtensionStrings, extensions[i].extensionN
ame) < 0) { | 108 find_string(*fInstanceExtensionStrings, extensions[i].extensionN
ame) < 0) { |
131 fInstanceExtensionStrings->push_back() = extensions[i].extension
Name; | 109 fInstanceExtensionStrings->push_back() = extensions[i].extension
Name; |
132 SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensio
nStrings->back(), | 110 SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensio
nStrings->back(), |
133 cmp); | 111 cmp); |
134 } | 112 } |
135 } | 113 } |
136 delete[] extensions; | 114 delete[] extensions; |
137 } | 115 } |
138 | 116 |
| 117 return true; |
| 118 } |
| 119 |
| 120 bool GrVkExtensions::initDevice(uint32_t specVersion, VkInstance inst, VkPhysica
lDevice physDev) { |
| 121 |
| 122 GET_PROC_LOCAL(inst, EnumerateDeviceExtensionProperties); |
| 123 GET_PROC_LOCAL(inst, EnumerateDeviceLayerProperties); |
| 124 |
| 125 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; |
| 126 |
| 127 if (!EnumerateDeviceExtensionProperties || |
| 128 !EnumerateDeviceLayerProperties) { |
| 129 return false; |
| 130 } |
| 131 |
139 // device layers | 132 // device layers |
140 layerCount = 0; | 133 uint32_t layerCount = 0; |
141 res = enumerateDeviceLayerProperties(physDev, &layerCount, nullptr); | 134 VkResult res = EnumerateDeviceLayerProperties(physDev, &layerCount, nullptr)
; |
142 if (VK_SUCCESS != res) { | 135 if (VK_SUCCESS != res) { |
143 return false; | 136 return false; |
144 } | 137 } |
145 layers = new VkLayerProperties[layerCount]; | 138 VkLayerProperties* layers = new VkLayerProperties[layerCount]; |
146 res = enumerateDeviceLayerProperties(physDev, &layerCount, layers); | 139 res = EnumerateDeviceLayerProperties(physDev, &layerCount, layers); |
147 if (VK_SUCCESS != res) { | 140 if (VK_SUCCESS != res) { |
148 return false; | 141 return false; |
149 } | 142 } |
150 for (uint32_t i = 0; i < layerCount; ++i) { | 143 for (uint32_t i = 0; i < layerCount; ++i) { |
151 if (specVersion >= layers[i].specVersion) { | 144 if (specVersion >= layers[i].specVersion) { |
152 fDeviceLayerStrings->push_back() = layers[i].layerName; | 145 fDeviceLayerStrings->push_back() = layers[i].layerName; |
153 } | 146 } |
154 } | 147 } |
155 delete[] layers; | 148 delete[] layers; |
156 if (!fDeviceLayerStrings->empty()) { | 149 if (!fDeviceLayerStrings->empty()) { |
157 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | 150 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; |
158 SkTQSort(&fDeviceLayerStrings->front(), &fDeviceLayerStrings->back(), cm
p); | 151 SkTQSort(&fDeviceLayerStrings->front(), &fDeviceLayerStrings->back(), cm
p); |
159 } | 152 } |
160 | 153 |
161 // device extensions | 154 // device extensions |
162 // via Vulkan implementation and implicitly enabled layers | 155 // via Vulkan implementation and implicitly enabled layers |
163 extensionCount = 0; | 156 uint32_t extensionCount = 0; |
164 res = enumerateDeviceExtensionProperties(physDev, nullptr, &extensionCount,
nullptr); | 157 res = EnumerateDeviceExtensionProperties(physDev, nullptr, &extensionCount,
nullptr); |
165 if (VK_SUCCESS != res) { | 158 if (VK_SUCCESS != res) { |
166 return false; | 159 return false; |
167 } | 160 } |
168 extensions = new VkExtensionProperties[extensionCount]; | 161 VkExtensionProperties* extensions = new VkExtensionProperties[extensionCount
]; |
169 res = enumerateDeviceExtensionProperties(physDev, nullptr, &extensionCount,
extensions); | 162 res = EnumerateDeviceExtensionProperties(physDev, nullptr, &extensionCount,
extensions); |
170 if (VK_SUCCESS != res) { | 163 if (VK_SUCCESS != res) { |
171 return false; | 164 return false; |
172 } | 165 } |
173 for (uint32_t i = 0; i < extensionCount; ++i) { | 166 for (uint32_t i = 0; i < extensionCount; ++i) { |
174 if (specVersion >= extensions[i].specVersion) { | 167 if (specVersion >= extensions[i].specVersion) { |
175 fDeviceExtensionStrings->push_back() = extensions[i].extensionName; | 168 fDeviceExtensionStrings->push_back() = extensions[i].extensionName; |
176 } | 169 } |
177 } | 170 } |
178 delete[] extensions; | 171 delete[] extensions; |
179 if (!fDeviceExtensionStrings->empty()) { | 172 if (!fDeviceExtensionStrings->empty()) { |
180 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | 173 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; |
181 SkTQSort(&fDeviceExtensionStrings->front(), &fDeviceExtensionStrings->ba
ck(), cmp); | 174 SkTQSort(&fDeviceExtensionStrings->front(), &fDeviceExtensionStrings->ba
ck(), cmp); |
182 } | 175 } |
183 // via explicitly enabled layers | 176 // via explicitly enabled layers |
184 layerCount = fDeviceLayerStrings->count(); | 177 layerCount = fDeviceLayerStrings->count(); |
185 for (uint32_t layerIndex = 0; layerIndex < layerCount; ++layerIndex) { | 178 for (uint32_t layerIndex = 0; layerIndex < layerCount; ++layerIndex) { |
186 uint32_t extensionCount = 0; | 179 uint32_t extensionCount = 0; |
187 res = enumerateDeviceExtensionProperties(physDev, | 180 res = EnumerateDeviceExtensionProperties(physDev, |
188 (*fDeviceLayerStrings)[layerInd
ex].c_str(), | 181 (*fDeviceLayerStrings)[layerIndex].c_str(), |
189 &extensionCount, nullptr); | 182 &extensionCount, nullptr); |
190 if (VK_SUCCESS != res) { | 183 if (VK_SUCCESS != res) { |
191 return false; | 184 return false; |
192 } | 185 } |
193 VkExtensionProperties* extensions = new VkExtensionProperties[extensionC
ount]; | 186 VkExtensionProperties* extensions = new VkExtensionProperties[extensionC
ount]; |
194 res = enumerateDeviceExtensionProperties(physDev, | 187 res = EnumerateDeviceExtensionProperties(physDev, |
195 (*fDeviceLayerStrings)[layerInd
ex].c_str(), | 188 (*fDeviceLayerStrings)[layerIndex].c_str(), |
196 &extensionCount, extensions); | 189 &extensionCount, extensions); |
197 if (VK_SUCCESS != res) { | 190 if (VK_SUCCESS != res) { |
198 return false; | 191 return false; |
199 } | 192 } |
200 for (uint32_t i = 0; i < extensionCount; ++i) { | 193 for (uint32_t i = 0; i < extensionCount; ++i) { |
201 // if not already in the list, add it | 194 // if not already in the list, add it |
202 if (specVersion >= extensions[i].specVersion && | 195 if (specVersion >= extensions[i].specVersion && |
203 find_string(*fDeviceExtensionStrings, extensions[i].extensionNam
e) < 0) { | 196 find_string(*fDeviceExtensionStrings, extensions[i].extensionNam
e) < 0) { |
204 fDeviceExtensionStrings->push_back() = extensions[i].extensionNa
me; | 197 fDeviceExtensionStrings->push_back() = extensions[i].extensionNa
me; |
205 SkTQSort(&fDeviceExtensionStrings->front(), &fDeviceExtensionStr
ings->back(), cmp); | 198 SkTQSort(&fDeviceExtensionStrings->front(), &fDeviceExtensionStr
ings->back(), cmp); |
206 } | 199 } |
207 } | 200 } |
208 delete[] extensions; | 201 delete[] extensions; |
209 } | 202 } |
210 | 203 |
211 fInitialized = true; | |
212 return true; | 204 return true; |
213 } | 205 } |
214 | 206 |
215 | |
216 bool GrVkExtensions::hasInstanceExtension(const char ext[]) const { | 207 bool GrVkExtensions::hasInstanceExtension(const char ext[]) const { |
217 SkASSERT(fInitialized); | |
218 | |
219 return find_string(*fInstanceExtensionStrings, ext) >= 0; | 208 return find_string(*fInstanceExtensionStrings, ext) >= 0; |
220 } | 209 } |
221 | 210 |
222 bool GrVkExtensions::hasDeviceExtension(const char ext[]) const { | 211 bool GrVkExtensions::hasDeviceExtension(const char ext[]) const { |
223 SkASSERT(fInitialized); | |
224 | |
225 return find_string(*fDeviceExtensionStrings, ext) >= 0; | 212 return find_string(*fDeviceExtensionStrings, ext) >= 0; |
226 } | 213 } |
227 | 214 |
228 bool GrVkExtensions::hasInstanceLayer(const char ext[]) const { | 215 bool GrVkExtensions::hasInstanceLayer(const char ext[]) const { |
229 SkASSERT(fInitialized); | |
230 | |
231 return find_string(*fInstanceLayerStrings, ext) >= 0; | 216 return find_string(*fInstanceLayerStrings, ext) >= 0; |
232 } | 217 } |
233 | 218 |
234 bool GrVkExtensions::hasDeviceLayer(const char ext[]) const { | 219 bool GrVkExtensions::hasDeviceLayer(const char ext[]) const { |
235 SkASSERT(fInitialized); | |
236 | |
237 return find_string(*fDeviceLayerStrings, ext) >= 0; | 220 return find_string(*fDeviceLayerStrings, ext) >= 0; |
238 } | 221 } |
239 | 222 |
240 | |
241 bool GrVkExtensions::removeInstanceExtension(const char ext[]) { | |
242 SkASSERT(fInitialized); | |
243 int idx = find_string(*fInstanceExtensionStrings, ext); | |
244 if (idx >= 0) { | |
245 // This is not terribly effecient but we really only expect this functio
n to be called at | |
246 // most a handful of times when our test programs start. | |
247 SkAutoTDelete< SkTArray<SkString> > oldStrings(fInstanceExtensionStrings
.release()); | |
248 fInstanceExtensionStrings.reset(new SkTArray<SkString>(oldStrings->count
() - 1)); | |
249 fInstanceExtensionStrings->push_back_n(idx, &oldStrings->front()); | |
250 fInstanceExtensionStrings->push_back_n(oldStrings->count() - idx-1, &(*o
ldStrings)[idx]+1); | |
251 return true; | |
252 } else { | |
253 return false; | |
254 } | |
255 } | |
256 | |
257 bool GrVkExtensions::removeDeviceExtension(const char ext[]) { | |
258 SkASSERT(fInitialized); | |
259 int idx = find_string(*fDeviceExtensionStrings, ext); | |
260 if (idx >= 0) { | |
261 // This is not terribly effecient but we really only expect this functio
n to be called at | |
262 // most a handful of times when our test programs start. | |
263 SkAutoTDelete< SkTArray<SkString> > oldStrings(fDeviceExtensionStrings.r
elease()); | |
264 fDeviceExtensionStrings.reset(new SkTArray<SkString>(oldStrings->count()
- 1)); | |
265 fDeviceExtensionStrings->push_back_n(idx, &oldStrings->front()); | |
266 fDeviceExtensionStrings->push_back_n(oldStrings->count() - idx-1, &(*old
Strings)[idx] + 1); | |
267 return true; | |
268 } | |
269 else { | |
270 return false; | |
271 } | |
272 } | |
273 | |
274 bool GrVkExtensions::removeInstanceLayer(const char ext[]) { | |
275 SkASSERT(fInitialized); | |
276 int idx = find_string(*fInstanceLayerStrings, ext); | |
277 if (idx >= 0) { | |
278 // This is not terribly effecient but we really only expect this functio
n to be called at | |
279 // most a handful of times when our test programs start. | |
280 SkAutoTDelete< SkTArray<SkString> > oldStrings(fInstanceLayerStrings.rel
ease()); | |
281 fInstanceLayerStrings.reset(new SkTArray<SkString>(oldStrings->count() -
1)); | |
282 fInstanceLayerStrings->push_back_n(idx, &oldStrings->front()); | |
283 fInstanceLayerStrings->push_back_n(oldStrings->count() - idx - 1, &(*old
Strings)[idx] + 1); | |
284 return true; | |
285 } | |
286 else { | |
287 return false; | |
288 } | |
289 } | |
290 | |
291 bool GrVkExtensions::removeDeviceLayer(const char ext[]) { | |
292 SkASSERT(fInitialized); | |
293 int idx = find_string(*fDeviceLayerStrings, ext); | |
294 if (idx >= 0) { | |
295 // This is not terribly effecient but we really only expect this functio
n to be called at | |
296 // most a handful of times when our test programs start. | |
297 SkAutoTDelete< SkTArray<SkString> > oldStrings(fDeviceLayerStrings.relea
se()); | |
298 fDeviceLayerStrings.reset(new SkTArray<SkString>(oldStrings->count() - 1
)); | |
299 fDeviceLayerStrings->push_back_n(idx, &oldStrings->front()); | |
300 fDeviceLayerStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldSt
rings)[idx] + 1); | |
301 return true; | |
302 } | |
303 else { | |
304 return false; | |
305 } | |
306 } | |
307 | |
308 void GrVkExtensions::addInstanceExtension(const char ext[]) { | |
309 int idx = find_string(*fInstanceExtensionStrings, ext); | |
310 if (idx < 0) { | |
311 // This is not the most effecient approach since we end up doing a full
sort of the | |
312 // extensions after the add | |
313 fInstanceExtensionStrings->push_back().set(ext); | |
314 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | |
315 SkTQSort(&fInstanceExtensionStrings->front(), &fInstanceExtensionStrings
->back(), cmp); | |
316 } | |
317 } | |
318 | |
319 void GrVkExtensions::addDeviceExtension(const char ext[]) { | |
320 int idx = find_string(*fDeviceExtensionStrings, ext); | |
321 if (idx < 0) { | |
322 // This is not the most effecient approach since we end up doing a full
sort of the | |
323 // extensions after the add | |
324 fDeviceExtensionStrings->push_back().set(ext); | |
325 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | |
326 SkTQSort(&fDeviceExtensionStrings->front(), &fDeviceExtensionStrings->ba
ck(), cmp); | |
327 } | |
328 } | |
329 | |
330 void GrVkExtensions::addInstanceLayer(const char ext[]) { | |
331 int idx = find_string(*fInstanceLayerStrings, ext); | |
332 if (idx < 0) { | |
333 // This is not the most effecient approach since we end up doing a full
sort of the | |
334 // extensions after the add | |
335 fInstanceLayerStrings->push_back().set(ext); | |
336 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | |
337 SkTQSort(&fInstanceLayerStrings->front(), &fInstanceLayerStrings->back()
, cmp); | |
338 } | |
339 } | |
340 | |
341 void GrVkExtensions::addDeviceLayer(const char ext[]) { | |
342 int idx = find_string(*fDeviceLayerStrings, ext); | |
343 if (idx < 0) { | |
344 // This is not the most effecient approach since we end up doing a full
sort of the | |
345 // extensions after the add | |
346 fDeviceLayerStrings->push_back().set(ext); | |
347 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | |
348 SkTQSort(&fDeviceLayerStrings->front(), &fDeviceLayerStrings->back(), cm
p); | |
349 } | |
350 } | |
351 | |
352 void GrVkExtensions::print(const char* sep) const { | 223 void GrVkExtensions::print(const char* sep) const { |
353 if (nullptr == sep) { | 224 if (nullptr == sep) { |
354 sep = " "; | 225 sep = " "; |
355 } | 226 } |
356 int cnt = fInstanceExtensionStrings->count(); | 227 int cnt = fInstanceExtensionStrings->count(); |
357 SkDebugf("Instance Extensions: "); | 228 SkDebugf("Instance Extensions: "); |
358 for (int i = 0; i < cnt; ++i) { | 229 for (int i = 0; i < cnt; ++i) { |
359 SkDebugf("%s%s", (*fInstanceExtensionStrings)[i].c_str(), (i < cnt - 1)
? sep : ""); | 230 SkDebugf("%s%s", (*fInstanceExtensionStrings)[i].c_str(), (i < cnt - 1)
? sep : ""); |
360 } | 231 } |
361 cnt = fDeviceExtensionStrings->count(); | 232 cnt = fDeviceExtensionStrings->count(); |
362 SkDebugf("\nDevice Extensions: "); | 233 SkDebugf("\nDevice Extensions: "); |
363 for (int i = 0; i < cnt; ++i) { | 234 for (int i = 0; i < cnt; ++i) { |
364 SkDebugf("%s%s", (*fDeviceExtensionStrings)[i].c_str(), (i < cnt - 1) ?
sep : ""); | 235 SkDebugf("%s%s", (*fDeviceExtensionStrings)[i].c_str(), (i < cnt - 1) ?
sep : ""); |
365 } | 236 } |
366 cnt = fInstanceLayerStrings->count(); | 237 cnt = fInstanceLayerStrings->count(); |
367 SkDebugf("\nInstance Layers: "); | 238 SkDebugf("\nInstance Layers: "); |
368 for (int i = 0; i < cnt; ++i) { | 239 for (int i = 0; i < cnt; ++i) { |
369 SkDebugf("%s%s", (*fInstanceLayerStrings)[i].c_str(), (i < cnt - 1) ? se
p : ""); | 240 SkDebugf("%s%s", (*fInstanceLayerStrings)[i].c_str(), (i < cnt - 1) ? se
p : ""); |
370 } | 241 } |
371 cnt = fDeviceLayerStrings->count(); | 242 cnt = fDeviceLayerStrings->count(); |
372 SkDebugf("\nDevice Layers: "); | 243 SkDebugf("\nDevice Layers: "); |
373 for (int i = 0; i < cnt; ++i) { | 244 for (int i = 0; i < cnt; ++i) { |
374 SkDebugf("%s%s", (*fDeviceLayerStrings)[i].c_str(), (i < cnt - 1) ? sep
: ""); | 245 SkDebugf("%s%s", (*fDeviceLayerStrings)[i].c_str(), (i < cnt - 1) ? sep
: ""); |
375 } | 246 } |
376 } | 247 } |
OLD | NEW |