blob: fc9540efeaa016035ffd61aff12552ceb9857567 [file] [log] [blame]
Karl Schultzb932f102016-02-04 09:41:29 -07001///////////////////////////////////////////////////////////////////////////////
Antoine Laboure3795c12015-10-27 12:21:09 -07002//
Karl Schultzb932f102016-02-04 09:41:29 -07003// 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 Laboure3795c12015-10-27 12:21:09 -07007//
Karl Schultzb932f102016-02-04 09:41:29 -07008// 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 Laboure3795c12015-10-27 12:21:09 -070014//
Karl Schultzb932f102016-02-04 09:41:29 -070015// The above copyright notice(s) and this permission notice shall be included in
16// all copies or substantial portions of the Materials.
17//
Karl Schultzb932f102016-02-04 09:41:29 -070018// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Antoine Labour38841df2016-01-28 15:05:57 -080019// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Karl Schultzb932f102016-02-04 09:41:29 -070020// 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 Laboure3795c12015-10-27 12:21:09 -070027
28#define VK_PROTOTYPES
29#include "vkjson.h"
30
31#include <utility>
32
33VkJsonAllProperties 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 Hall66e6a3f2016-03-26 14:30:55 -070068 VkFormatProperties format_properties = {};
Antoine Laboure3795c12015-10-27 12:21:09 -070069 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}