• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 The Khronos Group Inc.
3  * Copyright (c) 2023 Valve Corporation
4  * Copyright (c) 2023 LunarG, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and/or associated documentation files (the "Materials"), to
8  * deal in the Materials without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Materials, and to permit persons to whom the Materials are
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice(s) and this permission notice shall be included in
14  * all copies or substantial portions of the Materials.
15  *
16  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  *
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
23  * USE OR OTHER DEALINGS IN THE MATERIALS.
24  *
25  * Author: Charles Giessen <charles@lunarg.com>
26  */
27 
28 #include <vulkan/vulkan.h>
29 
30 #include <chrono>
31 #include <iostream>
32 #include <vector>
33 #include <string>
34 #include <iomanip>
35 #include <thread>
36 
main()37 int main() {
38     // uint32_t iterations = 20;
39     // std::vector<std::chrono::microseconds> samples;
40     // samples.resize(iterations);
41     // for (uint32_t i = 0; i < iterations; i++) {
42     //     auto t1 = std::chrono::system_clock::now();
43     //     uint32_t count = 0;
44     //     vkEnumerateInstanceExtensionProperties(nullptr, &count, nullptr);
45     //     // vkEnumerateInstanceLayerProperties(&count, nullptr);
46     //     // vkEnumerateInstanceVersion(&count);
47     //     auto t2 = std::chrono::system_clock::now();
48     //     samples[i] = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1);
49     // }
50     // std::chrono::microseconds total_time{};
51     // for (uint32_t i = 0; i < iterations; i++) {
52     //     total_time += samples[i];
53     // }
54     // std::cout << "average time " << total_time.count() / iterations << " (μs)\n";
55     // std::cout << std::setw(10) << "Iteration" << std::setw(12) << " Time (μs)\n";
56     // for (uint32_t i = 0; i < iterations; i++) {
57     //     std::cout << std::setw(10) << std::to_string(i) << std::setw(12) << samples[i].count() << "\n";
58     // }
59 
60     uint32_t count = 0;
61     VkInstanceCreateInfo ci{};
62     VkInstance i{};
63     auto res = vkCreateInstance(&ci, nullptr, &i);
64     if (res != VK_SUCCESS) return -1;
65     std::cout << "After called vkCreateInstance\n";
66     do {
67         std::cout << '\n' << "Press a key to continue...";
68     } while (std::cin.get() != '\n');
69     vkDestroyInstance(i, nullptr);
70     std::cout << "After called vkDestroyInstance\n";
71     do {
72         std::cout << '\n' << "Press a key to continue...";
73     } while (std::cin.get() != '\n');
74 }
75