Karl Schultz | b932f10 | 2016-02-04 09:41:29 -0700 | [diff] [blame] | 1 | /////////////////////////////////////////////////////////////////////////////// |
Antoine Labour | e3795c1 | 2015-10-27 12:21:09 -0700 | [diff] [blame] | 2 | // |
Karl Schultz | b932f10 | 2016-02-04 09:41:29 -0700 | [diff] [blame] | 3 | // Copyright (c) 2015-2016 The Khronos Group Inc. |
| 4 | // Copyright (c) 2015-2016 Valve Corporation |
| 5 | // Copyright (c) 2015-2016 LunarG, Inc. |
| 6 | // Copyright (c) 2015-2016 Google, Inc. |
Antoine Labour | e3795c1 | 2015-10-27 12:21:09 -0700 | [diff] [blame] | 7 | // |
Karl Schultz | b932f10 | 2016-02-04 09:41:29 -0700 | [diff] [blame] | 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | // of this software and/or associated documentation files (the "Materials"), to |
| 10 | // deal in the Materials without restriction, including without limitation the |
| 11 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 12 | // sell copies of the Materials, and to permit persons to whom the Materials are |
| 13 | // furnished to do so, subject to the following conditions: |
Antoine Labour | e3795c1 | 2015-10-27 12:21:09 -0700 | [diff] [blame] | 14 | // |
Karl Schultz | b932f10 | 2016-02-04 09:41:29 -0700 | [diff] [blame] | 15 | // The above copyright notice(s) and this permission notice shall be included in |
| 16 | // all copies or substantial portions of the Materials. |
| 17 | // |
Karl Schultz | b932f10 | 2016-02-04 09:41:29 -0700 | [diff] [blame] | 18 | // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Antoine Labour | 38841df | 2016-01-28 15:05:57 -0800 | [diff] [blame] | 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Karl Schultz | b932f10 | 2016-02-04 09:41:29 -0700 | [diff] [blame] | 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 21 | // |
| 22 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 23 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 24 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 25 | // USE OR OTHER DEALINGS IN THE MATERIALS. |
| 26 | /////////////////////////////////////////////////////////////////////////////// |
Antoine Labour | e3795c1 | 2015-10-27 12:21:09 -0700 | [diff] [blame] | 27 | |
| 28 | #define VK_PROTOTYPES |
| 29 | #include "vkjson.h" |
| 30 | |
| 31 | #include <utility> |
| 32 | |
| 33 | VkJsonAllProperties VkJsonGetAllProperties(VkPhysicalDevice physical_device) { |
| 34 | VkJsonAllProperties properties; |
| 35 | vkGetPhysicalDeviceProperties(physical_device, &properties.properties); |
| 36 | vkGetPhysicalDeviceFeatures(physical_device, &properties.features); |
| 37 | vkGetPhysicalDeviceMemoryProperties(physical_device, &properties.memory); |
| 38 | |
| 39 | uint32_t queue_family_count = 0; |
| 40 | vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_family_count, |
| 41 | nullptr); |
| 42 | if (queue_family_count > 0) { |
| 43 | properties.queues.resize(queue_family_count); |
| 44 | vkGetPhysicalDeviceQueueFamilyProperties( |
| 45 | physical_device, &queue_family_count, properties.queues.data()); |
| 46 | } |
| 47 | |
| 48 | // Only device extensions. |
| 49 | // TODO(piman): do we want to show layer extensions? |
| 50 | uint32_t extension_count = 0; |
| 51 | vkEnumerateDeviceExtensionProperties(physical_device, nullptr, |
| 52 | &extension_count, nullptr); |
| 53 | if (extension_count > 0) { |
| 54 | properties.extensions.resize(extension_count); |
| 55 | vkEnumerateDeviceExtensionProperties(physical_device, nullptr, |
| 56 | &extension_count, |
| 57 | properties.extensions.data()); |
| 58 | } |
| 59 | |
| 60 | uint32_t layer_count = 0; |
| 61 | vkEnumerateDeviceLayerProperties(physical_device, &layer_count, nullptr); |
| 62 | if (layer_count > 0) { |
| 63 | properties.layers.resize(layer_count); |
| 64 | vkEnumerateDeviceLayerProperties(physical_device, &layer_count, |
| 65 | properties.layers.data()); |
| 66 | } |
| 67 | |
Jesse Hall | 66e6a3f | 2016-03-26 14:30:55 -0700 | [diff] [blame] | 68 | VkFormatProperties format_properties = {}; |
Antoine Labour | e3795c1 | 2015-10-27 12:21:09 -0700 | [diff] [blame] | 69 | for (VkFormat format = VK_FORMAT_R4G4_UNORM_PACK8; |
| 70 | format <= VK_FORMAT_END_RANGE; |
| 71 | format = static_cast<VkFormat>(format + 1)) { |
| 72 | vkGetPhysicalDeviceFormatProperties(physical_device, format, |
| 73 | &format_properties); |
| 74 | if (format_properties.linearTilingFeatures || |
| 75 | format_properties.optimalTilingFeatures || |
| 76 | format_properties.bufferFeatures) { |
| 77 | properties.formats.insert(std::make_pair(format, format_properties)); |
| 78 | } |
| 79 | } |
| 80 | return properties; |
| 81 | } |