1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2020 The Khronos Group Inc.
6 * Copyright (c) 2020 Google LLC
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 *//*!
21 * \file
22 * \brief VK_EXT_device_memory_report extension tests.
23 *//*--------------------------------------------------------------------*/
24
25 #include "vktMemoryDeviceMemoryReportTests.hpp"
26
27 #include "vktCustomInstancesDevices.hpp"
28 #include "vktExternalMemoryUtil.hpp"
29 #include "vktTestCaseUtil.hpp"
30
31 #include "vkDeviceUtil.hpp"
32 #include "vkObjUtil.hpp"
33 #include "vkQueryUtil.hpp"
34 #include "vkRefUtil.hpp"
35 #include "vkTypeUtil.hpp"
36
37 #include "tcuCommandLine.hpp"
38 #include "tcuTestCase.hpp"
39 #include "tcuTestLog.hpp"
40
41 #include "deSharedPtr.hpp"
42
43 #include <set>
44 #include <vector>
45
46 namespace vkt
47 {
48 namespace memory
49 {
50 namespace
51 {
52
53 #define VK_DESCRIPTOR_TYPE_LAST (VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT + 1)
54
55 using namespace vk;
56 using namespace vkt::ExternalMemoryUtil;
57 using de::MovePtr;
58 using de::SharedPtr;
59
60 enum CallbackMarker
61 {
62 MARKER_UNKNOWN = 0,
63 MARKER_ALLOCATE,
64 MARKER_FREE,
65 MARKER_IMPORT,
66 MARKER_UNIMPORT,
67 MARKER_ALLOCATION_FAILED
68 };
69
70 class CallbackRecorder
71 {
72 public:
CallbackRecorder(void)73 CallbackRecorder(void): mMarker(MARKER_UNKNOWN) {}
74 ~CallbackRecorder(void) = default;
75
76 typedef std::vector<std::pair<VkDeviceMemoryReportCallbackDataEXT, CallbackMarker>>::const_iterator RecordIterator;
77
getRecordsBegin(void) const78 RecordIterator getRecordsBegin (void) const
79 {
80 return mRecords.begin();
81 }
82
getRecordsEnd(void) const83 RecordIterator getRecordsEnd (void) const
84 {
85 return mRecords.end();
86 }
87
getNumRecords(void) const88 std::size_t getNumRecords (void) const
89 {
90 return mRecords.size();
91 }
92
setCallbackMarker(CallbackMarker marker)93 void setCallbackMarker(CallbackMarker marker)
94 {
95 mMarker = marker;
96 }
97
callbackInternal(const VkDeviceMemoryReportCallbackDataEXT * pCallbackData)98 void callbackInternal (const VkDeviceMemoryReportCallbackDataEXT* pCallbackData)
99 {
100 mRecords.emplace_back(*pCallbackData, mMarker);
101 }
102
callback(const struct VkDeviceMemoryReportCallbackDataEXT * pCallbackData,void * pUserData)103 static VKAPI_ATTR void VKAPI_CALL callback (const struct VkDeviceMemoryReportCallbackDataEXT* pCallbackData, void* pUserData)
104 {
105 reinterpret_cast<CallbackRecorder*>(pUserData)->callbackInternal(pCallbackData);
106 }
107
108 private:
109 typedef std::vector<std::pair<VkDeviceMemoryReportCallbackDataEXT, CallbackMarker>> Records;
110
111 Records mRecords;
112 CallbackMarker mMarker;
113 };
114
115 struct Environment
116 {
117 const PlatformInterface& vkp;
118 const InstanceInterface& vki;
119 VkInstance instance;
120 VkPhysicalDevice physicalDevice;
121 const DeviceInterface& vkd;
122 VkDevice device;
123 deUint32 queueFamilyIndex;
124 const BinaryCollection& programBinaries;
125 const tcu::CommandLine& commandLine;
126 const CallbackRecorder* recorder;
127
Environmentvkt::memory::__anond607d4f40111::Environment128 Environment (const PlatformInterface& vkp_,
129 const InstanceInterface& vki_,
130 VkInstance instance_,
131 VkPhysicalDevice physicalDevice_,
132 const DeviceInterface& vkd_,
133 VkDevice device_,
134 deUint32 queueFamilyIndex_,
135 const BinaryCollection& programBinaries_,
136 const tcu::CommandLine& commandLine_,
137 const CallbackRecorder* recorder_)
138 : vkp (vkp_)
139 , vki (vki_)
140 , instance (instance_)
141 , physicalDevice (physicalDevice_)
142 , vkd (vkd_)
143 , device (device_)
144 , queueFamilyIndex (queueFamilyIndex_)
145 , programBinaries (programBinaries_)
146 , commandLine (commandLine_)
147 , recorder (recorder_)
148 {
149 }
150 };
151
152 template<typename Case>
153 struct Dependency
154 {
155 typename Case::Resources resources;
156 Unique<typename Case::Type> object;
157
Dependencyvkt::memory::__anond607d4f40111::Dependency158 Dependency (const Environment& env, const typename Case::Parameters& params)
159 : resources (env, params)
160 , object (Case::create(env, resources, params))
161 {}
162 };
163
createDeviceWithMemoryReport(deBool isValidationEnabled,const PlatformInterface & vkp,VkInstance instance,const InstanceInterface & vki,VkPhysicalDevice physicalDevice,deUint32 queueFamilyIndex,const CallbackRecorder * recorder)164 static Move<VkDevice> createDeviceWithMemoryReport (deBool isValidationEnabled,
165 const PlatformInterface& vkp,
166 VkInstance instance,
167 const InstanceInterface& vki,
168 VkPhysicalDevice physicalDevice,
169 deUint32 queueFamilyIndex,
170 const CallbackRecorder* recorder)
171 {
172 const deUint32 queueCount = 1;
173 const float queuePriority = 1.0f;
174 const char* const enabledExtensions[] = {"VK_EXT_device_memory_report"};
175 const VkPhysicalDeviceDeviceMemoryReportFeaturesEXT deviceMemoryReportFeatures =
176 {
177 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT, // VkStructureType sType;
178 DE_NULL, // void* pNext;
179 VK_TRUE // VkBool32 deviceMemoryReport;
180 };
181 const VkDeviceDeviceMemoryReportCreateInfoEXT deviceMemoryReportCreateInfo =
182 {
183 VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT, // VkStructureType sType;
184 &deviceMemoryReportFeatures, // void* pNext;
185 (VkDeviceMemoryReportFlagsEXT)0, // VkDeviceMemoryReportFlagsEXT flags;
186 recorder->callback, // PFN_vkDeviceMemoryReportCallbackEXT pfnUserCallback;
187 (void*)recorder, // void* pUserData;
188 };
189 const VkDeviceQueueCreateInfo queueCreateInfo =
190 {
191 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType;
192 DE_NULL, // const void* pNext;
193 (VkDeviceQueueCreateFlags)0, // VkDeviceQueueCreateFlags flags;
194 queueFamilyIndex, // deUint32 queueFamilyIndex;
195 queueCount, // deUint32 queueCount;
196 &queuePriority, // const float* pQueuePriorities;
197 };
198 const VkDeviceCreateInfo deviceCreateInfo =
199 {
200 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType;
201 &deviceMemoryReportCreateInfo, // const void* pNext;
202 (VkDeviceCreateFlags)0, // VkDeviceCreateFlags flags;
203 queueCount, // uint32_t queueCreateInfoCount;
204 &queueCreateInfo, // const VkDeviceQueueCreateInfo* pQueueCreateInfos;
205 0u, // uint32_t enabledLayerCount
206 DE_NULL, // const char* const* ppEnabledLayerNames
207 DE_LENGTH_OF_ARRAY(enabledExtensions), // uint32_t enabledExtensionCount
208 DE_ARRAY_BEGIN(enabledExtensions), // const char* const* ppEnabledExtensionNames
209 DE_NULL, // const VkPhysicalDeviceFeatures* pEnabledFeatures
210 };
211
212 return createCustomDevice(isValidationEnabled, vkp, instance, vki, physicalDevice, &deviceCreateInfo);
213 }
214
215 struct Device
216 {
217 typedef VkDevice Type;
218
219 struct Parameters
220 {
Parametersvkt::memory::__anond607d4f40111::Device::Parameters221 Parameters (void) {}
222 };
223
224 struct Resources
225 {
Resourcesvkt::memory::__anond607d4f40111::Device::Resources226 Resources (const Environment&, const Parameters&) {}
227 };
228
createvkt::memory::__anond607d4f40111::Device229 static Move<VkDevice> create (const Environment& env, const Resources&, const Parameters&)
230 {
231 return createDeviceWithMemoryReport(env.commandLine.isValidationEnabled(), env.vkp, env.instance, env.vki, env.physicalDevice, env.queueFamilyIndex, env.recorder);
232 }
233 };
234
235 struct DeviceMemory
236 {
237 typedef VkDeviceMemory Type;
238
239 struct Parameters
240 {
241 VkDeviceSize size;
242 deUint32 memoryTypeIndex;
243
Parametersvkt::memory::__anond607d4f40111::DeviceMemory::Parameters244 Parameters (VkDeviceSize size_, deUint32 memoryTypeIndex_)
245 : size (size_)
246 , memoryTypeIndex (memoryTypeIndex_)
247 {
248 DE_ASSERT(memoryTypeIndex < VK_MAX_MEMORY_TYPES);
249 }
250 };
251
252 struct Resources
253 {
Resourcesvkt::memory::__anond607d4f40111::DeviceMemory::Resources254 Resources (const Environment&, const Parameters&) {}
255 };
256
createvkt::memory::__anond607d4f40111::DeviceMemory257 static Move<VkDeviceMemory> create (const Environment& env, const Resources&, const Parameters& params)
258 {
259 const VkMemoryAllocateInfo memoryAllocateInfo =
260 {
261 VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // VkStructureType sType;
262 DE_NULL, // const void* pNext;
263 params.size, // VkDeviceSize allocationSize;
264 params.memoryTypeIndex, // uint32_t memoryTypeIndex;
265 };
266
267 return allocateMemory(env.vkd, env.device, &memoryAllocateInfo);
268 }
269 };
270
getDeviceMemoryParameters(const VkMemoryRequirements & memReqs)271 DeviceMemory::Parameters getDeviceMemoryParameters (const VkMemoryRequirements& memReqs)
272 {
273 return DeviceMemory::Parameters(memReqs.size, deCtz32(memReqs.memoryTypeBits));
274 }
275
getDeviceMemoryParameters(const Environment & env,VkImage image)276 DeviceMemory::Parameters getDeviceMemoryParameters (const Environment& env, VkImage image)
277 {
278 return getDeviceMemoryParameters(getImageMemoryRequirements(env.vkd, env.device, image));
279 }
280
getDeviceMemoryParameters(const Environment & env,VkBuffer buffer)281 DeviceMemory::Parameters getDeviceMemoryParameters (const Environment& env, VkBuffer buffer)
282 {
283 return getDeviceMemoryParameters(getBufferMemoryRequirements(env.vkd, env.device, buffer));
284 }
285
286 struct Buffer
287 {
288 typedef VkBuffer Type;
289
290 struct Parameters
291 {
292 VkDeviceSize size;
293 VkBufferUsageFlags usage;
294
Parametersvkt::memory::__anond607d4f40111::Buffer::Parameters295 Parameters (VkDeviceSize size_,
296 VkBufferUsageFlags usage_)
297 : size (size_)
298 , usage (usage_)
299 {}
300 };
301
302 struct Resources
303 {
Resourcesvkt::memory::__anond607d4f40111::Buffer::Resources304 Resources (const Environment&, const Parameters&) {}
305 };
306
createvkt::memory::__anond607d4f40111::Buffer307 static Move<VkBuffer> create (const Environment& env, const Resources&, const Parameters& params)
308 {
309 const VkBufferCreateInfo bufferCreateInfo =
310 {
311 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
312 DE_NULL, // const void* pNext;
313 (VkBufferCreateFlags)0, // VkBufferCreateFlags flags;
314 params.size, // VkDeviceSize size;
315 params.usage, // VkBufferUsageFlags usage;
316 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
317 1u, // uint32_t queueFamilyIndexCount;
318 &env.queueFamilyIndex, // const uint32_t* pQueueFamilyIndices;
319 };
320
321 return createBuffer(env.vkd, env.device, &bufferCreateInfo);
322 }
323 };
324
325 struct BufferView
326 {
327 typedef VkBufferView Type;
328
329 struct Parameters
330 {
331 Buffer::Parameters buffer;
332 VkFormat format;
333 VkDeviceSize offset;
334 VkDeviceSize range;
335
Parametersvkt::memory::__anond607d4f40111::BufferView::Parameters336 Parameters (const Buffer::Parameters& buffer_,
337 VkFormat format_,
338 VkDeviceSize offset_,
339 VkDeviceSize range_)
340 : buffer (buffer_)
341 , format (format_)
342 , offset (offset_)
343 , range (range_)
344 {}
345 };
346
347 struct Resources
348 {
349 Dependency<Buffer> buffer;
350 Dependency<DeviceMemory> memory;
351
Resourcesvkt::memory::__anond607d4f40111::BufferView::Resources352 Resources (const Environment& env, const Parameters& params)
353 : buffer(env, params.buffer)
354 , memory(env, getDeviceMemoryParameters(env, *buffer.object))
355 {
356 VK_CHECK(env.vkd.bindBufferMemory(env.device, *buffer.object, *memory.object, 0));
357 }
358 };
359
createvkt::memory::__anond607d4f40111::BufferView360 static Move<VkBufferView> create (const Environment& env, const Resources& res, const Parameters& params)
361 {
362 const VkBufferViewCreateInfo bufferViewCreateInfo =
363 {
364 VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, // VkStructureType sType;
365 DE_NULL, // const void* pNext;
366 (VkBufferViewCreateFlags)0, // VkBufferViewCreateFlags flags;
367 *res.buffer.object, // VkBuffer buffer;
368 params.format, // VkFormat format;
369 params.offset, // VkDeviceSize offset;
370 params.range, // VkDeviceSize range;
371 };
372
373 return createBufferView(env.vkd, env.device, &bufferViewCreateInfo);
374 }
375 };
376
377 struct Image
378 {
379 typedef VkImage Type;
380
381 struct Parameters
382 {
383 VkImageCreateFlags flags;
384 VkImageType imageType;
385 VkFormat format;
386 VkExtent3D extent;
387 deUint32 mipLevels;
388 deUint32 arraySize;
389 VkSampleCountFlagBits samples;
390 VkImageTiling tiling;
391 VkImageUsageFlags usage;
392 VkImageLayout initialLayout;
393
Parametersvkt::memory::__anond607d4f40111::Image::Parameters394 Parameters (VkImageCreateFlags flags_,
395 VkImageType imageType_,
396 VkFormat format_,
397 VkExtent3D extent_,
398 deUint32 mipLevels_,
399 deUint32 arraySize_,
400 VkSampleCountFlagBits samples_,
401 VkImageTiling tiling_,
402 VkImageUsageFlags usage_,
403 VkImageLayout initialLayout_)
404 : flags (flags_)
405 , imageType (imageType_)
406 , format (format_)
407 , extent (extent_)
408 , mipLevels (mipLevels_)
409 , arraySize (arraySize_)
410 , samples (samples_)
411 , tiling (tiling_)
412 , usage (usage_)
413 , initialLayout (initialLayout_)
414 {}
415 };
416
417 struct Resources
418 {
Resourcesvkt::memory::__anond607d4f40111::Image::Resources419 Resources (const Environment&, const Parameters&) {}
420 };
421
createvkt::memory::__anond607d4f40111::Image422 static Move<VkImage> create (const Environment& env, const Resources&, const Parameters& params)
423 {
424 const VkImageCreateInfo imageCreateInfo =
425 {
426 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
427 DE_NULL, // const void* pNext;
428 params.flags, // VkImageCreateFlags flags;
429 params.imageType, // VkImageType imageType;
430 params.format, // VkFormat format;
431 params.extent, // VkExtent3D extent;
432 params.mipLevels, // uint32_t mipLevels;
433 params.arraySize, // uint32_t arrayLayers;
434 params.samples, // VkSampleCountFlagBits samples;
435 params.tiling, // VkImageTiling tiling;
436 params.usage, // VkImageUsageFlags usage;
437 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
438 1u, // uint32_t queueFamilyIndexCount;
439 &env.queueFamilyIndex, // const uint32_t* pQueueFamilyIndices;
440 params.initialLayout, // VkImageLayout initialLayout;
441 };
442
443 return createImage(env.vkd, env.device, &imageCreateInfo);
444 }
445 };
446
447 struct ImageView
448 {
449 typedef VkImageView Type;
450
451 struct Parameters
452 {
453 Image::Parameters image;
454 VkImageViewType viewType;
455 VkFormat format;
456 VkComponentMapping components;
457 VkImageSubresourceRange subresourceRange;
458
Parametersvkt::memory::__anond607d4f40111::ImageView::Parameters459 Parameters (const Image::Parameters& image_,
460 VkImageViewType viewType_,
461 VkFormat format_,
462 VkComponentMapping components_,
463 VkImageSubresourceRange subresourceRange_)
464 : image (image_)
465 , viewType (viewType_)
466 , format (format_)
467 , components (components_)
468 , subresourceRange (subresourceRange_)
469 {}
470 };
471
472 struct Resources
473 {
474 Dependency<Image> image;
475 Dependency<DeviceMemory> memory;
476
Resourcesvkt::memory::__anond607d4f40111::ImageView::Resources477 Resources (const Environment& env, const Parameters& params)
478 : image (env, params.image)
479 , memory(env, getDeviceMemoryParameters(env, *image.object))
480 {
481 VK_CHECK(env.vkd.bindImageMemory(env.device, *image.object, *memory.object, 0));
482 }
483 };
484
createvkt::memory::__anond607d4f40111::ImageView485 static Move<VkImageView> create (const Environment& env, const Resources& res, const Parameters& params)
486 {
487 const VkImageViewCreateInfo imageViewCreateInfo =
488 {
489 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
490 DE_NULL, // const void* pNext;
491 (VkImageViewCreateFlags)0, // VkImageViewCreateFlags flags;
492 *res.image.object, // VkImage image;
493 params.viewType, // VkImageViewType viewType;
494 params.format, // VkFormat format;
495 params.components, // VkComponentMapping components;
496 params.subresourceRange, // VkImageSubresourceRange subresourceRange;
497 };
498
499 return createImageView(env.vkd, env.device, &imageViewCreateInfo);
500 }
501 };
502
503 struct Semaphore
504 {
505 typedef VkSemaphore Type;
506
507 struct Parameters
508 {
509 VkSemaphoreCreateFlags flags;
510
Parametersvkt::memory::__anond607d4f40111::Semaphore::Parameters511 Parameters (VkSemaphoreCreateFlags flags_)
512 : flags(flags_)
513 {}
514 };
515
516 struct Resources
517 {
Resourcesvkt::memory::__anond607d4f40111::Semaphore::Resources518 Resources (const Environment&, const Parameters&) {}
519 };
520
createvkt::memory::__anond607d4f40111::Semaphore521 static Move<VkSemaphore> create (const Environment& env, const Resources&, const Parameters& params)
522 {
523 const VkSemaphoreCreateInfo semaphoreCreateInfo =
524 {
525 VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, // VkStructureType sType;
526 DE_NULL, // const void* pNext;
527 params.flags, // VkSemaphoreCreateFlags flags;
528 };
529
530 return createSemaphore(env.vkd, env.device, &semaphoreCreateInfo);
531 }
532 };
533
534 struct Fence
535 {
536 typedef VkFence Type;
537
538 struct Parameters
539 {
540 VkFenceCreateFlags flags;
541
Parametersvkt::memory::__anond607d4f40111::Fence::Parameters542 Parameters (VkFenceCreateFlags flags_)
543 : flags(flags_)
544 {}
545 };
546
547 struct Resources
548 {
Resourcesvkt::memory::__anond607d4f40111::Fence::Resources549 Resources (const Environment&, const Parameters&) {}
550 };
551
createvkt::memory::__anond607d4f40111::Fence552 static Move<VkFence> create (const Environment& env, const Resources&, const Parameters& params)
553 {
554 const VkFenceCreateInfo fenceCreateInfo =
555 {
556 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
557 DE_NULL, // const void* pNext;
558 params.flags, // VkFenceCreateFlags flags;
559 };
560
561 return createFence(env.vkd, env.device, &fenceCreateInfo);
562 }
563 };
564
565 struct Event
566 {
567 typedef VkEvent Type;
568
569 struct Parameters
570 {
571 VkEventCreateFlags flags;
572
Parametersvkt::memory::__anond607d4f40111::Event::Parameters573 Parameters (VkEventCreateFlags flags_)
574 : flags(flags_)
575 {}
576 };
577
578 struct Resources
579 {
Resourcesvkt::memory::__anond607d4f40111::Event::Resources580 Resources (const Environment&, const Parameters&) {}
581 };
582
createvkt::memory::__anond607d4f40111::Event583 static Move<VkEvent> create (const Environment& env, const Resources&, const Parameters& params)
584 {
585 const VkEventCreateInfo eventCreateInfo =
586 {
587 VK_STRUCTURE_TYPE_EVENT_CREATE_INFO, // VkStructureType sType;
588 DE_NULL, // const void* pNext;
589 params.flags, // VkEventCreateFlags flags;
590 };
591
592 return createEvent(env.vkd, env.device, &eventCreateInfo);
593 }
594 };
595
596 struct QueryPool
597 {
598 typedef VkQueryPool Type;
599
600 struct Parameters
601 {
602 VkQueryType queryType;
603 deUint32 entryCount;
604 VkQueryPipelineStatisticFlags pipelineStatistics;
605
Parametersvkt::memory::__anond607d4f40111::QueryPool::Parameters606 Parameters (VkQueryType queryType_,
607 deUint32 entryCount_,
608 VkQueryPipelineStatisticFlags pipelineStatistics_)
609 : queryType (queryType_)
610 , entryCount (entryCount_)
611 , pipelineStatistics (pipelineStatistics_)
612 {}
613 };
614
615 struct Resources
616 {
Resourcesvkt::memory::__anond607d4f40111::QueryPool::Resources617 Resources (const Environment&, const Parameters&) {}
618 };
619
createvkt::memory::__anond607d4f40111::QueryPool620 static Move<VkQueryPool> create (const Environment& env, const Resources&, const Parameters& params)
621 {
622 const VkQueryPoolCreateInfo queryPoolCreateInfo =
623 {
624 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, // VkStructureType sType;
625 DE_NULL, // const void* pNext;
626 (VkQueryPoolCreateFlags)0, // VkQueryPoolCreateFlags flags;
627 params.queryType, // VkQueryType queryType;
628 params.entryCount, // uint32_t queryCount;
629 params.pipelineStatistics, // VkQueryPipelineStatisticFlags pipelineStatistics;
630 };
631
632 return createQueryPool(env.vkd, env.device, &queryPoolCreateInfo);
633 }
634 };
635
636 struct ShaderModule
637 {
638 typedef VkShaderModule Type;
639
640 struct Parameters
641 {
642 VkShaderStageFlagBits shaderStage;
643 std::string binaryName;
644
Parametersvkt::memory::__anond607d4f40111::ShaderModule::Parameters645 Parameters (VkShaderStageFlagBits shaderStage_,
646 const std::string& binaryName_)
647 : shaderStage (shaderStage_)
648 , binaryName (binaryName_)
649 {}
650 };
651
652 struct Resources
653 {
654 const ProgramBinary& binary;
655
Resourcesvkt::memory::__anond607d4f40111::ShaderModule::Resources656 Resources (const Environment& env, const Parameters& params)
657 : binary(env.programBinaries.get(params.binaryName))
658 {}
659 };
660
getSourcevkt::memory::__anond607d4f40111::ShaderModule661 static const char* getSource (VkShaderStageFlagBits stage)
662 {
663 switch (stage)
664 {
665 case VK_SHADER_STAGE_VERTEX_BIT:
666 return "#version 310 es\n"
667 "layout(location = 0) in highp vec4 a_position;\n"
668 "void main () { gl_Position = a_position; }\n";
669
670 case VK_SHADER_STAGE_FRAGMENT_BIT:
671 return "#version 310 es\n"
672 "layout(location = 0) out mediump vec4 o_color;\n"
673 "void main () { o_color = vec4(1.0, 0.5, 0.25, 1.0); }";
674
675 case VK_SHADER_STAGE_COMPUTE_BIT:
676 return "#version 310 es\n"
677 "layout(binding = 0) buffer Input { highp uint dataIn[]; };\n"
678 "layout(binding = 1) buffer Output { highp uint dataOut[]; };\n"
679 "void main (void)\n"
680 "{\n"
681 " dataOut[gl_GlobalInvocationID.x] = ~dataIn[gl_GlobalInvocationID.x];\n"
682 "}\n";
683
684 default:
685 DE_FATAL("Not implemented");
686 return DE_NULL;
687 }
688 }
689
initProgramsvkt::memory::__anond607d4f40111::ShaderModule690 static void initPrograms (SourceCollections& dst, Parameters params)
691 {
692 const char* const source = getSource(params.shaderStage);
693
694 DE_ASSERT(source);
695
696 dst.glslSources.add(params.binaryName)
697 << glu::ShaderSource(getGluShaderType(params.shaderStage), source);
698 }
699
createvkt::memory::__anond607d4f40111::ShaderModule700 static Move<VkShaderModule> create (const Environment& env, const Resources& res, const Parameters&)
701 {
702 const VkShaderModuleCreateInfo shaderModuleCreateInfo =
703 {
704 VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, // VkStructureType sType;
705 DE_NULL, // const void* pNext;
706 (VkShaderModuleCreateFlags)0, // VkShaderModuleCreateFlags flags;
707 res.binary.getSize(), // size_t codeSize;
708 (const deUint32*)res.binary.getBinary(), // const uint32_t* pCode;
709 };
710
711 return createShaderModule(env.vkd, env.device, &shaderModuleCreateInfo);
712 }
713 };
714
715 struct PipelineCache
716 {
717 typedef VkPipelineCache Type;
718
719 struct Parameters
720 {
Parametersvkt::memory::__anond607d4f40111::PipelineCache::Parameters721 Parameters (void) {}
722 };
723
724 struct Resources
725 {
Resourcesvkt::memory::__anond607d4f40111::PipelineCache::Resources726 Resources (const Environment&, const Parameters&) {}
727 };
728
createvkt::memory::__anond607d4f40111::PipelineCache729 static Move<VkPipelineCache> create (const Environment& env, const Resources&, const Parameters&)
730 {
731 const VkPipelineCacheCreateInfo pipelineCacheCreateInfo =
732 {
733 VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, // VkStructureType sType;
734 DE_NULL, // const void* pNext;
735 (VkPipelineCacheCreateFlags)0u, // VkPipelineCacheCreateFlags flags;
736 0u, // size_t initialDataSize;
737 DE_NULL, // const void* pInitialData;
738 };
739
740 return createPipelineCache(env.vkd, env.device, &pipelineCacheCreateInfo);
741 }
742 };
743
744 struct Sampler
745 {
746 typedef VkSampler Type;
747
748 struct Parameters
749 {
750 VkFilter magFilter;
751 VkFilter minFilter;
752 VkSamplerMipmapMode mipmapMode;
753 VkSamplerAddressMode addressModeU;
754 VkSamplerAddressMode addressModeV;
755 VkSamplerAddressMode addressModeW;
756 float mipLodBias;
757 VkBool32 anisotropyEnable;
758 float maxAnisotropy;
759 VkBool32 compareEnable;
760 VkCompareOp compareOp;
761 float minLod;
762 float maxLod;
763 VkBorderColor borderColor;
764 VkBool32 unnormalizedCoordinates;
765
Parametersvkt::memory::__anond607d4f40111::Sampler::Parameters766 Parameters (void)
767 : magFilter (VK_FILTER_NEAREST)
768 , minFilter (VK_FILTER_NEAREST)
769 , mipmapMode (VK_SAMPLER_MIPMAP_MODE_NEAREST)
770 , addressModeU (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
771 , addressModeV (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
772 , addressModeW (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
773 , mipLodBias (0.0f)
774 , anisotropyEnable (VK_FALSE)
775 , maxAnisotropy (1.0f)
776 , compareEnable (VK_FALSE)
777 , compareOp (VK_COMPARE_OP_ALWAYS)
778 , minLod (-1000.f)
779 , maxLod (+1000.f)
780 , borderColor (VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK)
781 , unnormalizedCoordinates (VK_FALSE)
782 {}
783 };
784
785 struct Resources
786 {
Resourcesvkt::memory::__anond607d4f40111::Sampler::Resources787 Resources (const Environment&, const Parameters&) {}
788 };
789
createvkt::memory::__anond607d4f40111::Sampler790 static Move<VkSampler> create (const Environment& env, const Resources&, const Parameters& params)
791 {
792 const VkSamplerCreateInfo samplerCreateInfo =
793 {
794 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, // VkStructureType sType;
795 DE_NULL, // const void* pNext;
796 (VkSamplerCreateFlags)0, // VkSamplerCreateFlags flags;
797 params.magFilter, // VkFilter magFilter;
798 params.minFilter, // VkFilter minFilter;
799 params.mipmapMode, // VkSamplerMipmapMode mipmapMode;
800 params.addressModeU, // VkSamplerAddressMode addressModeU;
801 params.addressModeV, // VkSamplerAddressMode addressModeV;
802 params.addressModeW, // VkSamplerAddressMode addressModeW;
803 params.mipLodBias, // float mipLodBias;
804 params.anisotropyEnable, // VkBool32 anisotropyEnable;
805 params.maxAnisotropy, // float maxAnisotropy;
806 params.compareEnable, // VkBool32 compareEnable;
807 params.compareOp, // VkCompareOp compareOp;
808 params.minLod, // float minLod;
809 params.maxLod, // float maxLod;
810 params.borderColor, // VkBorderColor borderColor;
811 params.unnormalizedCoordinates, // VkBool32 unnormalizedCoordinates;
812 };
813
814 return createSampler(env.vkd, env.device, &samplerCreateInfo);
815 }
816 };
817
818 struct DescriptorSetLayout
819 {
820 typedef VkDescriptorSetLayout Type;
821
822 struct Parameters
823 {
824 struct Binding
825 {
826 deUint32 binding;
827 VkDescriptorType descriptorType;
828 deUint32 descriptorCount;
829 VkShaderStageFlags stageFlags;
830 bool useImmutableSampler;
831
Bindingvkt::memory::__anond607d4f40111::DescriptorSetLayout::Parameters::Binding832 Binding (deUint32 binding_,
833 VkDescriptorType descriptorType_,
834 deUint32 descriptorCount_,
835 VkShaderStageFlags stageFlags_,
836 bool useImmutableSampler_)
837 : binding (binding_)
838 , descriptorType (descriptorType_)
839 , descriptorCount (descriptorCount_)
840 , stageFlags (stageFlags_)
841 , useImmutableSampler (useImmutableSampler_)
842 {}
843
Bindingvkt::memory::__anond607d4f40111::DescriptorSetLayout::Parameters::Binding844 Binding (void) {}
845 };
846
847 std::vector<Binding> bindings;
848
Parametersvkt::memory::__anond607d4f40111::DescriptorSetLayout::Parameters849 Parameters (const std::vector<Binding>& bindings_)
850 : bindings(bindings_)
851 {}
852
emptyvkt::memory::__anond607d4f40111::DescriptorSetLayout::Parameters853 static Parameters empty (void)
854 {
855 return Parameters(std::vector<Binding>());
856 }
857
singlevkt::memory::__anond607d4f40111::DescriptorSetLayout::Parameters858 static Parameters single (deUint32 binding,
859 VkDescriptorType descriptorType,
860 deUint32 descriptorCount,
861 VkShaderStageFlags stageFlags,
862 bool useImmutableSampler = false)
863 {
864 std::vector<Binding> bindings;
865 bindings.push_back(Binding(binding, descriptorType, descriptorCount, stageFlags, useImmutableSampler));
866 return Parameters(bindings);
867 }
868 };
869
870 struct Resources
871 {
872 std::vector<VkDescriptorSetLayoutBinding> bindings;
873 MovePtr<Dependency<Sampler>> immutableSampler;
874 std::vector<VkSampler> immutableSamplersPtr;
875
Resourcesvkt::memory::__anond607d4f40111::DescriptorSetLayout::Resources876 Resources (const Environment& env, const Parameters& params)
877 {
878 for (std::vector<Parameters::Binding>::const_iterator cur = params.bindings.begin(); cur != params.bindings.end(); cur++)
879 {
880 if (cur->useImmutableSampler && !immutableSampler)
881 {
882 immutableSampler = de::newMovePtr<Dependency<Sampler>>(env, Sampler::Parameters());
883
884 if (cur->useImmutableSampler && immutableSamplersPtr.size() < (size_t)cur->descriptorCount)
885 immutableSamplersPtr.resize(cur->descriptorCount, *immutableSampler->object);
886 }
887 }
888
889 for (std::vector<Parameters::Binding>::const_iterator cur = params.bindings.begin(); cur != params.bindings.end(); cur++)
890 {
891 const VkDescriptorSetLayoutBinding binding =
892 {
893 cur->binding, // uint32_t binding;
894 cur->descriptorType, // VkDescriptorType descriptorType;
895 cur->descriptorCount, // uint32_t descriptorCount;
896 cur->stageFlags, // VkShaderStageFlags stageFlags;
897 (cur->useImmutableSampler ? &immutableSamplersPtr[0] : DE_NULL), // const VkSampler* pImmutableSamplers;
898 };
899
900 bindings.push_back(binding);
901 }
902 }
903 };
904
createvkt::memory::__anond607d4f40111::DescriptorSetLayout905 static Move<VkDescriptorSetLayout> create (const Environment& env, const Resources& res, const Parameters&)
906 {
907 const VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo =
908 {
909 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, // VkStructureType sType;
910 DE_NULL, // const void* pNext;
911 (VkDescriptorSetLayoutCreateFlags)0, // VkDescriptorSetLayoutCreateFlags flags;
912 (deUint32)res.bindings.size(), // uint32_t bindingCount;
913 (res.bindings.empty() ? DE_NULL : &res.bindings[0]), // const VkDescriptorSetLayoutBinding* pBindings;
914 };
915
916 return createDescriptorSetLayout(env.vkd, env.device, &descriptorSetLayoutCreateInfo);
917 }
918 };
919
920 struct PipelineLayout
921 {
922 typedef VkPipelineLayout Type;
923
924 struct Parameters
925 {
926 std::vector<DescriptorSetLayout::Parameters> descriptorSetLayouts;
927 std::vector<VkPushConstantRange> pushConstantRanges;
928
Parametersvkt::memory::__anond607d4f40111::PipelineLayout::Parameters929 Parameters (void) {}
930
emptyvkt::memory::__anond607d4f40111::PipelineLayout::Parameters931 static Parameters empty (void)
932 {
933 return Parameters();
934 }
935
singleDescriptorSetvkt::memory::__anond607d4f40111::PipelineLayout::Parameters936 static Parameters singleDescriptorSet (const DescriptorSetLayout::Parameters& descriptorSetLayout)
937 {
938 Parameters params;
939 params.descriptorSetLayouts.push_back(descriptorSetLayout);
940 return params;
941 }
942 };
943
944 struct Resources
945 {
946 typedef SharedPtr<Dependency<DescriptorSetLayout>> DescriptorSetLayoutDepSp;
947 typedef std::vector<DescriptorSetLayoutDepSp> DescriptorSetLayouts;
948
949 DescriptorSetLayouts descriptorSetLayouts;
950 std::vector<VkDescriptorSetLayout> pSetLayouts;
951
Resourcesvkt::memory::__anond607d4f40111::PipelineLayout::Resources952 Resources (const Environment& env, const Parameters& params)
953 {
954 for (std::vector<DescriptorSetLayout::Parameters>::const_iterator dsParams = params.descriptorSetLayouts.begin();
955 dsParams != params.descriptorSetLayouts.end();
956 ++dsParams)
957 {
958 descriptorSetLayouts.push_back(DescriptorSetLayoutDepSp(new Dependency<DescriptorSetLayout>(env, *dsParams)));
959 pSetLayouts.push_back(*descriptorSetLayouts.back()->object);
960 }
961 }
962 };
963
createvkt::memory::__anond607d4f40111::PipelineLayout964 static Move<VkPipelineLayout> create (const Environment& env, const Resources& res, const Parameters& params)
965 {
966 const VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo =
967 {
968 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType;
969 DE_NULL, // const void* pNext;
970 (VkPipelineLayoutCreateFlags)0, // VkPipelineLayoutCreateFlags flags;
971 (deUint32)res.pSetLayouts.size(), // uint32_t setLayoutCount;
972 (res.pSetLayouts.empty() ? DE_NULL : &res.pSetLayouts[0]), // const VkDescriptorSetLayout* pSetLayouts;
973 (deUint32)params.pushConstantRanges.size(), // uint32_t pushConstantRangeCount;
974 (params.pushConstantRanges.empty() ? DE_NULL : ¶ms.pushConstantRanges[0]), // const VkPushConstantRange* pPushConstantRanges;
975 };
976
977 return createPipelineLayout(env.vkd, env.device, &pipelineLayoutCreateInfo);
978 }
979 };
980
981 struct RenderPass
982 {
983 typedef VkRenderPass Type;
984
985 struct Parameters
986 {
Parametersvkt::memory::__anond607d4f40111::RenderPass::Parameters987 Parameters (void) {}
988 };
989
990 struct Resources
991 {
Resourcesvkt::memory::__anond607d4f40111::RenderPass::Resources992 Resources (const Environment&, const Parameters&) {}
993 };
994
createvkt::memory::__anond607d4f40111::RenderPass995 static Move<VkRenderPass> create (const Environment& env, const Resources&, const Parameters&)
996 {
997 return makeRenderPass(env.vkd, env.device, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D16_UNORM,
998 VK_ATTACHMENT_LOAD_OP_CLEAR,
999 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1000 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1001 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1002 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
1003 }
1004 };
1005
1006 struct GraphicsPipeline
1007 {
1008 typedef VkPipeline Type;
1009
1010 struct Parameters
1011 {
Parametersvkt::memory::__anond607d4f40111::GraphicsPipeline::Parameters1012 Parameters (void) {}
1013 };
1014
1015 struct Resources
1016 {
1017 Dependency<ShaderModule> vertexShader;
1018 Dependency<ShaderModule> fragmentShader;
1019 Dependency<PipelineLayout> layout;
1020 Dependency<RenderPass> renderPass;
1021 Dependency<PipelineCache> pipelineCache;
1022
Resourcesvkt::memory::__anond607d4f40111::GraphicsPipeline::Resources1023 Resources (const Environment& env, const Parameters&)
1024 : vertexShader (env, ShaderModule::Parameters(VK_SHADER_STAGE_VERTEX_BIT, "vert"))
1025 , fragmentShader (env, ShaderModule::Parameters(VK_SHADER_STAGE_FRAGMENT_BIT, "frag"))
1026 , layout (env, PipelineLayout::Parameters::singleDescriptorSet(
1027 DescriptorSetLayout::Parameters::single(0u, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1u, VK_SHADER_STAGE_FRAGMENT_BIT, true)))
1028 , renderPass (env, RenderPass::Parameters())
1029 , pipelineCache (env, PipelineCache::Parameters())
1030 {}
1031 };
1032
initProgramsvkt::memory::__anond607d4f40111::GraphicsPipeline1033 static void initPrograms (SourceCollections& dst, Parameters)
1034 {
1035 ShaderModule::initPrograms(dst, ShaderModule::Parameters(VK_SHADER_STAGE_VERTEX_BIT, "vert"));
1036 ShaderModule::initPrograms(dst, ShaderModule::Parameters(VK_SHADER_STAGE_FRAGMENT_BIT, "frag"));
1037 }
1038
createvkt::memory::__anond607d4f40111::GraphicsPipeline1039 static Move<VkPipeline> create (const Environment& env, const Resources& res, const Parameters&)
1040 {
1041 const VkPipelineShaderStageCreateInfo stages[] =
1042 {
1043 {
1044 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
1045 DE_NULL, // const void* pNext;
1046 (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
1047 VK_SHADER_STAGE_VERTEX_BIT, // VkShaderStageFlagBits stage;
1048 *res.vertexShader.object, // VkShaderModule module;
1049 "main", // const char* pName;
1050 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
1051 },
1052 {
1053 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
1054 DE_NULL, // const void* pNext;
1055 (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
1056 VK_SHADER_STAGE_FRAGMENT_BIT, // VkShaderStageFlagBits stage;
1057 *res.fragmentShader.object, // VkShaderModule module;
1058 "main", // const char* pName;
1059 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
1060 }
1061 };
1062 const VkVertexInputBindingDescription vertexBindings[] =
1063 {
1064 {
1065 0u, // uint32_t binding;
1066 16u, // uint32_t stride;
1067 VK_VERTEX_INPUT_RATE_VERTEX, // VkVertexInputRate inputRate;
1068 }
1069 };
1070 const VkVertexInputAttributeDescription vertexAttribs[] =
1071 {
1072 {
1073 0u, // uint32_t location;
1074 0u, // uint32_t binding;
1075 VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
1076 0u, // uint32_t offset;
1077 }
1078 };
1079 const VkPipelineVertexInputStateCreateInfo vertexInputState =
1080 {
1081 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
1082 DE_NULL, // const void* pNext;
1083 (VkPipelineVertexInputStateCreateFlags)0, // VkPipelineVertexInputStateCreateFlags flags;
1084 DE_LENGTH_OF_ARRAY(vertexBindings), // uint32_t vertexBindingDescriptionCount;
1085 vertexBindings, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
1086 DE_LENGTH_OF_ARRAY(vertexAttribs), // uint32_t vertexAttributeDescriptionCount;
1087 vertexAttribs, // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
1088 };
1089 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
1090 {
1091 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
1092 DE_NULL, // const void* pNext;
1093 (VkPipelineInputAssemblyStateCreateFlags)0, // VkPipelineInputAssemblyStateCreateFlags flags;
1094 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology;
1095 VK_FALSE, // VkBool32 primitiveRestartEnable;
1096 };
1097 const VkViewport viewport = makeViewport(tcu::UVec2(64));
1098 const VkRect2D scissor = makeRect2D(tcu::UVec2(64));
1099
1100 const VkPipelineViewportStateCreateInfo viewportState =
1101 {
1102 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
1103 DE_NULL, // const void* pNext;
1104 (VkPipelineViewportStateCreateFlags)0, // VkPipelineViewportStateCreateFlags flags;
1105 1u, // uint32_t viewportCount;
1106 &viewport, // const VkViewport* pViewports;
1107 1u, // uint32_t scissorCount;
1108 &scissor, // const VkRect2D* pScissors;
1109 };
1110 const VkPipelineRasterizationStateCreateInfo rasterState =
1111 {
1112 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
1113 DE_NULL, // const void* pNext;
1114 (VkPipelineRasterizationStateCreateFlags)0, // VkPipelineRasterizationStateCreateFlags flags;
1115 VK_FALSE, // VkBool32 depthClampEnable;
1116 VK_FALSE, // VkBool32 rasterizerDiscardEnable;
1117 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
1118 VK_CULL_MODE_BACK_BIT, // VkCullModeFlags cullMode;
1119 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
1120 VK_FALSE, // VkBool32 depthBiasEnable;
1121 0.0f, // float depthBiasConstantFactor;
1122 0.0f, // float depthBiasClamp;
1123 0.0f, // float depthBiasSlopeFactor;
1124 1.0f, // float lineWidth;
1125 };
1126 const VkPipelineMultisampleStateCreateInfo multisampleState =
1127 {
1128 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
1129 DE_NULL, // const void* pNext;
1130 (VkPipelineMultisampleStateCreateFlags)0, // VkPipelineMultisampleStateCreateFlags flags;
1131 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples;
1132 VK_FALSE, // VkBool32 sampleShadingEnable;
1133 1.0f, // float minSampleShading;
1134 DE_NULL, // const VkSampleMask* pSampleMask;
1135 VK_FALSE, // VkBool32 alphaToCoverageEnable;
1136 VK_FALSE, // VkBool32 alphaToOneEnable;
1137 };
1138 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1139 {
1140 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType;
1141 DE_NULL, // const void* pNext;
1142 (VkPipelineDepthStencilStateCreateFlags)0, // VkPipelineDepthStencilStateCreateFlags flags;
1143 VK_TRUE, // VkBool32 depthTestEnable;
1144 VK_TRUE, // VkBool32 depthWriteEnable;
1145 VK_COMPARE_OP_LESS, // VkCompareOp depthCompareOp;
1146 VK_FALSE, // VkBool32 depthBoundsTestEnable;
1147 VK_FALSE, // VkBool32 stencilTestEnable;
1148 {
1149 VK_STENCIL_OP_KEEP, // VkStencilOp failOp;
1150 VK_STENCIL_OP_KEEP, // VkStencilOp passOp;
1151 VK_STENCIL_OP_KEEP, // VkStencilOp depthFailOp;
1152 VK_COMPARE_OP_ALWAYS, // VkCompareOp compareOp;
1153 0u, // uint32_t compareMask;
1154 0u, // uint32_t writeMask;
1155 0u, // uint32_t reference;
1156 },
1157 {
1158 VK_STENCIL_OP_KEEP, // VkStencilOp failOp;
1159 VK_STENCIL_OP_KEEP, // VkStencilOp passOp;
1160 VK_STENCIL_OP_KEEP, // VkStencilOp depthFailOp;
1161 VK_COMPARE_OP_ALWAYS, // VkCompareOp compareOp;
1162 0u, // uint32_t compareMask;
1163 0u, // uint32_t writeMask;
1164 0u, // uint32_t reference;
1165 },
1166 0.0f, // float minDepthBounds;
1167 1.0f, // float maxDepthBounds;
1168 };
1169 const VkPipelineColorBlendAttachmentState colorBlendAttState[]=
1170 {
1171 {
1172 VK_FALSE, // VkBool32 blendEnable;
1173 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor;
1174 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor;
1175 VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp;
1176 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor;
1177 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor;
1178 VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp;
1179 VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
1180 VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT, // VkColorComponentFlags colorWriteMask;
1181 }
1182 };
1183 const VkPipelineColorBlendStateCreateInfo colorBlendState =
1184 {
1185 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
1186 DE_NULL, // const void* pNext;
1187 (VkPipelineColorBlendStateCreateFlags)0, // VkPipelineColorBlendStateCreateFlags flags;
1188 VK_FALSE, // VkBool32 logicOpEnable;
1189 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
1190 DE_LENGTH_OF_ARRAY(colorBlendAttState), // uint32_t attachmentCount;
1191 colorBlendAttState, // const VkPipelineColorBlendAttachmentState* pAttachments;
1192 { 0.0f, 0.0f, 0.0f, 0.0f }, // float blendConstants[4];
1193 };
1194 const VkGraphicsPipelineCreateInfo pipelineCreateInfo =
1195 {
1196 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
1197 DE_NULL, // const void* pNext;
1198 (VkPipelineCreateFlags)0, // VkPipelineCreateFlags flags;
1199 DE_LENGTH_OF_ARRAY(stages), // uint32_t stageCount;
1200 stages, // const VkPipelineShaderStageCreateInfo* pStages;
1201 &vertexInputState, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
1202 &inputAssemblyState, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
1203 DE_NULL, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
1204 &viewportState, // const VkPipelineViewportStateCreateInfo* pViewportState;
1205 &rasterState, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
1206 &multisampleState, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
1207 &depthStencilState, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
1208 &colorBlendState, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
1209 (const VkPipelineDynamicStateCreateInfo*)DE_NULL, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
1210 *res.layout.object, // VkPipelineLayout layout;
1211 *res.renderPass.object, // VkRenderPass renderPass;
1212 0u, // uint32_t subpass;
1213 (VkPipeline)0, // VkPipeline basePipelineHandle;
1214 0, // int32_t basePipelineIndex;
1215 };
1216
1217 return createGraphicsPipeline(env.vkd, env.device, *res.pipelineCache.object, &pipelineCreateInfo);
1218 }
1219 };
1220
1221 struct ComputePipeline
1222 {
1223 typedef VkPipeline Type;
1224
1225 struct Parameters
1226 {
Parametersvkt::memory::__anond607d4f40111::ComputePipeline::Parameters1227 Parameters (void) {}
1228 };
1229
1230 struct Resources
1231 {
1232 Dependency<ShaderModule> shaderModule;
1233 Dependency<PipelineLayout> layout;
1234 Dependency<PipelineCache> pipelineCache;
1235
getDescriptorSetLayoutvkt::memory::__anond607d4f40111::ComputePipeline::Resources1236 static DescriptorSetLayout::Parameters getDescriptorSetLayout (void)
1237 {
1238 typedef DescriptorSetLayout::Parameters::Binding Binding;
1239
1240 std::vector<Binding> bindings;
1241
1242 bindings.push_back(Binding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1u, VK_SHADER_STAGE_COMPUTE_BIT, false));
1243 bindings.push_back(Binding(1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1u, VK_SHADER_STAGE_COMPUTE_BIT, false));
1244
1245 return DescriptorSetLayout::Parameters(bindings);
1246 }
1247
Resourcesvkt::memory::__anond607d4f40111::ComputePipeline::Resources1248 Resources (const Environment& env, const Parameters&)
1249 : shaderModule (env, ShaderModule::Parameters(VK_SHADER_STAGE_COMPUTE_BIT, "comp"))
1250 , layout (env, PipelineLayout::Parameters::singleDescriptorSet(getDescriptorSetLayout()))
1251 , pipelineCache (env, PipelineCache::Parameters())
1252 {}
1253 };
1254
initProgramsvkt::memory::__anond607d4f40111::ComputePipeline1255 static void initPrograms (SourceCollections& dst, Parameters)
1256 {
1257 ShaderModule::initPrograms(dst, ShaderModule::Parameters(VK_SHADER_STAGE_COMPUTE_BIT, "comp"));
1258 }
1259
createvkt::memory::__anond607d4f40111::ComputePipeline1260 static Move<VkPipeline> create (const Environment& env, const Resources& res, const Parameters&)
1261 {
1262 const VkComputePipelineCreateInfo pipelineCreateInfo =
1263 {
1264 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType;
1265 DE_NULL, // const void* pNext;
1266 (VkPipelineCreateFlags)0, // VkPipelineCreateFlags flags;
1267 {
1268 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
1269 DE_NULL, // const void* pNext;
1270 (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
1271 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
1272 *res.shaderModule.object, // VkShaderModule module;
1273 "main", // const char* pName;
1274 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
1275 },
1276 *res.layout.object, // VkPipelineLayout layout;
1277 (VkPipeline)0, // VkPipeline basePipelineHandle;
1278 0u, // int32_t basePipelineIndex;
1279 };
1280
1281 return createComputePipeline(env.vkd, env.device, *res.pipelineCache.object, &pipelineCreateInfo);
1282 }
1283 };
1284
1285 struct DescriptorPool
1286 {
1287 typedef VkDescriptorPool Type;
1288
1289 struct Parameters
1290 {
1291 VkDescriptorPoolCreateFlags flags;
1292 deUint32 maxSets;
1293 std::vector<VkDescriptorPoolSize> poolSizes;
1294
Parametersvkt::memory::__anond607d4f40111::DescriptorPool::Parameters1295 Parameters (VkDescriptorPoolCreateFlags flags_,
1296 deUint32 maxSets_,
1297 const std::vector<VkDescriptorPoolSize>& poolSizes_)
1298 : flags (flags_)
1299 , maxSets (maxSets_)
1300 , poolSizes (poolSizes_)
1301 {}
1302
singleTypevkt::memory::__anond607d4f40111::DescriptorPool::Parameters1303 static Parameters singleType (VkDescriptorPoolCreateFlags flags,
1304 deUint32 maxSets,
1305 VkDescriptorType type,
1306 deUint32 count)
1307 {
1308 std::vector<VkDescriptorPoolSize> poolSizes;
1309 poolSizes.push_back(makeDescriptorPoolSize(type, count));
1310 return Parameters(flags, maxSets, poolSizes);
1311 }
1312 };
1313
1314 struct Resources
1315 {
Resourcesvkt::memory::__anond607d4f40111::DescriptorPool::Resources1316 Resources (const Environment&, const Parameters&) {}
1317 };
1318
createvkt::memory::__anond607d4f40111::DescriptorPool1319 static Move<VkDescriptorPool> create (const Environment& env, const Resources&, const Parameters& params)
1320 {
1321 const VkDescriptorPoolCreateInfo descriptorPoolCreateInfo =
1322 {
1323 VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, // VkStructureType sType;
1324 DE_NULL, // const void* pNext;
1325 params.flags, // VkDescriptorPoolCreateFlags flags;
1326 params.maxSets, // uint32_t maxSets;
1327 (deUint32)params.poolSizes.size(), // uint32_t poolSizeCount;
1328 (params.poolSizes.empty() ? DE_NULL : ¶ms.poolSizes[0]), // const VkDescriptorPoolSize* pPoolSizes;
1329 };
1330
1331 return createDescriptorPool(env.vkd, env.device, &descriptorPoolCreateInfo);
1332 }
1333 };
1334
1335 struct DescriptorSet
1336 {
1337 typedef VkDescriptorSet Type;
1338
1339 struct Parameters
1340 {
1341 DescriptorSetLayout::Parameters descriptorSetLayout;
1342
Parametersvkt::memory::__anond607d4f40111::DescriptorSet::Parameters1343 Parameters (const DescriptorSetLayout::Parameters& descriptorSetLayout_)
1344 : descriptorSetLayout(descriptorSetLayout_)
1345 {}
1346 };
1347
1348 struct Resources
1349 {
1350 Dependency<DescriptorPool> descriptorPool;
1351 Dependency<DescriptorSetLayout> descriptorSetLayout;
1352
computePoolSizesvkt::memory::__anond607d4f40111::DescriptorSet::Resources1353 static std::vector<VkDescriptorPoolSize> computePoolSizes (const DescriptorSetLayout::Parameters& layout, int maxSets)
1354 {
1355 deUint32 countByType[VK_DESCRIPTOR_TYPE_LAST];
1356 std::vector<VkDescriptorPoolSize> typeCounts;
1357
1358 std::fill(DE_ARRAY_BEGIN(countByType), DE_ARRAY_END(countByType), 0u);
1359
1360 for (std::vector<DescriptorSetLayout::Parameters::Binding>::const_iterator cur = layout.bindings.begin(); cur != layout.bindings.end(); cur++)
1361 {
1362 DE_ASSERT((deUint32)cur->descriptorType < VK_DESCRIPTOR_TYPE_LAST);
1363 countByType[cur->descriptorType] += cur->descriptorCount * maxSets;
1364 }
1365
1366 for (deUint32 type = 0; type < VK_DESCRIPTOR_TYPE_LAST; type++)
1367 {
1368 if (countByType[type] > 0)
1369 typeCounts.push_back(makeDescriptorPoolSize((VkDescriptorType)type, countByType[type]));
1370 }
1371
1372 return typeCounts;
1373 }
1374
Resourcesvkt::memory::__anond607d4f40111::DescriptorSet::Resources1375 Resources (const Environment& env, const Parameters& params)
1376 : descriptorPool (env, DescriptorPool::Parameters(VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u, computePoolSizes(params.descriptorSetLayout, 1u)))
1377 , descriptorSetLayout (env, params.descriptorSetLayout)
1378 {
1379 }
1380 };
1381
createvkt::memory::__anond607d4f40111::DescriptorSet1382 static Move<VkDescriptorSet> create (const Environment& env, const Resources& res, const Parameters&)
1383 {
1384 const VkDescriptorSetAllocateInfo allocateInfo =
1385 {
1386 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType;
1387 DE_NULL, // const void* pNext;
1388 *res.descriptorPool.object, // VkDescriptorPool descriptorPool;
1389 1u, // uint32_t descriptorSetCount;
1390 &(*res.descriptorSetLayout.object), // const VkDescriptorSetLayout* pSetLayouts;
1391 };
1392
1393 return allocateDescriptorSet(env.vkd, env.device, &allocateInfo);
1394 }
1395 };
1396
1397 struct Framebuffer
1398 {
1399 typedef VkFramebuffer Type;
1400
1401 struct Parameters
1402 {
Parametersvkt::memory::__anond607d4f40111::Framebuffer::Parameters1403 Parameters (void)
1404 {}
1405 };
1406
1407 struct Resources
1408 {
1409 Dependency<ImageView> colorAttachment;
1410 Dependency<ImageView> depthStencilAttachment;
1411 Dependency<RenderPass> renderPass;
1412
Resourcesvkt::memory::__anond607d4f40111::Framebuffer::Resources1413 Resources (const Environment& env, const Parameters&)
1414 : colorAttachment (env, ImageView::Parameters(Image::Parameters(0u, VK_IMAGE_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM,
1415 makeExtent3D(256, 256, 1),
1416 1u, 1u,
1417 VK_SAMPLE_COUNT_1_BIT,
1418 VK_IMAGE_TILING_OPTIMAL,
1419 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
1420 VK_IMAGE_LAYOUT_UNDEFINED),
1421 VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM,
1422 makeComponentMappingRGBA(),
1423 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u)))
1424 , depthStencilAttachment (env, ImageView::Parameters(Image::Parameters(0u, VK_IMAGE_TYPE_2D, VK_FORMAT_D16_UNORM,
1425 makeExtent3D(256, 256, 1),
1426 1u, 1u,
1427 VK_SAMPLE_COUNT_1_BIT,
1428 VK_IMAGE_TILING_OPTIMAL,
1429 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
1430 VK_IMAGE_LAYOUT_UNDEFINED),
1431 VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_D16_UNORM,
1432 makeComponentMappingRGBA(),
1433 makeImageSubresourceRange(VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 1u, 0u, 1u)))
1434 , renderPass (env, RenderPass::Parameters())
1435 {}
1436 };
1437
createvkt::memory::__anond607d4f40111::Framebuffer1438 static Move<VkFramebuffer> create (const Environment& env, const Resources& res, const Parameters&)
1439 {
1440 const VkImageView attachments[] =
1441 {
1442 *res.colorAttachment.object,
1443 *res.depthStencilAttachment.object,
1444 };
1445 const VkFramebufferCreateInfo framebufferCreateInfo =
1446 {
1447 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
1448 DE_NULL, // const void* pNext;
1449 (VkFramebufferCreateFlags)0, // VkFramebufferCreateFlags flags;
1450 *res.renderPass.object, // VkRenderPass renderPass;
1451 (deUint32)DE_LENGTH_OF_ARRAY(attachments), // uint32_t attachmentCount;
1452 attachments, // const VkImageView* pAttachments;
1453 256u, // uint32_t width;
1454 256u, // uint32_t height;
1455 1u, // uint32_t layers;
1456 };
1457
1458 return createFramebuffer(env.vkd, env.device, &framebufferCreateInfo);
1459 }
1460 };
1461
1462 struct CommandPool
1463 {
1464 typedef VkCommandPool Type;
1465
1466 struct Parameters
1467 {
1468 VkCommandPoolCreateFlags flags;
1469
Parametersvkt::memory::__anond607d4f40111::CommandPool::Parameters1470 Parameters (VkCommandPoolCreateFlags flags_)
1471 : flags(flags_)
1472 {}
1473 };
1474
1475 struct Resources
1476 {
Resourcesvkt::memory::__anond607d4f40111::CommandPool::Resources1477 Resources (const Environment&, const Parameters&) {}
1478 };
1479
createvkt::memory::__anond607d4f40111::CommandPool1480 static Move<VkCommandPool> create (const Environment& env, const Resources&, const Parameters& params)
1481 {
1482 const VkCommandPoolCreateInfo commandPoolCreateInfo =
1483 {
1484 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
1485 DE_NULL, // const void* pNext;
1486 params.flags, // VkCommandPoolCreateFlags flags;
1487 env.queueFamilyIndex, // uint32_t queueFamilyIndex;
1488 };
1489
1490 return createCommandPool(env.vkd, env.device, &commandPoolCreateInfo);
1491 }
1492 };
1493
1494 struct CommandBuffer
1495 {
1496 typedef VkCommandBuffer Type;
1497
1498 struct Parameters
1499 {
1500 CommandPool::Parameters commandPool;
1501 VkCommandBufferLevel level;
1502
Parametersvkt::memory::__anond607d4f40111::CommandBuffer::Parameters1503 Parameters (const CommandPool::Parameters& commandPool_,
1504 VkCommandBufferLevel level_)
1505 : commandPool (commandPool_)
1506 , level (level_)
1507 {}
1508 };
1509
1510 struct Resources
1511 {
1512 Dependency<CommandPool> commandPool;
1513
Resourcesvkt::memory::__anond607d4f40111::CommandBuffer::Resources1514 Resources (const Environment& env, const Parameters& params)
1515 : commandPool(env, params.commandPool)
1516 {}
1517 };
1518
createvkt::memory::__anond607d4f40111::CommandBuffer1519 static Move<VkCommandBuffer> create (const Environment& env, const Resources& res, const Parameters& params)
1520 {
1521 const VkCommandBufferAllocateInfo allocateInfo =
1522 {
1523 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
1524 DE_NULL, // const void* pNext;
1525 *res.commandPool.object, // VkCommandPool commandPool;
1526 params.level, // VkCommandBufferLevel level;
1527 1, // uint32_t commandBufferCount;
1528 };
1529
1530 return allocateCommandBuffer(env.vkd, env.device, &allocateInfo);
1531 }
1532 };
1533
1534 template<typename Object>
1535 struct NamedParameters
1536 {
1537 const char* name;
1538 typename Object::Parameters parameters;
1539 };
1540
1541 template<typename Object>
1542 struct CaseDescription
1543 {
1544 typename FunctionInstance1<typename Object::Parameters>::Function function;
1545 const NamedParameters<Object>* paramsBegin;
1546 const NamedParameters<Object>* paramsEnd;
1547 };
1548
1549 #define CASE_DESC(FUNCTION, CASES) \
1550 { FUNCTION, DE_ARRAY_BEGIN(CASES), DE_ARRAY_END(CASES) }
1551
1552 struct CaseDescriptions
1553 {
1554 CaseDescription<Device> device;
1555 CaseDescription<DeviceMemory> deviceMemory;
1556 CaseDescription<Buffer> buffer;
1557 CaseDescription<BufferView> bufferView;
1558 CaseDescription<Image> image;
1559 CaseDescription<ImageView> imageView;
1560 CaseDescription<Semaphore> semaphore;
1561 CaseDescription<Event> event;
1562 CaseDescription<Fence> fence;
1563 CaseDescription<QueryPool> queryPool;
1564 CaseDescription<ShaderModule> shaderModule;
1565 CaseDescription<PipelineCache> pipelineCache;
1566 CaseDescription<Sampler> sampler;
1567 CaseDescription<DescriptorSetLayout> descriptorSetLayout;
1568 CaseDescription<PipelineLayout> pipelineLayout;
1569 CaseDescription<RenderPass> renderPass;
1570 CaseDescription<GraphicsPipeline> graphicsPipeline;
1571 CaseDescription<ComputePipeline> computePipeline;
1572 CaseDescription<DescriptorPool> descriptorPool;
1573 CaseDescription<DescriptorSet> descriptorSet;
1574 CaseDescription<Framebuffer> framebuffer;
1575 CaseDescription<CommandPool> commandPool;
1576 CaseDescription<CommandBuffer> commandBuffer;
1577 };
1578
1579 template<typename Object>
checkSupport(Context & context,typename Object::Parameters)1580 static void checkSupport (Context& context, typename Object::Parameters)
1581 {
1582 context.requireDeviceFunctionality("VK_EXT_device_memory_report");
1583 }
1584
1585 template<typename Object>
addCases(const MovePtr<tcu::TestCaseGroup> & group,const CaseDescription<Object> & cases)1586 void addCases (const MovePtr<tcu::TestCaseGroup>& group, const CaseDescription<Object>& cases)
1587 {
1588 for (const NamedParameters<Object>* cur = cases.paramsBegin; cur != cases.paramsEnd; cur++)
1589 {
1590 addFunctionCase(group.get(), cur->name, "", checkSupport<Object>, cases.function, cur->parameters);
1591 }
1592 }
1593
1594 template<typename Object>
addCasesWithProgs(const MovePtr<tcu::TestCaseGroup> & group,const CaseDescription<Object> & cases)1595 void addCasesWithProgs (const MovePtr<tcu::TestCaseGroup>& group, const CaseDescription<Object>& cases)
1596 {
1597 for (const NamedParameters<Object>* cur = cases.paramsBegin; cur != cases.paramsEnd; cur++)
1598 {
1599 addFunctionCaseWithPrograms(group.get(), cur->name, "", checkSupport<Object>, Object::initPrograms, cases.function, cur->parameters);
1600 }
1601 }
1602
createObjectTestsGroup(tcu::TestContext & testCtx,const char * name,const char * desc,const CaseDescriptions & cases)1603 tcu::TestCaseGroup* createObjectTestsGroup (tcu::TestContext& testCtx, const char* name, const char* desc, const CaseDescriptions& cases)
1604 {
1605 MovePtr<tcu::TestCaseGroup> group (new tcu::TestCaseGroup(testCtx, name, desc));
1606
1607 addCases (group, cases.device);
1608 addCases (group, cases.deviceMemory);
1609 addCases (group, cases.buffer);
1610 addCases (group, cases.bufferView);
1611 addCases (group, cases.image);
1612 addCases (group, cases.imageView);
1613 addCases (group, cases.semaphore);
1614 addCases (group, cases.event);
1615 addCases (group, cases.fence);
1616 addCases (group, cases.queryPool);
1617 addCasesWithProgs (group, cases.shaderModule);
1618 addCases (group, cases.pipelineCache);
1619 addCases (group, cases.sampler);
1620 addCases (group, cases.descriptorSetLayout);
1621 addCases (group, cases.pipelineLayout);
1622 addCases (group, cases.renderPass);
1623 addCasesWithProgs (group, cases.graphicsPipeline);
1624 addCasesWithProgs (group, cases.computePipeline);
1625 addCases (group, cases.descriptorPool);
1626 addCases (group, cases.descriptorSet);
1627 addCases (group, cases.framebuffer);
1628 addCases (group, cases.commandPool);
1629 addCases (group, cases.commandBuffer);
1630
1631 return group.release();
1632 }
1633
validateCallbackRecords(Context & context,const CallbackRecorder & recorder)1634 static deBool validateCallbackRecords (Context& context, const CallbackRecorder& recorder)
1635 {
1636 tcu::TestLog& log = context.getTestContext().getLog();
1637 const VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
1638 const InstanceInterface& vki = context.getInstanceInterface();
1639 const VkPhysicalDeviceMemoryProperties memoryProperties = getPhysicalDeviceMemoryProperties(vki, physicalDevice);
1640 std::set<std::pair<deUint64, deUint64>> memoryObjectSet;
1641
1642 for (auto iter = recorder.getRecordsBegin(); iter != recorder.getRecordsEnd(); iter++)
1643 {
1644 const VkDeviceMemoryReportCallbackDataEXT& record = iter->first;
1645
1646 if ((record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATE_EXT ||
1647 record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATION_FAILED_EXT) &&
1648 record.heapIndex >= memoryProperties.memoryHeapCount)
1649 {
1650 log << tcu::TestLog::Message << "memoryHeapCount: " << memoryProperties.memoryHeapCount << tcu::TestLog::EndMessage;
1651 log << tcu::TestLog::Message << record << tcu::TestLog::EndMessage;
1652 return false;
1653 }
1654
1655 if (record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATION_FAILED_EXT)
1656 {
1657 log << tcu::TestLog::Message << "Observed ALLOCATION_FAILED event" << tcu::TestLog::EndMessage;
1658 log << tcu::TestLog::Message << record << tcu::TestLog::EndMessage;
1659 continue;
1660 }
1661
1662 if (record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATE_EXT ||
1663 record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_IMPORT_EXT)
1664 {
1665 memoryObjectSet.insert(std::make_pair(record.memoryObjectId, record.objectHandle));
1666 continue;
1667 }
1668
1669 if (record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_FREE_EXT ||
1670 record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_UNIMPORT_EXT)
1671 {
1672 const auto objectPair = std::make_pair(record.memoryObjectId, record.objectHandle);
1673 if (!memoryObjectSet.count(objectPair))
1674 {
1675 log << tcu::TestLog::Message << "Unpaired or out-of-order free/unimport event" << tcu::TestLog::EndMessage;
1676 log << tcu::TestLog::Message << record << tcu::TestLog::EndMessage;
1677 return false;
1678 }
1679 memoryObjectSet.erase(objectPair);
1680 }
1681 }
1682
1683 if (!memoryObjectSet.empty())
1684 {
1685 log << tcu::TestLog::Message << "Unpaired alloc/import event" << tcu::TestLog::EndMessage;
1686 return false;
1687 }
1688
1689 return true;
1690 }
1691
1692 struct EnvClone
1693 {
1694 Unique<VkDevice> device;
1695 DeviceDriver vkd;
1696 Environment env;
1697
EnvClonevkt::memory::__anond607d4f40111::EnvClone1698 EnvClone (const Environment& parent)
1699 : device (Device::create(parent, Device::Resources(parent, Device::Parameters()), Device::Parameters()))
1700 , vkd (parent.vkp, parent.instance, *device)
1701 , env (parent.vkp, parent.vki, parent.instance, parent.physicalDevice, vkd, *device, parent.queueFamilyIndex, parent.programBinaries, parent.commandLine, nullptr)
1702 {
1703 }
1704 };
1705
1706 template<typename Object>
createDestroyObjectTest(Context & context,typename Object::Parameters params)1707 tcu::TestStatus createDestroyObjectTest (Context& context, typename Object::Parameters params)
1708 {
1709 CallbackRecorder recorder;
1710 const Environment env (context.getPlatformInterface(),
1711 context.getInstanceInterface(),
1712 context.getInstance(),
1713 context.getPhysicalDevice(),
1714 context.getDeviceInterface(),
1715 context.getDevice(),
1716 context.getUniversalQueueFamilyIndex(),
1717 context.getBinaryCollection(),
1718 context.getTestContext().getCommandLine(),
1719 &recorder);
1720
1721 if (std::is_same<Object, Device>::value)
1722 {
1723 const typename Object::Resources res (env, params);
1724 Unique<typename Object::Type> obj (Object::create(env, res, params));
1725 }
1726 else
1727 {
1728 const EnvClone envWithCustomDevice (env);
1729 const typename Object::Resources res (envWithCustomDevice.env, params);
1730 Unique<typename Object::Type> obj (Object::create(envWithCustomDevice.env, res, params));
1731 }
1732
1733 if (!validateCallbackRecords(context, recorder))
1734 {
1735 return tcu::TestStatus::fail("Invalid device memory report callback");
1736 }
1737
1738 return tcu::TestStatus::pass("Ok");
1739 }
1740
vkDeviceMemoryAllocateAndFreeTest(Context & context)1741 tcu::TestStatus vkDeviceMemoryAllocateAndFreeTest (Context& context)
1742 {
1743 CallbackRecorder recorder;
1744 const PlatformInterface& vkp = context.getPlatformInterface();
1745 const VkInstance instance = context.getInstance();
1746 const InstanceInterface& vki = context.getInstanceInterface();
1747 const VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
1748 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1749 const deBool isValidationEnabled = context.getTestContext().getCommandLine().isValidationEnabled();
1750 const Unique<VkDevice> device (createDeviceWithMemoryReport(isValidationEnabled, vkp, instance, vki, physicalDevice, queueFamilyIndex, &recorder));
1751 const DeviceDriver vkd (vkp, instance, *device);
1752 const VkPhysicalDeviceMemoryProperties memoryProperties = getPhysicalDeviceMemoryProperties(vki, physicalDevice);
1753 const VkDeviceSize testSize = 1024;
1754 const deUint32 testTypeIndex = 0;
1755 const deUint32 testHeapIndex = memoryProperties.memoryTypes[testTypeIndex].heapIndex;
1756 deUint64 objectHandle = 0;
1757
1758 {
1759 recorder.setCallbackMarker(MARKER_ALLOCATE);
1760
1761 VkResult result = VK_SUCCESS;
1762 VkDeviceMemory memory = DE_NULL;
1763 const VkMemoryAllocateInfo memoryAllocateInfo =
1764 {
1765 VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // VkStructureType sType;
1766 DE_NULL, // const void* pNext;
1767 testSize, // VkDeviceSize allocationSize;
1768 testHeapIndex, // uint32_t memoryTypeIndex;
1769 };
1770
1771 result = vkd.allocateMemory(*device, &memoryAllocateInfo, (const VkAllocationCallbacks*)DE_NULL, &memory);
1772 if (result != VK_SUCCESS)
1773 {
1774 return tcu::TestStatus::fail("Unable to allocate " + de::toString(testSize) + " bytes of memory");
1775 }
1776 objectHandle = memory.getInternal();
1777
1778 recorder.setCallbackMarker(MARKER_FREE);
1779 vkd.freeMemory(*device, memory, (const VkAllocationCallbacks*)DE_NULL);
1780 }
1781
1782 recorder.setCallbackMarker(MARKER_UNKNOWN);
1783
1784 deBool allocateEvent = false;
1785 deBool freeEvent = false;
1786 deUint64 memoryObjectId = 0;
1787
1788 for (auto iter = recorder.getRecordsBegin(); iter != recorder.getRecordsEnd(); iter++)
1789 {
1790 const VkDeviceMemoryReportCallbackDataEXT& record = iter->first;
1791 const CallbackMarker marker = iter->second;
1792
1793 if (record.objectHandle == objectHandle && record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATE_EXT)
1794 {
1795 TCU_CHECK(marker == MARKER_ALLOCATE);
1796 TCU_CHECK(record.objectType == VK_OBJECT_TYPE_DEVICE_MEMORY);
1797 TCU_CHECK(memoryObjectId == 0);
1798 TCU_CHECK(record.memoryObjectId != 0);
1799 TCU_CHECK_MSG(record.size >= testSize, ("record.size=" + de::toString(record.size) + ", testSize=" + de::toString(testSize)).c_str());
1800 TCU_CHECK(record.heapIndex == testHeapIndex);
1801
1802 memoryObjectId = record.memoryObjectId;
1803 allocateEvent = true;
1804 }
1805 else if (record.objectHandle == objectHandle && record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_FREE_EXT)
1806 {
1807 TCU_CHECK(marker == MARKER_FREE);
1808 TCU_CHECK_MSG(record.memoryObjectId == memoryObjectId,
1809 ("record.memoryObjectId=" + de::toString(record.memoryObjectId) +
1810 ", memoryObjectId=" + de::toString(memoryObjectId)).c_str());
1811
1812 freeEvent = true;
1813 }
1814 }
1815
1816 TCU_CHECK(allocateEvent);
1817 TCU_CHECK(freeEvent);
1818
1819 return tcu::TestStatus::pass("Ok");
1820 }
1821
vkDeviceMemoryAllocationFailedTest(Context & context)1822 tcu::TestStatus vkDeviceMemoryAllocationFailedTest (Context& context)
1823 {
1824 CallbackRecorder recorder;
1825 const PlatformInterface& vkp = context.getPlatformInterface();
1826 const VkInstance instance = context.getInstance();
1827 const InstanceInterface& vki = context.getInstanceInterface();
1828 const VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
1829 const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
1830 const deBool isValidationEnabled = context.getTestContext().getCommandLine().isValidationEnabled();
1831 const Unique<VkDevice> device (createDeviceWithMemoryReport(isValidationEnabled, vkp, instance, vki, physicalDevice, queueFamilyIndex, &recorder));
1832 const DeviceDriver vkd (vkp, instance, *device);
1833 const VkPhysicalDeviceMemoryProperties memoryProperties = getPhysicalDeviceMemoryProperties(vki, physicalDevice);
1834 const VkDeviceSize testSize = std::numeric_limits<deUint64>::max();
1835 const deUint32 testTypeIndex = 0;
1836 const deUint32 testHeapIndex = memoryProperties.memoryTypes[testTypeIndex].heapIndex;
1837
1838 {
1839 recorder.setCallbackMarker(MARKER_ALLOCATION_FAILED);
1840
1841 VkResult result = VK_SUCCESS;
1842 VkDeviceMemory memory = DE_NULL;
1843 const VkMemoryAllocateInfo memoryAllocateInfo =
1844 {
1845 VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // VkStructureType sType;
1846 DE_NULL, // const void* pNext;
1847 testSize, // VkDeviceSize allocationSize;
1848 testHeapIndex, // uint32_t memoryTypeIndex;
1849 };
1850
1851 result = vkd.allocateMemory(*device, &memoryAllocateInfo, (const VkAllocationCallbacks*)DE_NULL, &memory);
1852 if (result == VK_SUCCESS)
1853 {
1854 return tcu::TestStatus::fail("Should not be able to allocate UINT64_MAX bytes of memory");
1855 }
1856
1857 recorder.setCallbackMarker(MARKER_UNKNOWN);
1858 }
1859
1860 deBool allocationFailedEvent = false;
1861
1862 for (auto iter = recorder.getRecordsBegin(); iter != recorder.getRecordsEnd(); iter++)
1863 {
1864 const VkDeviceMemoryReportCallbackDataEXT& record = iter->first;
1865 const CallbackMarker marker = iter->second;
1866
1867 if (record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATION_FAILED_EXT)
1868 {
1869 TCU_CHECK(marker == MARKER_ALLOCATION_FAILED);
1870 TCU_CHECK(record.objectType == VK_OBJECT_TYPE_DEVICE_MEMORY);
1871 TCU_CHECK_MSG(record.size >= testSize, ("record.size=" + de::toString(record.size) + ", testSize=" + de::toString(testSize)).c_str());
1872 TCU_CHECK(record.heapIndex == testHeapIndex);
1873
1874 allocationFailedEvent = true;
1875 }
1876 }
1877
1878 TCU_CHECK(allocationFailedEvent);
1879
1880 return tcu::TestStatus::pass("Ok");
1881 }
1882
checkSupport(Context & context)1883 static void checkSupport (Context& context)
1884 {
1885 context.requireDeviceFunctionality("VK_EXT_device_memory_report");
1886 }
1887
createVkDeviceMemoryTestsGroup(tcu::TestContext & testCtx,const char * name,const char * desc)1888 tcu::TestCaseGroup* createVkDeviceMemoryTestsGroup (tcu::TestContext& testCtx, const char* name, const char* desc)
1889 {
1890 MovePtr<tcu::TestCaseGroup> group (new tcu::TestCaseGroup(testCtx, name, desc));
1891
1892 addFunctionCase(group.get(), "allocate_and_free", "", checkSupport, vkDeviceMemoryAllocateAndFreeTest);
1893 addFunctionCase(group.get(), "allocation_failed", "", checkSupport, vkDeviceMemoryAllocationFailedTest);
1894
1895 return group.release();
1896 }
1897
checkSupport(Context & context,VkExternalMemoryHandleTypeFlagBits externalMemoryType)1898 static void checkSupport (Context& context, VkExternalMemoryHandleTypeFlagBits externalMemoryType)
1899 {
1900 context.requireInstanceFunctionality("VK_KHR_external_memory_capabilities");
1901 context.requireDeviceFunctionality("VK_EXT_device_memory_report");
1902 context.requireDeviceFunctionality("VK_KHR_dedicated_allocation");
1903 context.requireDeviceFunctionality("VK_KHR_get_memory_requirements2");
1904
1905 if (externalMemoryType & (VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
1906 VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT))
1907 {
1908 context.requireDeviceFunctionality("VK_KHR_external_memory_fd");
1909 }
1910
1911 if (externalMemoryType & VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT)
1912 {
1913 context.requireDeviceFunctionality("VK_EXT_external_memory_dma_buf");
1914 }
1915
1916 if (externalMemoryType & (VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT |
1917 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT |
1918 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT |
1919 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT |
1920 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT |
1921 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT))
1922 {
1923 context.requireDeviceFunctionality("VK_KHR_external_memory_win32");
1924 }
1925
1926 if (externalMemoryType & VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)
1927 {
1928 context.requireDeviceFunctionality("VK_ANDROID_external_memory_android_hardware_buffer");
1929 }
1930 }
1931
getInstanceExtensions(const deUint32 instanceVersion)1932 static std::vector<std::string> getInstanceExtensions (const deUint32 instanceVersion)
1933 {
1934 std::vector<std::string> instanceExtensions;
1935
1936 if (!isCoreInstanceExtension(instanceVersion, "VK_KHR_get_physical_device_properties2"))
1937 instanceExtensions.push_back("VK_KHR_get_physical_device_properties2");
1938
1939 if (!isCoreInstanceExtension(instanceVersion, "VK_KHR_external_memory_capabilities"))
1940 instanceExtensions.push_back("VK_KHR_external_memory_capabilities");
1941
1942 return instanceExtensions;
1943 }
1944
createExternalMemoryDevice(deBool isValidationEnabled,const PlatformInterface & vkp,VkInstance instance,const InstanceInterface & vki,VkPhysicalDevice physicalDevice,deUint32 apiVersion,deUint32 queueFamilyIndex,VkExternalMemoryHandleTypeFlagBits externalMemoryType,const CallbackRecorder * recorder)1945 static Move<VkDevice> createExternalMemoryDevice (deBool isValidationEnabled,
1946 const PlatformInterface& vkp,
1947 VkInstance instance,
1948 const InstanceInterface& vki,
1949 VkPhysicalDevice physicalDevice,
1950 deUint32 apiVersion,
1951 deUint32 queueFamilyIndex,
1952 VkExternalMemoryHandleTypeFlagBits externalMemoryType,
1953 const CallbackRecorder* recorder)
1954 {
1955 const deUint32 queueCount = 1;
1956 const float queuePriority = 1.0f;
1957 std::vector<const char*> enabledExtensions = {"VK_EXT_device_memory_report"};
1958
1959 if (!isCoreDeviceExtension(apiVersion, "VK_KHR_dedicated_allocation"))
1960 {
1961 enabledExtensions.push_back("VK_KHR_dedicated_allocation");
1962 }
1963 if (!isCoreDeviceExtension(apiVersion, "VK_KHR_get_memory_requirements2"))
1964 {
1965 enabledExtensions.push_back("VK_KHR_get_memory_requirements2");
1966 }
1967
1968 if (externalMemoryType & (VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
1969 VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT))
1970 {
1971 if (!isCoreDeviceExtension(apiVersion, "VK_KHR_external_memory_fd"))
1972 {
1973 enabledExtensions.push_back("VK_KHR_external_memory_fd");
1974 }
1975 }
1976
1977 if (externalMemoryType & VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT)
1978 {
1979 enabledExtensions.push_back("VK_EXT_external_memory_dma_buf");
1980 }
1981
1982 if (externalMemoryType & (VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT |
1983 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT |
1984 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT |
1985 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT |
1986 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT |
1987 VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT))
1988 {
1989 enabledExtensions.push_back("VK_KHR_external_memory_win32");
1990 }
1991
1992 if (externalMemoryType & VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)
1993 {
1994 enabledExtensions.push_back("VK_ANDROID_external_memory_android_hardware_buffer");
1995 enabledExtensions.push_back("VK_EXT_queue_family_foreign");
1996 if (!isCoreDeviceExtension(apiVersion, "VK_KHR_sampler_ycbcr_conversion"))
1997 {
1998 enabledExtensions.push_back("VK_KHR_sampler_ycbcr_conversion");
1999 }
2000 }
2001
2002 const VkPhysicalDeviceDeviceMemoryReportFeaturesEXT deviceMemoryReportFeatures =
2003 {
2004 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT, // VkStructureType sType;
2005 DE_NULL, // void* pNext;
2006 VK_TRUE // VkBool32 deviceMemoryReport;
2007 };
2008 const VkDeviceDeviceMemoryReportCreateInfoEXT deviceMemoryReportCreateInfo =
2009 {
2010 VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT, // VkStructureType sType;
2011 &deviceMemoryReportFeatures, // void* pNext;
2012 (VkDeviceMemoryReportFlagsEXT)0, // VkDeviceMemoryReportFlagsEXT flags;
2013 recorder->callback, // PFN_vkDeviceMemoryReportCallbackEXT pfnUserCallback;
2014 (void*)recorder, // void* pUserData;
2015 };
2016 const VkDeviceQueueCreateInfo queueCreateInfo =
2017 {
2018 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType;
2019 DE_NULL, // const void* pNext;
2020 (VkDeviceQueueCreateFlags)0, // VkDeviceQueueCreateFlags flags;
2021 queueFamilyIndex, // deUint32 queueFamilyIndex;
2022 queueCount, // deUint32 queueCount;
2023 &queuePriority, // const float* pQueuePriorities;
2024 };
2025 const VkDeviceCreateInfo deviceCreateInfo =
2026 {
2027 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType;
2028 &deviceMemoryReportCreateInfo, // const void* pNext;
2029 (VkDeviceCreateFlags)0, // VkDeviceCreateFlags flags;
2030 queueCount, // uint32_t queueCreateInfoCount;
2031 &queueCreateInfo, // const VkDeviceQueueCreateInfo* pQueueCreateInfos;
2032 0u, // uint32_t enabledLayerCount;
2033 DE_NULL, // const char* const* ppEnabledLayerNames;
2034 (deUint32)enabledExtensions.size(), // uint32_t enabledExtensionCount;
2035 enabledExtensions.data(), // const char* const* ppEnabledExtensionNames;
2036 DE_NULL, // const VkPhysicalDeviceFeatures* pEnabledFeatures;
2037 };
2038
2039 return createCustomDevice(isValidationEnabled, vkp, instance, vki, physicalDevice, &deviceCreateInfo);
2040 }
2041
checkBufferSupport(const InstanceInterface & vki,VkPhysicalDevice device,VkBufferUsageFlags usage,VkExternalMemoryHandleTypeFlagBits externalMemoryType)2042 static void checkBufferSupport (const InstanceInterface& vki,
2043 VkPhysicalDevice device,
2044 VkBufferUsageFlags usage,
2045 VkExternalMemoryHandleTypeFlagBits externalMemoryType)
2046 {
2047 const VkPhysicalDeviceExternalBufferInfo info =
2048 {
2049 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO, // VkStructureType sType;
2050 DE_NULL, // void* pNext;
2051 (VkBufferCreateFlags)0, // VkBufferCreateFlags flags;
2052 usage, // VkBufferUsageFlags usage;
2053 externalMemoryType, // VkExternalMemoryHandleTypeFlagBits handleType;
2054 };
2055 VkExternalBufferProperties properties =
2056 {
2057 VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES, // VkStructureType sType;
2058 DE_NULL, // void* pNext;
2059 { 0u, 0u, 0u }, // VkExternalMemoryProperties externalMemoryProperties;
2060 };
2061
2062 vki.getPhysicalDeviceExternalBufferProperties(device, &info, &properties);
2063
2064 if ((properties.externalMemoryProperties.externalMemoryFeatures & VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT) == 0)
2065 TCU_THROW(NotSupportedError, "External handle type doesn't support exporting buffer");
2066
2067 if ((properties.externalMemoryProperties.externalMemoryFeatures & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) == 0)
2068 TCU_THROW(NotSupportedError, "External handle type doesn't support importing buffer");
2069 }
2070
testImportAndUnimportExternalMemory(Context & context,VkExternalMemoryHandleTypeFlagBits externalMemoryType)2071 tcu::TestStatus testImportAndUnimportExternalMemory (Context& context, VkExternalMemoryHandleTypeFlagBits externalMemoryType)
2072 {
2073 CallbackRecorder recorder;
2074 const PlatformInterface& vkp (context.getPlatformInterface());
2075 const CustomInstance instance (createCustomInstanceWithExtensions(context, getInstanceExtensions(context.getUsedApiVersion())));
2076 const InstanceDriver& vki (instance.getDriver());
2077 const VkPhysicalDevice physicalDevice (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
2078 const deUint32 queueFamilyIndex (context.getUniversalQueueFamilyIndex());
2079 const Unique<VkDevice> device (createExternalMemoryDevice(context.getTestContext().getCommandLine().isValidationEnabled(),
2080 vkp,
2081 instance,
2082 vki,
2083 physicalDevice,
2084 context.getUsedApiVersion(),
2085 queueFamilyIndex,
2086 externalMemoryType,
2087 &recorder));
2088 const DeviceDriver vkd (vkp, instance, *device);
2089 const VkBufferUsageFlags usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
2090 const VkDeviceSize bufferSize = 1024;
2091
2092 checkBufferSupport(vki, physicalDevice, usage, externalMemoryType);
2093
2094 const Unique<VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, externalMemoryType, bufferSize, 0u, usage));
2095 const VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
2096 const deUint32 memoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
2097 deUint64 objectHandle = 0;
2098 deUint64 objectHandleA = 0;
2099 deUint64 objectHandleB = 0;
2100
2101 {
2102 recorder.setCallbackMarker(MARKER_ALLOCATE);
2103 const Unique<VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, memoryTypeIndex, externalMemoryType, *buffer));
2104 objectHandle = (*memory).getInternal();
2105 NativeHandle handleA;
2106
2107 getMemoryNative(vkd, *device, *memory, externalMemoryType, handleA);
2108
2109 NativeHandle handleB (handleA);
2110 const Unique<VkBuffer> bufferA (createExternalBuffer(vkd, *device, queueFamilyIndex, externalMemoryType, bufferSize, 0u, usage));
2111 const Unique<VkBuffer> bufferB (createExternalBuffer(vkd, *device, queueFamilyIndex, externalMemoryType, bufferSize, 0u, usage));
2112
2113 {
2114 recorder.setCallbackMarker(MARKER_IMPORT);
2115 const Unique<VkDeviceMemory> memoryA (importDedicatedMemory(vkd, *device, *bufferA, requirements, externalMemoryType, memoryTypeIndex, handleA));
2116 const Unique<VkDeviceMemory> memoryB (importDedicatedMemory(vkd, *device, *bufferB, requirements, externalMemoryType, memoryTypeIndex, handleB));
2117 objectHandleA = (*memoryA).getInternal();
2118 objectHandleB = (*memoryB).getInternal();
2119 recorder.setCallbackMarker(MARKER_UNIMPORT);
2120 }
2121
2122 recorder.setCallbackMarker(MARKER_FREE);
2123 }
2124
2125 recorder.setCallbackMarker(MARKER_UNKNOWN);
2126
2127 deBool allocateEvent = false;
2128 deBool freeEvent = false;
2129 deBool importA = false;
2130 deBool importB = false;
2131 deBool unimportA = false;
2132 deBool unimportB = false;
2133 deUint64 memoryObjectId = 0;
2134
2135 for (auto iter = recorder.getRecordsBegin(); iter != recorder.getRecordsEnd(); iter++)
2136 {
2137 const VkDeviceMemoryReportCallbackDataEXT& record = iter->first;
2138 const CallbackMarker marker = iter->second;
2139
2140 if (record.objectHandle == objectHandle && record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATE_EXT)
2141 {
2142 TCU_CHECK(marker == MARKER_ALLOCATE);
2143 TCU_CHECK(record.objectType == VK_OBJECT_TYPE_DEVICE_MEMORY);
2144 TCU_CHECK(memoryObjectId == 0);
2145 TCU_CHECK(record.memoryObjectId != 0);
2146 TCU_CHECK_MSG(record.size >= requirements.size,
2147 ("size: record=" + de::toString(record.size) +
2148 ", requirements=" + de::toString(requirements.size)).c_str());
2149
2150 allocateEvent = true;
2151 memoryObjectId = record.memoryObjectId;
2152 }
2153 else if (record.objectHandle == objectHandleA && record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_IMPORT_EXT)
2154 {
2155 TCU_CHECK(marker == MARKER_IMPORT);
2156 TCU_CHECK(record.objectType == VK_OBJECT_TYPE_DEVICE_MEMORY);
2157 TCU_CHECK_MSG(record.size >= requirements.size,
2158 ("sizeA: record=" + de::toString(record.size) +
2159 ", requirements=" + de::toString(requirements.size)).c_str());
2160 TCU_CHECK_MSG(record.memoryObjectId == memoryObjectId,
2161 ("memoryObjectIdA: record=" + de::toString(record.memoryObjectId) +
2162 ", original=" + de::toString(memoryObjectId)).c_str());
2163
2164 importA = true;
2165 }
2166 else if (record.objectHandle == objectHandleB && record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_IMPORT_EXT)
2167 {
2168 TCU_CHECK(marker == MARKER_IMPORT);
2169 TCU_CHECK(record.objectType == VK_OBJECT_TYPE_DEVICE_MEMORY);
2170 TCU_CHECK_MSG(record.size >= requirements.size,
2171 ("sizeB: record=" + de::toString(record.size) +
2172 ", requirements=" + de::toString(requirements.size)).c_str());
2173 TCU_CHECK_MSG(record.memoryObjectId == memoryObjectId,
2174 ("memoryObjectIdB: record=" + de::toString(record.memoryObjectId) +
2175 ", original=" + de::toString(memoryObjectId)).c_str());
2176
2177 importB = true;
2178 }
2179 else if (record.objectHandle == objectHandleB && record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_UNIMPORT_EXT)
2180 {
2181 TCU_CHECK(marker == MARKER_UNIMPORT);
2182 TCU_CHECK_MSG(record.memoryObjectId == memoryObjectId,
2183 ("memoryObjectIdA: record=" + de::toString(record.memoryObjectId) +
2184 ", original=" + de::toString(memoryObjectId)).c_str());
2185
2186 unimportB = true;
2187 }
2188 else if (record.objectHandle == objectHandleA && record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_UNIMPORT_EXT)
2189 {
2190 TCU_CHECK(marker == MARKER_UNIMPORT);
2191 TCU_CHECK_MSG(record.memoryObjectId == memoryObjectId,
2192 ("memoryObjectIdB: record=" + de::toString(record.memoryObjectId) +
2193 ", original=" + de::toString(memoryObjectId)).c_str());
2194
2195 unimportA = true;
2196 }
2197 else if (record.objectHandle == objectHandle && record.type == VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_FREE_EXT)
2198 {
2199 TCU_CHECK(marker == MARKER_FREE);
2200 TCU_CHECK_MSG(record.memoryObjectId == memoryObjectId,
2201 ("memoryObjectId: record=" + de::toString(record.memoryObjectId) +
2202 ", original=" + de::toString(memoryObjectId)).c_str());
2203
2204 freeEvent = true;
2205 }
2206 }
2207
2208 TCU_CHECK(allocateEvent);
2209 TCU_CHECK(importA);
2210 TCU_CHECK(importB);
2211 TCU_CHECK(unimportB);
2212 TCU_CHECK(unimportA);
2213 TCU_CHECK(freeEvent);
2214
2215 return tcu::TestStatus::pass("Pass");
2216 }
2217
createExternalMemoryTestsGroup(tcu::TestContext & testCtx,const char * name,const char * desc)2218 tcu::TestCaseGroup* createExternalMemoryTestsGroup (tcu::TestContext& testCtx, const char* name, const char* desc)
2219 {
2220 MovePtr<tcu::TestCaseGroup> group (new tcu::TestCaseGroup(testCtx, name, desc));
2221
2222 const std::vector<VkExternalMemoryHandleTypeFlagBits> externalMemoryTypes =
2223 {
2224 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT,
2225 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT,
2226 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT,
2227 VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
2228 VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT
2229 };
2230
2231 for (const auto externalMemoryType : externalMemoryTypes)
2232 {
2233 const std::string testName = std::string("import_and_unimport_") + std::string(externalMemoryTypeToName(externalMemoryType));
2234
2235 addFunctionCase(group.get(), testName.c_str(), "", checkSupport, testImportAndUnimportExternalMemory, externalMemoryType);
2236 }
2237
2238 return group.release();
2239 }
2240
2241 } // anonymous
2242
createDeviceMemoryReportTests(tcu::TestContext & testCtx)2243 tcu::TestCaseGroup* createDeviceMemoryReportTests (tcu::TestContext& testCtx)
2244 {
2245 MovePtr<tcu::TestCaseGroup> deviceMemoryReportTests (new tcu::TestCaseGroup(testCtx, "device_memory_report", "Device Memory Report tests"));
2246
2247 const Image::Parameters img1D (0u,
2248 VK_IMAGE_TYPE_1D,
2249 VK_FORMAT_R8G8B8A8_UNORM,
2250 makeExtent3D(256, 1, 1),
2251 1u,
2252 4u,
2253 VK_SAMPLE_COUNT_1_BIT,
2254 VK_IMAGE_TILING_OPTIMAL,
2255 VK_IMAGE_USAGE_SAMPLED_BIT,
2256 VK_IMAGE_LAYOUT_UNDEFINED);
2257 const Image::Parameters img2D (0u,
2258 VK_IMAGE_TYPE_2D,
2259 VK_FORMAT_R8G8B8A8_UNORM,
2260 makeExtent3D(64, 64, 1),
2261 1u,
2262 12u,
2263 VK_SAMPLE_COUNT_1_BIT,
2264 VK_IMAGE_TILING_OPTIMAL,
2265 VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
2266 VK_IMAGE_LAYOUT_UNDEFINED);
2267 const Image::Parameters imgCube (VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT,
2268 VK_IMAGE_TYPE_2D,
2269 VK_FORMAT_R8G8B8A8_UNORM,
2270 makeExtent3D(64, 64, 1),
2271 1u,
2272 12u,
2273 VK_SAMPLE_COUNT_1_BIT,
2274 VK_IMAGE_TILING_OPTIMAL,
2275 VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
2276 VK_IMAGE_LAYOUT_UNDEFINED);
2277 const Image::Parameters img3D (0u,
2278 VK_IMAGE_TYPE_3D,
2279 VK_FORMAT_R8G8B8A8_UNORM,
2280 makeExtent3D(64, 64, 4),
2281 1u,
2282 1u,
2283 VK_SAMPLE_COUNT_1_BIT,
2284 VK_IMAGE_TILING_OPTIMAL,
2285 VK_IMAGE_USAGE_SAMPLED_BIT,
2286 VK_IMAGE_LAYOUT_UNDEFINED);
2287 const ImageView::Parameters imgView1D (img1D,
2288 VK_IMAGE_VIEW_TYPE_1D,
2289 img1D.format,
2290 makeComponentMappingRGBA(),
2291 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u));
2292 const ImageView::Parameters imgView1DArr (img1D,
2293 VK_IMAGE_VIEW_TYPE_1D_ARRAY,
2294 img1D.format,
2295 makeComponentMappingRGBA(),
2296 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 4u));
2297 const ImageView::Parameters imgView2D (img2D,
2298 VK_IMAGE_VIEW_TYPE_2D,
2299 img2D.format,
2300 makeComponentMappingRGBA(),
2301 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u));
2302 const ImageView::Parameters imgView2DArr (img2D,
2303 VK_IMAGE_VIEW_TYPE_2D_ARRAY,
2304 img2D.format,
2305 makeComponentMappingRGBA(),
2306 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 8u));
2307 const ImageView::Parameters imgViewCube (imgCube,VK_IMAGE_VIEW_TYPE_CUBE,
2308 img2D.format,
2309 makeComponentMappingRGBA(),
2310 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 6u));
2311 const ImageView::Parameters imgViewCubeArr (imgCube,
2312 VK_IMAGE_VIEW_TYPE_CUBE_ARRAY,
2313 img2D.format,
2314 makeComponentMappingRGBA(),
2315 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 12u));
2316 const ImageView::Parameters imgView3D (img3D,
2317 VK_IMAGE_VIEW_TYPE_3D,
2318 img3D.format,
2319 makeComponentMappingRGBA(),
2320 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u));
2321
2322 const DescriptorSetLayout::Parameters singleUboDescLayout = DescriptorSetLayout::Parameters::single(0u, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1u, VK_SHADER_STAGE_VERTEX_BIT);
2323
2324 const NamedParameters<Device> s_deviceCases[] =
2325 {
2326 { "device", Device::Parameters() },
2327 };
2328 static const NamedParameters<DeviceMemory> s_deviceMemCases[] =
2329 {
2330 { "device_memory_small", DeviceMemory::Parameters(1024, 0u) },
2331 };
2332 static const NamedParameters<Buffer> s_bufferCases[] =
2333 {
2334 { "buffer_uniform_small", Buffer::Parameters(1024u, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT), },
2335 { "buffer_uniform_large", Buffer::Parameters(1024u*1024u*16u, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT), },
2336 { "buffer_storage_small", Buffer::Parameters(1024u, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT), },
2337 { "buffer_storage_large", Buffer::Parameters(1024u*1024u*16u, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT), },
2338 };
2339 static const NamedParameters<BufferView> s_bufferViewCases[] =
2340 {
2341 { "buffer_view_uniform_r8g8b8a8_unorm", BufferView::Parameters(Buffer::Parameters(8192u, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT), VK_FORMAT_R8G8B8A8_UNORM, 0u, 4096u) },
2342 { "buffer_view_storage_r8g8b8a8_unorm", BufferView::Parameters(Buffer::Parameters(8192u, VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT), VK_FORMAT_R8G8B8A8_UNORM, 0u, 4096u) },
2343 };
2344 static const NamedParameters<Image> s_imageCases[] =
2345 {
2346 { "image_1d", img1D },
2347 { "image_2d", img2D },
2348 { "image_3d", img3D },
2349 };
2350 static const NamedParameters<ImageView> s_imageViewCases[] =
2351 {
2352 { "image_view_1d", imgView1D },
2353 { "image_view_1d_arr", imgView1DArr },
2354 { "image_view_2d", imgView2D },
2355 { "image_view_2d_arr", imgView2DArr },
2356 { "image_view_cube", imgViewCube },
2357 { "image_view_cube_arr", imgViewCubeArr },
2358 { "image_view_3d", imgView3D },
2359 };
2360 static const NamedParameters<Semaphore> s_semaphoreCases[] =
2361 {
2362 { "semaphore", Semaphore::Parameters(0u), }
2363 };
2364 static const NamedParameters<Event> s_eventCases[] =
2365 {
2366 { "event", Event::Parameters(0u) }
2367 };
2368 static const NamedParameters<Fence> s_fenceCases[] =
2369 {
2370 { "fence", Fence::Parameters(0u) },
2371 { "fence_signaled", Fence::Parameters(VK_FENCE_CREATE_SIGNALED_BIT) }
2372 };
2373 static const NamedParameters<QueryPool> s_queryPoolCases[] =
2374 {
2375 { "query_pool", QueryPool::Parameters(VK_QUERY_TYPE_OCCLUSION, 1u, 0u) }
2376 };
2377 static const NamedParameters<ShaderModule> s_shaderModuleCases[] =
2378 {
2379 { "shader_module", ShaderModule::Parameters(VK_SHADER_STAGE_COMPUTE_BIT, "test") }
2380 };
2381 static const NamedParameters<PipelineCache> s_pipelineCacheCases[] =
2382 {
2383 { "pipeline_cache", PipelineCache::Parameters() }
2384 };
2385 static const NamedParameters<Sampler> s_samplerCases[] =
2386 {
2387 { "sampler", Sampler::Parameters() }
2388 };
2389 static const NamedParameters<DescriptorSetLayout> s_descriptorSetLayoutCases[] =
2390 {
2391 { "descriptor_set_layout_empty", DescriptorSetLayout::Parameters::empty() },
2392 { "descriptor_set_layout_single", singleUboDescLayout }
2393 };
2394 static const NamedParameters<PipelineLayout> s_pipelineLayoutCases[] =
2395 {
2396 { "pipeline_layout_empty", PipelineLayout::Parameters::empty() },
2397 { "pipeline_layout_single", PipelineLayout::Parameters::singleDescriptorSet(singleUboDescLayout) }
2398 };
2399 static const NamedParameters<RenderPass> s_renderPassCases[] =
2400 {
2401 { "render_pass", RenderPass::Parameters() }
2402 };
2403 static const NamedParameters<GraphicsPipeline> s_graphicsPipelineCases[] =
2404 {
2405 { "graphics_pipeline", GraphicsPipeline::Parameters() }
2406 };
2407 static const NamedParameters<ComputePipeline> s_computePipelineCases[] =
2408 {
2409 { "compute_pipeline", ComputePipeline::Parameters() }
2410 };
2411 static const NamedParameters<DescriptorPool> s_descriptorPoolCases[] =
2412 {
2413 { "descriptor_pool", DescriptorPool::Parameters::singleType((VkDescriptorPoolCreateFlags)0, 4u, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 3u) },
2414 { "descriptor_pool_free_descriptor_set", DescriptorPool::Parameters::singleType(VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 4u, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 3u) }
2415 };
2416 static const NamedParameters<DescriptorSet> s_descriptorSetCases[] =
2417 {
2418 { "descriptor_set", DescriptorSet::Parameters(singleUboDescLayout) }
2419 };
2420 static const NamedParameters<Framebuffer> s_framebufferCases[] =
2421 {
2422 { "framebuffer", Framebuffer::Parameters() }
2423 };
2424 static const NamedParameters<CommandPool> s_commandPoolCases[] =
2425 {
2426 { "command_pool", CommandPool::Parameters((VkCommandPoolCreateFlags)0) },
2427 { "command_pool_transient", CommandPool::Parameters(VK_COMMAND_POOL_CREATE_TRANSIENT_BIT) }
2428 };
2429 static const NamedParameters<CommandBuffer> s_commandBufferCases[] =
2430 {
2431 { "command_buffer_primary", CommandBuffer::Parameters(CommandPool::Parameters((VkCommandPoolCreateFlags)0u), VK_COMMAND_BUFFER_LEVEL_PRIMARY) },
2432 { "command_buffer_secondary", CommandBuffer::Parameters(CommandPool::Parameters((VkCommandPoolCreateFlags)0u), VK_COMMAND_BUFFER_LEVEL_SECONDARY) }
2433 };
2434
2435 const CaseDescriptions s_createDestroyObjectGroup =
2436 {
2437 CASE_DESC(createDestroyObjectTest <Device>, s_deviceCases),
2438 CASE_DESC(createDestroyObjectTest <DeviceMemory>, s_deviceMemCases),
2439 CASE_DESC(createDestroyObjectTest <Buffer>, s_bufferCases),
2440 CASE_DESC(createDestroyObjectTest <BufferView>, s_bufferViewCases),
2441 CASE_DESC(createDestroyObjectTest <Image>, s_imageCases),
2442 CASE_DESC(createDestroyObjectTest <ImageView>, s_imageViewCases),
2443 CASE_DESC(createDestroyObjectTest <Semaphore>, s_semaphoreCases),
2444 CASE_DESC(createDestroyObjectTest <Event>, s_eventCases),
2445 CASE_DESC(createDestroyObjectTest <Fence>, s_fenceCases),
2446 CASE_DESC(createDestroyObjectTest <QueryPool>, s_queryPoolCases),
2447 CASE_DESC(createDestroyObjectTest <ShaderModule>, s_shaderModuleCases),
2448 CASE_DESC(createDestroyObjectTest <PipelineCache>, s_pipelineCacheCases),
2449 CASE_DESC(createDestroyObjectTest <Sampler>, s_samplerCases),
2450 CASE_DESC(createDestroyObjectTest <DescriptorSetLayout>, s_descriptorSetLayoutCases),
2451 CASE_DESC(createDestroyObjectTest <PipelineLayout>, s_pipelineLayoutCases),
2452 CASE_DESC(createDestroyObjectTest <RenderPass>, s_renderPassCases),
2453 CASE_DESC(createDestroyObjectTest <GraphicsPipeline>, s_graphicsPipelineCases),
2454 CASE_DESC(createDestroyObjectTest <ComputePipeline>, s_computePipelineCases),
2455 CASE_DESC(createDestroyObjectTest <DescriptorPool>, s_descriptorPoolCases),
2456 CASE_DESC(createDestroyObjectTest <DescriptorSet>, s_descriptorSetCases),
2457 CASE_DESC(createDestroyObjectTest <Framebuffer>, s_framebufferCases),
2458 CASE_DESC(createDestroyObjectTest <CommandPool>, s_commandPoolCases),
2459 CASE_DESC(createDestroyObjectTest <CommandBuffer>, s_commandBufferCases),
2460 };
2461 deviceMemoryReportTests->addChild(createObjectTestsGroup(testCtx, "create_and_destroy_object", "Check emitted callbacks are properly paired", s_createDestroyObjectGroup));
2462 deviceMemoryReportTests->addChild(createVkDeviceMemoryTestsGroup(testCtx, "vk_device_memory", "Check callbacks are emitted properly for VkDeviceMemory"));
2463 deviceMemoryReportTests->addChild(createExternalMemoryTestsGroup(testCtx, "external_memory", "Check callbacks are emitted properly for external memory"));
2464
2465 return deviceMemoryReportTests.release();
2466 }
2467
2468 } // memory
2469 } // vkt
2470