Debian Codegraph @

deps/vkgears/vkgears.c

raw symbols SCIP
1 /*
2 * Hardinfo2 - System Information & Benchmark
3 * Copyright hardinfo2 project, hwspeedy 2025
4 * License: GPL2+
5 *
6 * Copyright © 2022 Collabora Ltd
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27 #include "matrix.h"cxx . . $ `<file>/deps/vkgears/matrix.h`/
28
29 #include <stdbool.h>
30 #include <stdio.h>
31 #include <assert.h>
32 #include <stdlib.h>
33 #include <stdarg.h>
34 #include <string.h>
35 #include <math.h>
36
37 #include <sys/time.h>
38
39 #include <vulkan/vulkan.h>
40
41 #include "wsi/wsi.h"cxx . . $ `<file>/deps/vkgears/wsi/wsi.h`/
42
43 /*Change this version on any changes to benchmark*/
44 #define VKBENCH_VERSIONcxx . . $ `deps/vkgears/vkgears.c:44:9`! 3
45
46 #ifndef VK_API_VERSION_MAJORcxx . . $ `<external>/13734482859137699468/vulkan_core.h:88:9`!
47 /* retain compatibility with old vulkan headers */
48 #define VK_API_VERSION_MAJOR VK_VERSION_MAJOR
49 #define VK_API_VERSION_MINOR VK_VERSION_MINOR
50 #define VK_API_VERSION_PATCH VK_VERSION_PATCH
51 #endif
52
53 static unsigned long device_indexcxx . . $ device_index. = 0;
54
55 static struct wsi_interfacecxx . . $ wsi_interface# wsicxx . . $ wsi.;
56
57 static VkInstancecxx . . $ VkInstance# instancecxx . . $ instance.;
58 static VkPhysicalDevicecxx . . $ VkPhysicalDevice# physical_devicecxx . . $ physical_device.;
59 static VkPhysicalDeviceMemoryPropertiescxx . . $ VkPhysicalDeviceMemoryProperties# mem_propscxx . . $ mem_props.;
60 static VkDevicecxx . . $ VkDevice# devicecxx . . $ device.;
61 static VkQueuecxx . . $ VkQueue# queuecxx . . $ queue.;
62
63 /* swapchain */
64 static int widthcxx . . $ width., heightcxx . . $ height., new_widthcxx . . $ new_width., new_heightcxx . . $ new_height.;
65 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! fullscreencxx . . $ fullscreen.;
66 static VkPresentModeKHRcxx . . $ VkPresentModeKHR# desidered_present_modecxx . . $ desidered_present_mode.;
67 static VkSampleCountFlagBitscxx . . $ VkSampleCountFlagBits# sample_countcxx . . $ sample_count.;
68 static uint32_tcxx . . $ uint32_t# image_countcxx . . $ image_count.;
69 static VkRenderPasscxx . . $ VkRenderPass# render_passcxx . . $ render_pass.;
70 static VkCommandPoolcxx . . $ VkCommandPool# cmd_poolcxx . . $ cmd_pool.;
71 static VkPresentModeKHRcxx . . $ VkPresentModeKHR# present_modecxx . . $ present_mode.;
72 static VkFormatcxx . . $ VkFormat# image_formatcxx . . $ image_format.;
73 static VkColorSpaceKHRcxx . . $ VkColorSpaceKHR# color_spacecxx . . $ color_space.;
74 static VkFormatcxx . . $ VkFormat# depth_formatcxx . . $ depth_format.;
75 uint32_tcxx . . $ uint32_t# min_image_countcxx . . $ min_image_count. = 2;
76 static VkSurfaceKHRcxx . . $ VkSurfaceKHR# surfacecxx . . $ surface.;
77 static VkSwapchainKHRcxx . . $ VkSwapchainKHR# swapchaincxx . . $ swapchain.;
78 static VkImagecxx . . $ VkImage# color_msaacxx . . $ color_msaa., depth_imagecxx . . $ depth_image.;
79 static VkImageViewcxx . . $ VkImageView# color_msaa_viewcxx . . $ color_msaa_view., depth_viewcxx . . $ depth_view.;
80 static VkDeviceMemorycxx . . $ VkDeviceMemory# color_msaa_memorycxx . . $ color_msaa_memory., depth_memorycxx . . $ depth_memory.;
81 static VkSemaphorecxx . . $ VkSemaphore# present_semaphorecxx . . $ present_semaphore.;
82
83 structcxx . . $ $anonymous_type_35552c03753a375_0# {
84 VkImagecxx . . $ VkImage# imagecxx . . $ $anonymous_type_35552c03753a375_0#image.;
85 VkImageViewcxx . . $ VkImageView# viewcxx . . $ $anonymous_type_35552c03753a375_0#view.;
86 VkFramebuffercxx . . $ VkFramebuffer# framebuffercxx . . $ $anonymous_type_35552c03753a375_0#framebuffer.;
87 } image_datacxx . . $ image_data.[5];
88
89 #define MAX_CONCURRENT_FRAMEScxx . . $ `deps/vkgears/vkgears.c:89:9`! 2
90 structcxx . . $ $anonymous_type_35552c03753a375_1# {
91 VkFencecxx . . $ VkFence# fencecxx . . $ $anonymous_type_35552c03753a375_1#fence.;
92 VkCommandBuffercxx . . $ VkCommandBuffer# cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.;
93 VkSemaphorecxx . . $ VkSemaphore# semaphorecxx . . $ $anonymous_type_35552c03753a375_1#semaphore.;
94 } frame_datacxx . . $ frame_data.[MAX_CONCURRENT_FRAMEScxx . . $ `deps/vkgears/vkgears.c:89:9`!];
95
96 #define ARRAY_SIZEcxx . . $ `deps/vkgears/vkgears.c:96:9`!(arr) (sizeof(arr) / sizeof((arr)[0]))
97
98 /* gear data */
99 static VkDescriptorSetcxx . . $ VkDescriptorSet# descriptor_setcxx . . $ descriptor_set.;
100 static VkDeviceMemorycxx . . $ VkDeviceMemory# ubo_memcxx . . $ ubo_mem.;
101 static VkDeviceMemorycxx . . $ VkDeviceMemory# vertex_memcxx . . $ vertex_mem.;
102 static VkBuffercxx . . $ VkBuffer# ubo_buffercxx . . $ ubo_buffer.;
103 static VkBuffercxx . . $ VkBuffer# vertex_buffercxx . . $ vertex_buffer.;
104 static VkPipelineLayoutcxx . . $ VkPipelineLayout# pipeline_layoutcxx . . $ pipeline_layout.;
105 static VkPipelinecxx . . $ VkPipeline# pipelinecxx . . $ pipeline.;
106 size_t vertex_offsetcxx . . $ vertex_offset., normals_offsetcxx . . $ normals_offset.;
107
108 structcxx . . $ $anonymous_type_35552c03753a375_2# {
109 uint32_tcxx . . $ uint32_t# first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex.;
110 uint32_tcxx . . $ uint32_t# vertex_countcxx . . $ $anonymous_type_35552c03753a375_2#vertex_count.;
111 } gearscxx . . $ gears.[3];
112
113 static float view_rotcxx . . $ view_rot.[3] = { 20.0, 30.0, 0.0 };
114 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! animatecxx . . $ animate. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
115
116 static void
117 errorvcxx . . $ errorv(ac175dd46a4e4d7f).(const char *format, va_listcxx . . $ va_list# args)
118 {
119 vfprintfcxx . . $ vfprintf(bded311e54d67f9c).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, format, args);
120 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
121 exitcxx . . $ exit(3ca292c338df9bb3).(1);
122 }
123
124 static void
125 errorcxx . . $ error(326aeb464d16410c).(const char *format, ...)
126 {
127 va_listcxx . . $ va_list# args;
128 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, format);
129 errorvcxx . . $ errorv(ac175dd46a4e4d7f).(format, args);
130 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args);
131 }
132
133 static double
134 current_timecxx . . $ current_time(31fa7155c10fdd13).(void)
135 {
136 struct timevalcxx . . $ timeval# tv;
137 (void) gettimeofdaycxx . . $ gettimeofday(ee8865a94200b3d6).(&tv, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! );
138 return (double) tv.tv_seccxx . . $ timeval#tv_sec. + tv.tv_useccxx . . $ timeval#tv_usec. / 1000000.0;
139 }
140
141 static void
142 init_vkcxx . . $ init_vk(85c52e162fed56f9).(const char *wsi_extension)
143 {
144 uint32_tcxx . . $ uint32_t# api_version = VK_API_VERSION_1_0cxx . . $ `<external>/13734482859137699468/vulkan_core.h:92:9`!;
145
146 // use Vulkan 1.1 if supported
147 uint32_tcxx . . $ uint32_t# instance_version = api_version;
148 VkResultcxx . . $ VkResult# res = vkEnumerateInstanceVersioncxx . . $ vkEnumerateInstanceVersion(550863150dfdd8b9).(&instance_version);
149 if (res == VK_SUCCESScxx . . $ VK_SUCCESS. && instance_version >= VK_API_VERSION_1_1cxx . . $ `<external>/13734482859137699468/vulkan_core.h:5367:9`!)
150 api_version = VK_API_VERSION_1_1cxx . . $ `<external>/13734482859137699468/vulkan_core.h:5367:9`!;
151
152 VkInstanceCreateFlagscxx . . $ VkInstanceCreateFlags# instance_flags = 0;
153
154 // Instance extensions to use
155 const char *inst_exts[3];
156
157 // Look for optional instance extensions
158 uint32_tcxx . . $ uint32_t# inst_ext_props_count = 0;
159 res = vkEnumerateInstanceExtensionPropertiescxx . . $ vkEnumerateInstanceExtensionProperties(27001f34b46d2a6d).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &inst_ext_props_count,
160 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
161 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
162 errorcxx . . $ error(326aeb464d16410c).("Failed to get instance extensions properties count");
163
164 VkExtensionPropertiescxx . . $ VkExtensionProperties# *inst_ext_props =
165 calloccxx . . $ calloc(63a7bf2941bfcd7a).(inst_ext_props_count, sizeof(VkExtensionPropertiescxx . . $ VkExtensionProperties#));
166 if (!inst_ext_props)
167 errorcxx . . $ error(326aeb464d16410c).("Failed to allocate extension properties");
168
169 res = vkEnumerateInstanceExtensionPropertiescxx . . $ vkEnumerateInstanceExtensionProperties(27001f34b46d2a6d).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &inst_ext_props_count,
170 inst_ext_props);
171 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
172 errorcxx . . $ error(326aeb464d16410c).("Failed to get instance extensions properties");
173
174 uint32_tcxx . . $ uint32_t# count = 0;
175 #ifdef VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAMEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:12514:9`!
176 for (uint32_tcxx . . $ uint32_t# i = 0; i < inst_ext_props_count; ++i) {
177 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(inst_ext_props[i].extensionNamecxx . . $ VkExtensionProperties#extensionName.,
178 VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAMEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:12514:9`!)) {
179 inst_exts[count++] =
180 VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAMEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:12514:9`!;
181 instance_flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHRcxx . . $ VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR.;
182 }
183 }
184 #endif
185
186 freecxx . . $ free(5d22bdacc48458e8).(inst_ext_props);
187
188 if (wsi_extension) {
189 /* Requires a WSI extension, add it and the base extension
190 * VK_KHR_SURFACE_EXTENSION_NAME
191 */
192 inst_exts[count++] = VK_KHR_SURFACE_EXTENSION_NAMEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:8819:9`!;
193 inst_exts[count++] = wsi_extension;
194 }
195
196 res = vkCreateInstancecxx . . $ vkCreateInstance(a841a7fc5e6952cf).(
197 &(VkInstanceCreateInfocxx . . $ VkInstanceCreateInfo#) {
198 .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO.,
199 .flags = instance_flags,
200 .pApplicationInfo = &(VkApplicationInfocxx . . $ VkApplicationInfo#) {
201 .sType = VK_STRUCTURE_TYPE_APPLICATION_INFOcxx . . $ VK_STRUCTURE_TYPE_APPLICATION_INFO.,
202 .pApplicationName = "Vulkan Benchmark",
203 .apiVersion = api_version,
204 },
205 .enabledExtensionCount = count,
206 .ppEnabledExtensionNames = inst_exts,
207 },
208 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
209 &instancecxx . . $ instance.);
210
211 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
212 errorcxx . . $ error(326aeb464d16410c).("Failed to create Vulkan instance.");
213
214 res = vkEnumeratePhysicalDevicescxx . . $ vkEnumeratePhysicalDevices(175e58b8545e73ae).(instancecxx . . $ instance., &count, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
215 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
216 errorcxx . . $ error(326aeb464d16410c).("Failed to enumerate physical devices.");
217
218 if (count == 0)
219 errorcxx . . $ error(326aeb464d16410c).("No Vulkan devices found.");
220
221 VkPhysicalDevicecxx . . $ VkPhysicalDevice# *physical_devices = calloccxx . . $ calloc(63a7bf2941bfcd7a).(count, sizeof(VkPhysicalDevicecxx . . $ VkPhysicalDevice#));
222 if (!physical_devices)
223 errorcxx . . $ error(326aeb464d16410c).("Failed to allocate physical devices.");
224
225 res = vkEnumeratePhysicalDevicescxx . . $ vkEnumeratePhysicalDevices(175e58b8545e73ae).(instancecxx . . $ instance., &count, physical_devices);
226 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
227 errorcxx . . $ error(326aeb464d16410c).("Failed to enumerate physical devices.");
228
229 if (device_indexcxx . . $ device_index. >= count)
230 errorcxx . . $ error(326aeb464d16410c).("Invalid device");
231
232 physical_devicecxx . . $ physical_device. = physical_devices[device_indexcxx . . $ device_index.];
233
234 vkGetPhysicalDeviceMemoryPropertiescxx . . $ vkGetPhysicalDeviceMemoryProperties(813adcf1e803573f).(physical_devicecxx . . $ physical_device., &mem_propscxx . . $ mem_props.);
235
236 count = 1;
237 VkQueueFamilyPropertiescxx . . $ VkQueueFamilyProperties# props;
238 vkGetPhysicalDeviceQueueFamilyPropertiescxx . . $ vkGetPhysicalDeviceQueueFamilyProperties(1a3e5e74accccb7e).(physical_devicecxx . . $ physical_device., &count, &props);
239 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(props.queueFlags & VK_QUEUE_GRAPHICS_BIT);
240
241 res = vkCreateDevicecxx . . $ vkCreateDevice(b6838f66b650b666).(physical_devicecxx . . $ physical_device.,
242 &(VkDeviceCreateInfocxx . . $ VkDeviceCreateInfo#) {
243 .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO.,
244 .queueCreateInfoCount = 1,
245 .pQueueCreateInfos = &(VkDeviceQueueCreateInfocxx . . $ VkDeviceQueueCreateInfo#) {
246 .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO.,
247 .queueFamilyIndex = 0,
248 .queueCount = 1,
249 .flags = 0,
250 .pQueuePriorities = (float []) { 1.0f },
251 },
252 .enabledExtensionCount = 1,
253 .ppEnabledExtensionNames = (const char * const []) {
254 VK_KHR_SWAPCHAIN_EXTENSION_NAMEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:8949:9`!,
255 },
256 },
257 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
258 &devicecxx . . $ device.);
259
260 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
261 errorcxx . . $ error(326aeb464d16410c).("Failed to create Vulkan device.");
262
263 vkGetDeviceQueuecxx . . $ vkGetDeviceQueue(ad70428aec1cd3fe).(devicecxx . . $ device., 0, 0, &queuecxx . . $ queue.);
264
265 vkCreateCommandPoolcxx . . $ vkCreateCommandPool(a85f959a9f6c3ff0).(devicecxx . . $ device.,
266 &(const VkCommandPoolCreateInfocxx . . $ VkCommandPoolCreateInfo#) {
267 .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO.,
268 .queueFamilyIndex = 0,
269 .flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BITcxx . . $ VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT.
270 },
271 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
272 &cmd_poolcxx . . $ cmd_pool.);
273
274 vkCreateSemaphorecxx . . $ vkCreateSemaphore(b2b2a0a4370c5e53).(devicecxx . . $ device.,
275 &(VkSemaphoreCreateInfocxx . . $ VkSemaphoreCreateInfo#) {
276 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO.,
277 },
278 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
279 &present_semaphorecxx . . $ present_semaphore.);
280 }
281
282 static int
283 find_memory_typecxx . . $ find_memory_type(68be34e0a2e51885).(const VkMemoryRequirementscxx . . $ VkMemoryRequirements# *reqs,
284 VkMemoryPropertyFlagscxx . . $ VkMemoryPropertyFlags# flags)
285 {
286 for (unsigned i = 0; (1u << i) <= reqs->memoryTypeBitscxx . . $ VkMemoryRequirements#memoryTypeBits. &&
287 i <= mem_propscxx . . $ mem_props..memoryTypeCountcxx . . $ VkPhysicalDeviceMemoryProperties#memoryTypeCount.; ++i) {
288 if ((reqs->memoryTypeBitscxx . . $ VkMemoryRequirements#memoryTypeBits. & (1u << i)) &&
289 (mem_propscxx . . $ mem_props..memoryTypescxx . . $ VkPhysicalDeviceMemoryProperties#memoryTypes.[i].propertyFlagscxx . . $ VkMemoryType#propertyFlags. & flags) == flags)
290 return i;
291 }
292 return -1;
293 }
294
295 static int
296 image_allocatecxx . . $ image_allocate(230fff06749e784c).(VkImagecxx . . $ VkImage# image, VkMemoryRequirementscxx . . $ VkMemoryRequirements# reqs, int memory_type,
297 VkDeviceMemorycxx . . $ VkDeviceMemory# *image_memory)
298 {
299 int res = vkAllocateMemorycxx . . $ vkAllocateMemory(ffce6ec704e8416f).(devicecxx . . $ device.,
300 &(VkMemoryAllocateInfocxx . . $ VkMemoryAllocateInfo#) {
301 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFOcxx . . $ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO.,
302 .allocationSize = reqs.sizecxx . . $ VkMemoryRequirements#size.,
303 .memoryTypeIndex = memory_type,
304 },
305 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
306 image_memory);
307 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
308 return -1;
309
310 res = vkBindImageMemorycxx . . $ vkBindImageMemory(745cbbda7ad902c0).(devicecxx . . $ device., image, *image_memory, 0);
311 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
312 return -1;
313
314 return 0;
315 }
316
317 static int
318 create_imagecxx . . $ create_image(bc7320cc2bdd85ff).(VkFormatcxx . . $ VkFormat# format,
319 VkExtent3Dcxx . . $ VkExtent3D# extent,
320 VkSampleCountFlagBitscxx . . $ VkSampleCountFlagBits# samples,
321 VkImageUsageFlagscxx . . $ VkImageUsageFlags# usage,
322 VkImagecxx . . $ VkImage# *image)
323 {
324 VkResultcxx . . $ VkResult# res = vkCreateImagecxx . . $ vkCreateImage(980188b1bb18635a).(devicecxx . . $ device.,
325 &(VkImageCreateInfocxx . . $ VkImageCreateInfo#) {
326 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO.,
327 .flags = 0,
328 .imageType = VK_IMAGE_TYPE_2Dcxx . . $ VK_IMAGE_TYPE_2D.,
329 .format = format,
330 .extent = extent,
331 .mipLevels = 1,
332 .arrayLayers = 1,
333 .samples = samples,
334 .tiling = VK_IMAGE_TILING_OPTIMALcxx . . $ VK_IMAGE_TILING_OPTIMAL.,
335 .usage = usage,
336 .sharingMode = VK_SHARING_MODE_EXCLUSIVEcxx . . $ VK_SHARING_MODE_EXCLUSIVE.,
337 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINEDcxx . . $ VK_IMAGE_LAYOUT_UNDEFINED.,
338 }, 0, image);
339 if (res != VK_SUCCESScxx . . $ VK_SUCCESS.)
340 return -1;
341
342 return 0;
343 }
344
345 static int
346 create_image_viewcxx . . $ create_image_view(cdb0feaa4627b392).(VkImagecxx . . $ VkImage# image,
347 VkFormatcxx . . $ VkFormat# view_format,
348 VkImageAspectFlagscxx . . $ VkImageAspectFlags# aspect_mask,
349 VkImageViewcxx . . $ VkImageView# *image_view)
350 {
351 int res = vkCreateImageViewcxx . . $ vkCreateImageView(77fe79dbf32b7a71).(devicecxx . . $ device.,
352 &(VkImageViewCreateInfocxx . . $ VkImageViewCreateInfo#) {
353 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO.,
354 .image = image,
355 .viewType = VK_IMAGE_VIEW_TYPE_2Dcxx . . $ VK_IMAGE_VIEW_TYPE_2D.,
356 .format = view_format,
357 .components = {
358 .r = VK_COMPONENT_SWIZZLE_Rcxx . . $ VK_COMPONENT_SWIZZLE_R.,
359 .g = VK_COMPONENT_SWIZZLE_Gcxx . . $ VK_COMPONENT_SWIZZLE_G.,
360 .b = VK_COMPONENT_SWIZZLE_Bcxx . . $ VK_COMPONENT_SWIZZLE_B.,
361 .a = VK_COMPONENT_SWIZZLE_Acxx . . $ VK_COMPONENT_SWIZZLE_A.,
362 },
363 .subresourceRange = {
364 .aspectMask = aspect_mask,
365 .baseMipLevel = 0,
366 .levelCount = 1,
367 .baseArrayLayer = 0,
368 .layerCount = 1,
369 },
370 },
371 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
372 image_view);
373
374 if(res != VK_SUCCESScxx . . $ VK_SUCCESS.)
375 return -1;
376 return 0;
377 }
378
379 static void
380 create_render_passcxx . . $ create_render_pass(d878ad36e69247c7).()
381 {
382 int attachment_count, color_attachment_index, dependency_count;
383 VkAttachmentReferencecxx . . $ VkAttachmentReference# *resolve_attachments = (VkAttachmentReferencecxx . . $ VkAttachmentReference# []) {
384 {
385 .attachment = 0,
386 .layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMALcxx . . $ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL.
387 }
388 };
389
390 if (sample_countcxx . . $ sample_count. != VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT.) {
391 attachment_count = 3;
392 dependency_count = 3;
393 color_attachment_index = 2;
394 } else {
395 attachment_count = 2;
396 dependency_count = 2;
397 resolve_attachments = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
398 color_attachment_index = 0;
399 }
400
401 vkCreateRenderPasscxx . . $ vkCreateRenderPass(12dd99065d164a87).(devicecxx . . $ device.,
402 &(VkRenderPassCreateInfocxx . . $ VkRenderPassCreateInfo#) {
403 .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO.,
404 .attachmentCount = attachment_count,
405 .pAttachments = (VkAttachmentDescriptioncxx . . $ VkAttachmentDescription#[]) {
406 {
407 .format = image_formatcxx . . $ image_format.,
408 .samples = VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT.,
409 .loadOp = VK_ATTACHMENT_LOAD_OP_CLEARcxx . . $ VK_ATTACHMENT_LOAD_OP_CLEAR.,
410 .storeOp = VK_ATTACHMENT_STORE_OP_STOREcxx . . $ VK_ATTACHMENT_STORE_OP_STORE.,
411 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINEDcxx . . $ VK_IMAGE_LAYOUT_UNDEFINED.,
412 .finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHRcxx . . $ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.,
413 },
414 {
415 .format = depth_formatcxx . . $ depth_format.,
416 .samples = sample_countcxx . . $ sample_count.,
417 .loadOp = VK_ATTACHMENT_LOAD_OP_CLEARcxx . . $ VK_ATTACHMENT_LOAD_OP_CLEAR.,
418 .storeOp = VK_ATTACHMENT_STORE_OP_DONT_CAREcxx . . $ VK_ATTACHMENT_STORE_OP_DONT_CARE.,
419 .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CAREcxx . . $ VK_ATTACHMENT_LOAD_OP_DONT_CARE.,
420 .stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CAREcxx . . $ VK_ATTACHMENT_STORE_OP_DONT_CARE.,
421 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINEDcxx . . $ VK_IMAGE_LAYOUT_UNDEFINED.,
422 .finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMALcxx . . $ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL.,
423 },
424 {
425 .format = image_formatcxx . . $ image_format.,
426 .samples = sample_countcxx . . $ sample_count.,
427 .loadOp = VK_ATTACHMENT_LOAD_OP_CLEARcxx . . $ VK_ATTACHMENT_LOAD_OP_CLEAR.,
428 .storeOp = VK_ATTACHMENT_STORE_OP_STOREcxx . . $ VK_ATTACHMENT_STORE_OP_STORE.,
429 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINEDcxx . . $ VK_IMAGE_LAYOUT_UNDEFINED.,
430 .finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMALcxx . . $ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL.,
431 },
432 },
433 .subpassCount = 1,
434 .pSubpasses = (VkSubpassDescriptioncxx . . $ VkSubpassDescription# []) {
435 {
436 .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICScxx . . $ VK_PIPELINE_BIND_POINT_GRAPHICS.,
437 .inputAttachmentCount = 0,
438 .colorAttachmentCount = 1,
439 .pColorAttachments = (VkAttachmentReferencecxx . . $ VkAttachmentReference# []) {
440 {
441 .attachment = color_attachment_index,
442 .layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMALcxx . . $ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL.
443 }
444 },
445 .pDepthStencilAttachment = (VkAttachmentReferencecxx . . $ VkAttachmentReference# []) {
446 {
447 .attachment = 1,
448 .layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMALcxx . . $ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL.,
449 }
450 },
451 .pResolveAttachments = resolve_attachments,
452 .preserveAttachmentCount = 0,
453 .pPreserveAttachments = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
454 }
455 },
456 .dependencyCount = dependency_count,
457 .pDependencies = (VkSubpassDependencycxx . . $ VkSubpassDependency# []) {
458 {
459 /* depth buffer is shared between swapchain images */
460 .srcSubpass = VK_SUBPASS_EXTERNALcxx . . $ `<external>/13734482859137699468/vulkan_core.h:138:9`!,
461 .dstSubpass = 0,
462 .srcStageMask = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BITcxx . . $ VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT. |
463 VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BITcxx . . $ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT.,
464 .dstStageMask = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BITcxx . . $ VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT. |
465 VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BITcxx . . $ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT.,
466 .srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BITcxx . . $ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT.,
467 .dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BITcxx . . $ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT. |
468 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BITcxx . . $ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT.,
469 .dependencyFlags = 0,
470 },
471 {
472 /* image layout */
473 .srcSubpass = VK_SUBPASS_EXTERNALcxx . . $ `<external>/13734482859137699468/vulkan_core.h:138:9`!,
474 .dstSubpass = 0,
475 .srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BITcxx . . $ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT.,
476 .dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BITcxx . . $ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT.,
477 .srcAccessMask = 0,
478 .dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BITcxx . . $ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT. |
479 VK_ACCESS_COLOR_ATTACHMENT_READ_BITcxx . . $ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT.,
480 .dependencyFlags = 0,
481 },
482 {
483 /* msaa buffer is shared between swapchain images */
484 .srcSubpass = VK_SUBPASS_EXTERNALcxx . . $ `<external>/13734482859137699468/vulkan_core.h:138:9`!,
485 .dstSubpass = 0,
486 .srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BITcxx . . $ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT.,
487 .dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BITcxx . . $ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT.,
488 .srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BITcxx . . $ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT.,
489 .dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BITcxx . . $ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT. |
490 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BITcxx . . $ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT.,
491 .dependencyFlags = 0,
492 },
493 },
494 },
495 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
496 &render_passcxx . . $ render_pass.);
497 }
498
499 static void
500 configure_swapchaincxx . . $ configure_swapchain(d878ad36e69247c7).()
501 {
502 VkSurfaceCapabilitiesKHRcxx . . $ VkSurfaceCapabilitiesKHR# surface_caps;
503 vkGetPhysicalDeviceSurfaceCapabilitiesKHRcxx . . $ vkGetPhysicalDeviceSurfaceCapabilitiesKHR(49f177147f7c56e).(physical_devicecxx . . $ physical_device., surfacecxx . . $ surface.,
504 &surface_caps);
505 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(surface_caps.supportedCompositeAlpha &
506 VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR);
507
508 VkBool32cxx . . $ VkBool32# supported;
509 vkGetPhysicalDeviceSurfaceSupportKHRcxx . . $ vkGetPhysicalDeviceSurfaceSupportKHR(f6ee3c4049dd6ae5).(physical_devicecxx . . $ physical_device., 0, surfacecxx . . $ surface.,
510 &supported);
511 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(supported);
512
513 uint32_tcxx . . $ uint32_t# count;
514 vkGetPhysicalDeviceSurfacePresentModesKHRcxx . . $ vkGetPhysicalDeviceSurfacePresentModesKHR(e8cddfcbfd0fa2a9).(physical_devicecxx . . $ physical_device., surfacecxx . . $ surface.,
515 &count, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
516
517 VkPresentModeKHRcxx . . $ VkPresentModeKHR# *present_modes = calloccxx . . $ calloc(63a7bf2941bfcd7a).(count, sizeof(VkPresentModeKHRcxx . . $ VkPresentModeKHR#));
518 if (!present_modes)
519 errorcxx . . $ error(326aeb464d16410c).("Failed to allocate array for present modes.");
520
521 vkGetPhysicalDeviceSurfacePresentModesKHRcxx . . $ vkGetPhysicalDeviceSurfacePresentModesKHR(e8cddfcbfd0fa2a9).(physical_devicecxx . . $ physical_device., surfacecxx . . $ surface.,
522 &count, present_modes);
523 uint32_tcxx . . $ uint32_t# i;
524 present_modecxx . . $ present_mode. = VK_PRESENT_MODE_MAILBOX_KHRcxx . . $ VK_PRESENT_MODE_MAILBOX_KHR.;
525 for (i = 0; i < count; i++) {
526 if (present_modes[i] == desidered_present_modecxx . . $ desidered_present_mode.) {
527 present_modecxx . . $ present_mode. = desidered_present_modecxx . . $ desidered_present_mode.;
528 break;
529 }
530 }
531
532 freecxx . . $ free(5d22bdacc48458e8).(present_modes);
533
534 min_image_countcxx . . $ min_image_count. = 2;
535 if (min_image_countcxx . . $ min_image_count. < surface_caps.minImageCountcxx . . $ VkSurfaceCapabilitiesKHR#minImageCount.) {
536 if (surface_caps.minImageCountcxx . . $ VkSurfaceCapabilitiesKHR#minImageCount. > ARRAY_SIZEcxx . . $ `deps/vkgears/vkgears.c:96:9`!(image_data))
537 errorcxx . . $ error(326aeb464d16410c).("surface_caps.minImageCount is too large (is: %d, max: %d)",
538 surface_caps.minImageCountcxx . . $ VkSurfaceCapabilitiesKHR#minImageCount., ARRAY_SIZEcxx . . $ `deps/vkgears/vkgears.c:96:9`!(image_data));
539 min_image_countcxx . . $ min_image_count. = surface_caps.minImageCountcxx . . $ VkSurfaceCapabilitiesKHR#minImageCount.;
540 }
541
542 if (surface_caps.maxImageCountcxx . . $ VkSurfaceCapabilitiesKHR#maxImageCount. > 0 &&
543 min_image_countcxx . . $ min_image_count. > surface_caps.maxImageCountcxx . . $ VkSurfaceCapabilitiesKHR#maxImageCount.) {
544 min_image_countcxx . . $ min_image_count. = surface_caps.maxImageCountcxx . . $ VkSurfaceCapabilitiesKHR#maxImageCount.;
545 }
546
547 vkGetPhysicalDeviceSurfaceFormatsKHRcxx . . $ vkGetPhysicalDeviceSurfaceFormatsKHR(b0b90f84bb23f928).(physical_devicecxx . . $ physical_device., surfacecxx . . $ surface.,
548 &count, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
549
550 VkSurfaceFormatKHRcxx . . $ VkSurfaceFormatKHR# *surface_formats = calloccxx . . $ calloc(63a7bf2941bfcd7a).(count,
551 sizeof(VkSurfaceFormatKHRcxx . . $ VkSurfaceFormatKHR#));
552 if (!surface_formats)
553 errorcxx . . $ error(326aeb464d16410c).("Failed to allocate array for surface formats");
554
555 vkGetPhysicalDeviceSurfaceFormatsKHRcxx . . $ vkGetPhysicalDeviceSurfaceFormatsKHR(b0b90f84bb23f928).(physical_devicecxx . . $ physical_device., surfacecxx . . $ surface.,
556 &count, surface_formats);
557 image_formatcxx . . $ image_format. = surface_formats[0].formatcxx . . $ VkSurfaceFormatKHR#format.;
558 color_spacecxx . . $ color_space. = surface_formats[0].colorSpacecxx . . $ VkSurfaceFormatKHR#colorSpace.;
559 for (i = 0; i < count; i++) {
560 if (surface_formats[i].formatcxx . . $ VkSurfaceFormatKHR#format. == VK_FORMAT_B8G8R8A8_SRGBcxx . . $ VK_FORMAT_B8G8R8A8_SRGB. &&
561 surface_formats[i].colorSpacecxx . . $ VkSurfaceFormatKHR#colorSpace. == VK_COLOR_SPACE_SRGB_NONLINEAR_KHRcxx . . $ VK_COLOR_SPACE_SRGB_NONLINEAR_KHR.) {
562 image_formatcxx . . $ image_format. = surface_formats[i].formatcxx . . $ VkSurfaceFormatKHR#format.;
563 color_spacecxx . . $ color_space. = surface_formats[i].colorSpacecxx . . $ VkSurfaceFormatKHR#colorSpace.;
564 break;
565 }
566 }
567
568 freecxx . . $ free(5d22bdacc48458e8).(surface_formats);
569
570 /* either VK_FORMAT_D32_SFLOAT or VK_FORMAT_X8_D24_UNORM_PACK32 needs to
571 * be supported; find out which one
572 */
573 VkFormatPropertiescxx . . $ VkFormatProperties# props;
574 vkGetPhysicalDeviceFormatPropertiescxx . . $ vkGetPhysicalDeviceFormatProperties(1211675914486c42).(physical_devicecxx . . $ physical_device., VK_FORMAT_D32_SFLOATcxx . . $ VK_FORMAT_D32_SFLOAT.,
575 &props);
576 depth_formatcxx . . $ depth_format. = (props.optimalTilingFeaturescxx . . $ VkFormatProperties#optimalTilingFeatures. &
577 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BITcxx . . $ VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT.) ?
578 VK_FORMAT_D32_SFLOATcxx . . $ VK_FORMAT_D32_SFLOAT. : VK_FORMAT_X8_D24_UNORM_PACK32cxx . . $ VK_FORMAT_X8_D24_UNORM_PACK32.;
579 }
580
581 static void
582 create_swapchaincxx . . $ create_swapchain(d878ad36e69247c7).()
583 {
584 vkCreateSwapchainKHRcxx . . $ vkCreateSwapchainKHR(a5b481f1c539bc83).(devicecxx . . $ device.,
585 &(VkSwapchainCreateInfoKHRcxx . . $ VkSwapchainCreateInfoKHR#) {
586 .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHRcxx . . $ VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR.,
587 .flags = 0,
588 .surface = surfacecxx . . $ surface.,
589 .minImageCount = min_image_countcxx . . $ min_image_count.,
590 .imageFormat = image_formatcxx . . $ image_format.,
591 .imageColorSpace = color_spacecxx . . $ color_space.,
592 .imageExtent = { widthcxx . . $ width., heightcxx . . $ height. },
593 .imageArrayLayers = 1,
594 .imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BITcxx . . $ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT.,
595 .imageSharingMode = VK_SHARING_MODE_EXCLUSIVEcxx . . $ VK_SHARING_MODE_EXCLUSIVE.,
596 .queueFamilyIndexCount = 1,
597 .pQueueFamilyIndices = (uint32_tcxx . . $ uint32_t#[]) { 0 },
598 .preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHRcxx . . $ VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR.,
599 .compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHRcxx . . $ VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR.,
600 .presentMode = present_modecxx . . $ present_mode.,
601 }, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &swapchaincxx . . $ swapchain.);
602
603 int res;
604 if (sample_countcxx . . $ sample_count. != VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT.) {
605 res = create_imagecxx . . $ create_image(bc7320cc2bdd85ff).(image_formatcxx . . $ image_format.,
606 (VkExtent3Dcxx . . $ VkExtent3D#) {
607 .width = widthcxx . . $ width.,
608 .height = heightcxx . . $ height.,
609 .depth = 1,
610 },
611 sample_countcxx . . $ sample_count.,
612 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BITcxx . . $ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT. |
613 VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BITcxx . . $ VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT.,
614 &color_msaacxx . . $ color_msaa.);
615 if (res)
616 errorcxx . . $ error(326aeb464d16410c).("Failed to create resolve image");
617
618 VkMemoryRequirementscxx . . $ VkMemoryRequirements# msaa_reqs;
619 vkGetImageMemoryRequirementscxx . . $ vkGetImageMemoryRequirements(a6b81d78e8848133).(devicecxx . . $ device., color_msaacxx . . $ color_msaa., &msaa_reqs);
620 int memory_type =
621 find_memory_typecxx . . $ find_memory_type(68be34e0a2e51885).(&msaa_reqs, VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BITcxx . . $ VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT.);
622 if (memory_type < 0) {
623 memory_type =
624 find_memory_typecxx . . $ find_memory_type(68be34e0a2e51885).(&msaa_reqs, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BITcxx . . $ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT.);
625 if (memory_type < 0)
626 errorcxx . . $ error(326aeb464d16410c).("find_memory_type failed");
627 }
628 res = image_allocatecxx . . $ image_allocate(230fff06749e784c).(color_msaacxx . . $ color_msaa., msaa_reqs, memory_type,
629 &color_msaa_memorycxx . . $ color_msaa_memory.);
630 if (res)
631 errorcxx . . $ error(326aeb464d16410c).("Failed to allocate memory for the resolve image");
632
633 res = create_image_viewcxx . . $ create_image_view(cdb0feaa4627b392).(color_msaacxx . . $ color_msaa., image_formatcxx . . $ image_format.,
634 VK_IMAGE_ASPECT_COLOR_BITcxx . . $ VK_IMAGE_ASPECT_COLOR_BIT., &color_msaa_viewcxx . . $ color_msaa_view.);
635
636 if (res)
637 errorcxx . . $ error(326aeb464d16410c).("Failed to create the image view for the resolve image");
638 }
639
640 res = create_imagecxx . . $ create_image(bc7320cc2bdd85ff).(depth_formatcxx . . $ depth_format.,
641 (VkExtent3Dcxx . . $ VkExtent3D#) {
642 .width = widthcxx . . $ width.,
643 .height = heightcxx . . $ height.,
644 .depth = 1,
645 },
646 sample_countcxx . . $ sample_count.,
647 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BITcxx . . $ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT. |
648 VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BITcxx . . $ VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT.,
649 &depth_imagecxx . . $ depth_image.);
650
651 if (res)
652 errorcxx . . $ error(326aeb464d16410c).("Failed to create depth image");
653
654 VkMemoryRequirementscxx . . $ VkMemoryRequirements# depth_reqs;
655 vkGetImageMemoryRequirementscxx . . $ vkGetImageMemoryRequirements(a6b81d78e8848133).(devicecxx . . $ device., depth_imagecxx . . $ depth_image., &depth_reqs);
656 int memory_type =
657 find_memory_typecxx . . $ find_memory_type(68be34e0a2e51885).(&depth_reqs, VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BITcxx . . $ VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT.);
658 if (memory_type < 0) {
659 memory_type =
660 find_memory_typecxx . . $ find_memory_type(68be34e0a2e51885).(&depth_reqs, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BITcxx . . $ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT.);
661 if (memory_type < 0)
662 errorcxx . . $ error(326aeb464d16410c).("find_memory_type failed");
663 }
664 res = image_allocatecxx . . $ image_allocate(230fff06749e784c).(depth_imagecxx . . $ depth_image., depth_reqs, memory_type, &depth_memorycxx . . $ depth_memory.);
665 if (res)
666 errorcxx . . $ error(326aeb464d16410c).("Failed to allocate memory for the depth image");
667
668 res = create_image_viewcxx . . $ create_image_view(cdb0feaa4627b392).(depth_imagecxx . . $ depth_image.,
669 depth_formatcxx . . $ depth_format.,
670 VK_IMAGE_ASPECT_DEPTH_BITcxx . . $ VK_IMAGE_ASPECT_DEPTH_BIT.,
671 &depth_viewcxx . . $ depth_view.);
672
673 if (res)
674 errorcxx . . $ error(326aeb464d16410c).("Failed to create the image view for the depth image");
675
676 int attachment_count = sample_countcxx . . $ sample_count. != VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT. ? 3 : 2;
677
678 vkGetSwapchainImagesKHRcxx . . $ vkGetSwapchainImagesKHR(f4576b5bbddf48e0).(devicecxx . . $ device., swapchaincxx . . $ swapchain.,
679 &image_countcxx . . $ image_count., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
680 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(image_count > 0);
681
682 VkImagecxx . . $ VkImage# *swapchain_images = calloccxx . . $ calloc(63a7bf2941bfcd7a).(image_countcxx . . $ image_count., sizeof(VkImagecxx . . $ VkImage#));
683 if (!swapchain_images)
684 errorcxx . . $ error(326aeb464d16410c).("Failed to allocate array for swapchain images.");
685
686 vkGetSwapchainImagesKHRcxx . . $ vkGetSwapchainImagesKHR(f4576b5bbddf48e0).(devicecxx . . $ device., swapchaincxx . . $ swapchain.,
687 &image_countcxx . . $ image_count., swapchain_images);
688
689 for (uint32_tcxx . . $ uint32_t# i = 0; i < image_countcxx . . $ image_count.; i++) {
690 image_datacxx . . $ image_data.[i].imagecxx . . $ $anonymous_type_35552c03753a375_0#image. = swapchain_images[i];
691 vkCreateImageViewcxx . . $ vkCreateImageView(77fe79dbf32b7a71).(devicecxx . . $ device.,
692 &(VkImageViewCreateInfocxx . . $ VkImageViewCreateInfo#) {
693 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO.,
694 .image = swapchain_images[i],
695 .viewType = VK_IMAGE_VIEW_TYPE_2Dcxx . . $ VK_IMAGE_VIEW_TYPE_2D.,
696 .format = image_formatcxx . . $ image_format.,
697 .components = {
698 .r = VK_COMPONENT_SWIZZLE_Rcxx . . $ VK_COMPONENT_SWIZZLE_R.,
699 .g = VK_COMPONENT_SWIZZLE_Gcxx . . $ VK_COMPONENT_SWIZZLE_G.,
700 .b = VK_COMPONENT_SWIZZLE_Bcxx . . $ VK_COMPONENT_SWIZZLE_B.,
701 .a = VK_COMPONENT_SWIZZLE_Acxx . . $ VK_COMPONENT_SWIZZLE_A.,
702 },
703 .subresourceRange = {
704 .aspectMask = VK_IMAGE_ASPECT_COLOR_BITcxx . . $ VK_IMAGE_ASPECT_COLOR_BIT.,
705 .baseMipLevel = 0,
706 .levelCount = 1,
707 .baseArrayLayer = 0,
708 .layerCount = 1,
709 },
710 },
711 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
712 &image_datacxx . . $ image_data.[i].viewcxx . . $ $anonymous_type_35552c03753a375_0#view.);
713
714 vkCreateFramebuffercxx . . $ vkCreateFramebuffer(27c87b0e2c5d2184).(devicecxx . . $ device.,
715 &(VkFramebufferCreateInfocxx . . $ VkFramebufferCreateInfo#) {
716 .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO.,
717 .renderPass = render_passcxx . . $ render_pass.,
718 .attachmentCount = attachment_count,
719 .pAttachments = (VkImageViewcxx . . $ VkImageView#[]) {
720 image_datacxx . . $ image_data.[i].viewcxx . . $ $anonymous_type_35552c03753a375_0#view.,
721 depth_viewcxx . . $ depth_view.,
722 color_msaa_viewcxx . . $ color_msaa_view.,
723 },
724 .width = widthcxx . . $ width.,
725 .height = heightcxx . . $ height.,
726 .layers = 1
727 },
728 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
729 &image_datacxx . . $ image_data.[i].framebuffercxx . . $ $anonymous_type_35552c03753a375_0#framebuffer.);
730 }
731
732 freecxx . . $ free(5d22bdacc48458e8).(swapchain_images);
733
734 for (uint32_tcxx . . $ uint32_t# i = 0; i < MAX_CONCURRENT_FRAMEScxx . . $ `deps/vkgears/vkgears.c:89:9`!; ++i) {
735 vkCreateFencecxx . . $ vkCreateFence(1c91e238481b51c).(devicecxx . . $ device.,
736 &(VkFenceCreateInfocxx . . $ VkFenceCreateInfo#) {
737 .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO.,
738 .flags = VK_FENCE_CREATE_SIGNALED_BITcxx . . $ VK_FENCE_CREATE_SIGNALED_BIT.
739 },
740 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
741 &frame_datacxx . . $ frame_data.[i].fencecxx . . $ $anonymous_type_35552c03753a375_1#fence.);
742
743 vkAllocateCommandBufferscxx . . $ vkAllocateCommandBuffers(bbaff6e20759d081).(devicecxx . . $ device.,
744 &(VkCommandBufferAllocateInfocxx . . $ VkCommandBufferAllocateInfo#) {
745 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFOcxx . . $ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO.,
746 .commandPool = cmd_poolcxx . . $ cmd_pool.,
747 .level = VK_COMMAND_BUFFER_LEVEL_PRIMARYcxx . . $ VK_COMMAND_BUFFER_LEVEL_PRIMARY.,
748 .commandBufferCount = 1,
749 },
750 &frame_datacxx . . $ frame_data.[i].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.);
751
752 vkCreateSemaphorecxx . . $ vkCreateSemaphore(b2b2a0a4370c5e53).(devicecxx . . $ device.,
753 &(VkSemaphoreCreateInfocxx . . $ VkSemaphoreCreateInfo#) {
754 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO.,
755 },
756 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
757 &frame_datacxx . . $ frame_data.[i].semaphorecxx . . $ $anonymous_type_35552c03753a375_1#semaphore.);
758 }
759 }
760
761 static void
762 free_swapchain_datacxx . . $ free_swapchain_data(d878ad36e69247c7).()
763 {
764 for (uint32_tcxx . . $ uint32_t# i = 0; i < MAX_CONCURRENT_FRAMEScxx . . $ `deps/vkgears/vkgears.c:89:9`!; i++) {
765 vkFreeCommandBufferscxx . . $ vkFreeCommandBuffers(86f38fa957993b94).(devicecxx . . $ device., cmd_poolcxx . . $ cmd_pool., 1, &frame_datacxx . . $ frame_data.[i].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.);
766 vkDestroyFencecxx . . $ vkDestroyFence(c11a4c49bd28adf1).(devicecxx . . $ device., frame_datacxx . . $ frame_data.[i].fencecxx . . $ $anonymous_type_35552c03753a375_1#fence., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
767 vkDestroySemaphorecxx . . $ vkDestroySemaphore(9f95ec9e67729a6).(devicecxx . . $ device., frame_datacxx . . $ frame_data.[i].semaphorecxx . . $ $anonymous_type_35552c03753a375_1#semaphore., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
768 }
769
770 for (uint32_tcxx . . $ uint32_t# i = 0; i < image_countcxx . . $ image_count.; i++) {
771 vkDestroyFramebuffercxx . . $ vkDestroyFramebuffer(6296ef2b31636270).(devicecxx . . $ device., image_datacxx . . $ image_data.[i].framebuffercxx . . $ $anonymous_type_35552c03753a375_0#framebuffer., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
772 vkDestroyImageViewcxx . . $ vkDestroyImageView(a7d513fc087b0a05).(devicecxx . . $ device., image_datacxx . . $ image_data.[i].viewcxx . . $ $anonymous_type_35552c03753a375_0#view., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
773 }
774
775 vkDestroyImageViewcxx . . $ vkDestroyImageView(a7d513fc087b0a05).(devicecxx . . $ device., depth_viewcxx . . $ depth_view., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
776 vkDestroyImagecxx . . $ vkDestroyImage(3e69a458d7ef6a33).(devicecxx . . $ device., depth_imagecxx . . $ depth_image., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
777 vkFreeMemorycxx . . $ vkFreeMemory(865424c3a272d84).(devicecxx . . $ device., depth_memorycxx . . $ depth_memory., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
778
779 if (sample_countcxx . . $ sample_count. != VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT.) {
780 vkDestroyImageViewcxx . . $ vkDestroyImageView(a7d513fc087b0a05).(devicecxx . . $ device., color_msaa_viewcxx . . $ color_msaa_view., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
781 vkDestroyImagecxx . . $ vkDestroyImage(3e69a458d7ef6a33).(devicecxx . . $ device., color_msaacxx . . $ color_msaa., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
782 vkFreeMemorycxx . . $ vkFreeMemory(865424c3a272d84).(devicecxx . . $ device., color_msaa_memorycxx . . $ color_msaa_memory., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
783 }
784 }
785
786 static void
787 recreate_swapchaincxx . . $ recreate_swapchain(d878ad36e69247c7).()
788 {
789 vkDeviceWaitIdlecxx . . $ vkDeviceWaitIdle(999a9f8bd09b19b1).(devicecxx . . $ device.);
790 free_swapchain_datacxx . . $ free_swapchain_data(d878ad36e69247c7).();
791 vkDestroySwapchainKHRcxx . . $ vkDestroySwapchainKHR(85876bb8834e3627).(devicecxx . . $ device., swapchaincxx . . $ swapchain., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
792 widthcxx . . $ width. = new_widthcxx . . $ new_width., heightcxx . . $ height. = new_heightcxx . . $ new_height.;
793 create_swapchaincxx . . $ create_swapchain(d878ad36e69247c7).();
794 }
795
796 static VkBuffercxx . . $ VkBuffer#
797 create_buffercxx . . $ create_buffer(21c7aa90a8a0ec42).(VkDeviceSizecxx . . $ VkDeviceSize# size, VkBufferUsageFlagscxx . . $ VkBufferUsageFlags# usage)
798 {
799 VkBuffercxx . . $ VkBuffer# buffer;
800
801 VkResultcxx . . $ VkResult# result =
802 vkCreateBuffercxx . . $ vkCreateBuffer(c2e371062d4ff0ca).(devicecxx . . $ device.,
803 &(VkBufferCreateInfocxx . . $ VkBufferCreateInfo#) {
804 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO.,
805 .size = size,
806 .usage = usage,
807 .flags = 0
808 },
809 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
810 &buffer);
811
812 if (result != VK_SUCCESScxx . . $ VK_SUCCESS.)
813 errorcxx . . $ error(326aeb464d16410c).("Failed to create buffer");
814
815 return buffer;
816 }
817
818 static VkDeviceMemorycxx . . $ VkDeviceMemory#
819 allocate_buffer_memcxx . . $ allocate_buffer_mem(c02fa7840163383b).(VkBuffercxx . . $ VkBuffer# buffer, VkDeviceSizecxx . . $ VkDeviceSize# mem_size)
820 {
821 VkMemoryRequirementscxx . . $ VkMemoryRequirements# reqs;
822 vkGetBufferMemoryRequirementscxx . . $ vkGetBufferMemoryRequirements(97102bef16e1f7c5).(devicecxx . . $ device., buffer, &reqs);
823
824 int memory_type = find_memory_typecxx . . $ find_memory_type(68be34e0a2e51885).(&reqs,
825 VK_MEMORY_PROPERTY_HOST_VISIBLE_BITcxx . . $ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT. |
826 VK_MEMORY_PROPERTY_HOST_COHERENT_BITcxx . . $ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT.);
827 if (memory_type < 0)
828 errorcxx . . $ error(326aeb464d16410c).("failed to find coherent memory type");
829
830 VkDeviceMemorycxx . . $ VkDeviceMemory# mem;
831 vkAllocateMemorycxx . . $ vkAllocateMemory(ffce6ec704e8416f).(devicecxx . . $ device.,
832 &(VkMemoryAllocateInfocxx . . $ VkMemoryAllocateInfo#) {
833 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFOcxx . . $ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO.,
834 .allocationSize = mem_size,
835 .memoryTypeIndex = memory_type,
836 },
837 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
838 &mem);
839 return mem;
840 }
841
842 static uint32_tcxx . . $ uint32_t# vs_spirv_sourcecxx . . $ vs_spirv_source.[] = {
843 #include "gear.vert.spv.h"cxx . . $ `<file>/deps/vkgears/gear.vert.spv.h`/
844 };
845
846 static uint32_tcxx . . $ uint32_t# fs_spirv_sourcecxx . . $ fs_spirv_source.[] = {
847 #include "gear.frag.spv.h"cxx . . $ `<file>/deps/vkgears/gear.frag.spv.h`/
848 };
849
850 struct ubocxx . . $ ubo# {
851 float projectioncxx . . $ ubo#projection.[4][4];
852 };
853
854 struct push_constantscxx . . $ push_constants# {
855 float modelviewcxx . . $ push_constants#modelview.[4][4];
856 float material_colorcxx . . $ push_constants#material_color.[3];
857 };
858
859 struct gearcxx . . $ gear# {
860 int nverticescxx . . $ gear#nvertices.;
861 };
862
863 #define GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`! 6
864
865 static int
866 create_gearcxx . . $ create_gear(af79a91ecacb9f96).(float verts[],
867 float inner_radius, float outer_radius, float width,
868 int teeth, float tooth_depth)
869 {
870 // normal state
871 float current_normal[3];
872 #define SET_NORMALcxx . . $ `deps/vkgears/vkgears.c:872:9`!(x, y, z) do { \
873 current_normal[0] = x; \
874 current_normal[1] = y; \
875 current_normal[2] = z; \
876 } while (0)
877
878 // vertex buffer state
879 unsigned num_verts = 0;
880
881 #define EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(x, y, z) do { \
882 verts[num_verts * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`! + 0] = x; \
883 verts[num_verts * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`! + 1] = y; \
884 verts[num_verts * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`! + 2] = z; \
885 memcpy(verts + num_verts * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`! + 3, \
886 current_normal, sizeof(current_normal)); \
887 num_verts++; \
888 } while (0)
889
890 // strip restart-logic
891 int cur_strip_start = 0;
892 #define START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!() do { \
893 cur_strip_start = num_verts; \
894 if (cur_strip_start) \
895 num_verts += 2; \
896 } while(0);
897
898 #define END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!() do { \
899 if (cur_strip_start) { \
900 memcpy(verts + cur_strip_start * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!, \
901 verts + (cur_strip_start - 1) * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!, \
902 sizeof(float) * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!); \
903 memcpy(verts + (cur_strip_start + 1) * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!, \
904 verts + (cur_strip_start + 2) * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!, \
905 sizeof(float) * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!); \
906 } \
907 } while (0)
908
909 float r0 = inner_radius;
910 float r1 = outer_radius - tooth_depth / 2.0;
911 float r2 = outer_radius + tooth_depth / 2.0;
912
913 float da = 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / teeth / 4.0;
914
915 SET_NORMALcxx . . $ `deps/vkgears/vkgears.c:872:9`!(0.0, 0.0, 1.0);
916
917 /* draw front face */
918 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
919 for (int i = 0; i <= teeth; i++) {
920 float angle = i * 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / teeth;
921 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r0 * cos(angle), r0 * sin(angle), width * 0.5);
922 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle), r1 * sin(angle), width * 0.5);
923 if (i < teeth) {
924 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r0 * cos(angle), r0 * sin(angle), width * 0.5);
925 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 3 * da),
926 r1 * sin(angle + 3 * da), width * 0.5);
927 }
928 }
929 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
930
931 /* draw front sides of teeth */
932 for (int i = 0; i < teeth; i++) {
933 float angle = i * 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / teeth;
934 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
935 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle), r1 * sin(angle), width * 0.5);
936 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
937 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
938 width * 0.5);
939 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
940 width * 0.5);
941 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
942 }
943
944 SET_NORMALcxx . . $ `deps/vkgears/vkgears.c:872:9`!(0.0, 0.0, -1.0);
945
946 /* draw back face */
947 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
948 for (int i = 0; i <= teeth; i++) {
949 float angle = i * 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / teeth;
950 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
951 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
952 if (i < teeth) {
953 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
954 -width * 0.5);
955 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
956 }
957 }
958 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
959
960 /* draw back sides of teeth */
961 for (int i = 0; i < teeth; i++) {
962 float angle = i * 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / teeth;
963 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
964 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
965 -width * 0.5);
966 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
967 -width * 0.5);
968 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
969 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
970 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
971 }
972
973 /* draw outward faces of teeth */
974 for (int i = 0; i < teeth; i++) {
975 float angle = i * 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / teeth;
976 float u = r2 * cos(angle + da) - r1 * cos(angle);
977 float v = r2 * sin(angle + da) - r1 * sin(angle);
978 float len = sqrt(u * u + v * v);
979 u /= len;
980 v /= len;
981 SET_NORMALcxx . . $ `deps/vkgears/vkgears.c:872:9`!(v, -u, 0.0);
982 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
983 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle), r1 * sin(angle), width * 0.5);
984 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
985
986 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
987 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
988 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
989
990 SET_NORMALcxx . . $ `deps/vkgears/vkgears.c:872:9`!(cos(angle), sin(angle), 0.0);
991 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
992 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + da), r2 * sin(angle + da),
993 width * 0.5);
994 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + da), r2 * sin(angle + da),
995 -width * 0.5);
996 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
997 width * 0.5);
998 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
999 -width * 0.5);
1000 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
1001
1002 u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
1003 v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
1004 SET_NORMALcxx . . $ `deps/vkgears/vkgears.c:872:9`!(v, -u, 0.0);
1005 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
1006 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
1007 width * 0.5);
1008 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
1009 -width * 0.5);
1010 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1011 width * 0.5);
1012 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1013 -width * 0.5);
1014 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
1015
1016 SET_NORMALcxx . . $ `deps/vkgears/vkgears.c:872:9`!(cos(angle), sin(angle), 0.0);
1017 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
1018 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1019 width * 0.5);
1020 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
1021 -width * 0.5);
1022 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 4 * da), r1 * sin(angle + 4 * da),
1023 width * 0.5);
1024 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r1 * cos(angle + 4 * da), r1 * sin(angle + 4 * da),
1025 -width * 0.5);
1026 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
1027 }
1028
1029 /* draw inside radius cylinder */
1030 START_STRIPcxx . . $ `deps/vkgears/vkgears.c:892:9`!();
1031 for (int i = 0; i <= teeth; i++) {
1032 float angle = i * 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / teeth;
1033 SET_NORMALcxx . . $ `deps/vkgears/vkgears.c:872:9`!(-cos(angle), -sin(angle), 0.0);
1034 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
1035 EMIT_VERTEXcxx . . $ `deps/vkgears/vkgears.c:881:9`!(r0 * cos(angle), r0 * sin(angle), width * 0.5);
1036 }
1037 END_STRIPcxx . . $ `deps/vkgears/vkgears.c:898:9`!();
1038
1039 return num_verts;
1040 }
1041
1042
1043 static void
1044 init_gearscxx . . $ init_gears(d878ad36e69247c7).()
1045 {
1046 VkResultcxx . . $ VkResult# r;
1047
1048 VkDescriptorSetLayoutcxx . . $ VkDescriptorSetLayout# set_layout;
1049 vkCreateDescriptorSetLayoutcxx . . $ vkCreateDescriptorSetLayout(7dcf8fd5b19165ce).(devicecxx . . $ device.,
1050 &(VkDescriptorSetLayoutCreateInfocxx . . $ VkDescriptorSetLayoutCreateInfo#) {
1051 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO.,
1052 .bindingCount = 1,
1053 .pBindings = (VkDescriptorSetLayoutBindingcxx . . $ VkDescriptorSetLayoutBinding#[]) {
1054 {
1055 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFERcxx . . $ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER.,
1056 .descriptorCount = 1,
1057 .stageFlags = VK_SHADER_STAGE_VERTEX_BITcxx . . $ VK_SHADER_STAGE_VERTEX_BIT.,
1058 .pImmutableSamplers = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!
1059 }
1060 }
1061 },
1062 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1063 &set_layout);
1064
1065 vkCreatePipelineLayoutcxx . . $ vkCreatePipelineLayout(c421c8a8e36f3972).(devicecxx . . $ device.,
1066 &(VkPipelineLayoutCreateInfocxx . . $ VkPipelineLayoutCreateInfo#) {
1067 .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO.,
1068 .setLayoutCount = 1,
1069 .pSetLayouts = &set_layout,
1070 .pPushConstantRanges = (VkPushConstantRangecxx . . $ VkPushConstantRange#[]) {
1071 {
1072 .offset = 0,
1073 .size = sizeof(struct push_constantscxx . . $ push_constants#),
1074 .stageFlags = VK_SHADER_STAGE_VERTEX_BITcxx . . $ VK_SHADER_STAGE_VERTEX_BIT.,
1075 },
1076 },
1077 .pushConstantRangeCount = 1,
1078 },
1079 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1080 &pipeline_layoutcxx . . $ pipeline_layout.);
1081
1082 VkShaderModulecxx . . $ VkShaderModule# vs_module;
1083 vkCreateShaderModulecxx . . $ vkCreateShaderModule(73c71af860ac500b).(devicecxx . . $ device.,
1084 &(VkShaderModuleCreateInfocxx . . $ VkShaderModuleCreateInfo#) {
1085 .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO.,
1086 .codeSize = sizeof(vs_spirv_sourcecxx . . $ vs_spirv_source.),
1087 .pCode = vs_spirv_sourcecxx . . $ vs_spirv_source.,
1088 },
1089 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1090 &vs_module);
1091
1092 VkShaderModulecxx . . $ VkShaderModule# fs_module;
1093 vkCreateShaderModulecxx . . $ vkCreateShaderModule(73c71af860ac500b).(devicecxx . . $ device.,
1094 &(VkShaderModuleCreateInfocxx . . $ VkShaderModuleCreateInfo#) {
1095 .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO.,
1096 .codeSize = sizeof(fs_spirv_sourcecxx . . $ fs_spirv_source.),
1097 .pCode = fs_spirv_sourcecxx . . $ fs_spirv_source.,
1098 },
1099 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1100 &fs_module);
1101
1102 vkCreateGraphicsPipelinescxx . . $ vkCreateGraphicsPipelines(9535aff39cf69d59).(devicecxx . . $ device.,
1103 (VkPipelineCachecxx . . $ VkPipelineCache#) { VK_NULL_HANDLEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:43:21`! },
1104 1,
1105 &(VkGraphicsPipelineCreateInfocxx . . $ VkGraphicsPipelineCreateInfo#) {
1106 .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO.,
1107 .stageCount = 2,
1108 .pStages = (VkPipelineShaderStageCreateInfocxx . . $ VkPipelineShaderStageCreateInfo#[]) {
1109 {
1110 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO.,
1111 .stage = VK_SHADER_STAGE_VERTEX_BITcxx . . $ VK_SHADER_STAGE_VERTEX_BIT.,
1112 .module = vs_module,
1113 .pName = "main",
1114 },
1115 {
1116 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO.,
1117 .stage = VK_SHADER_STAGE_FRAGMENT_BITcxx . . $ VK_SHADER_STAGE_FRAGMENT_BIT.,
1118 .module = fs_module,
1119 .pName = "main",
1120 },
1121 },
1122 .pVertexInputState = &(VkPipelineVertexInputStateCreateInfocxx . . $ VkPipelineVertexInputStateCreateInfo#) {
1123 .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO.,
1124 .vertexBindingDescriptionCount = 2,
1125 .pVertexBindingDescriptions = (VkVertexInputBindingDescriptioncxx . . $ VkVertexInputBindingDescription#[]) {
1126 {
1127 .binding = 0,
1128 .stride = 6 * sizeof(float),
1129 .inputRate = VK_VERTEX_INPUT_RATE_VERTEXcxx . . $ VK_VERTEX_INPUT_RATE_VERTEX.
1130 },
1131 {
1132 .binding = 1,
1133 .stride = 6 * sizeof(float),
1134 .inputRate = VK_VERTEX_INPUT_RATE_VERTEXcxx . . $ VK_VERTEX_INPUT_RATE_VERTEX.
1135 },
1136 },
1137 .vertexAttributeDescriptionCount = 2,
1138 .pVertexAttributeDescriptions = (VkVertexInputAttributeDescriptioncxx . . $ VkVertexInputAttributeDescription#[]) {
1139 {
1140 .location = 0,
1141 .binding = 0,
1142 .format = VK_FORMAT_R32G32B32_SFLOATcxx . . $ VK_FORMAT_R32G32B32_SFLOAT.,
1143 .offset = 0
1144 },
1145 {
1146 .location = 1,
1147 .binding = 1,
1148 .format = VK_FORMAT_R32G32B32_SFLOATcxx . . $ VK_FORMAT_R32G32B32_SFLOAT.,
1149 .offset = 0
1150 },
1151 }
1152 },
1153 .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfocxx . . $ VkPipelineInputAssemblyStateCreateInfo#) {
1154 .sType =
1155 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO.,
1156 .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIPcxx . . $ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP.,
1157 .primitiveRestartEnable = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!,
1158 },
1159
1160 .pViewportState = &(VkPipelineViewportStateCreateInfocxx . . $ VkPipelineViewportStateCreateInfo#) {
1161 .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.,
1162 .viewportCount = 1,
1163 .scissorCount = 1,
1164 },
1165
1166 .pRasterizationState = &(VkPipelineRasterizationStateCreateInfocxx . . $ VkPipelineRasterizationStateCreateInfo#) {
1167 .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO.,
1168 .rasterizerDiscardEnable = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!,
1169 .polygonMode = VK_POLYGON_MODE_FILLcxx . . $ VK_POLYGON_MODE_FILL.,
1170 .cullMode = VK_CULL_MODE_BACK_BITcxx . . $ VK_CULL_MODE_BACK_BIT.,
1171 .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISEcxx . . $ VK_FRONT_FACE_COUNTER_CLOCKWISE.,
1172 .lineWidth = 1.0f,
1173 },
1174
1175 .pMultisampleState = &(VkPipelineMultisampleStateCreateInfocxx . . $ VkPipelineMultisampleStateCreateInfo#) {
1176 .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO.,
1177 .rasterizationSamples = sample_countcxx . . $ sample_count.,
1178 },
1179 .pDepthStencilState = &(VkPipelineDepthStencilStateCreateInfocxx . . $ VkPipelineDepthStencilStateCreateInfo#) {
1180 .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO.,
1181 .depthTestEnable = VK_TRUEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:129:9`!,
1182 .depthWriteEnable = VK_TRUEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:129:9`!,
1183 .depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUALcxx . . $ VK_COMPARE_OP_LESS_OR_EQUAL.,
1184 },
1185
1186 .pColorBlendState = &(VkPipelineColorBlendStateCreateInfocxx . . $ VkPipelineColorBlendStateCreateInfo#) {
1187 .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO.,
1188 .attachmentCount = 1,
1189 .pAttachments = (VkPipelineColorBlendAttachmentStatecxx . . $ VkPipelineColorBlendAttachmentState# []) {
1190 { .colorWriteMask = VK_COLOR_COMPONENT_A_BITcxx . . $ VK_COLOR_COMPONENT_A_BIT. |
1191 VK_COLOR_COMPONENT_R_BITcxx . . $ VK_COLOR_COMPONENT_R_BIT. |
1192 VK_COLOR_COMPONENT_G_BITcxx . . $ VK_COLOR_COMPONENT_G_BIT. |
1193 VK_COLOR_COMPONENT_B_BITcxx . . $ VK_COLOR_COMPONENT_B_BIT. },
1194 }
1195 },
1196
1197 .pDynamicState = &(VkPipelineDynamicStateCreateInfocxx . . $ VkPipelineDynamicStateCreateInfo#) {
1198 .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO.,
1199 .dynamicStateCount = 2,
1200 .pDynamicStates = (VkDynamicStatecxx . . $ VkDynamicState#[]) {
1201 VK_DYNAMIC_STATE_VIEWPORTcxx . . $ VK_DYNAMIC_STATE_VIEWPORT.,
1202 VK_DYNAMIC_STATE_SCISSORcxx . . $ VK_DYNAMIC_STATE_SCISSOR.,
1203 },
1204 },
1205
1206 .flags = 0,
1207 .layout = pipeline_layoutcxx . . $ pipeline_layout.,
1208 .renderPass = render_passcxx . . $ render_pass.,
1209 .subpass = 0,
1210 .basePipelineHandle = (VkPipelinecxx . . $ VkPipeline#) { 0 },
1211 .basePipelineIndex = 0
1212 },
1213 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1214 &pipelinecxx . . $ pipeline.);
1215
1216 #define MAX_VERTScxx . . $ `deps/vkgears/vkgears.c:1216:9`! 10000
1217 float verts[MAX_VERTScxx . . $ `deps/vkgears/vkgears.c:1216:9`! * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!];
1218
1219 gearscxx . . $ gears.[0].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. = 0;
1220 gearscxx . . $ gears.[0].vertex_countcxx . . $ $anonymous_type_35552c03753a375_2#vertex_count. = create_gearcxx . . $ create_gear(af79a91ecacb9f96).(verts + gearscxx . . $ gears.[0].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. *
1221 GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!,
1222 1.0, 4.0, 1.0, 20, 0.7);
1223 gearscxx . . $ gears.[1].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. = gearscxx . . $ gears.[0].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. + gearscxx . . $ gears.[0].vertex_countcxx . . $ $anonymous_type_35552c03753a375_2#vertex_count.;
1224 gearscxx . . $ gears.[1].vertex_countcxx . . $ $anonymous_type_35552c03753a375_2#vertex_count. = create_gearcxx . . $ create_gear(af79a91ecacb9f96).(verts + gearscxx . . $ gears.[1].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. *
1225 GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!,
1226 0.5, 2.0, 2.0, 10, 0.7);
1227 gearscxx . . $ gears.[2].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. = gearscxx . . $ gears.[1].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. + gearscxx . . $ gears.[1].vertex_countcxx . . $ $anonymous_type_35552c03753a375_2#vertex_count.;
1228 gearscxx . . $ gears.[2].vertex_countcxx . . $ $anonymous_type_35552c03753a375_2#vertex_count. = create_gearcxx . . $ create_gear(af79a91ecacb9f96).(verts + gearscxx . . $ gears.[2].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. *
1229 GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`!,
1230 1.3, 2.0, 0.5, 10, 0.7);
1231
1232 unsigned num_verts = gearscxx . . $ gears.[2].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex. + gearscxx . . $ gears.[2].vertex_countcxx . . $ $anonymous_type_35552c03753a375_2#vertex_count.;
1233 unsigned mem_size = sizeof(float) * GEAR_VERTEX_STRIDEcxx . . $ `deps/vkgears/vkgears.c:863:9`! * num_verts;
1234 vertex_offsetcxx . . $ vertex_offset. = 0;
1235 normals_offsetcxx . . $ normals_offset. = sizeof(float) * 3;
1236 ubo_buffercxx . . $ ubo_buffer. = create_buffercxx . . $ create_buffer(21c7aa90a8a0ec42).(sizeof(struct ubocxx . . $ ubo#),
1237 VK_BUFFER_USAGE_UNIFORM_BUFFER_BITcxx . . $ VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT. |
1238 VK_BUFFER_USAGE_TRANSFER_DST_BITcxx . . $ VK_BUFFER_USAGE_TRANSFER_DST_BIT.);
1239 vertex_buffercxx . . $ vertex_buffer. = create_buffercxx . . $ create_buffer(21c7aa90a8a0ec42).(mem_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BITcxx . . $ VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.);
1240
1241 ubo_memcxx . . $ ubo_mem. = allocate_buffer_memcxx . . $ allocate_buffer_mem(c02fa7840163383b).(ubo_buffercxx . . $ ubo_buffer., sizeof(struct ubocxx . . $ ubo#));
1242 vertex_memcxx . . $ vertex_mem. = allocate_buffer_memcxx . . $ allocate_buffer_mem(c02fa7840163383b).(vertex_buffercxx . . $ vertex_buffer., mem_size);
1243
1244 void *map;
1245 r = vkMapMemorycxx . . $ vkMapMemory(94b3bead52dc75c6).(devicecxx . . $ device., vertex_memcxx . . $ vertex_mem., 0, mem_size, 0, &map);
1246 if (r != VK_SUCCESScxx . . $ VK_SUCCESS.)
1247 errorcxx . . $ error(326aeb464d16410c).("vkMapMemory failed");
1248 memcpycxx . . $ memcpy(cc817cb175f282d).(map, verts, mem_size);
1249 vkUnmapMemorycxx . . $ vkUnmapMemory(779b8c2be240a686).(devicecxx . . $ device., vertex_memcxx . . $ vertex_mem.);
1250
1251 vkBindBufferMemorycxx . . $ vkBindBufferMemory(4b2f710fa27ce16e).(devicecxx . . $ device., ubo_buffercxx . . $ ubo_buffer., ubo_memcxx . . $ ubo_mem., 0);
1252 vkBindBufferMemorycxx . . $ vkBindBufferMemory(4b2f710fa27ce16e).(devicecxx . . $ device., vertex_buffercxx . . $ vertex_buffer., vertex_memcxx . . $ vertex_mem., 0);
1253
1254 VkDescriptorPoolcxx . . $ VkDescriptorPool# desc_pool;
1255 const VkDescriptorPoolCreateInfocxx . . $ VkDescriptorPoolCreateInfo# create_info = {
1256 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFOcxx . . $ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO.,
1257 .pNext = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1258 .flags = 0,
1259 .maxSets = 1,
1260 .poolSizeCount = 1,
1261 .pPoolSizes = (VkDescriptorPoolSizecxx . . $ VkDescriptorPoolSize#[]) {
1262 {
1263 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFERcxx . . $ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER.,
1264 .descriptorCount = 1
1265 },
1266 }
1267 };
1268
1269 vkCreateDescriptorPoolcxx . . $ vkCreateDescriptorPool(325c2258811d8256).(devicecxx . . $ device., &create_info, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &desc_pool);
1270
1271 vkAllocateDescriptorSetscxx . . $ vkAllocateDescriptorSets(324e8096174c3fcb).(devicecxx . . $ device.,
1272 &(VkDescriptorSetAllocateInfocxx . . $ VkDescriptorSetAllocateInfo#) {
1273 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFOcxx . . $ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO.,
1274 .descriptorPool = desc_pool,
1275 .descriptorSetCount = 1,
1276 .pSetLayouts = &set_layout,
1277 }, &descriptor_setcxx . . $ descriptor_set.);
1278
1279 vkUpdateDescriptorSetscxx . . $ vkUpdateDescriptorSets(6c4015bf30b249b8).(devicecxx . . $ device., 1,
1280 (VkWriteDescriptorSetcxx . . $ VkWriteDescriptorSet# []) {
1281 {
1282 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SETcxx . . $ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET.,
1283 .dstSet = descriptor_setcxx . . $ descriptor_set.,
1284 .dstBinding = 0,
1285 .dstArrayElement = 0,
1286 .descriptorCount = 1,
1287 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFERcxx . . $ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER.,
1288 .pBufferInfo = &(VkDescriptorBufferInfocxx . . $ VkDescriptorBufferInfo#) {
1289 .buffer = ubo_buffercxx . . $ ubo_buffer.,
1290 .offset = 0,
1291 .range = sizeof(struct ubocxx . . $ ubo#),
1292 }
1293 }
1294 },
1295 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1296 }
1297
1298 static void
1299 draw_gearcxx . . $ draw_gear(b5580b2b1538db9c).(VkCommandBuffercxx . . $ VkCommandBuffer# cmdbuf, const float view[4][4],
1300 float position[2], float angle,
1301 const float material_color[3],
1302 unsigned first_vertex, unsigned vertex_count)
1303 {
1304 /* Translate and rotate the gear */
1305 float modelview[4][4];
1306 mat4_identitycxx . . $ mat4_identity(9fb3ef344050b01e).(modelview);
1307 mat4_multiplycxx . . $ mat4_multiply(5065313d6ca3a3cb).(modelview, view);
1308 mat4_translatecxx . . $ mat4_translate(2259ce7c40860d6a).(modelview, position[0], position[1], 0);
1309 mat4_rotatecxx . . $ mat4_rotate(f300fda151434b52).(modelview, 2 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! * angle / 360.0, 0, 0, 1);
1310
1311 float h = (float)heightcxx . . $ height. / widthcxx . . $ width.;
1312 float projection[4][4];
1313 mat4_identitycxx . . $ mat4_identity(9fb3ef344050b01e).(projection);
1314 mat4_frustum_vkcxx . . $ mat4_frustum_vk(fbc97a2c47040f0c).(projection, -1.0, 1.0, -h, +h, 5.0f, 60.0f);
1315
1316 struct push_constantscxx . . $ push_constants# push_constants;
1317 mat4_identitycxx . . $ mat4_identity(9fb3ef344050b01e).(push_constants.modelviewcxx . . $ push_constants#modelview.);
1318 mat4_multiplycxx . . $ mat4_multiply(5065313d6ca3a3cb).(push_constants.modelviewcxx . . $ push_constants#modelview., modelview);
1319 memcpycxx . . $ memcpy(cc817cb175f282d).(push_constants.material_colorcxx . . $ push_constants#material_color., material_color,
1320 sizeof(push_constants.material_colorcxx . . $ push_constants#material_color.));
1321
1322 vkCmdPushConstantscxx . . $ vkCmdPushConstants(b50a758567d27fcd).(cmdbuf, pipeline_layoutcxx . . $ pipeline_layout., VK_SHADER_STAGE_VERTEX_BITcxx . . $ VK_SHADER_STAGE_VERTEX_BIT.,
1323 0, sizeof(push_constants), &push_constants);
1324 vkCmdDrawcxx . . $ vkCmdDraw(a3efa3e44bb9676a).(cmdbuf, vertex_count, 1, first_vertex, 0);
1325 }
1326
1327 float anglecxx . . $ angle. = 0.0;
1328
1329 #define G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(x) ((x) < 0.04045 ? (x) / 12.92 : powf(((x) + 0.055) / 1.055, 2.4))
1330
1331 static void
1332 draw_gearscxx . . $ draw_gears(6bf228755210d43).(VkCommandBuffercxx . . $ VkCommandBuffer# cmdbuf, const float view[4][4])
1333 {
1334 vkCmdBindVertexBufferscxx . . $ vkCmdBindVertexBuffers(745965af072d932f).(cmdbuf, 0, 2,
1335 (VkBuffercxx . . $ VkBuffer#[]) {
1336 vertex_buffercxx . . $ vertex_buffer.,
1337 vertex_buffercxx . . $ vertex_buffer.,
1338 },
1339 (VkDeviceSizecxx . . $ VkDeviceSize#[]) {
1340 vertex_offsetcxx . . $ vertex_offset.,
1341 normals_offsetcxx . . $ normals_offset.
1342 });
1343
1344 vkCmdBindPipelinecxx . . $ vkCmdBindPipeline(a95207047c5ef813).(cmdbuf, VK_PIPELINE_BIND_POINT_GRAPHICScxx . . $ VK_PIPELINE_BIND_POINT_GRAPHICS., pipelinecxx . . $ pipeline.);
1345
1346 vkCmdBindDescriptorSetscxx . . $ vkCmdBindDescriptorSets(a4dd1987beda3a9c).(cmdbuf,
1347 VK_PIPELINE_BIND_POINT_GRAPHICScxx . . $ VK_PIPELINE_BIND_POINT_GRAPHICS.,
1348 pipeline_layoutcxx . . $ pipeline_layout.,
1349 0, 1,
1350 &descriptor_setcxx . . $ descriptor_set., 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1351
1352 vkCmdSetViewportcxx . . $ vkCmdSetViewport(7dcfeac1c20425a1).(cmdbuf, 0, 1,
1353 &(VkViewportcxx . . $ VkViewport#) {
1354 .x = 0,
1355 .y = 0,
1356 .width = widthcxx . . $ width.,
1357 .height = heightcxx . . $ height.,
1358 .minDepth = 0,
1359 .maxDepth = 1,
1360 });
1361
1362 vkCmdSetScissorcxx . . $ vkCmdSetScissor(b097772153d0d791).(cmdbuf, 0, 1,
1363 &(VkRect2Dcxx . . $ VkRect2D#) {
1364 .offset = { 0, 0 },
1365 .extent = { widthcxx . . $ width., heightcxx . . $ height. },
1366 });
1367
1368 float positions[3][2] = {
1369 {-3.0, -2.0},
1370 { 3.1, -2.0},
1371 {-3.1, 4.2},
1372 };
1373
1374 float angles[3] = {
1375 anglecxx . . $ angle.,
1376 -2.0 * anglecxx . . $ angle. - 9.0,
1377 -2.0 * anglecxx . . $ angle. - 25.0,
1378 };
1379
1380 const float material_colors[3][3] = {
1381 { G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(0.8), G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(0.1), G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(0.0) },
1382 { G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(0.0), G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(0.8), G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(0.2) },
1383 { G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(0.2), G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(0.2), G2Lcxx . . $ `deps/vkgears/vkgears.c:1329:9`!(1.0) },
1384 };
1385
1386 for (int i = 0; i < 3; ++i) {
1387 draw_gearcxx . . $ draw_gear(b5580b2b1538db9c).(cmdbuf, view, positions[i], angles[i], material_colors[i],
1388 gearscxx . . $ gears.[i].first_vertexcxx . . $ $anonymous_type_35552c03753a375_2#first_vertex., gearscxx . . $ gears.[i].vertex_countcxx . . $ $anonymous_type_35552c03753a375_2#vertex_count.);
1389 }
1390 }
1391
1392 static const char *
1393 get_devtype_strcxx . . $ get_devtype_str(c91842766bb7f82b).(VkPhysicalDeviceTypecxx . . $ VkPhysicalDeviceType# devtype)
1394 {
1395 static char buf[256];
1396 switch (devtype) {
1397 case VK_PHYSICAL_DEVICE_TYPE_OTHERcxx . . $ VK_PHYSICAL_DEVICE_TYPE_OTHER.:
1398 return "other";
1399 case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPUcxx . . $ VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU.:
1400 return "integrated GPU";
1401 case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPUcxx . . $ VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU.:
1402 return "discrete GPU";
1403 case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPUcxx . . $ VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU.:
1404 return "virtual GPU";
1405 case VK_PHYSICAL_DEVICE_TYPE_CPUcxx . . $ VK_PHYSICAL_DEVICE_TYPE_CPU.:
1406 return "CPU";
1407 default:
1408 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "Unknown (%08x)", devtype);
1409 return buf;
1410 }
1411 }
1412
1413 static void
1414 usagecxx . . $ usage(49f6e7a06ebc5aa8).(void)
1415 {
1416 printfcxx . . $ printf(581fddd72a8db8fc).("Usage:\n");
1417 printfcxx . . $ printf(581fddd72a8db8fc).(" -device N Use Vulkan device #N\n");
1418 printfcxx . . $ printf(581fddd72a8db8fc).(" -samples N run in multisample mode with N samples\n");
1419 printfcxx . . $ printf(581fddd72a8db8fc).(" -present-mailbox run with present mode mailbox\n");
1420 printfcxx . . $ printf(581fddd72a8db8fc).(" -present-immediate run with present mode immediate\n");
1421 printfcxx . . $ printf(581fddd72a8db8fc).(" -fullscreen run in fullscreen mode\n");
1422 printfcxx . . $ printf(581fddd72a8db8fc).(" -info display Vulkan device info\n");
1423 printfcxx . . $ printf(581fddd72a8db8fc).(" -size WxH window size\n");
1424 }
1425
1426 static void
1427 print_device_extensionscxx . . $ print_device_extensions(d878ad36e69247c7).()
1428 {
1429 uint32_tcxx . . $ uint32_t# num_extensions = 0;
1430 VkExtensionPropertiescxx . . $ VkExtensionProperties# *extensions;
1431 VkResultcxx . . $ VkResult# result =
1432 vkEnumerateDeviceExtensionPropertiescxx . . $ vkEnumerateDeviceExtensionProperties(e0918f97db37b227).(physical_devicecxx . . $ physical_device., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1433 &num_extensions, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1434 if (result != VK_SUCCESScxx . . $ VK_SUCCESS.)
1435 errorcxx . . $ error(326aeb464d16410c).("Failed to enumerate device extensions");
1436
1437 if (num_extensions > 0) {
1438 extensions = calloccxx . . $ calloc(63a7bf2941bfcd7a).(num_extensions, sizeof(VkExtensionPropertiescxx . . $ VkExtensionProperties#));
1439 if (!extensions)
1440 errorcxx . . $ error(326aeb464d16410c).("Failed to allocate memory");
1441
1442 result =
1443 vkEnumerateDeviceExtensionPropertiescxx . . $ vkEnumerateDeviceExtensionProperties(e0918f97db37b227).(physical_devicecxx . . $ physical_device., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1444 &num_extensions, extensions);
1445 if (result != VK_SUCCESScxx . . $ VK_SUCCESS.) {
1446 freecxx . . $ free(5d22bdacc48458e8).(extensions);
1447 errorcxx . . $ error(326aeb464d16410c).("Failed to enumerate device extensions");
1448 }
1449
1450 printfcxx . . $ printf(581fddd72a8db8fc).("deviceExtensions =\n");
1451 for (uint32_tcxx . . $ uint32_t# i = 0; i < num_extensions; ++i)
1452 printfcxx . . $ printf(581fddd72a8db8fc).("\t%s\n", extensions[i].extensionNamecxx . . $ VkExtensionProperties#extensionName.);
1453
1454 freecxx . . $ free(5d22bdacc48458e8).(extensions);
1455 }
1456 }
1457
1458 static void
1459 print_infocxx . . $ print_info(d878ad36e69247c7).()
1460 {
1461 VkPhysicalDevicePropertiescxx . . $ VkPhysicalDeviceProperties# properties;
1462 vkGetPhysicalDevicePropertiescxx . . $ vkGetPhysicalDeviceProperties(c373f9fb243e367).(physical_devicecxx . . $ physical_device., &properties);
1463 printfcxx . . $ printf(581fddd72a8db8fc).("apiVersion = %d.%d.%d\n",
1464 VK_API_VERSION_MAJORcxx . . $ `<external>/13734482859137699468/vulkan_core.h:88:9`!(properties.apiVersion),
1465 VK_API_VERSION_MINORcxx . . $ `<external>/13734482859137699468/vulkan_core.h:89:9`!(properties.apiVersion),
1466 VK_API_VERSION_PATCHcxx . . $ `<external>/13734482859137699468/vulkan_core.h:90:9`!(properties.apiVersion));
1467 printfcxx . . $ printf(581fddd72a8db8fc).("driverVersion = %04x\n", properties.driverVersioncxx . . $ VkPhysicalDeviceProperties#driverVersion.);
1468 printfcxx . . $ printf(581fddd72a8db8fc).("vendorID = %04x\n", properties.vendorIDcxx . . $ VkPhysicalDeviceProperties#vendorID.);
1469 printfcxx . . $ printf(581fddd72a8db8fc).("deviceID = %04x\n", properties.deviceIDcxx . . $ VkPhysicalDeviceProperties#deviceID.);
1470 printfcxx . . $ printf(581fddd72a8db8fc).("deviceType = %s\n", get_devtype_strcxx . . $ get_devtype_str(c91842766bb7f82b).(properties.deviceTypecxx . . $ VkPhysicalDeviceProperties#deviceType.));
1471 printfcxx . . $ printf(581fddd72a8db8fc).("deviceName = %s\n", properties.deviceNamecxx . . $ VkPhysicalDeviceProperties#deviceName.);
1472 print_device_extensionscxx . . $ print_device_extensions(d878ad36e69247c7).();
1473 }
1474
1475 static VkSampleCountFlagBitscxx . . $ VkSampleCountFlagBits#
1476 sample_count_flagcxx . . $ sample_count_flag(3e10d25b5e7313d5).(int sample_count)
1477 {
1478 switch (sample_count) {
1479 case 1:
1480 return VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT.;
1481 case 2:
1482 return VK_SAMPLE_COUNT_2_BITcxx . . $ VK_SAMPLE_COUNT_2_BIT.;
1483 case 4:
1484 return VK_SAMPLE_COUNT_4_BITcxx . . $ VK_SAMPLE_COUNT_4_BIT.;
1485 case 8:
1486 return VK_SAMPLE_COUNT_8_BITcxx . . $ VK_SAMPLE_COUNT_8_BIT.;
1487 case 16:
1488 return VK_SAMPLE_COUNT_16_BITcxx . . $ VK_SAMPLE_COUNT_16_BIT.;
1489 case 32:
1490 return VK_SAMPLE_COUNT_32_BITcxx . . $ VK_SAMPLE_COUNT_32_BIT.;
1491 case 64:
1492 return VK_SAMPLE_COUNT_64_BITcxx . . $ VK_SAMPLE_COUNT_64_BIT.;
1493 default:
1494 errorcxx . . $ error(326aeb464d16410c).("Invalid sample count");
1495 }
1496 return VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT.;
1497 }
1498
1499 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
1500 check_sample_count_supportcxx . . $ check_sample_count_support(7c441a83a200cdea).(VkSampleCountFlagBitscxx . . $ VkSampleCountFlagBits# sample_count)
1501 {
1502 VkPhysicalDevicePropertiescxx . . $ VkPhysicalDeviceProperties# properties;
1503 vkGetPhysicalDevicePropertiescxx . . $ vkGetPhysicalDeviceProperties(c373f9fb243e367).(physical_devicecxx . . $ physical_device., &properties);
1504
1505 return (sample_count & properties.limitscxx . . $ VkPhysicalDeviceProperties#limits..framebufferColorSampleCountscxx . . $ VkPhysicalDeviceLimits#framebufferColorSampleCounts.) &&
1506 (sample_count & properties.limitscxx . . $ VkPhysicalDeviceProperties#limits..framebufferDepthSampleCountscxx . . $ VkPhysicalDeviceLimits#framebufferDepthSampleCounts.);
1507 }
1508
1509 static void
1510 wsi_resizecxx . . $ wsi_resize(3e454b8ccf442868).(int p_new_width, int p_new_height)
1511 {
1512 new_widthcxx . . $ new_width. = p_new_width;
1513 new_heightcxx . . $ new_height. = p_new_height;
1514 }
1515
1516 /*static void
1517 wsi_key_press(bool down, enum wsi_key key) {
1518 if (!down)
1519 return;
1520 switch (key) {
1521 case WSI_KEY_ESC:
1522 exit(0);
1523 case WSI_KEY_UP:
1524 view_rot[0] += 5.0;
1525 break;
1526 case WSI_KEY_DOWN:
1527 view_rot[0] -= 5.0;
1528 break;
1529 case WSI_KEY_LEFT:
1530 view_rot[1] += 5.0;
1531 break;
1532 case WSI_KEY_RIGHT:
1533 view_rot[1] -= 5.0;
1534 break;
1535 case WSI_KEY_A:
1536 animate = !animate;
1537 break;
1538 default:
1539 break;
1540 }
1541 }*/
1542
1543 static void
1544 wsi_exitcxx . . $ wsi_exit(d878ad36e69247c7).()
1545 {
1546 exitcxx . . $ exit(3ca292c338df9bb3).(0);
1547 }
1548
1549 static struct wsi_callbackscxx . . $ wsi_callbacks# wsi_callbackscxx . . $ wsi_callbacks. = {
1550 .resize = wsi_resizecxx . . $ wsi_resize(3e454b8ccf442868).,
1551 //.key_press = wsi_key_press,
1552 .exit = wsi_exitcxx . . $ wsi_exit(d878ad36e69247c7).,
1553 };
1554
1555 static void
1556 buffer_barriercxx . . $ buffer_barrier(e43e05e7ea73d59c).(VkCommandBuffercxx . . $ VkCommandBuffer# cmd_buffer,
1557 VkPipelineStageFlagscxx . . $ VkPipelineStageFlags# src_flags,
1558 VkPipelineStageFlagscxx . . $ VkPipelineStageFlags# dst_flags,
1559 VkAccessFlagscxx . . $ VkAccessFlags# src_access,
1560 VkAccessFlagscxx . . $ VkAccessFlags# dst_access,
1561 VkBuffercxx . . $ VkBuffer# buffer,
1562 VkDeviceSizecxx . . $ VkDeviceSize# offset,
1563 VkDeviceSizecxx . . $ VkDeviceSize# size)
1564 {
1565 vkCmdPipelineBarriercxx . . $ vkCmdPipelineBarrier(ca392870b0aa0c0c).(cmd_buffer,
1566 src_flags, dst_flags,
1567 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1568 1, &(VkBufferMemoryBarriercxx . . $ VkBufferMemoryBarrier#) {
1569 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIERcxx . . $ VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER.,
1570 .pNext = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
1571 .srcAccessMask = src_access,
1572 .dstAccessMask = dst_access,
1573 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNOREDcxx . . $ `<external>/13734482859137699468/vulkan_core.h:126:9`!,
1574 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNOREDcxx . . $ `<external>/13734482859137699468/vulkan_core.h:126:9`!,
1575 .buffer = buffer,
1576 .offset = offset,
1577 .size = size,
1578 },
1579 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1580 }
1581
1582 int
1583 maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[])
1584 {
1585 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! printInfo = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1586 sample_countcxx . . $ sample_count. = VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT.;
1587 desidered_present_modecxx . . $ desidered_present_mode. = VK_PRESENT_MODE_MAILBOX_KHRcxx . . $ VK_PRESENT_MODE_MAILBOX_KHR.;
1588 widthcxx . . $ width. = 1024;
1589 heightcxx . . $ height. = 800;
1590 fullscreencxx . . $ fullscreen. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1591
1592 for (int i = 1; i < argc; i++) {
1593 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "-info") == 0) {
1594 printInfo = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1595 }
1596 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "-samples") == 0 && i + 1 < argc) {
1597 i++;
1598 sample_countcxx . . $ sample_count. = sample_count_flagcxx . . $ sample_count_flag(3e10d25b5e7313d5).(strtolcxx . . $ strtol(44bbb87609b212fc).(argv[i], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10));
1599 }
1600 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "-present-mailbox") == 0) {
1601 desidered_present_modecxx . . $ desidered_present_mode. = VK_PRESENT_MODE_MAILBOX_KHRcxx . . $ VK_PRESENT_MODE_MAILBOX_KHR.;
1602 }
1603 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "-present-immediate") == 0) {
1604 desidered_present_modecxx . . $ desidered_present_mode. = VK_PRESENT_MODE_IMMEDIATE_KHRcxx . . $ VK_PRESENT_MODE_IMMEDIATE_KHR.;
1605 }
1606 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "-size") == 0 && i + 1 < argc) {
1607 i++;
1608 char *token;
1609 token = strtokcxx . . $ strtok(b7b3a83273496486).(argv[i], "x");
1610 if (!token)
1611 continue;
1612 long tmp = strtolcxx . . $ strtol(44bbb87609b212fc).(token, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10);
1613 if (tmp > 0)
1614 widthcxx . . $ width. = tmp;
1615 if ((token = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "x"))) {
1616 tmp = strtolcxx . . $ strtol(44bbb87609b212fc).(token, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10);
1617 if (tmp > 0)
1618 heightcxx . . $ height. = tmp;
1619 }
1620 }
1621 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "-fullscreen") == 0) {
1622 fullscreencxx . . $ fullscreen. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1623 }
1624 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "-device") == 0 && i + 1 < argc) {
1625 i++;
1626 device_indexcxx . . $ device_index. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[i], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10);
1627 }
1628 else {
1629 usagecxx . . $ usage(49f6e7a06ebc5aa8).();
1630 return -1;
1631 }
1632 }
1633
1634 new_widthcxx . . $ new_width. = widthcxx . . $ width., new_heightcxx . . $ new_height. = heightcxx . . $ height.;
1635
1636 wsicxx . . $ wsi. = get_wsi_interfacecxx . . $ get_wsi_interface(be94db10e8850b66).();
1637 wsicxx . . $ wsi..set_wsi_callbackscxx . . $ wsi_interface#set_wsi_callbacks.(wsi_callbackscxx . . $ wsi_callbacks.);
1638
1639 wsicxx . . $ wsi..init_displaycxx . . $ wsi_interface#init_display.();
1640 wsicxx . . $ wsi..init_windowcxx . . $ wsi_interface#init_window.("Vulkan Benchmark", widthcxx . . $ width., heightcxx . . $ height., fullscreencxx . . $ fullscreen.);
1641
1642 init_vkcxx . . $ init_vk(85c52e162fed56f9).(wsicxx . . $ wsi..required_extension_namecxx . . $ wsi_interface#required_extension_name.);
1643
1644 if (!check_sample_count_supportcxx . . $ check_sample_count_support(7c441a83a200cdea).(sample_countcxx . . $ sample_count.))
1645 errorcxx . . $ error(326aeb464d16410c).("Sample count not supported");
1646
1647 int attachment_count = sample_countcxx . . $ sample_count. != VK_SAMPLE_COUNT_1_BITcxx . . $ VK_SAMPLE_COUNT_1_BIT. ? 3 : 2;
1648
1649 if (printInfo)
1650 print_infocxx . . $ print_info(d878ad36e69247c7).();
1651
1652 if (!wsicxx . . $ wsi..create_surfacecxx . . $ wsi_interface#create_surface.(physical_devicecxx . . $ physical_device., instancecxx . . $ instance., &surfacecxx . . $ surface.))
1653 errorcxx . . $ error(326aeb464d16410c).("Failed to create surface!");
1654
1655 configure_swapchaincxx . . $ configure_swapchain(d878ad36e69247c7).();
1656 create_render_passcxx . . $ create_render_pass(d878ad36e69247c7).();
1657 create_swapchaincxx . . $ create_swapchain(d878ad36e69247c7).();
1658 init_gearscxx . . $ init_gears(d878ad36e69247c7).();
1659
1660 while (1) {
1661 static int frames = 0;
1662 static double tRot0 = -1.0, tRate0 = -1.0;
1663
1664 if (wsicxx . . $ wsi..update_windowcxx . . $ wsi_interface#update_window.()) {
1665 printfcxx . . $ printf(581fddd72a8db8fc).("update window failed\n");
1666 break;
1667 }
1668
1669 static uint32_tcxx . . $ uint32_t# frame_index;
1670 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(frame_index < ARRAY_SIZEcxx . . $ `deps/vkgears/vkgears.c:96:9`!(frame_data));
1671 vkWaitForFencescxx . . $ vkWaitForFences(a00bf67dd3a0f81f).(devicecxx . . $ device., 1, &frame_datacxx . . $ frame_data.[frame_index].fencecxx . . $ $anonymous_type_35552c03753a375_1#fence., VK_TRUEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:129:9`!,
1672 UINT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:119:10`!);
1673 vkResetFencescxx . . $ vkResetFences(de8dd46aa6a98c36).(devicecxx . . $ device., 1, &frame_datacxx . . $ frame_data.[frame_index].fencecxx . . $ $anonymous_type_35552c03753a375_1#fence.);
1674
1675 uint32_tcxx . . $ uint32_t# image_index;
1676 VkResultcxx . . $ VkResult# result =
1677 vkAcquireNextImageKHRcxx . . $ vkAcquireNextImageKHR(ad25e04ca1de5afd).(devicecxx . . $ device., swapchaincxx . . $ swapchain., UINT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:119:10`!,
1678 frame_datacxx . . $ frame_data.[frame_index].semaphorecxx . . $ $anonymous_type_35552c03753a375_1#semaphore.,
1679 VK_NULL_HANDLEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:43:21`!, &image_index);
1680 if (result == VK_SUBOPTIMAL_KHRcxx . . $ VK_SUBOPTIMAL_KHR. ||
1681 widthcxx . . $ width. != new_widthcxx . . $ new_width. || heightcxx . . $ height. != new_heightcxx . . $ new_height.) {
1682 recreate_swapchaincxx . . $ recreate_swapchain(d878ad36e69247c7).();
1683 continue;
1684 }
1685 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(result == VK_SUCCESS);
1686
1687 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(image_index < ARRAY_SIZEcxx . . $ `deps/vkgears/vkgears.c:96:9`!(image_data));
1688
1689 double dt, t = current_timecxx . . $ current_time(31fa7155c10fdd13).();
1690
1691 if (tRot0 < 0.0)
1692 tRot0 = t;
1693 dt = t - tRot0;
1694 tRot0 = t;
1695
1696 if (animatecxx . . $ animate.) {
1697 /* advance rotation for next frame */
1698 anglecxx . . $ angle. += 70.0 * dt; /* 70 degrees per second */
1699 anglecxx . . $ angle. = fmodfcxx . . $ fmodf(d59a45cd3bfd2eda).(anglecxx . . $ angle., 360.0f); /* prevents eventual overflow */
1700 }
1701
1702 vkBeginCommandBuffercxx . . $ vkBeginCommandBuffer(c316b142daee0543).(frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.,
1703 &(VkCommandBufferBeginInfocxx . . $ VkCommandBufferBeginInfo#) {
1704 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFOcxx . . $ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO.,
1705 .flags = 0
1706 });
1707
1708 /* projection matrix */
1709 float h = (float)heightcxx . . $ height. / widthcxx . . $ width.;
1710 struct ubocxx . . $ ubo# ubo;
1711 mat4_identitycxx . . $ mat4_identity(9fb3ef344050b01e).(ubo.projectioncxx . . $ ubo#projection.);
1712 mat4_frustum_vkcxx . . $ mat4_frustum_vk(fbc97a2c47040f0c).(ubo.projectioncxx . . $ ubo#projection., -1.0, 1.0, -h, +h, 5.0f, 60.0f);
1713
1714 buffer_barriercxx . . $ buffer_barrier(e43e05e7ea73d59c).(frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.,
1715 VK_PIPELINE_STAGE_VERTEX_SHADER_BITcxx . . $ VK_PIPELINE_STAGE_VERTEX_SHADER_BIT.,
1716 VK_PIPELINE_STAGE_TRANSFER_BITcxx . . $ VK_PIPELINE_STAGE_TRANSFER_BIT.,
1717 0, 0,
1718 ubo_buffercxx . . $ ubo_buffer., 0, sizeof(ubo));
1719
1720 vkCmdUpdateBuffercxx . . $ vkCmdUpdateBuffer(c81e052a26a5d946).(frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer., ubo_buffercxx . . $ ubo_buffer., 0,
1721 sizeof(ubo), &ubo);
1722
1723 buffer_barriercxx . . $ buffer_barrier(e43e05e7ea73d59c).(frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.,
1724 VK_PIPELINE_STAGE_TRANSFER_BITcxx . . $ VK_PIPELINE_STAGE_TRANSFER_BIT.,
1725 VK_PIPELINE_STAGE_VERTEX_SHADER_BITcxx . . $ VK_PIPELINE_STAGE_VERTEX_SHADER_BIT.,
1726 VK_ACCESS_TRANSFER_WRITE_BITcxx . . $ VK_ACCESS_TRANSFER_WRITE_BIT.,
1727 VK_ACCESS_UNIFORM_READ_BITcxx . . $ VK_ACCESS_UNIFORM_READ_BIT.,
1728 ubo_buffercxx . . $ ubo_buffer., 0, sizeof(ubo));
1729
1730 /* Translate and rotate the view */
1731 float view[4][4];
1732 mat4_identitycxx . . $ mat4_identity(9fb3ef344050b01e).(view);
1733 mat4_translatecxx . . $ mat4_translate(2259ce7c40860d6a).(view, 0, 0, -40);
1734 mat4_rotatecxx . . $ mat4_rotate(f300fda151434b52).(view, 2 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! * view_rotcxx . . $ view_rot.[0] / 360.0, 1, 0, 0);
1735 mat4_rotatecxx . . $ mat4_rotate(f300fda151434b52).(view, 2 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! * view_rotcxx . . $ view_rot.[1] / 360.0, 0, 1, 0);
1736 mat4_rotatecxx . . $ mat4_rotate(f300fda151434b52).(view, 2 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! * view_rotcxx . . $ view_rot.[2] / 360.0, 0, 0, 1);
1737
1738 vkCmdBeginRenderPasscxx . . $ vkCmdBeginRenderPass(c1129be0fb8c79e7).(frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.,
1739 &(VkRenderPassBeginInfocxx . . $ VkRenderPassBeginInfo#) {
1740 .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFOcxx . . $ VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO.,
1741 .renderPass = render_passcxx . . $ render_pass.,
1742 .framebuffer = image_datacxx . . $ image_data.[image_index].framebuffercxx . . $ $anonymous_type_35552c03753a375_0#framebuffer.,
1743 .renderArea = { { 0, 0 }, { widthcxx . . $ width., heightcxx . . $ height. } },
1744 .clearValueCount = attachment_count,
1745 .pClearValues = (VkClearValuecxx . . $ VkClearValue# []) {
1746 { .color = { .float32 = { 0.0f, 0.0f, 0.0f, 1.0f } } },
1747 { .depthStencil.depth = 1.0f },
1748 { .color = { .float32 = { 0.0f, 0.0f, 0.0f, 1.0f } } },
1749 }
1750 },
1751 VK_SUBPASS_CONTENTS_INLINEcxx . . $ VK_SUBPASS_CONTENTS_INLINE.);
1752
1753 draw_gearscxx . . $ draw_gears(6bf228755210d43).(frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer., view);
1754
1755 vkCmdEndRenderPasscxx . . $ vkCmdEndRenderPass(1316ea956fcd8604).(frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.);
1756 vkEndCommandBuffercxx . . $ vkEndCommandBuffer(3af836937eb9bf6f).(frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.);
1757
1758 vkQueueSubmitcxx . . $ vkQueueSubmit(6d1a85fc5477fe55).(queuecxx . . $ queue., 1,
1759 &(VkSubmitInfocxx . . $ VkSubmitInfo#) {
1760 .sType = VK_STRUCTURE_TYPE_SUBMIT_INFOcxx . . $ VK_STRUCTURE_TYPE_SUBMIT_INFO.,
1761 .waitSemaphoreCount = 1,
1762 .pWaitSemaphores = &frame_datacxx . . $ frame_data.[frame_index].semaphorecxx . . $ $anonymous_type_35552c03753a375_1#semaphore.,
1763 .signalSemaphoreCount = 1,
1764 .pSignalSemaphores = &present_semaphorecxx . . $ present_semaphore.,
1765 .pWaitDstStageMask = (VkPipelineStageFlagscxx . . $ VkPipelineStageFlags# []) {
1766 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BITcxx . . $ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT.,
1767 },
1768 .commandBufferCount = 1,
1769 .pCommandBuffers = &frame_datacxx . . $ frame_data.[frame_index].cmd_buffercxx . . $ $anonymous_type_35552c03753a375_1#cmd_buffer.,
1770 }, frame_datacxx . . $ frame_data.[frame_index].fencecxx . . $ $anonymous_type_35552c03753a375_1#fence.);
1771
1772 vkQueuePresentKHRcxx . . $ vkQueuePresentKHR(3f1be578d4d01ffd).(queuecxx . . $ queue.,
1773 &(VkPresentInfoKHRcxx . . $ VkPresentInfoKHR#) {
1774 .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHRcxx . . $ VK_STRUCTURE_TYPE_PRESENT_INFO_KHR.,
1775 .pWaitSemaphores = &present_semaphorecxx . . $ present_semaphore.,
1776 .waitSemaphoreCount = 1,
1777 .swapchainCount = 1,
1778 .pSwapchains = (VkSwapchainKHRcxx . . $ VkSwapchainKHR#[]) { swapchaincxx . . $ swapchain., },
1779 .pImageIndices = (uint32_tcxx . . $ uint32_t#[]) { image_index, },
1780 .pResults = &result,
1781 });
1782
1783 frames++;
1784
1785 frame_index++;
1786 if (frame_index == MAX_CONCURRENT_FRAMEScxx . . $ `deps/vkgears/vkgears.c:89:9`!)
1787 frame_index = 0;
1788
1789 if (tRate0 < 0.0)
1790 tRate0 = t;
1791 if (t - tRate0 >= 3.0) {
1792 float seconds = t - tRate0;
1793 float fps = frames / seconds;
1794 printfcxx . . $ printf(581fddd72a8db8fc).("Ver=%d, Result:%6.3f\n", VKBENCH_VERSIONcxx . . $ `deps/vkgears/vkgears.c:44:9`!, fps);
1795 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
1796 tRate0 = t;
1797 frames = 0;
1798 break;
1799 }
1800 }
1801
1802 wsicxx . . $ wsi..fini_windowcxx . . $ wsi_interface#fini_window.();
1803 wsicxx . . $ wsi..fini_displaycxx . . $ wsi_interface#fini_display.();
1804 return 0;
1805 }