vulkaninfo.c revision b5fad79e4bb8089a6a9519d248c378079822d2c6
146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu/*
246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu *
38a17da586c0f31c72aefe229449d55ea18682be9Courtney Goeltzenleuchter * Copyright (C) 2015 Valve Corporation
446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu *
546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * Permission is hereby granted, free of charge, to any person obtaining a
646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * copy of this software and associated documentation files (the "Software"),
746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * to deal in the Software without restriction, including without limitation
846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * the rights to use, copy, modify, merge, publish, distribute, sublicense,
946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * and/or sell copies of the Software, and to permit persons to whom the
1046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * Software is furnished to do so, subject to the following conditions:
1146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu *
1246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * The above copyright notice and this permission notice shall be included
1346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * in all copies or substantial portions of the Software.
1446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu *
1546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu * DEALINGS IN THE SOFTWARE.
2296cd795bb585711057cd90d37a2251419384c937Courtney Goeltzenleuchter *
2396cd795bb585711057cd90d37a2251419384c937Courtney Goeltzenleuchter * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
2496cd795bb585711057cd90d37a2251419384c937Courtney Goeltzenleuchter * Author: David Pinedo <david@lunarg.com>
2596cd795bb585711057cd90d37a2251419384c937Courtney Goeltzenleuchter * Author: Mark Lobodzinski <mark@lunarg.com>
2646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu */
27d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu#include <stdlib.h>
28d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu#include <stdio.h>
29d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu#include <stdbool.h>
30d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu#include <string.h>
3146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu#include <assert.h>
32825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski#include <inttypes.h>
33d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
34ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott#ifdef _WIN32
35b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#define VK_USE_PLATFORM_WIN32_KHR
3618fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo#include <fcntl.h>
3718fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo#include <io.h>
38ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott
39b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#else  // _WIN32
40b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#define VK_USE_PLATFORM_XCB_KHR
41b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#endif // _WIN32
4264070a88a7a4411e0eb0d7148bd1a1598e74a88cIan Elliott
43e36b208f32a0959cd7590b1717aac3ef19631b1aIan Elliott
44329ca9eb16cdbee7a7644fb08ade7b3d3bb32e23David Pinedo#include <vulkan/vulkan.h>
4546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
4646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu#define ERR(err) printf("%s:%d: failed with %s\n", \
479cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    __FILE__, __LINE__, vk_result_string(err));
4846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
4918fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo#ifdef _WIN32
5018fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
517c83aa210365e148877f0f3698292a1b509018ffIan Elliott#define snprintf _snprintf
527c83aa210365e148877f0f3698292a1b509018ffIan Elliott
5318fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedobool consoleCreated = false;
5418fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
5518fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo#define WAIT_FOR_CONSOLE_DESTROY \
5618fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    do { \
5718fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        if (consoleCreated) \
5818fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo            Sleep(INFINITE); \
5918fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    } while (0)
6018fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo#else
6118fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    #define WAIT_FOR_CONSOLE_DESTROY
6218fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo#endif
6318fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
6418fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
6518fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo#define ERR_EXIT(err) \
6618fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    do { \
6718fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        ERR(err); \
6818fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        fflush(stdout); \
6918fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        WAIT_FOR_CONSOLE_DESTROY; \
7018fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        exit(-1); \
7118fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo   } while (0)
7246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
7322a30866de6210d780995dfaaae39f1a73115aa0Tony Barbour#if defined(NDEBUG) && defined(__GNUC__)
7422a30866de6210d780995dfaaae39f1a73115aa0Tony Barbour#define U_ASSERT_ONLY __attribute__((unused))
7522a30866de6210d780995dfaaae39f1a73115aa0Tony Barbour#else
7622a30866de6210d780995dfaaae39f1a73115aa0Tony Barbour#define U_ASSERT_ONLY
7722a30866de6210d780995dfaaae39f1a73115aa0Tony Barbour#endif
7822a30866de6210d780995dfaaae39f1a73115aa0Tony Barbour
7946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
8046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
8146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu#define MAX_GPUS 8
8246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
8346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu#define MAX_QUEUE_TYPES 5
844e19ed0ed322e45993bac7917a1a253dbaaf88f9Ian Elliott#define APP_SHORT_NAME "vulkaninfo"
8546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
8646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wustruct app_gpu;
8746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
8846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wustruct app_dev {
8946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    struct app_gpu *gpu; /* point back to the GPU */
9046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
91382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchter    VkDevice obj;
9246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
9346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
941f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu    VkFormatProperties format_props[VK_FORMAT_RANGE_SIZE];
9546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu};
9646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
9718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchterstruct layer_extension_list {
9818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    VkLayerProperties layer_properties;
9918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    uint32_t extension_count;
10018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    VkExtensionProperties *extension_properties;
10118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter};
10218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
1033c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchterstruct app_instance {
1043c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    VkInstance  instance;
10518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    uint32_t global_layer_count;
10618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    struct layer_extension_list *global_layers;
1073c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    uint32_t global_extension_count;
1083c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    VkExtensionProperties *global_extensions;
1093c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter};
1103c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter
11146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wustruct app_gpu {
112e2d07a5a3810d83d0ea7ecb396d61477893b74a4Mark Lobodzinski    uint32_t id;
1138205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    VkPhysicalDevice obj;
11446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
1158205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    VkPhysicalDeviceProperties props;
11646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
117e2d07a5a3810d83d0ea7ecb396d61477893b74a4Mark Lobodzinski    uint32_t queue_count;
118ef72e2a7cf4fa5708fdbfbc1c972a24ad0dbf809Cody Northrop    VkQueueFamilyProperties *queue_props;
119ddcb6192458d696a106f48eeb12fd0390a3ca63fCourtney Goeltzenleuchter    VkDeviceQueueCreateInfo *queue_reqs;
12046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
1218205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    VkPhysicalDeviceMemoryProperties memory_props;
122a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes    VkPhysicalDeviceFeatures features;
1237dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    VkPhysicalDevice limits;
12446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
12518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    uint32_t device_layer_count;
12618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    struct layer_extension_list *device_layers;
12718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
1283c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    uint32_t device_extension_count;
1293c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    VkExtensionProperties *device_extensions;
13046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
13146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    struct app_dev dev;
13246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu};
13346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
134382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchterstatic const char *vk_result_string(VkResult err)
13546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu{
13646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    switch (err) {
13746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu#define STR(r) case r: return #r
1389cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_SUCCESS);
1399cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_NOT_READY);
1409cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_TIMEOUT);
1419cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_EVENT_SET);
1429cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_EVENT_RESET);
1439cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_ERROR_INITIALIZATION_FAILED);
1448205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    STR(VK_ERROR_OUT_OF_HOST_MEMORY);
1458205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    STR(VK_ERROR_OUT_OF_DEVICE_MEMORY);
1469cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_ERROR_DEVICE_LOST);
147ac544f3737b45a5b35251100a3396aa8be397d8dCourtney Goeltzenleuchter    STR(VK_ERROR_LAYER_NOT_PRESENT);
148ac544f3737b45a5b35251100a3396aa8be397d8dCourtney Goeltzenleuchter    STR(VK_ERROR_EXTENSION_NOT_PRESENT);
1499cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_ERROR_MEMORY_MAP_FAILED);
1509cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter    STR(VK_ERROR_INCOMPATIBLE_DRIVER);
15146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu#undef STR
15246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    default: return "UNKNOWN_RESULT";
15346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    }
15446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu}
155d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
1568205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbourstatic const char *vk_physical_device_type_string(VkPhysicalDeviceType type)
157d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu{
158190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    switch (type) {
1598205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour#define STR(r) case VK_PHYSICAL_DEVICE_TYPE_ ##r: return #r
160190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    STR(OTHER);
1618205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    STR(INTEGRATED_GPU);
1628205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    STR(DISCRETE_GPU);
1638205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    STR(VIRTUAL_GPU);
164d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu#undef STR
1658205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    default: return "UNKNOWN_DEVICE";
166190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    }
167d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
168d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
169382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchterstatic const char *vk_format_string(VkFormat fmt)
170d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu{
1712b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    switch (fmt) {
1728205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour#define STR(r) case VK_FORMAT_ ##r: return #r
173190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    STR(UNDEFINED);
17469c479e1fcc4664a6ec1e704913cfbca77fc397cChia-I Wu    STR(R4G4_UNORM_PACK8);
17569c479e1fcc4664a6ec1e704913cfbca77fc397cChia-I Wu    STR(R4G4B4A4_UNORM_PACK16);
17683207a949a06fbf22ec0d8bdb3fc44b0d9e20573Chia-I Wu    STR(B4G4R4A4_UNORM_PACK16);
17769c479e1fcc4664a6ec1e704913cfbca77fc397cChia-I Wu    STR(R5G6B5_UNORM_PACK16);
1786880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B5G6R5_UNORM_PACK16);
17969c479e1fcc4664a6ec1e704913cfbca77fc397cChia-I Wu    STR(R5G5B5A1_UNORM_PACK16);
18083207a949a06fbf22ec0d8bdb3fc44b0d9e20573Chia-I Wu    STR(B5G5R5A1_UNORM_PACK16);
1818c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(A1R5G5B5_UNORM_PACK16);
1822b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8_UNORM);
1832b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8_SNORM);
1842b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8_USCALED);
1852b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8_SSCALED);
1862b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8_UINT);
1872b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8_SINT);
1882b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8_SRGB);
1892b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8_UNORM);
1902b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8_SNORM);
1912b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8_USCALED);
1922b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8_SSCALED);
1932b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8_UINT);
1942b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8_SINT);
1952b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8_SRGB);
1962b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8_UNORM);
1972b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8_SNORM);
1982b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8_USCALED);
1992b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8_SSCALED);
2002b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8_UINT);
2012b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8_SINT);
2022b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8_SRGB);
2036880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8_UNORM);
2046880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8_SNORM);
2056880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8_USCALED);
2066880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8_SSCALED);
2076880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8_UINT);
2086880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8_SINT);
2096880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8_SRGB);
2102b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8A8_UNORM);
2112b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8A8_SNORM);
2122b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8A8_USCALED);
2132b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8A8_SSCALED);
2142b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8A8_UINT);
2152b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8A8_SINT);
2162b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R8G8B8A8_SRGB);
2176880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8A8_UNORM);
2186880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8A8_SNORM);
2196880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8A8_USCALED);
2206880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8A8_SSCALED);
2216880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8A8_UINT);
2226880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8A8_SINT);
2236880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(B8G8R8A8_SRGB);
2248c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(A8B8G8R8_UNORM_PACK32);
2258c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(A8B8G8R8_SNORM_PACK32);
2268c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(A8B8G8R8_USCALED_PACK32);
2278c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(A8B8G8R8_SSCALED_PACK32);
2288c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(A8B8G8R8_UINT_PACK32);
2298c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(A8B8G8R8_SINT_PACK32);
2308c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(A8B8G8R8_SRGB_PACK32);
2316880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(A2R10G10B10_UNORM_PACK32);
2326880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(A2R10G10B10_SNORM_PACK32);
2336880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(A2R10G10B10_USCALED_PACK32);
2346880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(A2R10G10B10_SSCALED_PACK32);
2356880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(A2R10G10B10_UINT_PACK32);
2366880c8ef75c8a90d4cd5af18fddaa9c828da828bChia-I Wu    STR(A2R10G10B10_SINT_PACK32);
2379eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(A2B10G10R10_UNORM_PACK32);
2389eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(A2B10G10R10_SNORM_PACK32);
2399eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(A2B10G10R10_USCALED_PACK32);
2409eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(A2B10G10R10_SSCALED_PACK32);
2419eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(A2B10G10R10_UINT_PACK32);
2429eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(A2B10G10R10_SINT_PACK32);
2432b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16_UNORM);
2442b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16_SNORM);
2452b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16_USCALED);
2462b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16_SSCALED);
2472b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16_UINT);
2482b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16_SINT);
2492b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16_SFLOAT);
2502b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16_UNORM);
2512b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16_SNORM);
2522b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16_USCALED);
2532b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16_SSCALED);
2542b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16_UINT);
2552b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16_SINT);
2562b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16_SFLOAT);
2572b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16_UNORM);
2582b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16_SNORM);
2592b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16_USCALED);
2602b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16_SSCALED);
2612b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16_UINT);
2622b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16_SINT);
2632b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16_SFLOAT);
2642b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16A16_UNORM);
2652b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16A16_SNORM);
2662b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16A16_USCALED);
2672b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16A16_SSCALED);
2682b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16A16_UINT);
2692b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16A16_SINT);
2702b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R16G16B16A16_SFLOAT);
2712b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32_UINT);
2722b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32_SINT);
2732b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32_SFLOAT);
2742b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32_UINT);
2752b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32_SINT);
2762b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32_SFLOAT);
2772b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32B32_UINT);
2782b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32B32_SINT);
2792b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32B32_SFLOAT);
2802b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32B32A32_UINT);
2812b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32B32A32_SINT);
2822b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R32G32B32A32_SFLOAT);
2838c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(R64_UINT);
2848c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(R64_SINT);
2852b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R64_SFLOAT);
2868c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(R64G64_UINT);
2878c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(R64G64_SINT);
2882b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R64G64_SFLOAT);
2898c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(R64G64B64_UINT);
2908c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(R64G64B64_SINT);
2912b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R64G64B64_SFLOAT);
2928c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(R64G64B64A64_UINT);
2938c85974bfa2cf3c4f90227370fc56eaaa867a18eChia-I Wu    STR(R64G64B64A64_SINT);
2942b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(R64G64B64A64_SFLOAT);
2959eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(B10G11R11_UFLOAT_PACK32);
2969eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(E5B9G9R9_UFLOAT_PACK32);
2972b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(D16_UNORM);
2989eabb8f3c350ba8f8f5bb4a71dd65d081bd4dc5dChia-I Wu    STR(X8_D24_UNORM_PACK32);
2992b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(D32_SFLOAT);
3002b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(S8_UINT);
3012b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(D16_UNORM_S8_UINT);
3022b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(D24_UNORM_S8_UINT);
3032b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    STR(D32_SFLOAT_S8_UINT);
3041fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC1_RGB_UNORM_BLOCK);
3051fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC1_RGB_SRGB_BLOCK);
3061fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC2_UNORM_BLOCK);
3071fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC2_SRGB_BLOCK);
3081fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC3_UNORM_BLOCK);
3091fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC3_SRGB_BLOCK);
3101fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC4_UNORM_BLOCK);
3111fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC4_SNORM_BLOCK);
3121fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC5_UNORM_BLOCK);
3131fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC5_SNORM_BLOCK);
3141fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC6H_UFLOAT_BLOCK);
3151fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC6H_SFLOAT_BLOCK);
3161fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC7_UNORM_BLOCK);
3171fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(BC7_SRGB_BLOCK);
3181fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ETC2_R8G8B8_UNORM_BLOCK);
3191fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ETC2_R8G8B8A1_UNORM_BLOCK);
3201fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ETC2_R8G8B8A8_UNORM_BLOCK);
3211fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(EAC_R11_UNORM_BLOCK);
3221fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(EAC_R11_SNORM_BLOCK);
3231fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(EAC_R11G11_UNORM_BLOCK);
3241fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(EAC_R11G11_SNORM_BLOCK);
3251fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_4x4_UNORM_BLOCK);
3261fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_4x4_SRGB_BLOCK);
3271fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_5x4_UNORM_BLOCK);
3281fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_5x4_SRGB_BLOCK);
3291fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_5x5_UNORM_BLOCK);
3301fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_5x5_SRGB_BLOCK);
3311fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_6x5_UNORM_BLOCK);
3321fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_6x5_SRGB_BLOCK);
3331fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_6x6_UNORM_BLOCK);
3341fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_6x6_SRGB_BLOCK);
3351fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_8x5_UNORM_BLOCK);
3361fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_8x5_SRGB_BLOCK);
3371fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_8x6_UNORM_BLOCK);
3381fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_8x6_SRGB_BLOCK);
3391fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_8x8_UNORM_BLOCK);
3401fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_8x8_SRGB_BLOCK);
3411fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_10x5_UNORM_BLOCK);
3421fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_10x5_SRGB_BLOCK);
3431fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_10x6_UNORM_BLOCK);
3441fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_10x6_SRGB_BLOCK);
3451fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_10x8_UNORM_BLOCK);
3461fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_10x8_SRGB_BLOCK);
3471fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_10x10_UNORM_BLOCK);
3481fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_10x10_SRGB_BLOCK);
3491fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_12x10_UNORM_BLOCK);
3501fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_12x10_SRGB_BLOCK);
3511fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_12x12_UNORM_BLOCK);
3521fb4618a2c5bf3ad852c6f0ebba6bc47810334caChia-I Wu    STR(ASTC_12x12_SRGB_BLOCK);
353d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu#undef STR
3542b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes    default: return "UNKNOWN_FORMAT";
355190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    }
356d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
357d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
35846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wustatic void app_dev_init_formats(struct app_dev *dev)
35946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu{
360382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchter    VkFormat f;
3612b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes
3621f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu    for (f = 0; f < VK_FORMAT_RANGE_SIZE; f++) {
363382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchter        const VkFormat fmt = f;
3642b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes
36501d2ae18f05184e04eb29a2ab30480f8d4660d25Courtney Goeltzenleuchter        vkGetPhysicalDeviceFormatProperties(dev->gpu->obj, fmt, &dev->format_props[f]);
36646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    }
36746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu}
36846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
36918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchterstatic void extract_version(uint32_t version, uint32_t *major, uint32_t *minor, uint32_t *patch)
37018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter{
37118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    *major = version >> 22;
37218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    *minor = (version >> 12) & 0x3ff;
37318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    *patch = version & 0xfff;
37418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter}
37518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
37618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchterstatic void app_get_physical_device_layer_extensions(
37718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        struct app_gpu *gpu,
37818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        char *layer_name,
37918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        uint32_t *extension_count,
38018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        VkExtensionProperties **extension_properties)
38118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter{
38218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    VkResult err;
38318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    uint32_t ext_count = 0;
38418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    VkExtensionProperties *ext_ptr = NULL;
38518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
38618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    /* repeat get until VK_INCOMPLETE goes away */
38718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    do {
38874c4ce9c4fa101c0989a29cf918e799fa67adcecCourtney Goeltzenleuchter        err = vkEnumerateDeviceExtensionProperties(gpu->obj, layer_name, &ext_count, NULL);
38918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        assert(!err);
39018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
39118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        if (ext_ptr) {
39218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            free(ext_ptr);
39318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        }
39418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        ext_ptr = malloc(ext_count * sizeof(VkExtensionProperties));
39574c4ce9c4fa101c0989a29cf918e799fa67adcecCourtney Goeltzenleuchter        err = vkEnumerateDeviceExtensionProperties(gpu->obj, layer_name, &ext_count, ext_ptr);
39618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    } while (err == VK_INCOMPLETE);
39718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    assert(!err);
39818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
39918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    *extension_count = ext_count;
40018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    *extension_properties = ext_ptr;
40118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter}
40218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
40346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wustatic void app_dev_init(struct app_dev *dev, struct app_gpu *gpu)
40446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu{
405ddcb6192458d696a106f48eeb12fd0390a3ca63fCourtney Goeltzenleuchter    VkDeviceCreateInfo info = {
4069cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter        .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
40746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu        .pNext = NULL,
408045654f003fa47a4a15cba6709222c75b5e72e41Chia-I Wu        .queueCreateInfoCount = 0,
409045654f003fa47a4a15cba6709222c75b5e72e41Chia-I Wu        .pQueueCreateInfos = NULL,
410763a749795bb4827efbbf19cbc87b959511496ddChia-I Wu        .enabledLayerNameCount = 0,
41118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        .ppEnabledLayerNames = NULL,
412763a749795bb4827efbbf19cbc87b959511496ddChia-I Wu        .enabledExtensionNameCount = 0,
41318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        .ppEnabledExtensionNames = NULL,
41446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    };
4153c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    VkResult U_ASSERT_ONLY err;
4163c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    // Extensions to enable
41718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    static const char *known_extensions[] = {
41864070a88a7a4411e0eb0d7148bd1a1598e74a88cIan Elliott        VK_KHR_SWAPCHAIN_EXTENSION_NAME,
4193c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    };
420426b90566abae5716741aade41184dc4dafe4aa4Tony Barbour
42118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    uint32_t count = 0;
42218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
42318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    /* Scan layers */
42418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    VkLayerProperties *device_layer_properties = NULL;
42518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    struct layer_extension_list *device_layers = NULL;
42618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
42718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    do {
42874c4ce9c4fa101c0989a29cf918e799fa67adcecCourtney Goeltzenleuchter        err = vkEnumerateDeviceLayerProperties(gpu->obj, &count, NULL);
42918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        assert(!err);
43018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
43118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        if (device_layer_properties) {
43218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            free(device_layer_properties);
43318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        }
43418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        device_layer_properties = malloc(sizeof(VkLayerProperties) * count);
43518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        assert(device_layer_properties);
43618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
43718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        if (device_layers) {
43818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            free(device_layers);
43918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        }
44018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        device_layers = malloc(sizeof(struct layer_extension_list) * count);
44118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        assert(device_layers);
44218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
44374c4ce9c4fa101c0989a29cf918e799fa67adcecCourtney Goeltzenleuchter        err = vkEnumerateDeviceLayerProperties(gpu->obj, &count, device_layer_properties);
44418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    } while (err == VK_INCOMPLETE);
4453c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    assert(!err);
4463c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter
44718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    gpu->device_layer_count = count;
44818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    gpu->device_layers = device_layers;
44918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
45018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    for (uint32_t i = 0; i < gpu->device_layer_count; i++) {
45118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        VkLayerProperties *src_info = &device_layer_properties[i];
45218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        struct layer_extension_list *dst_info = &gpu->device_layers[i];
45318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        memcpy(&dst_info->layer_properties, src_info, sizeof(VkLayerProperties));
45418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
45518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        /* Save away layer extension info for report */
45618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        app_get_physical_device_layer_extensions(
45718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                    gpu,
45818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                    src_info->layerName,
45918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                    &dst_info->extension_count,
46018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                    &dst_info->extension_properties);
4613c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    }
46218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    free(device_layer_properties);
46318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
46418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    app_get_physical_device_layer_extensions(
46518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                gpu,
46618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                NULL,
46718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                &gpu->device_extension_count,
46818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                &gpu->device_extensions);
4693c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter
4709e42b8882f26e897f0022f5ce800a04f4d2ad1cfCourtney Goeltzenleuchter    fflush(stdout);
4719e42b8882f26e897f0022f5ce800a04f4d2ad1cfCourtney Goeltzenleuchter
47218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    uint32_t enabled_extension_count = 0;
47367a07414039ea03404711b0d9204ba35930d1d21Courtney Goeltzenleuchter    uint32_t known_extension_count = ARRAY_SIZE(known_extensions);
47418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
47567a07414039ea03404711b0d9204ba35930d1d21Courtney Goeltzenleuchter    for (uint32_t i = 0; i < known_extension_count; i++) {
4761f41f54bc20d57faed702aec3074eacdfc34680dCourtney Goeltzenleuchter        VkBool32 extension_found = 0;
47718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        for (uint32_t j = 0; j < gpu->device_extension_count; j++) {
47818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            VkExtensionProperties *ext_prop = &gpu->device_extensions[j];
4791f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu            if (!strcmp(known_extensions[i], ext_prop->extensionName)) {
48018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
48118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                extension_found = 1;
48218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                enabled_extension_count++;
4833c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter            }
4843c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        }
48518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        if (!extension_found) {
48618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            printf("Cannot find extension: %s\n", known_extensions[i]);
487ac544f3737b45a5b35251100a3396aa8be397d8dCourtney Goeltzenleuchter            ERR_EXIT(VK_ERROR_EXTENSION_NOT_PRESENT);
48818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        }
4893c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    }
49046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
49146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    /* request all queues */
492045654f003fa47a4a15cba6709222c75b5e72e41Chia-I Wu    info.queueCreateInfoCount = gpu->queue_count;
493045654f003fa47a4a15cba6709222c75b5e72e41Chia-I Wu    info.pQueueCreateInfos = gpu->queue_reqs;
49446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
495763a749795bb4827efbbf19cbc87b959511496ddChia-I Wu    info.enabledLayerNameCount = 0;
49618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    info.ppEnabledLayerNames = NULL;
497763a749795bb4827efbbf19cbc87b959511496ddChia-I Wu    info.enabledExtensionNameCount = enabled_extension_count;
49818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    info.ppEnabledExtensionNames = (const char*const*) known_extensions;
4993c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    dev->gpu = gpu;
50069f40128cce0970d10aaa30ea8c6b56a7dda3f36Chia-I Wu    err = vkCreateDevice(gpu->obj, &info, NULL, &dev->obj);
5013c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    if (err)
5023c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        ERR_EXIT(err);
50346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
50446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu}
50546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
50646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wustatic void app_dev_destroy(struct app_dev *dev)
50746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu{
50869f40128cce0970d10aaa30ea8c6b56a7dda3f36Chia-I Wu    vkDestroyDevice(dev->obj, NULL);
50946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu}
51046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
51118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchterstatic void app_get_global_layer_extensions(
51218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        char *layer_name,
51318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        uint32_t *extension_count,
51418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        VkExtensionProperties **extension_properties)
51518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter{
51618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    VkResult err;
51718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    uint32_t ext_count = 0;
51818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    VkExtensionProperties *ext_ptr = NULL;
51918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
52018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    /* repeat get until VK_INCOMPLETE goes away */
52118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    do {
52274c4ce9c4fa101c0989a29cf918e799fa67adcecCourtney Goeltzenleuchter        err = vkEnumerateInstanceExtensionProperties(layer_name, &ext_count, NULL);
52318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        assert(!err);
52418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
52518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        if (ext_ptr) {
52618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            free(ext_ptr);
52718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        }
52818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        ext_ptr = malloc(ext_count * sizeof(VkExtensionProperties));
52974c4ce9c4fa101c0989a29cf918e799fa67adcecCourtney Goeltzenleuchter        err = vkEnumerateInstanceExtensionProperties(layer_name, &ext_count, ext_ptr);
53018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    } while (err == VK_INCOMPLETE);
53118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    assert(!err);
53218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
53318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    *extension_count = ext_count;
53418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    *extension_properties = ext_ptr;
53518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter}
53618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
5373c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchterstatic void app_create_instance(struct app_instance *inst)
53846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu{
5393c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    const VkApplicationInfo app_info = {
5403c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
5413c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        .pNext = NULL,
5421f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu        .pApplicationName = APP_SHORT_NAME,
5431f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu        .applicationVersion = 1,
5443c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        .pEngineName = APP_SHORT_NAME,
5453c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        .engineVersion = 1,
5463c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        .apiVersion = VK_API_VERSION,
5473c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    };
5483c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    VkInstanceCreateInfo inst_info = {
5493c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
5503c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        .pNext = NULL,
5511f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu        .pApplicationInfo = &app_info,
552763a749795bb4827efbbf19cbc87b959511496ddChia-I Wu        .enabledLayerNameCount = 0,
55318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        .ppEnabledLayerNames = NULL,
554763a749795bb4827efbbf19cbc87b959511496ddChia-I Wu        .enabledExtensionNameCount = 0,
55518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        .ppEnabledExtensionNames = NULL,
5563c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    };
55722a30866de6210d780995dfaaae39f1a73115aa0Tony Barbour    VkResult U_ASSERT_ONLY err;
5583c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    // Global Extensions to enable
559aae1a570a95ca8074d48698372694bb1ef2b5530Ian Elliott    static char *known_extensions[] = {
56064070a88a7a4411e0eb0d7148bd1a1598e74a88cIan Elliott        VK_KHR_SURFACE_EXTENSION_NAME,
561b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#ifdef VK_USE_PLATFORM_ANDROID_KHR
562b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott        VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
563b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#endif
564b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#ifdef VK_USE_PLATFORM_MIR_KHR
565b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott        VK_KHR_MIR_SURFACE_EXTENSION_NAME,
566b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#endif
567b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#ifdef VK_USE_PLATFORM_WAYLAND_KHR
568b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott        VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
569b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#endif
570b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#ifdef VK_USE_PLATFORM_WIN32_KHR
571b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott        VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
572b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#endif
573b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#ifdef VK_USE_PLATFORM_XCB_KHR
574b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott        VK_KHR_XCB_SURFACE_EXTENSION_NAME,
575b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#endif
576b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#ifdef VK_USE_PLATFORM_XLIB_KHR
577b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott        VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
578b5fad79e4bb8089a6a9519d248c378079822d2c6Ian Elliott#endif
57946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    };
580426b90566abae5716741aade41184dc4dafe4aa4Tony Barbour
5813c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    uint32_t global_extension_count = 0;
58218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    uint32_t count = 0;
58318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
58418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    /* Scan layers */
58518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    VkLayerProperties *global_layer_properties = NULL;
58618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    struct layer_extension_list *global_layers = NULL;
58718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
58818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    do {
58974c4ce9c4fa101c0989a29cf918e799fa67adcecCourtney Goeltzenleuchter        err = vkEnumerateInstanceLayerProperties(&count, NULL);
59018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        assert(!err);
59118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
59218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        if (global_layer_properties) {
59318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            free(global_layer_properties);
59418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        }
59518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        global_layer_properties = malloc(sizeof(VkLayerProperties) * count);
59618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        assert(global_layer_properties);
59718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
59818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        if (global_layers) {
59918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            free(global_layers);
60018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        }
60118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        global_layers = malloc(sizeof(struct layer_extension_list) * count);
60218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        assert(global_layers);
6033c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter
60474c4ce9c4fa101c0989a29cf918e799fa67adcecCourtney Goeltzenleuchter        err = vkEnumerateInstanceLayerProperties(&count, global_layer_properties);
60518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    } while (err == VK_INCOMPLETE);
6063536b44d5d907e6ce3d97c40366f12a988c8036dTobin Ehlis    assert(!err);
6073536b44d5d907e6ce3d97c40366f12a988c8036dTobin Ehlis
60818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    inst->global_layer_count = count;
60918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    inst->global_layers = global_layers;
61018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
61118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    for (uint32_t i = 0; i < inst->global_layer_count; i++) {
61218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        VkLayerProperties *src_info = &global_layer_properties[i];
61318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        struct layer_extension_list *dst_info = &inst->global_layers[i];
61418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        memcpy(&dst_info->layer_properties, src_info, sizeof(VkLayerProperties));
61518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
61618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        /* Save away layer extension info for report */
61718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        app_get_global_layer_extensions(
61818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                    src_info->layerName,
61918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                    &dst_info->extension_count,
62018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                    &dst_info->extension_properties);
6213c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    }
62218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    free(global_layer_properties);
62318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
62418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    /* Collect global extensions */
62518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    inst->global_extension_count = 0;
62618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    app_get_global_layer_extensions(
62718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                NULL,
62818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                &inst->global_extension_count,
62918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                &inst->global_extensions);
6303c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter
6313c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    for (uint32_t i = 0; i < ARRAY_SIZE(known_extensions); i++) {
6321f41f54bc20d57faed702aec3074eacdfc34680dCourtney Goeltzenleuchter        VkBool32 extension_found = 0;
63318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        for (uint32_t j = 0; j < inst->global_extension_count; j++) {
63418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            VkExtensionProperties *extension_prop = &inst->global_extensions[j];
6351f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu            if (!strcmp(known_extensions[i], extension_prop->extensionName)) {
63618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
63718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                extension_found = 1;
6383c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter                global_extension_count++;
6393c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter            }
6403536b44d5d907e6ce3d97c40366f12a988c8036dTobin Ehlis        }
64118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        if (!extension_found) {
64218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            printf("Cannot find extension: %s\n", known_extensions[i]);
643ac544f3737b45a5b35251100a3396aa8be397d8dCourtney Goeltzenleuchter            ERR_EXIT(VK_ERROR_EXTENSION_NOT_PRESENT);
64418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        }
64546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    }
64646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
647763a749795bb4827efbbf19cbc87b959511496ddChia-I Wu    inst_info.enabledExtensionNameCount = global_extension_count;
64818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    inst_info.ppEnabledExtensionNames = (const char * const *) known_extensions;
64946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
65069f40128cce0970d10aaa30ea8c6b56a7dda3f36Chia-I Wu    err = vkCreateInstance(&inst_info, NULL, &inst->instance);
6513c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    if (err == VK_ERROR_INCOMPATIBLE_DRIVER) {
6523c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        printf("Cannot create Vulkan instance.\n");
6533c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        ERR_EXIT(err);
6543c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    } else if (err) {
6553c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter        ERR_EXIT(err);
65646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    }
6573c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter}
6583c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter
6593c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchterstatic void app_destroy_instance(struct app_instance *inst)
6603c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter{
6613c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    free(inst->global_extensions);
66269f40128cce0970d10aaa30ea8c6b56a7dda3f36Chia-I Wu    vkDestroyInstance(inst->instance, NULL);
66346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu}
66446c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
6653c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter
6668205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbourstatic void app_gpu_init(struct app_gpu *gpu, uint32_t id, VkPhysicalDevice obj)
66746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu{
668aae1a570a95ca8074d48698372694bb1ef2b5530Ian Elliott    uint32_t i;
66946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
67046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    memset(gpu, 0, sizeof(*gpu));
67146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
67246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    gpu->id = id;
67346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    gpu->obj = obj;
674426b90566abae5716741aade41184dc4dafe4aa4Tony Barbour
67501d2ae18f05184e04eb29a2ab30480f8d4660d25Courtney Goeltzenleuchter    vkGetPhysicalDeviceProperties(gpu->obj, &gpu->props);
67646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
67746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    /* get queue count */
67801d2ae18f05184e04eb29a2ab30480f8d4660d25Courtney Goeltzenleuchter    vkGetPhysicalDeviceQueueFamilyProperties(gpu->obj, &gpu->queue_count, NULL);
67946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
68046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    gpu->queue_props =
68146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu            malloc(sizeof(gpu->queue_props[0]) * gpu->queue_count);
682426b90566abae5716741aade41184dc4dafe4aa4Tony Barbour
68346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    if (!gpu->queue_props)
6848205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour        ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY);
68501d2ae18f05184e04eb29a2ab30480f8d4660d25Courtney Goeltzenleuchter    vkGetPhysicalDeviceQueueFamilyProperties(gpu->obj, &gpu->queue_count, gpu->queue_props);
68646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
68746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    /* set up queue requests */
68846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    gpu->queue_reqs = malloc(sizeof(*gpu->queue_reqs) * gpu->queue_count);
68946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    if (!gpu->queue_reqs)
6908205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour        ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY);
69146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    for (i = 0; i < gpu->queue_count; i++) {
692d3a8d3699ceffb62da8d95d1fb49242fb25b43bfCourtney Goeltzenleuchter        float *queue_priorities = malloc(gpu->queue_props[i].queueCount * sizeof(float));
693d3a8d3699ceffb62da8d95d1fb49242fb25b43bfCourtney Goeltzenleuchter        memset(queue_priorities, 0, gpu->queue_props[i].queueCount * sizeof(float));
694ea97564708cfcbebb42a842edac456e79643e716Courtney Goeltzenleuchter        gpu->queue_reqs[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
695ea97564708cfcbebb42a842edac456e79643e716Courtney Goeltzenleuchter        gpu->queue_reqs[i].pNext = NULL;
696fa6d36ea26354e4d68e81b05d1199a83c9fa3d6aChris Forbes        gpu->queue_reqs[i].queueFamilyIndex = i;
697045654f003fa47a4a15cba6709222c75b5e72e41Chia-I Wu        gpu->queue_reqs[i].queueCount = gpu->queue_props[i].queueCount;
698d3a8d3699ceffb62da8d95d1fb49242fb25b43bfCourtney Goeltzenleuchter        gpu->queue_reqs[i].pQueuePriorities = queue_priorities;
69946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    }
70046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
70101d2ae18f05184e04eb29a2ab30480f8d4660d25Courtney Goeltzenleuchter    vkGetPhysicalDeviceMemoryProperties(gpu->obj, &gpu->memory_props);
70246c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
70301d2ae18f05184e04eb29a2ab30480f8d4660d25Courtney Goeltzenleuchter    vkGetPhysicalDeviceFeatures(gpu->obj, &gpu->features);
704a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes
70546c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    app_dev_init(&gpu->dev, gpu);
70646c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    app_dev_init_formats(&gpu->dev);
70746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu}
70846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
70946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wustatic void app_gpu_destroy(struct app_gpu *gpu)
71046c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu{
71146c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    app_dev_destroy(&gpu->dev);
7123c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    free(gpu->device_extensions);
71346c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    free(gpu->queue_reqs);
714d3a8d3699ceffb62da8d95d1fb49242fb25b43bfCourtney Goeltzenleuchter    for (uint32_t i = 0; i < gpu->queue_count; i++) {
715d3a8d3699ceffb62da8d95d1fb49242fb25b43bfCourtney Goeltzenleuchter        free((void *) gpu->queue_reqs[i].pQueuePriorities);
716d3a8d3699ceffb62da8d95d1fb49242fb25b43bfCourtney Goeltzenleuchter    }
71746c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu    free(gpu->queue_props);
71846c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu}
71946c29ddef4360cac80d9dd533486aa1ab34776e1Chia-I Wu
720382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchterstatic void app_dev_dump_format_props(const struct app_dev *dev, VkFormat fmt)
721d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu{
722382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchter    const VkFormatProperties *props = &dev->format_props[fmt];
723190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    struct {
724190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu        const char *name;
725382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchter        VkFlags flags;
7264b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    } features[3];
727e2d07a5a3810d83d0ea7ecb396d61477893b74a4Mark Lobodzinski    uint32_t i;
728190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu
7294b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    features[0].name  = "linearTiling   FormatFeatureFlags";
7304b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    features[0].flags = props->linearTilingFeatures;
7314b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    features[1].name  = "optimalTiling  FormatFeatureFlags";
7324b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    features[1].flags = props->optimalTilingFeatures;
7334b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    features[2].name  = "bufferFeatures FormatFeatureFlags";
7344b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    features[2].flags = props->bufferFeatures;
7354b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski
7364b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    printf("\nFORMAT_%s:", vk_format_string(fmt));
7374b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    for (i = 0; i < ARRAY_SIZE(features); i++) {
7384b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski        printf("\n\t%s:", features[i].name);
7394b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski        if (features[i].flags == 0) {
7404b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski            printf("\n\t\tNone");
7414b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski        } else {
742752957901902cd3de9b99ef272d7b7fbaeef2705Courtney Goeltzenleuchter            printf("%s%s%s%s%s%s%s%s%s%s%s%s",
7434b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)               ? "\n\t\tVK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT"               : ""),
7444b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)               ? "\n\t\tVK_FORMAT_FEATURE_STORAGE_IMAGE_BIT"               : ""),
7454b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT)        ? "\n\t\tVK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT"        : ""),
7464b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)            ? "\n\t\tVK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT"            : ""),
7474b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT)      ? "\n\t\tVK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT"      : ""),
7484b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)    ? "\n\t\tVK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT"    : ""),
7491f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu               ((features[i].flags & VK_FORMAT_FEATURE_BLIT_SRC_BIT)                 ? "\n\t\tVK_FORMAT_FEATURE_BLIT_SRC_BIT"                 : ""),
7501f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu               ((features[i].flags & VK_FORMAT_FEATURE_BLIT_DST_BIT)            ? "\n\t\tVK_FORMAT_FEATURE_BLIT_DST_BIT"            : ""),
7514b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT)        ? "\n\t\tVK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT"        : ""),
7524b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT)        ? "\n\t\tVK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT"        : ""),
7534b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT) ? "\n\t\tVK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT" : ""),
7544b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski               ((features[i].flags & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT)               ? "\n\t\tVK_FORMAT_FEATURE_VERTEX_BUFFER_BIT"               : ""));
7554b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski        }
756190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    }
7574b36dd453ecb809731dbc68ccdb50e83f5417dd6Mark Lobodzinski    printf("\n");
758d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
759d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
760d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
761d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wustatic void
762d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wuapp_dev_dump(const struct app_dev *dev)
763d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu{
764382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchter    VkFormat fmt;
765190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu
7661f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu    for (fmt = 0; fmt < VK_FORMAT_RANGE_SIZE; fmt++) {
7672b7e88a1fdefc49d78e80765745e87e00034c2a0Jeremy Hayes        app_dev_dump_format_props(dev, fmt);
768190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    }
769d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
770d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
771009d8ca0c07c81adff475c48273207e170b4b5fbMike Stroyan#ifdef _WIN32
772009d8ca0c07c81adff475c48273207e170b4b5fbMike Stroyan#define PRINTF_SIZE_T_SPECIFIER    "%Iu"
773009d8ca0c07c81adff475c48273207e170b4b5fbMike Stroyan#else
774009d8ca0c07c81adff475c48273207e170b4b5fbMike Stroyan#define PRINTF_SIZE_T_SPECIFIER    "%zu"
775009d8ca0c07c81adff475c48273207e170b4b5fbMike Stroyan#endif
776009d8ca0c07c81adff475c48273207e170b4b5fbMike Stroyan
777a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbesstatic void app_gpu_dump_features(const struct app_gpu *gpu)
778a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes{
779a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes    const VkPhysicalDeviceFeatures *features = &gpu->features;
780a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes
781825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("VkPhysicalDeviceFeatures:\n");
782825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("=========================\n");
783825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski
784825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\trobustBufferAccess                      = %u\n", features->robustBufferAccess                     );
785825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tfullDrawIndexUint32                     = %u\n", features->fullDrawIndexUint32                    );
786825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\timageCubeArray                          = %u\n", features->imageCubeArray                         );
787825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tindependentBlend                        = %u\n", features->independentBlend                       );
788825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tgeometryShader                          = %u\n", features->geometryShader                         );
789825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\ttessellationShader                      = %u\n", features->tessellationShader                     );
790825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsampleRateShading                       = %u\n", features->sampleRateShading                      );
791c04519cd6e39256351df868dc721259d904f4542Chia-I Wu    printf("\tdualSrcBlend                            = %u\n", features->dualSrcBlend                           );
792825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tlogicOp                                 = %u\n", features->logicOp                                );
793825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tmultiDrawIndirect                       = %u\n", features->multiDrawIndirect                      );
794c04519cd6e39256351df868dc721259d904f4542Chia-I Wu    printf("\tdepthClamp                              = %u\n", features->depthClamp                             );
795825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tdepthBiasClamp                          = %u\n", features->depthBiasClamp                         );
7964291d8822ec2a685ef89ec2b210ff16857e25310Chia-I Wu    printf("\tfillModeNonSolid                        = %u\n", features->fillModeNonSolid                       );
797825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tdepthBounds                             = %u\n", features->depthBounds                            );
798825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\twideLines                               = %u\n", features->wideLines                              );
799825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tlargePoints                             = %u\n", features->largePoints                            );
800825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\ttextureCompressionETC2                  = %u\n", features->textureCompressionETC2                 );
801825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\ttextureCompressionASTC_LDR              = %u\n", features->textureCompressionASTC_LDR             );
802825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\ttextureCompressionBC                    = %u\n", features->textureCompressionBC                   );
803c51b121913d6f21ccefb3f7595178d3c87e11de4Chia-I Wu    printf("\tocclusionQueryPrecise           = %u\n", features->occlusionQueryPrecise          );
804825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tpipelineStatisticsQuery                 = %u\n", features->pipelineStatisticsQuery                );
805fd4bfc47a43f0f85b30f61d2f128a714c4bae326Chia-I Wu    printf("\tvertexSideEffects                       = %u\n", features->vertexPipelineStoresAndAtomics         );
806fd4bfc47a43f0f85b30f61d2f128a714c4bae326Chia-I Wu    printf("\ttessellationSideEffects                 = %u\n", features->fragmentStoresAndAtomics               );
807fd4bfc47a43f0f85b30f61d2f128a714c4bae326Chia-I Wu    printf("\tgeometrySideEffects                     = %u\n", features->shaderTessellationAndGeometryPointSize );
808825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderImageGatherExtended               = %u\n", features->shaderImageGatherExtended              );
809825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderStorageImageExtendedFormats       = %u\n", features->shaderStorageImageExtendedFormats      );
810825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderStorageImageMultisample           = %u\n", features->shaderStorageImageMultisample          );
811221f2f20a860bb8dd33533aacf4c795501a04e43Chia-I Wu    printf("\tshaderStorageImageReadWithoutFormat     = %u\n", features->shaderStorageImageReadWithoutFormat    );
812221f2f20a860bb8dd33533aacf4c795501a04e43Chia-I Wu    printf("\tshaderStorageImageWriteWithoutFormat    = %u\n", features->shaderStorageImageWriteWithoutFormat   );
813825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderUniformBufferArrayDynamicIndexing = %u\n", features->shaderUniformBufferArrayDynamicIndexing);
814825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderSampledImageArrayDynamicIndexing  = %u\n", features->shaderSampledImageArrayDynamicIndexing );
815825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderStorageBufferArrayDynamicIndexing = %u\n", features->shaderStorageBufferArrayDynamicIndexing);
816825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderStorageImageArrayDynamicIndexing  = %u\n", features->shaderStorageImageArrayDynamicIndexing );
817825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderClipDistance                      = %u\n", features->shaderClipDistance                     );
818825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderCullDistance                      = %u\n", features->shaderCullDistance                     );
819825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderFloat64                           = %u\n", features->shaderFloat64                          );
820825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderInt64                             = %u\n", features->shaderInt64                            );
821825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderInt16                             = %u\n", features->shaderInt16                            );
822825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tshaderResourceResidency                 = %u\n", features->shaderResourceResidency                );
823d3f9934956da83277b3ea10cb98954427384cb93Chia-I Wu    printf("\tshaderResourceMinLod                    = %u\n", features->shaderResourceMinLod                   );
824825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\talphaToOne                              = %u\n", features->alphaToOne                             );
8257dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\tsparseBinding                           = %u\n", features->sparseBinding                          );
826825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsparseResidencyBuffer                   = %u\n", features->sparseResidencyBuffer                  );
827825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsparseResidencyImage2D                  = %u\n", features->sparseResidencyImage2D                 );
828825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsparseResidencyImage3D                  = %u\n", features->sparseResidencyImage3D                 );
829825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsparseResidency2Samples                 = %u\n", features->sparseResidency2Samples                );
830825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsparseResidency4Samples                 = %u\n", features->sparseResidency4Samples                );
831825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsparseResidency8Samples                 = %u\n", features->sparseResidency8Samples                );
832825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsparseResidency16Samples                = %u\n", features->sparseResidency16Samples               );
833825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tsparseResidencyAliased                  = %u\n", features->sparseResidencyAliased                 );
834d507261fef1c6877aeaa636d0b684ecee0854e74Chia-I Wu    printf("\tvariableMultisampleRate                 = %u\n", features->variableMultisampleRate                );
835a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes}
836a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes
8377dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinskistatic void app_dump_sparse_props(const VkPhysicalDeviceSparseProperties *sparseProps)
838a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes{
8397dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski
8407dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\tVkPhysicalDeviceSparseProperties:\n");
8417dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t---------------------------------\n");
8427dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski
84300c8c98bc320535aebf61ad3fe255ebbd234549bCourtney Goeltzenleuchter    printf("\t\tresidencyStandard2DBlockShape     = %u\n", sparseProps->residencyStandard2DBlockShape    );
8447e470703805a7c93655ea18f553e225e84356429Chia-I Wu    printf("\t\tresidencyStandard2DMultisampleBlockShape = %u\n", sparseProps->residencyStandard2DMultisampleBlockShape);
84500c8c98bc320535aebf61ad3fe255ebbd234549bCourtney Goeltzenleuchter    printf("\t\tresidencyStandard3DBlockShape     = %u\n", sparseProps->residencyStandard3DBlockShape    );
84600c8c98bc320535aebf61ad3fe255ebbd234549bCourtney Goeltzenleuchter    printf("\t\tresidencyAlignedMipSize           = %u\n", sparseProps->residencyAlignedMipSize          );
84700c8c98bc320535aebf61ad3fe255ebbd234549bCourtney Goeltzenleuchter    printf("\t\tresidencyNonResidentStrict        = %u\n", sparseProps->residencyNonResidentStrict       );
8487dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski}
8497dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski
8507dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinskistatic void app_dump_limits(const VkPhysicalDeviceLimits *limits)
8517dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski{
8527dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\tVkPhysicalDeviceLimits:\n");
8537dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t-----------------------\n");
8547dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski
8557dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxImageDimension1D                     = 0x%" PRIxLEAST32 "\n", limits->maxImageDimension1D                    );
8567dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxImageDimension2D                     = 0x%" PRIxLEAST32 "\n", limits->maxImageDimension2D                    );
8577dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxImageDimension3D                     = 0x%" PRIxLEAST32 "\n", limits->maxImageDimension3D                    );
8587dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxImageDimensionCube                   = 0x%" PRIxLEAST32 "\n", limits->maxImageDimensionCube                  );
8597dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxImageArrayLayers                     = 0x%" PRIxLEAST32 "\n", limits->maxImageArrayLayers                    );
8607e470703805a7c93655ea18f553e225e84356429Chia-I Wu    printf("\t\tmaxTexelBufferElements                  = 0x%" PRIxLEAST32 "\n", limits->maxTexelBufferElements                 );
861d6633e2e0499acf899d8d5c1c8844089e0df5acbCourtney Goeltzenleuchter    printf("\t\tmaxUniformBufferRange                    = 0x%" PRIxLEAST32 "\n", limits->maxUniformBufferRange                 );
862d6633e2e0499acf899d8d5c1c8844089e0df5acbCourtney Goeltzenleuchter    printf("\t\tmaxStorageBufferRange                    = 0x%" PRIxLEAST32 "\n", limits->maxStorageBufferRange                 );
8637dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxPushConstantsSize                    = 0x%" PRIxLEAST32 "\n", limits->maxPushConstantsSize                   );
8647dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxMemoryAllocationCount                = 0x%" PRIxLEAST32 "\n", limits->maxMemoryAllocationCount               );
86564a9b66fc6479923fe4a4457818cfe8ae2603ebcChia-I Wu    printf("\t\tmaxSamplerAllocationCount               = 0x%" PRIxLEAST32 "\n", limits->maxSamplerAllocationCount              );
8667dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tbufferImageGranularity                  = 0x%" PRIxLEAST64 "\n", limits->bufferImageGranularity                 );
867a0258a51b8d4d16a26e81e321d4d8a5694031301Tony Barbour    printf("\t\tsparseAddressSpaceSize                  = 0x%" PRIxLEAST64 "\n", limits->sparseAddressSpaceSize                 );
8687dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxBoundDescriptorSets                  = 0x%" PRIxLEAST32 "\n", limits->maxBoundDescriptorSets                 );
8697dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxPerStageDescriptorSamplers           = 0x%" PRIxLEAST32 "\n", limits->maxPerStageDescriptorSamplers          );
8707dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxPerStageDescriptorUniformBuffers     = 0x%" PRIxLEAST32 "\n", limits->maxPerStageDescriptorUniformBuffers    );
8717dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxPerStageDescriptorStorageBuffers     = 0x%" PRIxLEAST32 "\n", limits->maxPerStageDescriptorStorageBuffers    );
8727dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxPerStageDescriptorSampledImages      = 0x%" PRIxLEAST32 "\n", limits->maxPerStageDescriptorSampledImages     );
8737dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxPerStageDescriptorStorageImages      = 0x%" PRIxLEAST32 "\n", limits->maxPerStageDescriptorStorageImages     );
87431bba406f0b7efcede27717534d17d2ba1732078Chia-I Wu    printf("\t\tmaxPerStageDescriptorInputAttachments   = 0x%" PRIxLEAST32 "\n", limits->maxPerStageDescriptorInputAttachments  );
875076be29e003296b3c846fbdbac62d583f4d81dd0Chia-I Wu    printf("\t\tmaxPerStageResources                    = 0x%" PRIxLEAST32 "\n", limits->maxPerStageResources                   );
8767dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxDescriptorSetSamplers                = 0x%" PRIxLEAST32 "\n", limits->maxDescriptorSetSamplers               );
8777dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxDescriptorSetUniformBuffers          = 0x%" PRIxLEAST32 "\n", limits->maxDescriptorSetUniformBuffers         );
878a0258a51b8d4d16a26e81e321d4d8a5694031301Tony Barbour    printf("\t\tmaxDescriptorSetUniformBuffersDynamic   = 0x%" PRIxLEAST32 "\n", limits->maxDescriptorSetUniformBuffersDynamic  );
8797dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxDescriptorSetStorageBuffers          = 0x%" PRIxLEAST32 "\n", limits->maxDescriptorSetStorageBuffers         );
880a0258a51b8d4d16a26e81e321d4d8a5694031301Tony Barbour    printf("\t\tmaxDescriptorSetStorageBuffersDynamic   = 0x%" PRIxLEAST32 "\n", limits->maxDescriptorSetStorageBuffersDynamic  );
8817dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxDescriptorSetSampledImages           = 0x%" PRIxLEAST32 "\n", limits->maxDescriptorSetSampledImages          );
8827dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxDescriptorSetStorageImages           = 0x%" PRIxLEAST32 "\n", limits->maxDescriptorSetStorageImages          );
88331bba406f0b7efcede27717534d17d2ba1732078Chia-I Wu    printf("\t\tmaxDescriptorSetInputAttachments        = 0x%" PRIxLEAST32 "\n", limits->maxDescriptorSetInputAttachments       );
8847dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxVertexInputAttributes                = 0x%" PRIxLEAST32 "\n", limits->maxVertexInputAttributes               );
885a0258a51b8d4d16a26e81e321d4d8a5694031301Tony Barbour    printf("\t\tmaxVertexInputBindings                  = 0x%" PRIxLEAST32 "\n", limits->maxVertexInputBindings                 );
8867dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxVertexInputAttributeOffset           = 0x%" PRIxLEAST32 "\n", limits->maxVertexInputAttributeOffset          );
8877dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxVertexInputBindingStride             = 0x%" PRIxLEAST32 "\n", limits->maxVertexInputBindingStride            );
8887dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxVertexOutputComponents               = 0x%" PRIxLEAST32 "\n", limits->maxVertexOutputComponents              );
889c04519cd6e39256351df868dc721259d904f4542Chia-I Wu    printf("\t\tmaxTessellationGenerationLevel                         = 0x%" PRIxLEAST32 "\n", limits->maxTessellationGenerationLevel          );
890c6fd2263876bb25d6ab7f2bfb76e6eab7b0d8053Courtney Goeltzenleuchter    printf("\t\tmaxTessellationPatchSize                        = 0x%" PRIxLEAST32 "\n", limits->maxTessellationPatchSize                       );
891c6fd2263876bb25d6ab7f2bfb76e6eab7b0d8053Courtney Goeltzenleuchter    printf("\t\tmaxTessellationControlPerVertexInputComponents  = 0x%" PRIxLEAST32 "\n", limits->maxTessellationControlPerVertexInputComponents );
892c6fd2263876bb25d6ab7f2bfb76e6eab7b0d8053Courtney Goeltzenleuchter    printf("\t\tmaxTessellationControlPerVertexOutputComponents = 0x%" PRIxLEAST32 "\n", limits->maxTessellationControlPerVertexOutputComponents);
893c6fd2263876bb25d6ab7f2bfb76e6eab7b0d8053Courtney Goeltzenleuchter    printf("\t\tmaxTessellationControlPerPatchOutputComponents  = 0x%" PRIxLEAST32 "\n", limits->maxTessellationControlPerPatchOutputComponents );
894c6fd2263876bb25d6ab7f2bfb76e6eab7b0d8053Courtney Goeltzenleuchter    printf("\t\tmaxTessellationControlTotalOutputComponents     = 0x%" PRIxLEAST32 "\n", limits->maxTessellationControlTotalOutputComponents    );
895c6fd2263876bb25d6ab7f2bfb76e6eab7b0d8053Courtney Goeltzenleuchter    printf("\t\tmaxTessellationEvaluationInputComponents        = 0x%" PRIxLEAST32 "\n", limits->maxTessellationEvaluationInputComponents       );
896c6fd2263876bb25d6ab7f2bfb76e6eab7b0d8053Courtney Goeltzenleuchter    printf("\t\tmaxTessellationEvaluationOutputComponents       = 0x%" PRIxLEAST32 "\n", limits->maxTessellationEvaluationOutputComponents      );
8977dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxGeometryShaderInvocations            = 0x%" PRIxLEAST32 "\n", limits->maxGeometryShaderInvocations           );
8987dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxGeometryInputComponents              = 0x%" PRIxLEAST32 "\n", limits->maxGeometryInputComponents             );
8997dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxGeometryOutputComponents             = 0x%" PRIxLEAST32 "\n", limits->maxGeometryOutputComponents            );
9007dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxGeometryOutputVertices               = 0x%" PRIxLEAST32 "\n", limits->maxGeometryOutputVertices              );
9017dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxGeometryTotalOutputComponents        = 0x%" PRIxLEAST32 "\n", limits->maxGeometryTotalOutputComponents       );
9027dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxFragmentInputComponents              = 0x%" PRIxLEAST32 "\n", limits->maxFragmentInputComponents             );
903c04519cd6e39256351df868dc721259d904f4542Chia-I Wu    printf("\t\tmaxFragmentOutputAttachments            = 0x%" PRIxLEAST32 "\n", limits->maxFragmentOutputAttachments           );
904c04519cd6e39256351df868dc721259d904f4542Chia-I Wu    printf("\t\tmaxFragmentDualSrcAttachments           = 0x%" PRIxLEAST32 "\n", limits->maxFragmentDualSrcAttachments          );
9057dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxFragmentCombinedOutputResources      = 0x%" PRIxLEAST32 "\n", limits->maxFragmentCombinedOutputResources     );
9067dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxComputeSharedMemorySize              = 0x%" PRIxLEAST32 "\n", limits->maxComputeSharedMemorySize             );
9077dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxComputeWorkGroupCount[0]             = 0x%" PRIxLEAST32 "\n", limits->maxComputeWorkGroupCount[0]            );
9087dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxComputeWorkGroupCount[1]             = 0x%" PRIxLEAST32 "\n", limits->maxComputeWorkGroupCount[1]            );
9097dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxComputeWorkGroupCount[2]             = 0x%" PRIxLEAST32 "\n", limits->maxComputeWorkGroupCount[2]            );
9107dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxComputeWorkGroupInvocations          = 0x%" PRIxLEAST32 "\n", limits->maxComputeWorkGroupInvocations         );
9117dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxComputeWorkGroupSize[0]              = 0x%" PRIxLEAST32 "\n", limits->maxComputeWorkGroupSize[0]             );
9127dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxComputeWorkGroupSize[1]              = 0x%" PRIxLEAST32 "\n", limits->maxComputeWorkGroupSize[1]             );
9137dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxComputeWorkGroupSize[2]              = 0x%" PRIxLEAST32 "\n", limits->maxComputeWorkGroupSize[2]             );
9147dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tsubPixelPrecisionBits                   = 0x%" PRIxLEAST32 "\n", limits->subPixelPrecisionBits                  );
9157dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tsubTexelPrecisionBits                   = 0x%" PRIxLEAST32 "\n", limits->subTexelPrecisionBits                  );
9167dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmipmapPrecisionBits                     = 0x%" PRIxLEAST32 "\n", limits->mipmapPrecisionBits                    );
9177dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxDrawIndexedIndexValue                = 0x%" PRIxLEAST32 "\n", limits->maxDrawIndexedIndexValue               );
9188ca320fc115441df2344d062fc45477bc89f7875Chia-I Wu    printf("\t\tmaxDrawIndirectCount                    = 0x%" PRIxLEAST32 "\n", limits->maxDrawIndirectCount                   );
9197dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxSamplerLodBias                       = %f\n",                 limits->maxSamplerLodBias                      );
9207dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxSamplerAnisotropy                    = %f\n",                 limits->maxSamplerAnisotropy                   );
9217dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxViewports                            = 0x%" PRIxLEAST32 "\n", limits->maxViewports                           );
9227dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxViewportDimensions[0]                = 0x%" PRIxLEAST32 "\n", limits->maxViewportDimensions[0]               );
9237dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxViewportDimensions[1]                = 0x%" PRIxLEAST32 "\n", limits->maxViewportDimensions[1]               );
9247dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tviewportBoundsRange[0]                  = %f\n",                 limits->viewportBoundsRange[0]                 );
9257dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tviewportBoundsRange[1]                  = %f\n",                 limits->viewportBoundsRange[1]                 );
9267dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tviewportSubPixelBits                    = 0x%" PRIxLEAST32 "\n", limits->viewportSubPixelBits                   );
9273ffcd73338dfeb8c3d9da4f5ba388311aad0d49fChia-I Wu    printf("\t\tminMemoryMapAlignment                   = " PRINTF_SIZE_T_SPECIFIER "\n", limits->minMemoryMapAlignment         );
9283ffcd73338dfeb8c3d9da4f5ba388311aad0d49fChia-I Wu    printf("\t\tminTexelBufferOffsetAlignment           = 0x%" PRIxLEAST64 "\n", limits->minTexelBufferOffsetAlignment          );
9293ffcd73338dfeb8c3d9da4f5ba388311aad0d49fChia-I Wu    printf("\t\tminUniformBufferOffsetAlignment         = 0x%" PRIxLEAST64 "\n", limits->minUniformBufferOffsetAlignment        );
9303ffcd73338dfeb8c3d9da4f5ba388311aad0d49fChia-I Wu    printf("\t\tminStorageBufferOffsetAlignment         = 0x%" PRIxLEAST64 "\n", limits->minStorageBufferOffsetAlignment        );
9317dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tminTexelOffset                          = 0x%" PRIxLEAST32 "\n", limits->minTexelOffset                         );
9327dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxTexelOffset                          = 0x%" PRIxLEAST32 "\n", limits->maxTexelOffset                         );
9337dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tminTexelGatherOffset                    = 0x%" PRIxLEAST32 "\n", limits->minTexelGatherOffset                   );
9347dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxTexelGatherOffset                    = 0x%" PRIxLEAST32 "\n", limits->maxTexelGatherOffset                   );
9357dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tminInterpolationOffset                  = %f\n",                 limits->minInterpolationOffset                 );
9367dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxInterpolationOffset                  = %f\n",                 limits->maxInterpolationOffset                 );
9377dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tsubPixelInterpolationOffsetBits         = 0x%" PRIxLEAST32 "\n", limits->subPixelInterpolationOffsetBits        );
9387dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxFramebufferWidth                     = 0x%" PRIxLEAST32 "\n", limits->maxFramebufferWidth                    );
9397dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxFramebufferHeight                    = 0x%" PRIxLEAST32 "\n", limits->maxFramebufferHeight                   );
9407dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxFramebufferLayers                    = 0x%" PRIxLEAST32 "\n", limits->maxFramebufferLayers                   );
9413138d6a7fafb314644a22a854267258769c6d6a0Chia-I Wu    printf("\t\tframebufferColorSampleCounts            = 0x%" PRIxLEAST32 "\n", limits->framebufferColorSampleCounts           );
9423138d6a7fafb314644a22a854267258769c6d6a0Chia-I Wu    printf("\t\tframebufferDepthSampleCounts            = 0x%" PRIxLEAST32 "\n", limits->framebufferDepthSampleCounts           );
9433138d6a7fafb314644a22a854267258769c6d6a0Chia-I Wu    printf("\t\tframebufferStencilSampleCounts          = 0x%" PRIxLEAST32 "\n", limits->framebufferStencilSampleCounts         );
9447dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxColorAttachments                     = 0x%" PRIxLEAST32 "\n", limits->maxColorAttachments                    );
9453138d6a7fafb314644a22a854267258769c6d6a0Chia-I Wu    printf("\t\tsampledImageColorSampleCounts           = 0x%" PRIxLEAST32 "\n", limits->sampledImageColorSampleCounts          );
9463138d6a7fafb314644a22a854267258769c6d6a0Chia-I Wu    printf("\t\tsampledImageDepthSampleCounts           = 0x%" PRIxLEAST32 "\n", limits->sampledImageDepthSampleCounts          );
9473138d6a7fafb314644a22a854267258769c6d6a0Chia-I Wu    printf("\t\tsampledImageStencilSampleCounts         = 0x%" PRIxLEAST32 "\n", limits->sampledImageStencilSampleCounts        );
9483138d6a7fafb314644a22a854267258769c6d6a0Chia-I Wu    printf("\t\tsampledImageIntegerSampleCounts         = 0x%" PRIxLEAST32 "\n", limits->sampledImageIntegerSampleCounts        );
9493138d6a7fafb314644a22a854267258769c6d6a0Chia-I Wu    printf("\t\tstorageImageSampleCounts                = 0x%" PRIxLEAST32 "\n", limits->storageImageSampleCounts               );
9507dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxSampleMaskWords                      = 0x%" PRIxLEAST32 "\n", limits->maxSampleMaskWords                     );
951c789f69f07b921211ca6929db9413598e9a574e7Chia-I Wu    printf("\t\ttimestampPeriod                         = 0x%f\n",               limits->timestampPeriod                        );
9527dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxClipDistances                        = 0x%" PRIxLEAST32 "\n", limits->maxClipDistances                       );
9537dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxCullDistances                        = 0x%" PRIxLEAST32 "\n", limits->maxCullDistances                       );
9547dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tmaxCombinedClipAndCullDistances         = 0x%" PRIxLEAST32 "\n", limits->maxCombinedClipAndCullDistances        );
9557dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tpointSizeRange[0]                       = %f\n",                 limits->pointSizeRange[0]                      );
9567dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tpointSizeRange[1]                       = %f\n",                 limits->pointSizeRange[1]                      );
9577dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tlineWidthRange[0]                       = %f\n",                 limits->lineWidthRange[0]                      );
9587dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tlineWidthRange[1]                       = %f\n",                 limits->lineWidthRange[1]                      );
9597dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tpointSizeGranularity                    = %f\n",                 limits->pointSizeGranularity                   );
9607dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    printf("\t\tlineWidthGranularity                    = %f\n",                 limits->lineWidthGranularity                   );
9613c332106cb0750f6a5a34f58a2e0735635ee7e97Chia-I Wu    printf("\t\tstrictLines                             = %u\n",                 limits->strictLines                            );
962a3939fcc66a34d14b3a473441b27d7e341515004Chia-I Wu    printf("\t\tstandardSampleLocations                 = %u\n",                 limits->standardSampleLocations                );
963ee0eaa1efc64c22968945a7b4bb27535fa04a510Chia-I Wu    printf("\t\toptimalBufferCopyOffsetAlignment        = 0x%" PRIxLEAST64 "\n", limits->optimalBufferCopyOffsetAlignment       );
964ee0eaa1efc64c22968945a7b4bb27535fa04a510Chia-I Wu    printf("\t\toptimalBufferCopyRowPitchAlignment      = 0x%" PRIxLEAST64 "\n", limits->optimalBufferCopyRowPitchAlignment     );
965ee0eaa1efc64c22968945a7b4bb27535fa04a510Chia-I Wu    printf("\t\tnonCoherentAtomSize                     = 0x%" PRIxLEAST64 "\n", limits->nonCoherentAtomSize                    );
966d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
967d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
96818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchterstatic void app_gpu_dump_props(const struct app_gpu *gpu)
96918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter{
97018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    const VkPhysicalDeviceProperties *props = &gpu->props;
97118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
972825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("VkPhysicalDeviceProperties:\n");
973825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("===========================\n");
974825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tapiVersion     = %u\n",                props->apiVersion);
975825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tdriverVersion  = %u\n",                props->driverVersion);
976d3f9934956da83277b3ea10cb98954427384cb93Chia-I Wu    printf("\tvendorID       = 0x%04x\n",            props->vendorID);
977d3f9934956da83277b3ea10cb98954427384cb93Chia-I Wu    printf("\tdeviceID       = 0x%04x\n",            props->deviceID);
978825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tdeviceType     = %s\n",                vk_physical_device_type_string(props->deviceType));
979825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tdeviceName     = %s\n",                props->deviceName);
9807dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski
9817dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    app_dump_limits(&gpu->props.limits);
9827dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski    app_dump_sparse_props(&gpu->props.sparseProperties);
9837dae6868682383bb8370d45784cbc94f357e745bMark Lobodzinski
98418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    fflush(stdout);
98518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter}
98618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
98718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchterstatic void app_dump_extensions(
98818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        const char *indent,
98918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        const char *layer_name,
99018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        const uint32_t extension_count,
99118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        const VkExtensionProperties *extension_properties)
9923c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter{
9933c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    uint32_t i;
99418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    if (layer_name && (strlen(layer_name) > 0)) {
99518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        printf("%s%s Extensions", indent, layer_name);
99618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    } else {
99718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        printf("Extensions");
9983c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    }
99918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    printf("\tcount = %d\n", extension_count);
100018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    for (i=0; i< extension_count; i++) {
100118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        VkExtensionProperties const *ext_prop = &extension_properties[i];
10023c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter
1003ff87c822214d31c677026f8dcf53d8f953b395fdCourtney Goeltzenleuchter        if (i>0)
100418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter            printf("\n"); // separator between extensions
100518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
100618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        printf("%s\t", indent);
1007d5b6e890d23a20280a2bed4a5358db1d8fafb74bIan Elliott        printf("%-32s: extension revision %2d",
10081f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu                       ext_prop->extensionName, ext_prop->specVersion);
1009ff87c822214d31c677026f8dcf53d8f953b395fdCourtney Goeltzenleuchter    }
1010ff87c822214d31c677026f8dcf53d8f953b395fdCourtney Goeltzenleuchter    printf("\n");
101118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    fflush(stdout);
1012ff87c822214d31c677026f8dcf53d8f953b395fdCourtney Goeltzenleuchter}
1013ff87c822214d31c677026f8dcf53d8f953b395fdCourtney Goeltzenleuchter
1014e2d07a5a3810d83d0ea7ecb396d61477893b74a4Mark Lobodzinskistatic void app_gpu_dump_queue_props(const struct app_gpu *gpu, uint32_t id)
1015d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu{
1016ef72e2a7cf4fa5708fdbfbc1c972a24ad0dbf809Cody Northrop    const VkQueueFamilyProperties *props = &gpu->queue_props[id];
1017190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu
1018825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("VkQueueFamilyProperties[%d]:\n", id);
1019825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("============================\n");
1020b21a51a4aae758d8b8f622eb7ca363bb7896cb00Chia-I Wu    printf("\tqueueFlags         = %c%c%c\n",
10219cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter            (props->queueFlags & VK_QUEUE_GRAPHICS_BIT) ? 'G' : '.',
10229cc421eb545767e22fd723dc573a7a3225261b1cCourtney Goeltzenleuchter            (props->queueFlags & VK_QUEUE_COMPUTE_BIT)  ? 'C' : '.',
1023c51b121913d6f21ccefb3f7595178d3c87e11de4Chia-I Wu            (props->queueFlags & VK_QUEUE_TRANSFER_BIT)      ? 'D' : '.');
1024825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tqueueCount         = %u\n",   props->queueCount);
102568535a67f71882ce0a4a915e2e9ddc9e2fb6c761Courtney Goeltzenleuchter    printf("\ttimestampValidBits = %u\n",   props->timestampValidBits);
10260339bc575660f6a9e04905cccfd8964cf8a87621Chia-I Wu    printf("\tminImageTransferGranularity = (%d, %d, %d)\n",
10270339bc575660f6a9e04905cccfd8964cf8a87621Chia-I Wu            props->minImageTransferGranularity.width,
10280339bc575660f6a9e04905cccfd8964cf8a87621Chia-I Wu            props->minImageTransferGranularity.height,
10290339bc575660f6a9e04905cccfd8964cf8a87621Chia-I Wu            props->minImageTransferGranularity.depth);
103018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    fflush(stdout);
1031d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
1032d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
1033d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wustatic void app_gpu_dump_memory_props(const struct app_gpu *gpu)
1034d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu{
10358205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    const VkPhysicalDeviceMemoryProperties *props = &gpu->memory_props;
1036d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
1037825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("VkPhysicalDeviceMemoryProperties:\n");
1038825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("=================================\n");
1039825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tmemoryTypeCount       = %u\n", props->memoryTypeCount);
1040723462910ef2f9ed0255b74399c835020a75a0b1Mark Lobodzinski    for (uint32_t i = 0; i < props->memoryTypeCount; i++) {
1041723462910ef2f9ed0255b74399c835020a75a0b1Mark Lobodzinski        printf("\tmemoryTypes[%u] : \n", i);
1042723462910ef2f9ed0255b74399c835020a75a0b1Mark Lobodzinski        printf("\t\tpropertyFlags = %u\n", props->memoryTypes[i].propertyFlags);
1043723462910ef2f9ed0255b74399c835020a75a0b1Mark Lobodzinski        printf("\t\theapIndex     = %u\n", props->memoryTypes[i].heapIndex);
1044723462910ef2f9ed0255b74399c835020a75a0b1Mark Lobodzinski    }
1045825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("\tmemoryHeapCount       = %u\n",                props->memoryHeapCount);
1046723462910ef2f9ed0255b74399c835020a75a0b1Mark Lobodzinski    for (uint32_t i = 0; i < props->memoryHeapCount; i++) {
1047723462910ef2f9ed0255b74399c835020a75a0b1Mark Lobodzinski        printf("\tmemoryHeaps[%u] : \n", i);
1048825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski        printf("\t\tsize          = " PRINTF_SIZE_T_SPECIFIER "\n", props->memoryHeaps[i].size);
1049723462910ef2f9ed0255b74399c835020a75a0b1Mark Lobodzinski    }
105018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    fflush(stdout);
1051d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
1052d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
1053d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wustatic void app_gpu_dump(const struct app_gpu *gpu)
1054d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu{
1055e2d07a5a3810d83d0ea7ecb396d61477893b74a4Mark Lobodzinski    uint32_t i;
1056190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu
1057825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("Device Extensions and layers:\n");
1058825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("=============================\n");
1059190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    printf("GPU%u\n", gpu->id);
1060190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    app_gpu_dump_props(gpu);
1061190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    printf("\n");
1062825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    app_dump_extensions("", "Device", gpu->device_extension_count, gpu->device_extensions);
106318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    printf("\n");
106418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    printf("Layers\tcount = %d\n", gpu->device_layer_count);
106518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    for (uint32_t i = 0; i < gpu->device_layer_count; i++) {
106618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        uint32_t major, minor, patch;
106718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        char spec_version[64], layer_version[64];
106818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        struct layer_extension_list const *layer_info = &gpu->device_layers[i];
106918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
107018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        extract_version(layer_info->layer_properties.specVersion, &major, &minor, &patch);
107118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        snprintf(spec_version, sizeof(spec_version), "%d.%d.%d", major, minor, patch);
10721f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu        extract_version(layer_info->layer_properties.implementationVersion, &major, &minor, &patch);
107318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        snprintf(layer_version, sizeof(layer_version), "%d.%d.%d", major, minor, patch);
107418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        printf("\t%s (%s) Vulkan version %s, layer version %s\n",
107518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter               layer_info->layer_properties.layerName,
10763f26dee9c7577a32f4a104a8d2028f4b1f2aeae6Ian Elliott               (char*) layer_info->layer_properties.description,
107718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter               spec_version, layer_version);
107818061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
107918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        app_dump_extensions("\t",
108018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                            layer_info->layer_properties.layerName,
108118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                            layer_info->extension_count,
108218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                            layer_info->extension_properties);
108318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        fflush(stdout);
108418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    }
1085ff87c822214d31c677026f8dcf53d8f953b395fdCourtney Goeltzenleuchter    printf("\n");
1086190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    for (i = 0; i < gpu->queue_count; i++) {
1087190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu        app_gpu_dump_queue_props(gpu, i);
1088190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu        printf("\n");
1089190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    }
1090190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    app_gpu_dump_memory_props(gpu);
1091190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    printf("\n");
1092a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes    app_gpu_dump_features(gpu);
1093a048b3146ed9bc094adf4d6ba7355cd8a5ef7008Chris Forbes    printf("\n");
1094190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    app_dev_dump(&gpu->dev);
1095d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
1096d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu
1097d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wuint main(int argc, char **argv)
1098d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu{
10997b4e9ec8af004566938363ba8ff06df5b88d201cDavid Pinedo    unsigned int major, minor, patch;
11007b4e9ec8af004566938363ba8ff06df5b88d201cDavid Pinedo    struct app_gpu gpus[MAX_GPUS];
11018205d901f17b1c76d89c956be235cf4e7a20a546Tony Barbour    VkPhysicalDevice objs[MAX_GPUS];
1102e2d07a5a3810d83d0ea7ecb396d61477893b74a4Mark Lobodzinski    uint32_t gpu_count, i;
1103382489d723fd0d3935da0dc7e1021c56c7b721d3Courtney Goeltzenleuchter    VkResult err;
11043c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    struct app_instance inst;
1105190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu
11067b4e9ec8af004566938363ba8ff06df5b88d201cDavid Pinedo    major = VK_API_VERSION >> 22;
11077b4e9ec8af004566938363ba8ff06df5b88d201cDavid Pinedo    minor = (VK_API_VERSION >> 12) & 0x4ff;
11087b4e9ec8af004566938363ba8ff06df5b88d201cDavid Pinedo    patch = VK_API_VERSION & 0xfff;
11097b4e9ec8af004566938363ba8ff06df5b88d201cDavid Pinedo    printf("===========\n");
1110b5ec4c29f35458d9a072956e983563a35d9c2416David Pinedo	printf("VULKAN INFO\n");
1111b5ec4c29f35458d9a072956e983563a35d9c2416David Pinedo    printf("===========\n\n");
1112b5ec4c29f35458d9a072956e983563a35d9c2416David Pinedo    printf("Vulkan API Version: %d %d %d\n\n", major, minor, patch);
1113b5ec4c29f35458d9a072956e983563a35d9c2416David Pinedo
11143c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    app_create_instance(&inst);
111518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
1116825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("Instance Extensions and layers:\n");
1117825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("===============================\n");
1118825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    app_dump_extensions("", "Instance", inst.global_extension_count, inst.global_extensions);
1119825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski
1120825cc51df04b93f130e48788ced8e63937272b4dMark Lobodzinski    printf("Instance Layers\tcount = %d\n", inst.global_layer_count);
112118061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    for (uint32_t i = 0; i < inst.global_layer_count; i++) {
112218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        uint32_t major, minor, patch;
112318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        char spec_version[64], layer_version[64];
112418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        VkLayerProperties const *layer_prop = &inst.global_layers[i].layer_properties;
112518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
112618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        extract_version(layer_prop->specVersion, &major, &minor, &patch);
112718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        snprintf(spec_version, sizeof(spec_version), "%d.%d.%d", major, minor, patch);
11281f85191a3a8479194ecb7b937aee284cf80cf08fChia-I Wu        extract_version(layer_prop->implementationVersion, &major, &minor, &patch);
112918061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        snprintf(layer_version, sizeof(layer_version), "%d.%d.%d", major, minor, patch);
113018061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        printf("\t%s (%s) Vulkan version %s, layer version %s\n",
11313f26dee9c7577a32f4a104a8d2028f4b1f2aeae6Ian Elliott               layer_prop->layerName, (char*) layer_prop->description, spec_version, layer_version);
113218061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter
113318061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter        app_dump_extensions("\t",
113418061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                            inst.global_layers[i].layer_properties.layerName,
113518061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                            inst.global_layers[i].extension_count,
113618061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter                            inst.global_layers[i].extension_properties);
113718061cdee54b19cd628178d2924a7a914c62a10bCourtney Goeltzenleuchter    }
113829669a43755f6caa97c4c1d447f494514ba343d9Jon Ashburn
11393c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    err = vkEnumeratePhysicalDevices(inst.instance, &gpu_count, NULL);
114007b309a0cdfca1532ad14038682716ea7f77538dJon Ashburn    if (err)
114107b309a0cdfca1532ad14038682716ea7f77538dJon Ashburn        ERR_EXIT(err);
114207b309a0cdfca1532ad14038682716ea7f77538dJon Ashburn    if (gpu_count > MAX_GPUS) {
114318fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        printf("Too many GPUS found \n");
1144ac544f3737b45a5b35251100a3396aa8be397d8dCourtney Goeltzenleuchter        ERR_EXIT(-1);
114507b309a0cdfca1532ad14038682716ea7f77538dJon Ashburn    }
11463c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    err = vkEnumeratePhysicalDevices(inst.instance, &gpu_count, objs);
1147190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    if (err)
1148190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu        ERR_EXIT(err);
1149190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu
1150190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    for (i = 0; i < gpu_count; i++) {
1151190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu        app_gpu_init(&gpus[i], i, objs[i]);
1152190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu        app_gpu_dump(&gpus[i]);
1153190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu        printf("\n\n");
1154190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    }
1155190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu
1156190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    for (i = 0; i < gpu_count; i++)
1157190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu        app_gpu_destroy(&gpus[i]);
1158190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu
11593c1ccf58f9f38b00cf0409e72fc65349aa11e742Courtney Goeltzenleuchter    app_destroy_instance(&inst);
11600b9a73720abbc3e1229507a4a97e0209976b7610Chia-I Wu
1161190ebdcce84b767d8db7a42383c834dc067b3e77Chia-I Wu    return 0;
1162d4bae362585dff8c456fb3b906512b4d2ef17fe8Chia-I Wu}
1163ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott
1164ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott#ifdef _WIN32
116518fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
116618fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo// Create a console window with a large scrollback size to which to send stdout.
116718fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo// Returns true if console window was successfully created, false otherwise.
116818fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedobool SetStdOutToNewConsole()
116918fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo{
117018fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    // don't do anything if we already have a console
117118fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    if (GetStdHandle(STD_OUTPUT_HANDLE))
117218fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        return false;
117318fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
117418fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    // allocate a console for this app
117518fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    AllocConsole();
117618fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
117718fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    // redirect unbuffered STDOUT to the console
117818fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
117918fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT);
118018fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    FILE *fp = _fdopen( fileDescriptor, "w" );
118118fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    *stdout = *fp;
118218fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    setvbuf( stdout, NULL, _IONBF, 0 );
118318fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
118418fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    // make the console window bigger
118518fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    CONSOLE_SCREEN_BUFFER_INFO csbi;
118618fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    SMALL_RECT r;
118718fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    COORD bufferSize;
118818fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    if (!GetConsoleScreenBufferInfo(consoleHandle, &csbi))
118918fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        return false;
1190d188757e3644ce0b7fda6228a2d4fccde4c67701David Pinedo    bufferSize.X = csbi.dwSize.X+30;
1191e1b115fdf18e54ebfd90e3990ad775527a38534bDavid Pinedo    bufferSize.Y = 20000;
119218fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    if (!SetConsoleScreenBufferSize(consoleHandle, bufferSize))
119318fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        return false;
119418fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    r.Left = r.Top = 0;
1195d188757e3644ce0b7fda6228a2d4fccde4c67701David Pinedo    r.Right = csbi.dwSize.X-1+30;
11963bf020c230cf7931af430c4918a22cd046edbb9bDavid Pinedo    r.Bottom = 50;
119718fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    if (!SetConsoleWindowInfo(consoleHandle, true, &r))
119818fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        return false;
119918fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
120018fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    // change the console window title
12014e19ed0ed322e45993bac7917a1a253dbaaf88f9Ian Elliott    if (!SetConsoleTitle(TEXT(APP_SHORT_NAME)))
120218fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        return false;
120318fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
120418fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    return true;
120518fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo}
120618fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo
1207ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliottint WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow)
1208ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott{
1209ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott    char *argv = pCmdLine;
121018fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    consoleCreated = SetStdOutToNewConsole();
1211ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott    main(1, &argv);
1212ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott    fflush(stdout);
121318fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo    if (consoleCreated)
121418fb9239e51c9449fa072e3a398a55777f5c3c62David Pinedo        Sleep(INFINITE);
1215ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott}
1216ea95f5c3967480a57ceb03a98e8370225094ce42Ian Elliott#endif
1217