Commit 79c7a1713fef4dde119fba998edfaafa2fbbaac9

Ryan C. Gordon 2021-08-24T12:41:41

testvulkan: reformatted to more-closely match SDL coding conventions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
diff --git a/test/testvulkan.c b/test/testvulkan.c
index 9b3bb39..ee6bde8 100644
--- a/test/testvulkan.c
+++ b/test/testvulkan.c
@@ -110,66 +110,39 @@ enum {
 
 static const char *getVulkanResultString(VkResult result)
 {
-    switch((int)result)
+    switch((int) result)
     {
-    case VK_SUCCESS:
-        return "VK_SUCCESS";
-    case VK_NOT_READY:
-        return "VK_NOT_READY";
-    case VK_TIMEOUT:
-        return "VK_TIMEOUT";
-    case VK_EVENT_SET:
-        return "VK_EVENT_SET";
-    case VK_EVENT_RESET:
-        return "VK_EVENT_RESET";
-    case VK_INCOMPLETE:
-        return "VK_INCOMPLETE";
-    case VK_ERROR_OUT_OF_HOST_MEMORY:
-        return "VK_ERROR_OUT_OF_HOST_MEMORY";
-    case VK_ERROR_OUT_OF_DEVICE_MEMORY:
-        return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
-    case VK_ERROR_INITIALIZATION_FAILED:
-        return "VK_ERROR_INITIALIZATION_FAILED";
-    case VK_ERROR_DEVICE_LOST:
-        return "VK_ERROR_DEVICE_LOST";
-    case VK_ERROR_MEMORY_MAP_FAILED:
-        return "VK_ERROR_MEMORY_MAP_FAILED";
-    case VK_ERROR_LAYER_NOT_PRESENT:
-        return "VK_ERROR_LAYER_NOT_PRESENT";
-    case VK_ERROR_EXTENSION_NOT_PRESENT:
-        return "VK_ERROR_EXTENSION_NOT_PRESENT";
-    case VK_ERROR_FEATURE_NOT_PRESENT:
-        return "VK_ERROR_FEATURE_NOT_PRESENT";
-    case VK_ERROR_INCOMPATIBLE_DRIVER:
-        return "VK_ERROR_INCOMPATIBLE_DRIVER";
-    case VK_ERROR_TOO_MANY_OBJECTS:
-        return "VK_ERROR_TOO_MANY_OBJECTS";
-    case VK_ERROR_FORMAT_NOT_SUPPORTED:
-        return "VK_ERROR_FORMAT_NOT_SUPPORTED";
-    case VK_ERROR_FRAGMENTED_POOL:
-        return "VK_ERROR_FRAGMENTED_POOL";
-    case VK_ERROR_SURFACE_LOST_KHR:
-        return "VK_ERROR_SURFACE_LOST_KHR";
-    case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
-        return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
-    case VK_SUBOPTIMAL_KHR:
-        return "VK_SUBOPTIMAL_KHR";
-    case VK_ERROR_OUT_OF_DATE_KHR:
-        return "VK_ERROR_OUT_OF_DATE_KHR";
-    case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
-        return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
-    case VK_ERROR_VALIDATION_FAILED_EXT:
-        return "VK_ERROR_VALIDATION_FAILED_EXT";
-    case VK_ERROR_OUT_OF_POOL_MEMORY_KHR:
-        return "VK_ERROR_OUT_OF_POOL_MEMORY_KHR";
-    case VK_ERROR_INVALID_SHADER_NV:
-        return "VK_ERROR_INVALID_SHADER_NV";
-    default:
-        break;
+        #define RESULT_CASE(x) case x: return #x
+        RESULT_CASE(VK_SUCCESS);
+        RESULT_CASE(VK_NOT_READY);
+        RESULT_CASE(VK_TIMEOUT);
+        RESULT_CASE(VK_EVENT_SET);
+        RESULT_CASE(VK_EVENT_RESET);
+        RESULT_CASE(VK_INCOMPLETE);
+        RESULT_CASE(VK_ERROR_OUT_OF_HOST_MEMORY);
+        RESULT_CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY);
+        RESULT_CASE(VK_ERROR_INITIALIZATION_FAILED);
+        RESULT_CASE(VK_ERROR_DEVICE_LOST);
+        RESULT_CASE(VK_ERROR_MEMORY_MAP_FAILED);
+        RESULT_CASE(VK_ERROR_LAYER_NOT_PRESENT);
+        RESULT_CASE(VK_ERROR_EXTENSION_NOT_PRESENT);
+        RESULT_CASE(VK_ERROR_FEATURE_NOT_PRESENT);
+        RESULT_CASE(VK_ERROR_INCOMPATIBLE_DRIVER);
+        RESULT_CASE(VK_ERROR_TOO_MANY_OBJECTS);
+        RESULT_CASE(VK_ERROR_FORMAT_NOT_SUPPORTED);
+        RESULT_CASE(VK_ERROR_FRAGMENTED_POOL);
+        RESULT_CASE(VK_ERROR_SURFACE_LOST_KHR);
+        RESULT_CASE(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR);
+        RESULT_CASE(VK_SUBOPTIMAL_KHR);
+        RESULT_CASE(VK_ERROR_OUT_OF_DATE_KHR);
+        RESULT_CASE(VK_ERROR_INCOMPATIBLE_DISPLAY_KHR);
+        RESULT_CASE(VK_ERROR_VALIDATION_FAILED_EXT);
+        RESULT_CASE(VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
+        RESULT_CASE(VK_ERROR_INVALID_SHADER_NV);
+        #undef RESULT_CASE
+        default: break;
     }
-    if(result < 0)
-        return "VK_ERROR_<Unknown>";
-    return "VK_<Unknown>";
+    return (result < 0) ? "VK_ERROR_<Unknown>" : "VK_<Unknown>";
 }
 
 typedef struct VulkanContext
@@ -219,8 +192,7 @@ static void quit(int rc)
 static void loadGlobalFunctions(void)
 {
     vkGetInstanceProcAddr = SDL_Vulkan_GetVkGetInstanceProcAddr();
-    if(!vkGetInstanceProcAddr)
-    {
+    if (!vkGetInstanceProcAddr) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "SDL_Vulkan_GetVkGetInstanceProcAddr(): %s\n",
                      SDL_GetError());
@@ -230,8 +202,7 @@ static void loadGlobalFunctions(void)
 #define VULKAN_DEVICE_FUNCTION(name)
 #define VULKAN_GLOBAL_FUNCTION(name)                                                   \
     name = (PFN_##name)vkGetInstanceProcAddr(VK_NULL_HANDLE, #name);                   \
-    if(!name)                                                                          \
-    {                                                                                  \
+    if (!name) {                                                                       \
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,                                     \
                      "vkGetInstanceProcAddr(VK_NULL_HANDLE, \"" #name "\") failed\n"); \
         quit(2);                                                                       \
@@ -251,26 +222,22 @@ static void createInstance(void)
     unsigned extensionCount = 0;
     VkResult result;
 
-
     appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
     appInfo.apiVersion = VK_API_VERSION_1_0;
     instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
     instanceCreateInfo.pApplicationInfo = &appInfo;
-    if(!SDL_Vulkan_GetInstanceExtensions(NULL, &extensionCount, NULL))
-    {
+    if (!SDL_Vulkan_GetInstanceExtensions(NULL, &extensionCount, NULL)) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "SDL_Vulkan_GetInstanceExtensions(): %s\n",
                      SDL_GetError());
         quit(2);
     }
-    extensions = SDL_malloc(sizeof(const char *) * extensionCount);
-    if(!extensions)
-    {
+    extensions = (const char **) SDL_malloc(sizeof(const char *) * extensionCount);
+    if (!extensions) {
         SDL_OutOfMemory();
         quit(2);
     }
-    if(!SDL_Vulkan_GetInstanceExtensions(NULL, &extensionCount, extensions))
-    {
+    if (!SDL_Vulkan_GetInstanceExtensions(NULL, &extensionCount, extensions)) {
         SDL_free((void*)extensions);
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "SDL_Vulkan_GetInstanceExtensions(): %s\n",
@@ -281,8 +248,7 @@ static void createInstance(void)
     instanceCreateInfo.ppEnabledExtensionNames = extensions;
     result = vkCreateInstance(&instanceCreateInfo, NULL, &vulkanContext->instance);
     SDL_free((void*)extensions);
-    if(result != VK_SUCCESS)
-    {
+    if (result != VK_SUCCESS) {
         vulkanContext->instance = VK_NULL_HANDLE;
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkCreateInstance(): %s\n",
@@ -296,9 +262,8 @@ static void loadInstanceFunctions(void)
 #define VULKAN_DEVICE_FUNCTION(name)
 #define VULKAN_GLOBAL_FUNCTION(name)
 #define VULKAN_INSTANCE_FUNCTION(name)                                           \
-    name = (PFN_##name)vkGetInstanceProcAddr(vulkanContext->instance, #name);     \
-    if(!name)                                                                    \
-    {                                                                            \
+    name = (PFN_##name)vkGetInstanceProcAddr(vulkanContext->instance, #name);    \
+    if (!name) {                                                                 \
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,                               \
                      "vkGetInstanceProcAddr(instance, \"" #name "\") failed\n"); \
         quit(2);                                                                 \
@@ -311,13 +276,11 @@ static void loadInstanceFunctions(void)
 
 static void createSurface(void)
 {
-    if(!SDL_Vulkan_CreateSurface(vulkanContext->window,
+    if (!SDL_Vulkan_CreateSurface(vulkanContext->window,
                                  vulkanContext->instance,
-                                 &vulkanContext->surface))
-    {
+                                 &vulkanContext->surface)) {
         vulkanContext->surface = VK_NULL_HANDLE;
-        SDL_LogError(
-            SDL_LOG_CATEGORY_APPLICATION, "SDL_Vulkan_CreateSurface(): %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Vulkan_CreateSurface(): %s\n", SDL_GetError());
         quit(2);
     }
 }
@@ -331,32 +294,27 @@ static void findPhysicalDevice(void)
     VkExtensionProperties *deviceExtensions = NULL;
     uint32_t deviceExtensionsAllocatedSize = 0;
     uint32_t physicalDeviceIndex;
+    VkResult result;
 
-    VkResult result =
-        vkEnumeratePhysicalDevices(vulkanContext->instance, &physicalDeviceCount, NULL);
-    if(result != VK_SUCCESS)
-    {
+    result = vkEnumeratePhysicalDevices(vulkanContext->instance, &physicalDeviceCount, NULL);
+    if (result != VK_SUCCESS) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkEnumeratePhysicalDevices(): %s\n",
                      getVulkanResultString(result));
         quit(2);
     }
-    if(physicalDeviceCount == 0)
-    {
+    if (physicalDeviceCount == 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkEnumeratePhysicalDevices(): no physical devices\n");
         quit(2);
     }
-    physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
-    if(!physicalDevices)
-    {
+    physicalDevices = (VkPhysicalDevice *) SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
+    if (!physicalDevices) {
         SDL_OutOfMemory();
         quit(2);
     }
-    result =
-        vkEnumeratePhysicalDevices(vulkanContext->instance, &physicalDeviceCount, physicalDevices);
-    if(result != VK_SUCCESS)
-    {
+    result = vkEnumeratePhysicalDevices(vulkanContext->instance, &physicalDeviceCount, physicalDevices);
+    if (result != VK_SUCCESS) {
         SDL_free(physicalDevices);
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkEnumeratePhysicalDevices(): %s\n",
@@ -364,55 +322,50 @@ static void findPhysicalDevice(void)
         quit(2);
     }
     vulkanContext->physicalDevice = NULL;
-    for(physicalDeviceIndex = 0; physicalDeviceIndex < physicalDeviceCount;
-        physicalDeviceIndex++)
-    {
+    for (physicalDeviceIndex = 0; physicalDeviceIndex < physicalDeviceCount; physicalDeviceIndex++) {
         uint32_t queueFamiliesCount = 0;
         uint32_t queueFamilyIndex;
         uint32_t deviceExtensionCount = 0;
         SDL_bool hasSwapchainExtension = SDL_FALSE;
         uint32_t i;
 
-
         VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex];
         vkGetPhysicalDeviceProperties(physicalDevice, &vulkanContext->physicalDeviceProperties);
-        if(VK_VERSION_MAJOR(vulkanContext->physicalDeviceProperties.apiVersion) < 1)
+        if(VK_VERSION_MAJOR(vulkanContext->physicalDeviceProperties.apiVersion) < 1) {
             continue;
+        }
         vkGetPhysicalDeviceFeatures(physicalDevice, &vulkanContext->physicalDeviceFeatures);
         vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamiliesCount, NULL);
-        if(queueFamiliesCount == 0)
+        if (queueFamiliesCount == 0) {
             continue;
-        if(queueFamiliesPropertiesAllocatedSize < queueFamiliesCount)
-        {
+        }
+        if (queueFamiliesPropertiesAllocatedSize < queueFamiliesCount) {
             SDL_free(queueFamiliesProperties);
             queueFamiliesPropertiesAllocatedSize = queueFamiliesCount;
-            queueFamiliesProperties =
-                SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize);
-            if(!queueFamiliesProperties)
-            {
+            queueFamiliesProperties = (VkQueueFamilyProperties *) SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize);
+            if (!queueFamiliesProperties) {
                 SDL_free(physicalDevices);
                 SDL_free(deviceExtensions);
                 SDL_OutOfMemory();
                 quit(2);
             }
         }
-        vkGetPhysicalDeviceQueueFamilyProperties(
-            physicalDevice, &queueFamiliesCount, queueFamiliesProperties);
+        vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamiliesCount, queueFamiliesProperties);
         vulkanContext->graphicsQueueFamilyIndex = queueFamiliesCount;
         vulkanContext->presentQueueFamilyIndex = queueFamiliesCount;
-        for(queueFamilyIndex = 0; queueFamilyIndex < queueFamiliesCount;
-            queueFamilyIndex++)
-        {
+        for (queueFamilyIndex = 0; queueFamilyIndex < queueFamiliesCount; queueFamilyIndex++) {
             VkBool32 supported = 0;
 
-            if(queueFamiliesProperties[queueFamilyIndex].queueCount == 0)
+            if (queueFamiliesProperties[queueFamilyIndex].queueCount == 0) {
                 continue;
-            if(queueFamiliesProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT)
+            }
+
+            if (queueFamiliesProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
                 vulkanContext->graphicsQueueFamilyIndex = queueFamilyIndex;
-            result = vkGetPhysicalDeviceSurfaceSupportKHR(
-                physicalDevice, queueFamilyIndex, vulkanContext->surface, &supported);
-            if(result != VK_SUCCESS)
-            {
+            }
+
+            result = vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, vulkanContext->surface, &supported);
+            if (result != VK_SUCCESS) {
                 SDL_free(physicalDevices);
                 SDL_free(queueFamiliesProperties);
                 SDL_free(deviceExtensions);
@@ -421,20 +374,22 @@ static void findPhysicalDevice(void)
                              getVulkanResultString(result));
                 quit(2);
             }
-            if(supported)
-            {
+            if (supported) {
                 vulkanContext->presentQueueFamilyIndex = queueFamilyIndex;
-                if(queueFamiliesProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT)
+                if (queueFamiliesProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
                     break; // use this queue because it can present and do graphics
+                }
             }
         }
-        if(vulkanContext->graphicsQueueFamilyIndex == queueFamiliesCount) // no good queues found
+
+        if (vulkanContext->graphicsQueueFamilyIndex == queueFamiliesCount) {  // no good queues found
             continue;
-        if(vulkanContext->presentQueueFamilyIndex == queueFamiliesCount) // no good queues found
+        }
+        if (vulkanContext->presentQueueFamilyIndex == queueFamiliesCount) {  // no good queues found
             continue;
-        result =
-            vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &deviceExtensionCount, NULL);
-        if(result != VK_SUCCESS)
+        }
+        result = vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &deviceExtensionCount, NULL);
+        if (result != VK_SUCCESS)
         {
             SDL_free(physicalDevices);
             SDL_free(queueFamiliesProperties);
@@ -444,26 +399,22 @@ static void findPhysicalDevice(void)
                          getVulkanResultString(result));
             quit(2);
         }
-        if(deviceExtensionCount == 0)
+        if (deviceExtensionCount == 0) {
             continue;
-        if(deviceExtensionsAllocatedSize < deviceExtensionCount)
-        {
+        }
+        if (deviceExtensionsAllocatedSize < deviceExtensionCount) {
             SDL_free(deviceExtensions);
             deviceExtensionsAllocatedSize = deviceExtensionCount;
-            deviceExtensions =
-                SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize);
-            if(!deviceExtensions)
-            {
+            deviceExtensions = SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize);
+            if (!deviceExtensions) {
                 SDL_free(physicalDevices);
                 SDL_free(queueFamiliesProperties);
                 SDL_OutOfMemory();
                 quit(2);
             }
         }
-        result = vkEnumerateDeviceExtensionProperties(
-            physicalDevice, NULL, &deviceExtensionCount, deviceExtensions);
-        if(result != VK_SUCCESS)
-        {
+        result = vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &deviceExtensionCount, deviceExtensions);
+        if (result != VK_SUCCESS) {
             SDL_free(physicalDevices);
             SDL_free(queueFamiliesProperties);
             SDL_free(deviceExtensions);
@@ -472,24 +423,22 @@ static void findPhysicalDevice(void)
                          getVulkanResultString(result));
             quit(2);
         }
-        for(i = 0; i < deviceExtensionCount; i++)
-        {
-            if(0 == SDL_strcmp(deviceExtensions[i].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME))
-            {
+        for (i = 0; i < deviceExtensionCount; i++) {
+            if(SDL_strcmp(deviceExtensions[i].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) {
                 hasSwapchainExtension = SDL_TRUE;
                 break;
             }
         }
-        if(!hasSwapchainExtension)
+        if (!hasSwapchainExtension) {
             continue;
+        }
         vulkanContext->physicalDevice = physicalDevice;
         break;
     }
     SDL_free(physicalDevices);
     SDL_free(queueFamiliesProperties);
     SDL_free(deviceExtensions);
-    if(!vulkanContext->physicalDevice)
-    {
+    if (!vulkanContext->physicalDevice) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Vulkan: no viable physical devices found");
         quit(2);
     }
@@ -516,13 +465,10 @@ static void createDevice(void)
     deviceCreateInfo.pEnabledFeatures = NULL;
     deviceCreateInfo.enabledExtensionCount = SDL_arraysize(deviceExtensionNames);
     deviceCreateInfo.ppEnabledExtensionNames = deviceExtensionNames;
-    result = vkCreateDevice(
-        vulkanContext->physicalDevice, &deviceCreateInfo, NULL, &vulkanContext->device);
-    if(result != VK_SUCCESS)
-    {
+    result = vkCreateDevice(vulkanContext->physicalDevice, &deviceCreateInfo, NULL, &vulkanContext->device);
+    if (result != VK_SUCCESS) {
         vulkanContext->device = VK_NULL_HANDLE;
-        SDL_LogError(
-            SDL_LOG_CATEGORY_APPLICATION, "vkCreateDevice(): %s\n", getVulkanResultString(result));
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkCreateDevice(): %s\n", getVulkanResultString(result));
         quit(2);
     }
 }
@@ -530,9 +476,8 @@ static void createDevice(void)
 static void loadDeviceFunctions(void)
 {
 #define VULKAN_DEVICE_FUNCTION(name)                                         \
-    name = (PFN_##name)vkGetDeviceProcAddr(vulkanContext->device, #name);     \
-    if(!name)                                                                \
-    {                                                                        \
+    name = (PFN_##name)vkGetDeviceProcAddr(vulkanContext->device, #name);    \
+    if (!name) {                                                             \
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,                           \
                      "vkGetDeviceProcAddr(device, \"" #name "\") failed\n"); \
         quit(2);                                                             \
@@ -553,13 +498,14 @@ static void getQueues(void)
                      vulkanContext->graphicsQueueFamilyIndex,
                      0,
                      &vulkanContext->graphicsQueue);
-    if(vulkanContext->graphicsQueueFamilyIndex != vulkanContext->presentQueueFamilyIndex)
+    if (vulkanContext->graphicsQueueFamilyIndex != vulkanContext->presentQueueFamilyIndex) {
         vkGetDeviceQueue(vulkanContext->device,
                          vulkanContext->presentQueueFamilyIndex,
                          0,
                          &vulkanContext->presentQueue);
-    else
+    } else {
         vulkanContext->presentQueue = vulkanContext->graphicsQueue;
+    }
 }
 
 static void createSemaphore(VkSemaphore *semaphore)
@@ -569,8 +515,7 @@ static void createSemaphore(VkSemaphore *semaphore)
     VkSemaphoreCreateInfo createInfo = {0};
     createInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
     result = vkCreateSemaphore(vulkanContext->device, &createInfo, NULL, semaphore);
-    if(result != VK_SUCCESS)
-    {
+    if (result != VK_SUCCESS) {
         *semaphore = VK_NULL_HANDLE;
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkCreateSemaphore(): %s\n",
@@ -587,10 +532,8 @@ static void createSemaphores(void)
 
 static void getSurfaceCaps(void)
 {
-    VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
-        vulkanContext->physicalDevice, vulkanContext->surface, &vulkanContext->surfaceCapabilities);
-    if(result != VK_SUCCESS)
-    {
+    VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vulkanContext->physicalDevice, vulkanContext->surface, &vulkanContext->surfaceCapabilities);
+    if (result != VK_SUCCESS) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): %s\n",
                      getVulkanResultString(result));
@@ -598,8 +541,7 @@ static void getSurfaceCaps(void)
     }
 
     // check surface usage
-    if(!(vulkanContext->surfaceCapabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT))
-    {
+    if (!(vulkanContext->surfaceCapabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT)) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "Vulkan surface doesn't support VK_IMAGE_USAGE_TRANSFER_DST_BIT\n");
         quit(2);
@@ -612,22 +554,18 @@ static void getSurfaceFormats(void)
                                                            vulkanContext->surface,
                                                            &vulkanContext->surfaceFormatsCount,
                                                            NULL);
-    if(result != VK_SUCCESS)
-    {
+    if (result != VK_SUCCESS) {
         vulkanContext->surfaceFormatsCount = 0;
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkGetPhysicalDeviceSurfaceFormatsKHR(): %s\n",
                      getVulkanResultString(result));
         quit(2);
     }
-    if(vulkanContext->surfaceFormatsCount > vulkanContext->surfaceFormatsAllocatedCount)
-    {
+    if (vulkanContext->surfaceFormatsCount > vulkanContext->surfaceFormatsAllocatedCount) {
         vulkanContext->surfaceFormatsAllocatedCount = vulkanContext->surfaceFormatsCount;
         SDL_free(vulkanContext->surfaceFormats);
-        vulkanContext->surfaceFormats =
-            SDL_malloc(sizeof(VkSurfaceFormatKHR) * vulkanContext->surfaceFormatsAllocatedCount);
-        if(!vulkanContext->surfaceFormats)
-        {
+        vulkanContext->surfaceFormats = (VkSurfaceFormatKHR *) SDL_malloc(sizeof(VkSurfaceFormatKHR) * vulkanContext->surfaceFormatsAllocatedCount);
+        if (!vulkanContext->surfaceFormats) {
             vulkanContext->surfaceFormatsCount = 0;
             SDL_OutOfMemory();
             quit(2);
@@ -637,8 +575,7 @@ static void getSurfaceFormats(void)
                                                   vulkanContext->surface,
                                                   &vulkanContext->surfaceFormatsCount,
                                                   vulkanContext->surfaceFormats);
-    if(result != VK_SUCCESS)
-    {
+    if (result != VK_SUCCESS) {
         vulkanContext->surfaceFormatsCount = 0;
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkGetPhysicalDeviceSurfaceFormatsKHR(): %s\n",
@@ -653,10 +590,8 @@ static void getSwapchainImages(void)
 
     SDL_free(vulkanContext->swapchainImages);
     vulkanContext->swapchainImages = NULL;
-    result = vkGetSwapchainImagesKHR(
-        vulkanContext->device, vulkanContext->swapchain, &vulkanContext->swapchainImageCount, NULL);
-    if(result != VK_SUCCESS)
-    {
+    result = vkGetSwapchainImagesKHR(vulkanContext->device, vulkanContext->swapchain, &vulkanContext->swapchainImageCount, NULL);
+    if (result != VK_SUCCESS) {
         vulkanContext->swapchainImageCount = 0;
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkGetSwapchainImagesKHR(): %s\n",
@@ -664,8 +599,7 @@ static void getSwapchainImages(void)
         quit(2);
     }
     vulkanContext->swapchainImages = SDL_malloc(sizeof(VkImage) * vulkanContext->swapchainImageCount);
-    if(!vulkanContext->swapchainImages)
-    {
+    if (!vulkanContext->swapchainImages) {
         SDL_OutOfMemory();
         quit(2);
     }
@@ -673,8 +607,7 @@ static void getSwapchainImages(void)
                                      vulkanContext->swapchain,
                                      &vulkanContext->swapchainImageCount,
                                      vulkanContext->swapchainImages);
-    if(result != VK_SUCCESS)
-    {
+    if (result != VK_SUCCESS) {
         SDL_free(vulkanContext->swapchainImages);
         vulkanContext->swapchainImages = NULL;
         vulkanContext->swapchainImageCount = 0;
@@ -694,25 +627,21 @@ static SDL_bool createSwapchain(void)
 
     // pick an image count
     vulkanContext->swapchainDesiredImageCount = vulkanContext->surfaceCapabilities.minImageCount + 1;
-    if(vulkanContext->swapchainDesiredImageCount > vulkanContext->surfaceCapabilities.maxImageCount
-       && vulkanContext->surfaceCapabilities.maxImageCount > 0)
+    if ( (vulkanContext->swapchainDesiredImageCount > vulkanContext->surfaceCapabilities.maxImageCount) &&
+         (vulkanContext->surfaceCapabilities.maxImageCount > 0) ) {
         vulkanContext->swapchainDesiredImageCount = vulkanContext->surfaceCapabilities.maxImageCount;
+    }
 
     // pick a format
-    if(vulkanContext->surfaceFormatsCount == 1
-       && vulkanContext->surfaceFormats[0].format == VK_FORMAT_UNDEFINED)
-    {
+    if ( (vulkanContext->surfaceFormatsCount == 1) &&
+         (vulkanContext->surfaceFormats[0].format == VK_FORMAT_UNDEFINED) ) {
         // aren't any preferred formats, so we pick
         vulkanContext->surfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
         vulkanContext->surfaceFormat.format = VK_FORMAT_R8G8B8A8_UNORM;
-    }
-    else
-    {
+    } else {
         vulkanContext->surfaceFormat = vulkanContext->surfaceFormats[0];
-        for(i = 0; i < vulkanContext->surfaceFormatsCount; i++)
-        {
-            if(vulkanContext->surfaceFormats[i].format == VK_FORMAT_R8G8B8A8_UNORM)
-            {
+        for (i = 0; i < vulkanContext->surfaceFormatsCount; i++) {
+            if(vulkanContext->surfaceFormats[i].format == VK_FORMAT_R8G8B8A8_UNORM) {
                 vulkanContext->surfaceFormat = vulkanContext->surfaceFormats[i];
                 break;
             }
@@ -732,8 +661,9 @@ static SDL_bool createSwapchain(void)
                                                    vulkanContext->surfaceCapabilities.minImageExtent.height,
                                                    vulkanContext->surfaceCapabilities.maxImageExtent.height);
 
-    if(w == 0 || h == 0)
+    if (w == 0 || h == 0) {
         return SDL_FALSE;
+    }
 
     getSurfaceCaps();
 
@@ -751,62 +681,63 @@ static SDL_bool createSwapchain(void)
     createInfo.presentMode = VK_PRESENT_MODE_FIFO_KHR;
     createInfo.clipped = VK_TRUE;
     createInfo.oldSwapchain = vulkanContext->swapchain;
-    result =
-        vkCreateSwapchainKHR(vulkanContext->device, &createInfo, NULL, &vulkanContext->swapchain);
-    if(createInfo.oldSwapchain)
+    result = vkCreateSwapchainKHR(vulkanContext->device, &createInfo, NULL, &vulkanContext->swapchain);
+
+    if (createInfo.oldSwapchain) {
         vkDestroySwapchainKHR(vulkanContext->device, createInfo.oldSwapchain, NULL);
-    if(result != VK_SUCCESS)
-    {
+    }
+
+    if(result != VK_SUCCESS) {
         vulkanContext->swapchain = VK_NULL_HANDLE;
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkCreateSwapchainKHR(): %s\n",
                      getVulkanResultString(result));
         quit(2);
     }
+
     getSwapchainImages();
     return SDL_TRUE;
 }
 
 static void destroySwapchain(void)
 {
-    if(vulkanContext->swapchain)
+    if (vulkanContext->swapchain) {
         vkDestroySwapchainKHR(vulkanContext->device, vulkanContext->swapchain, NULL);
-    vulkanContext->swapchain = VK_NULL_HANDLE;
+        vulkanContext->swapchain = VK_NULL_HANDLE;
+    }
     SDL_free(vulkanContext->swapchainImages);
     vulkanContext->swapchainImages = NULL;
 }
 
 static void destroyCommandBuffers(void)
 {
-    if(vulkanContext->commandBuffers)
+    if (vulkanContext->commandBuffers) {
         vkFreeCommandBuffers(vulkanContext->device,
                              vulkanContext->commandPool,
                              vulkanContext->swapchainImageCount,
                              vulkanContext->commandBuffers);
-    SDL_free(vulkanContext->commandBuffers);
-    vulkanContext->commandBuffers = NULL;
+        SDL_free(vulkanContext->commandBuffers);
+        vulkanContext->commandBuffers = NULL;
+    }
 }
 
 static void destroyCommandPool(void)
 {
-    if(vulkanContext->commandPool)
+    if (vulkanContext->commandPool) {
         vkDestroyCommandPool(vulkanContext->device, vulkanContext->commandPool, NULL);
+    }
     vulkanContext->commandPool = VK_NULL_HANDLE;
 }
 
 static void createCommandPool(void)
 {
     VkResult result;
-
     VkCommandPoolCreateInfo createInfo = {0};
     createInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
-    createInfo.flags =
-        VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT | VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
+    createInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT | VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
     createInfo.queueFamilyIndex = vulkanContext->graphicsQueueFamilyIndex;
-    result =
-        vkCreateCommandPool(vulkanContext->device, &createInfo, NULL, &vulkanContext->commandPool);
-    if(result != VK_SUCCESS)
-    {
+    result = vkCreateCommandPool(vulkanContext->device, &createInfo, NULL, &vulkanContext->commandPool);
+    if (result != VK_SUCCESS) {
         vulkanContext->commandPool = VK_NULL_HANDLE;
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkCreateCommandPool(): %s\n",
@@ -818,18 +749,14 @@ static void createCommandPool(void)
 static void createCommandBuffers(void)
 {
     VkResult result;
-
     VkCommandBufferAllocateInfo allocateInfo = {0};
     allocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
     allocateInfo.commandPool = vulkanContext->commandPool;
     allocateInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
     allocateInfo.commandBufferCount = vulkanContext->swapchainImageCount;
-    vulkanContext->commandBuffers =
-        SDL_malloc(sizeof(VkCommandBuffer) * vulkanContext->swapchainImageCount);
-    result =
-        vkAllocateCommandBuffers(vulkanContext->device, &allocateInfo, vulkanContext->commandBuffers);
-    if(result != VK_SUCCESS)
-    {
+    vulkanContext->commandBuffers = (VkCommandBuffer *) SDL_malloc(sizeof(VkCommandBuffer) * vulkanContext->swapchainImageCount);
+    result = vkAllocateCommandBuffers(vulkanContext->device, &allocateInfo, vulkanContext->commandBuffers);
+    if(result != VK_SUCCESS) {
         SDL_free(vulkanContext->commandBuffers);
         vulkanContext->commandBuffers = NULL;
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@@ -844,24 +771,18 @@ static void createFences(void)
     uint32_t i;
 
     vulkanContext->fences = SDL_malloc(sizeof(VkFence) * vulkanContext->swapchainImageCount);
-    if(!vulkanContext->fences)
-    {
+    if (!vulkanContext->fences) {
         SDL_OutOfMemory();
         quit(2);
     }
-    for(i = 0; i < vulkanContext->swapchainImageCount; i++)
-    {
+    for (i = 0; i < vulkanContext->swapchainImageCount; i++) {
         VkResult result;
-
         VkFenceCreateInfo createInfo = {0};
         createInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
         createInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
-        result =
-            vkCreateFence(vulkanContext->device, &createInfo, NULL, &vulkanContext->fences[i]);
-        if(result != VK_SUCCESS)
-        {
-            for(; i > 0; i--)
-            {
+        result = vkCreateFence(vulkanContext->device, &createInfo, NULL, &vulkanContext->fences[i]);
+        if(result != VK_SUCCESS) {
+            for(; i > 0; i--) {
                 vkDestroyFence(vulkanContext->device, vulkanContext->fences[i - 1], NULL);
             }
             SDL_free(vulkanContext->fences);
@@ -878,10 +799,11 @@ static void destroyFences(void)
 {
     uint32_t i;
 
-    if(!vulkanContext->fences)
+    if (!vulkanContext->fences) {
         return;
-    for(i = 0; i < vulkanContext->swapchainImageCount; i++)
-    {
+    }
+
+    for (i = 0; i < vulkanContext->swapchainImageCount; i++) {
         vkDestroyFence(vulkanContext->device, vulkanContext->fences[i], NULL);
     }
     SDL_free(vulkanContext->fences);
@@ -929,8 +851,7 @@ static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue *
     VkImageSubresourceRange clearRange = {0};
 
     VkResult result = vkResetCommandBuffer(commandBuffer, 0);
-    if(result != VK_SUCCESS)
-    {
+    if(result != VK_SUCCESS) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkResetCommandBuffer(): %s\n",
                      getVulkanResultString(result));
@@ -939,8 +860,7 @@ static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue *
     beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
     beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
     result = vkBeginCommandBuffer(commandBuffer, &beginInfo);
-    if(result != VK_SUCCESS)
-    {
+    if (result != VK_SUCCESS) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkBeginCommandBuffer(): %s\n",
                      getVulkanResultString(result));
@@ -957,8 +877,7 @@ static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue *
     clearRange.levelCount = 1;
     clearRange.baseArrayLayer = 0;
     clearRange.layerCount = 1;
-    vkCmdClearColorImage(
-        commandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, clearColor, 1, &clearRange);
+    vkCmdClearColorImage(commandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, clearColor, 1, &clearRange);
     recordPipelineImageBarrier(commandBuffer,
                                VK_ACCESS_TRANSFER_WRITE_BIT,
                                VK_ACCESS_MEMORY_READ_BIT,
@@ -966,8 +885,7 @@ static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue *
                                VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
                                image);
     result = vkEndCommandBuffer(commandBuffer);
-    if(result != VK_SUCCESS)
-    {
+    if (result != VK_SUCCESS) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkEndCommandBuffer(): %s\n",
                      getVulkanResultString(result));
@@ -981,8 +899,9 @@ static void destroySwapchainAndSwapchainSpecificStuff(SDL_bool doDestroySwapchai
     destroyFences();
     destroyCommandBuffers();
     destroyCommandPool();
-    if(doDestroySwapchain)
+    if (doDestroySwapchain) {
         destroySwapchain();
+    }
 }
 
 static SDL_bool createNewSwapchainAndSwapchainSpecificStuff(void)
@@ -990,8 +909,9 @@ static SDL_bool createNewSwapchainAndSwapchainSpecificStuff(void)
     destroySwapchainAndSwapchainSpecificStuff(SDL_FALSE);
     getSurfaceCaps();
     getSurfaceFormats();
-    if(!createSwapchain())
+    if(!createSwapchain()) {
         return SDL_FALSE;
+    }
     createCommandPool();
     createCommandBuffers();
     createFences();
@@ -1032,19 +952,32 @@ static void shutdownVulkan(SDL_bool doDestroySwapchain)
         int i;
         for (i = 0; i < state->num_windows; ++i) {
             vulkanContext = &vulkanContexts[i];
-            if(vulkanContext->device && vkDeviceWaitIdle)
+            if (vulkanContext->device && vkDeviceWaitIdle) {
                 vkDeviceWaitIdle(vulkanContext->device);
+            }
+
             destroySwapchainAndSwapchainSpecificStuff(doDestroySwapchain);
-            if(vulkanContext->imageAvailableSemaphore && vkDestroySemaphore)
+
+            if (vulkanContext->imageAvailableSemaphore && vkDestroySemaphore) {
                 vkDestroySemaphore(vulkanContext->device, vulkanContext->imageAvailableSemaphore, NULL);
-            if(vulkanContext->renderingFinishedSemaphore && vkDestroySemaphore)
+            }
+
+            if (vulkanContext->renderingFinishedSemaphore && vkDestroySemaphore) {
                 vkDestroySemaphore(vulkanContext->device, vulkanContext->renderingFinishedSemaphore, NULL);
-            if(vulkanContext->device && vkDestroyDevice)
+            }
+
+            if (vulkanContext->device && vkDestroyDevice) {
                 vkDestroyDevice(vulkanContext->device, NULL);
-            if(vulkanContext->surface && vkDestroySurfaceKHR)
+            }
+
+            if (vulkanContext->surface && vkDestroySurfaceKHR) {
                 vkDestroySurfaceKHR(vulkanContext->instance, vulkanContext->surface, NULL);
-            if(vulkanContext->instance && vkDestroyInstance)
+            }
+
+            if (vulkanContext->instance && vkDestroyInstance) {
                 vkDestroyInstance(vulkanContext->instance, NULL);
+            }
+
             SDL_free(vulkanContext->surfaceFormats);
         }
         SDL_free(vulkanContexts);
@@ -1065,8 +998,7 @@ static SDL_bool render(void)
     VkPresentInfoKHR presentInfo = {0};
     int w, h;
 
-    if(!vulkanContext->swapchain)
-    {
+    if (!vulkanContext->swapchain) {
         SDL_bool retval = createNewSwapchainAndSwapchainSpecificStuff();
         if(!retval)
             SDL_Delay(100);
@@ -1078,28 +1010,24 @@ static SDL_bool render(void)
                                             vulkanContext->imageAvailableSemaphore,
                                             VK_NULL_HANDLE,
                                             &frameIndex);
-    if(result == VK_ERROR_OUT_OF_DATE_KHR)
+    if (result == VK_ERROR_OUT_OF_DATE_KHR) {
         return createNewSwapchainAndSwapchainSpecificStuff();
-    if(result != VK_SUBOPTIMAL_KHR && result != VK_SUCCESS)
-    {
+    }
+
+    if ((result != VK_SUBOPTIMAL_KHR) && (result != VK_SUCCESS)) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkAcquireNextImageKHR(): %s\n",
                      getVulkanResultString(result));
         quit(2);
     }
-    result = vkWaitForFences(
-        vulkanContext->device, 1, &vulkanContext->fences[frameIndex], VK_FALSE, UINT64_MAX);
-    if(result != VK_SUCCESS)
-    {
-        SDL_LogError(
-            SDL_LOG_CATEGORY_APPLICATION, "vkWaitForFences(): %s\n", getVulkanResultString(result));
+    result = vkWaitForFences(vulkanContext->device, 1, &vulkanContext->fences[frameIndex], VK_FALSE, UINT64_MAX);
+    if (result != VK_SUCCESS) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkWaitForFences(): %s\n", getVulkanResultString(result));
         quit(2);
     }
     result = vkResetFences(vulkanContext->device, 1, &vulkanContext->fences[frameIndex]);
-    if(result != VK_SUCCESS)
-    {
-        SDL_LogError(
-            SDL_LOG_CATEGORY_APPLICATION, "vkResetFences(): %s\n", getVulkanResultString(result));
+    if (result != VK_SUCCESS) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkResetFences(): %s\n", getVulkanResultString(result));
         quit(2);
     }
     currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency();
@@ -1116,12 +1044,10 @@ static SDL_bool render(void)
     submitInfo.pCommandBuffers = &vulkanContext->commandBuffers[frameIndex];
     submitInfo.signalSemaphoreCount = 1;
     submitInfo.pSignalSemaphores = &vulkanContext->renderingFinishedSemaphore;
-    result = vkQueueSubmit(
-        vulkanContext->graphicsQueue, 1, &submitInfo, vulkanContext->fences[frameIndex]);
-    if(result != VK_SUCCESS)
-    {
-        SDL_LogError(
-            SDL_LOG_CATEGORY_APPLICATION, "vkQueueSubmit(): %s\n", getVulkanResultString(result));
+    result = vkQueueSubmit(vulkanContext->graphicsQueue, 1, &submitInfo, vulkanContext->fences[frameIndex]);
+
+    if (result != VK_SUCCESS) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "vkQueueSubmit(): %s\n", getVulkanResultString(result));
         quit(2);
     }
     presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
@@ -1131,26 +1057,24 @@ static SDL_bool render(void)
     presentInfo.pSwapchains = &vulkanContext->swapchain;
     presentInfo.pImageIndices = &frameIndex;
     result = vkQueuePresentKHR(vulkanContext->presentQueue, &presentInfo);
-    if(result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR)
-    {
+    if ((result == VK_ERROR_OUT_OF_DATE_KHR) || (result == VK_SUBOPTIMAL_KHR)) {
         return createNewSwapchainAndSwapchainSpecificStuff();
     }
-    if(result != VK_SUCCESS)
-    {
+
+    if (result != VK_SUCCESS) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                      "vkQueuePresentKHR(): %s\n",
                      getVulkanResultString(result));
         quit(2);
     }
     SDL_Vulkan_GetDrawableSize(vulkanContext->window, &w, &h);
-    if(w != (int)vulkanContext->swapchainSize.width || h != (int)vulkanContext->swapchainSize.height)
-    {
+    if(w != (int)vulkanContext->swapchainSize.width || h != (int)vulkanContext->swapchainSize.height) {
         return createNewSwapchainAndSwapchainSpecificStuff();
     }
     return SDL_TRUE;
 }
 
-int main(int argc, char *argv[])
+int main(int argc, char **argv)
 {
     int done;
     SDL_DisplayMode mode;
@@ -1163,8 +1087,7 @@ int main(int argc, char *argv[])
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
-    if(!state)
-    {
+    if(!state) {
         return 1;
     }
 
@@ -1191,17 +1114,16 @@ int main(int argc, char *argv[])
     frames = 0;
     then = SDL_GetTicks();
     done = 0;
-    while(!done)
-    {
+    while (!done) {
         /* Check for events */
-        ++frames;
-        while(SDL_PollEvent(&event))  /* !!! FIXME: fix coding conventions with braces and spaces */
-        {
+        frames++;
+        while(SDL_PollEvent(&event)) {
             /* Need to destroy the swapchain before the window created
              * by SDL.
              */
-            if (event.type == SDL_WINDOWEVENT_CLOSE)
+            if (event.type == SDL_WINDOWEVENT_CLOSE) {
                 destroySwapchainAndSwapchainSpecificStuff(SDL_TRUE);
+            }
             SDLTest_CommonEvent(state, &event, &done);
         }
 
@@ -1218,10 +1140,10 @@ int main(int argc, char *argv[])
 
     /* Print out some timing information */
     now = SDL_GetTicks();
-    if(now > then)
-    {
+    if (now > then) {
         SDL_Log("%2.2f frames per second\n", ((double)frames * 1000) / (now - then));
     }
+
     shutdownVulkan(SDL_TRUE);
     SDLTest_CommonQuit(state);
     return 0;