| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // Copyright (c) 2015-2016 The Khronos Group Inc. |
| // Copyright (c) 2015-2016 Valve Corporation |
| // Copyright (c) 2015-2016 LunarG, Inc. |
| // Copyright (c) 2015-2016 Google, Inc. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| #ifndef VK_PROTOTYPES |
| #define VK_PROTOTYPES |
| #endif |
| |
| #include "vkjson.h" |
| |
| #include <algorithm> |
| #include <utility> |
| |
| /* |
| * This file is autogenerated by vkjson_generator.py. Do not edit directly. |
| */ |
| namespace { |
| |
| bool EnumerateExtensions(const char* layer_name, |
| std::vector<VkExtensionProperties>* extensions) { |
| VkResult result; |
| uint32_t count = 0; |
| result = vkEnumerateInstanceExtensionProperties(layer_name, &count, nullptr); |
| if (result != VK_SUCCESS) |
| return false; |
| extensions->resize(count); |
| result = vkEnumerateInstanceExtensionProperties(layer_name, &count, |
| extensions->data()); |
| if (result != VK_SUCCESS) |
| return false; |
| return true; |
| } |
| |
| bool HasExtension(const char* extension_name, |
| const std::vector<VkExtensionProperties>& extensions) { |
| return std::find_if(extensions.cbegin(), extensions.cend(), |
| [extension_name](const VkExtensionProperties& extension) { |
| return strcmp(extension.extensionName, |
| extension_name) == 0; |
| }) != extensions.cend(); |
| } |
| } // anonymous namespace |
| |
| VkJsonDevice VkJsonGetDevice(VkPhysicalDevice physical_device) { |
| VkJsonDevice device; |
| |
| uint32_t extension_count = 0; |
| vkEnumerateDeviceExtensionProperties(physical_device, nullptr, |
| &extension_count, nullptr); |
| if (extension_count > 0) { |
| device.extensions.resize(extension_count); |
| vkEnumerateDeviceExtensionProperties( |
| physical_device, nullptr, &extension_count, device.extensions.data()); |
| } |
| |
| uint32_t layer_count = 0; |
| vkEnumerateDeviceLayerProperties(physical_device, &layer_count, nullptr); |
| if (layer_count > 0) { |
| device.layers.resize(layer_count); |
| vkEnumerateDeviceLayerProperties(physical_device, &layer_count, |
| device.layers.data()); |
| } |
| |
| VkPhysicalDeviceProperties2 properties = { |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, |
| nullptr, |
| {}, |
| }; |
| |
| if (HasExtension("VK_KHR_shader_float_controls", device.extensions)) { |
| device.khr_shader_float_controls.reported = true; |
| device.khr_shader_float_controls.float_controls_properties_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES; |
| device.khr_shader_float_controls.float_controls_properties_khr.pNext = |
| properties.pNext; |
| properties.pNext = |
| &device.khr_shader_float_controls.float_controls_properties_khr; |
| } |
| |
| if (HasExtension("VK_KHR_driver_properties", device.extensions)) { |
| device.khr_driver_properties.reported = true; |
| device.khr_driver_properties.driver_properties_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; |
| device.khr_driver_properties.driver_properties_khr.pNext = properties.pNext; |
| properties.pNext = &device.khr_driver_properties.driver_properties_khr; |
| } |
| |
| vkGetPhysicalDeviceProperties2(physical_device, &properties); |
| device.properties = properties.properties; |
| |
| VkPhysicalDeviceFeatures2 features = { |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, |
| nullptr, |
| {}, |
| }; |
| |
| if (HasExtension("VK_KHR_variable_pointers", device.extensions)) { |
| device.khr_variable_pointers.reported = true; |
| device.khr_variable_pointers.variable_pointer_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES; |
| device.khr_variable_pointers.variable_pointer_features_khr.pNext = |
| features.pNext; |
| features.pNext = |
| &device.khr_variable_pointers.variable_pointer_features_khr; |
| device.khr_variable_pointers.variable_pointers_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES; |
| device.khr_variable_pointers.variable_pointers_features_khr.pNext = |
| features.pNext; |
| features.pNext = |
| &device.khr_variable_pointers.variable_pointers_features_khr; |
| } |
| |
| if (HasExtension("VK_KHR_shader_float16_int8", device.extensions)) { |
| device.khr_shader_float16_int8.reported = true; |
| device.khr_shader_float16_int8.shader_float16_int8_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES; |
| device.khr_shader_float16_int8.shader_float16_int8_features_khr.pNext = |
| features.pNext; |
| features.pNext = |
| &device.khr_shader_float16_int8.shader_float16_int8_features_khr; |
| device.khr_shader_float16_int8.float16_int8_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES; |
| device.khr_shader_float16_int8.float16_int8_features_khr.pNext = |
| features.pNext; |
| features.pNext = &device.khr_shader_float16_int8.float16_int8_features_khr; |
| } |
| |
| if (HasExtension("VK_EXT_image_2d_view_of_3d", device.extensions)) { |
| device.ext_image_2d_view_of_3d.reported = true; |
| device.ext_image_2d_view_of_3d.image_2d_view_of_3d_features_ext.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT; |
| device.ext_image_2d_view_of_3d.image_2d_view_of_3d_features_ext.pNext = |
| features.pNext; |
| features.pNext = |
| &device.ext_image_2d_view_of_3d.image_2d_view_of_3d_features_ext; |
| } |
| |
| if (HasExtension("VK_EXT_custom_border_color", device.extensions)) { |
| device.ext_custom_border_color.reported = true; |
| device.ext_custom_border_color.custom_border_color_features_ext.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT; |
| device.ext_custom_border_color.custom_border_color_features_ext.pNext = |
| features.pNext; |
| features.pNext = |
| &device.ext_custom_border_color.custom_border_color_features_ext; |
| } |
| |
| if (HasExtension("VK_EXT_primitive_topology_list_restart", |
| device.extensions)) { |
| device.ext_primitive_topology_list_restart.reported = true; |
| device.ext_primitive_topology_list_restart |
| .primitive_topology_list_restart_features_ext.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT; |
| device.ext_primitive_topology_list_restart |
| .primitive_topology_list_restart_features_ext.pNext = features.pNext; |
| features.pNext = &device.ext_primitive_topology_list_restart |
| .primitive_topology_list_restart_features_ext; |
| } |
| |
| if (HasExtension("VK_EXT_provoking_vertex", device.extensions)) { |
| device.ext_provoking_vertex.reported = true; |
| device.ext_provoking_vertex.provoking_vertex_features_ext.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT; |
| device.ext_provoking_vertex.provoking_vertex_features_ext.pNext = |
| features.pNext; |
| features.pNext = &device.ext_provoking_vertex.provoking_vertex_features_ext; |
| } |
| |
| if (HasExtension("VK_KHR_index_type_uint8", device.extensions)) { |
| device.khr_index_type_uint8.reported = true; |
| device.khr_index_type_uint8.index_type_uint8_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES; |
| device.khr_index_type_uint8.index_type_uint8_features_khr.pNext = |
| features.pNext; |
| features.pNext = &device.khr_index_type_uint8.index_type_uint8_features_khr; |
| } |
| |
| if (HasExtension("VK_EXT_index_type_uint8", device.extensions)) { |
| device.ext_index_type_uint8.reported = true; |
| device.ext_index_type_uint8.index_type_uint8_features_ext.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES; |
| device.ext_index_type_uint8.index_type_uint8_features_ext.pNext = |
| features.pNext; |
| features.pNext = &device.ext_index_type_uint8.index_type_uint8_features_ext; |
| } |
| |
| if (HasExtension("VK_KHR_vertex_attribute_divisor", device.extensions)) { |
| device.khr_vertex_attribute_divisor.reported = true; |
| device.khr_vertex_attribute_divisor.vertex_attribute_divisor_features_khr |
| .sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES; |
| device.khr_vertex_attribute_divisor.vertex_attribute_divisor_features_khr |
| .pNext = features.pNext; |
| features.pNext = &device.khr_vertex_attribute_divisor |
| .vertex_attribute_divisor_features_khr; |
| } |
| |
| if (HasExtension("VK_EXT_vertex_attribute_divisor", device.extensions)) { |
| device.ext_vertex_attribute_divisor.reported = true; |
| device.ext_vertex_attribute_divisor.vertex_attribute_divisor_features_ext |
| .sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES; |
| device.ext_vertex_attribute_divisor.vertex_attribute_divisor_features_ext |
| .pNext = features.pNext; |
| features.pNext = &device.ext_vertex_attribute_divisor |
| .vertex_attribute_divisor_features_ext; |
| } |
| |
| if (HasExtension("VK_EXT_transform_feedback", device.extensions)) { |
| device.ext_transform_feedback.reported = true; |
| device.ext_transform_feedback.transform_feedback_features_ext.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT; |
| device.ext_transform_feedback.transform_feedback_features_ext.pNext = |
| features.pNext; |
| features.pNext = |
| &device.ext_transform_feedback.transform_feedback_features_ext; |
| } |
| |
| if (HasExtension("VK_KHR_shader_subgroup_uniform_control_flow", |
| device.extensions)) { |
| device.khr_shader_subgroup_uniform_control_flow.reported = true; |
| device.khr_shader_subgroup_uniform_control_flow |
| .shader_subgroup_uniform_control_flow_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR; |
| device.khr_shader_subgroup_uniform_control_flow |
| .shader_subgroup_uniform_control_flow_features_khr.pNext = |
| features.pNext; |
| features.pNext = &device.khr_shader_subgroup_uniform_control_flow |
| .shader_subgroup_uniform_control_flow_features_khr; |
| } |
| |
| if (HasExtension("VK_KHR_shader_subgroup_extended_types", |
| device.extensions)) { |
| device.khr_shader_subgroup_extended_types.reported = true; |
| device.khr_shader_subgroup_extended_types |
| .shader_subgroup_extended_types_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES; |
| device.khr_shader_subgroup_extended_types |
| .shader_subgroup_extended_types_features_khr.pNext = features.pNext; |
| features.pNext = &device.khr_shader_subgroup_extended_types |
| .shader_subgroup_extended_types_features_khr; |
| } |
| |
| if (HasExtension("VK_KHR_8bit_storage", device.extensions)) { |
| device.khr_8bit_storage.reported = true; |
| device.khr_8bit_storage.bit8_storage_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES; |
| device.khr_8bit_storage.bit8_storage_features_khr.pNext = features.pNext; |
| features.pNext = &device.khr_8bit_storage.bit8_storage_features_khr; |
| } |
| |
| if (HasExtension("VK_KHR_shader_integer_dot_product", device.extensions)) { |
| device.khr_shader_integer_dot_product.reported = true; |
| device.khr_shader_integer_dot_product |
| .shader_integer_dot_product_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES; |
| device.khr_shader_integer_dot_product |
| .shader_integer_dot_product_features_khr.pNext = features.pNext; |
| features.pNext = &device.khr_shader_integer_dot_product |
| .shader_integer_dot_product_features_khr; |
| } |
| |
| if (HasExtension("VK_IMG_relaxed_line_rasterization", device.extensions)) { |
| device.img_relaxed_line_rasterization.reported = true; |
| device.img_relaxed_line_rasterization |
| .relaxed_line_rasterization_features_img.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RELAXED_LINE_RASTERIZATION_FEATURES_IMG; |
| device.img_relaxed_line_rasterization |
| .relaxed_line_rasterization_features_img.pNext = features.pNext; |
| features.pNext = &device.img_relaxed_line_rasterization |
| .relaxed_line_rasterization_features_img; |
| } |
| |
| if (HasExtension("VK_KHR_line_rasterization", device.extensions)) { |
| device.khr_line_rasterization.reported = true; |
| device.khr_line_rasterization.line_rasterization_features_khr.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES; |
| device.khr_line_rasterization.line_rasterization_features_khr.pNext = |
| features.pNext; |
| features.pNext = |
| &device.khr_line_rasterization.line_rasterization_features_khr; |
| } |
| |
| if (HasExtension("VK_EXT_line_rasterization", device.extensions)) { |
| device.ext_line_rasterization.reported = true; |
| device.ext_line_rasterization.line_rasterization_features_ext.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES; |
| device.ext_line_rasterization.line_rasterization_features_ext.pNext = |
| features.pNext; |
| features.pNext = |
| &device.ext_line_rasterization.line_rasterization_features_ext; |
| } |
| |
| if (HasExtension("VK_EXT_primitives_generated_query", device.extensions)) { |
| device.ext_primitives_generated_query.reported = true; |
| device.ext_primitives_generated_query |
| .primitives_generated_query_features_ext.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVES_GENERATED_QUERY_FEATURES_EXT; |
| device.ext_primitives_generated_query |
| .primitives_generated_query_features_ext.pNext = features.pNext; |
| features.pNext = &device.ext_primitives_generated_query |
| .primitives_generated_query_features_ext; |
| } |
| |
| vkGetPhysicalDeviceFeatures2(physical_device, &features); |
| device.features = features.features; |
| |
| vkGetPhysicalDeviceMemoryProperties(physical_device, &device.memory); |
| |
| uint32_t queue_family_count = 0; |
| vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_family_count, |
| nullptr); |
| if (queue_family_count > 0) { |
| device.queues.resize(queue_family_count); |
| vkGetPhysicalDeviceQueueFamilyProperties( |
| physical_device, &queue_family_count, device.queues.data()); |
| } |
| |
| VkFormatProperties format_properties = {}; |
| for (VkFormat format = VK_FORMAT_R4G4_UNORM_PACK8; |
| // TODO(http://b/171403054): avoid hard-coding last value in the |
| // contiguous range |
| format <= VK_FORMAT_ASTC_12x12_SRGB_BLOCK; |
| format = static_cast<VkFormat>(format + 1)) { |
| vkGetPhysicalDeviceFormatProperties(physical_device, format, |
| &format_properties); |
| if (format_properties.linearTilingFeatures || |
| format_properties.optimalTilingFeatures || |
| format_properties.bufferFeatures) { |
| device.formats.insert(std::make_pair(format, format_properties)); |
| } |
| } |
| |
| if (device.properties.apiVersion >= VK_API_VERSION_1_1) { |
| for (VkFormat format = VK_FORMAT_G8B8G8R8_422_UNORM; |
| // TODO(http://b/171403054): avoid hard-coding last value in the |
| // contiguous range |
| format <= VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM; |
| format = static_cast<VkFormat>(format + 1)) { |
| vkGetPhysicalDeviceFormatProperties(physical_device, format, |
| &format_properties); |
| if (format_properties.linearTilingFeatures || |
| format_properties.optimalTilingFeatures || |
| format_properties.bufferFeatures) { |
| device.formats.insert(std::make_pair(format, format_properties)); |
| } |
| } |
| |
| device.subgroup_properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES; |
| device.subgroup_properties.pNext = properties.pNext; |
| properties.pNext = &device.subgroup_properties; |
| |
| device.point_clipping_properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES; |
| device.point_clipping_properties.pNext = properties.pNext; |
| properties.pNext = &device.point_clipping_properties; |
| |
| device.multiview_properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES; |
| device.multiview_properties.pNext = properties.pNext; |
| properties.pNext = &device.multiview_properties; |
| |
| device.id_properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES; |
| device.id_properties.pNext = properties.pNext; |
| properties.pNext = &device.id_properties; |
| |
| device.maintenance3_properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES; |
| device.maintenance3_properties.pNext = properties.pNext; |
| properties.pNext = &device.maintenance3_properties; |
| |
| vkGetPhysicalDeviceProperties2(physical_device, &properties); |
| |
| device.multiview_features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES; |
| device.multiview_features.pNext = features.pNext; |
| features.pNext = &device.multiview_features; |
| |
| device.variable_pointers_features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES; |
| device.variable_pointers_features.pNext = features.pNext; |
| features.pNext = &device.variable_pointers_features; |
| |
| device.protected_memory_features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES; |
| device.protected_memory_features.pNext = features.pNext; |
| features.pNext = &device.protected_memory_features; |
| |
| device.sampler_ycbcr_conversion_features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES; |
| device.sampler_ycbcr_conversion_features.pNext = features.pNext; |
| features.pNext = &device.sampler_ycbcr_conversion_features; |
| |
| device.shader_draw_parameter_features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES; |
| device.shader_draw_parameter_features.pNext = features.pNext; |
| features.pNext = &device.shader_draw_parameter_features; |
| |
| device.bit16_storage_features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES; |
| device.bit16_storage_features.pNext = features.pNext; |
| features.pNext = &device.bit16_storage_features; |
| |
| vkGetPhysicalDeviceFeatures2(physical_device, &features); |
| |
| VkPhysicalDeviceExternalFenceInfo external_fence_info = { |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO, nullptr, |
| VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT}; |
| VkExternalFenceProperties external_fence_properties = {}; |
| |
| for (VkExternalFenceHandleTypeFlagBits handle_type = |
| VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT; |
| handle_type <= VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT; |
| handle_type = |
| static_cast<VkExternalFenceHandleTypeFlagBits>(handle_type << 1)) { |
| external_fence_info.handleType = handle_type; |
| vkGetPhysicalDeviceExternalFenceProperties( |
| physical_device, &external_fence_info, &external_fence_properties); |
| if (external_fence_properties.exportFromImportedHandleTypes || |
| external_fence_properties.compatibleHandleTypes || |
| external_fence_properties.externalFenceFeatures) { |
| device.external_fence_properties.insert( |
| std::make_pair(handle_type, external_fence_properties)); |
| } |
| } |
| |
| VkPhysicalDeviceExternalSemaphoreInfo external_semaphore_info = { |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO, nullptr, |
| VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT}; |
| VkExternalSemaphoreProperties external_semaphore_properties = {}; |
| |
| for (VkExternalSemaphoreHandleTypeFlagBits handle_type = |
| VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT; |
| handle_type <= VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| handle_type = static_cast<VkExternalSemaphoreHandleTypeFlagBits>( |
| handle_type << 1)) { |
| external_semaphore_info.handleType = handle_type; |
| vkGetPhysicalDeviceExternalSemaphoreProperties( |
| physical_device, &external_semaphore_info, |
| &external_semaphore_properties); |
| if (external_semaphore_properties.exportFromImportedHandleTypes || |
| external_semaphore_properties.compatibleHandleTypes || |
| external_semaphore_properties.externalSemaphoreFeatures) { |
| device.external_semaphore_properties.insert( |
| std::make_pair(handle_type, external_semaphore_properties)); |
| } |
| } |
| } |
| |
| if (device.properties.apiVersion >= VK_API_VERSION_1_2) { |
| device.core11.properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES; |
| device.core11.properties.pNext = properties.pNext; |
| properties.pNext = &device.core11.properties; |
| |
| device.core12.properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES; |
| device.core12.properties.pNext = properties.pNext; |
| properties.pNext = &device.core12.properties; |
| |
| vkGetPhysicalDeviceProperties2(physical_device, &properties); |
| |
| device.core11.features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; |
| device.core11.features.pNext = features.pNext; |
| features.pNext = &device.core11.features; |
| |
| device.core12.features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; |
| device.core12.features.pNext = features.pNext; |
| features.pNext = &device.core12.features; |
| |
| vkGetPhysicalDeviceFeatures2(physical_device, &features); |
| } |
| |
| if (device.properties.apiVersion >= VK_API_VERSION_1_3) { |
| device.core13.properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES; |
| device.core13.properties.pNext = properties.pNext; |
| properties.pNext = &device.core13.properties; |
| |
| vkGetPhysicalDeviceProperties2(physical_device, &properties); |
| |
| device.core13.features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; |
| device.core13.features.pNext = features.pNext; |
| features.pNext = &device.core13.features; |
| |
| vkGetPhysicalDeviceFeatures2(physical_device, &features); |
| } |
| |
| if (device.properties.apiVersion >= VK_API_VERSION_1_4) { |
| device.core14.properties.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_4_PROPERTIES; |
| device.core14.properties.pNext = properties.pNext; |
| properties.pNext = &device.core14.properties; |
| |
| vkGetPhysicalDeviceProperties2(physical_device, &properties); |
| |
| if (device.core14.properties.copySrcLayoutCount > 0 || |
| device.core14.properties.copyDstLayoutCount > 0) { |
| if (device.core14.properties.copySrcLayoutCount > 0) { |
| device.core14.copy_src_layouts.resize( |
| device.core14.properties.copySrcLayoutCount); |
| device.core14.properties.pCopySrcLayouts = |
| device.core14.copy_src_layouts.data(); |
| } |
| if (device.core14.properties.copyDstLayoutCount > 0) { |
| device.core14.copy_dst_layouts.resize( |
| device.core14.properties.copyDstLayoutCount); |
| device.core14.properties.pCopyDstLayouts = |
| device.core14.copy_dst_layouts.data(); |
| } |
| vkGetPhysicalDeviceProperties2(physical_device, &properties); |
| } |
| |
| device.core14.features.sType = |
| VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_4_FEATURES; |
| device.core14.features.pNext = features.pNext; |
| features.pNext = &device.core14.features; |
| |
| vkGetPhysicalDeviceFeatures2(physical_device, &features); |
| } |
| |
| return device; |
| } |
| |
| VkJsonInstance VkJsonGetInstance() { |
| VkJsonInstance instance; |
| VkResult result; |
| uint32_t count; |
| |
| count = 0; |
| result = vkEnumerateInstanceLayerProperties(&count, nullptr); |
| if (result != VK_SUCCESS) |
| return VkJsonInstance(); |
| if (count > 0) { |
| std::vector<VkLayerProperties> layers(count); |
| result = vkEnumerateInstanceLayerProperties(&count, layers.data()); |
| if (result != VK_SUCCESS) |
| return VkJsonInstance(); |
| instance.layers.reserve(count); |
| for (auto& layer : layers) { |
| instance.layers.push_back( |
| VkJsonLayer{layer, std::vector<VkExtensionProperties>()}); |
| if (!EnumerateExtensions(layer.layerName, |
| &instance.layers.back().extensions)) |
| return VkJsonInstance(); |
| } |
| } |
| |
| if (!EnumerateExtensions(nullptr, &instance.extensions)) |
| return VkJsonInstance(); |
| |
| const VkApplicationInfo app_info = { |
| VK_STRUCTURE_TYPE_APPLICATION_INFO, |
| nullptr, |
| "vkjson_info", |
| 1, |
| "", |
| 0, |
| VK_API_VERSION_1_1, |
| }; |
| VkInstanceCreateInfo instance_info = { |
| VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, |
| nullptr, |
| 0, |
| &app_info, |
| 0, |
| nullptr, |
| 0, |
| nullptr, |
| }; |
| VkInstance vkinstance; |
| result = vkCreateInstance(&instance_info, nullptr, &vkinstance); |
| if (result != VK_SUCCESS) |
| return VkJsonInstance(); |
| |
| count = 0; |
| result = vkEnumeratePhysicalDevices(vkinstance, &count, nullptr); |
| if (result != VK_SUCCESS) { |
| vkDestroyInstance(vkinstance, nullptr); |
| return VkJsonInstance(); |
| } |
| |
| std::vector<VkPhysicalDevice> devices(count, VK_NULL_HANDLE); |
| result = vkEnumeratePhysicalDevices(vkinstance, &count, devices.data()); |
| if (result != VK_SUCCESS) { |
| vkDestroyInstance(vkinstance, nullptr); |
| return VkJsonInstance(); |
| } |
| |
| std::map<VkPhysicalDevice, uint32_t> device_map; |
| const uint32_t sz = devices.size(); |
| instance.devices.reserve(sz); |
| for (uint32_t i = 0; i < sz; ++i) { |
| device_map.insert(std::make_pair(devices[i], i)); |
| instance.devices.emplace_back(VkJsonGetDevice(devices[i])); |
| } |
| |
| result = vkEnumerateInstanceVersion(&instance.api_version); |
| if (result != VK_SUCCESS) { |
| vkDestroyInstance(vkinstance, nullptr); |
| return VkJsonInstance(); |
| } |
| |
| count = 0; |
| result = vkEnumeratePhysicalDeviceGroups(vkinstance, &count, nullptr); |
| if (result != VK_SUCCESS) { |
| vkDestroyInstance(vkinstance, nullptr); |
| return VkJsonInstance(); |
| } |
| |
| VkJsonDeviceGroup device_group; |
| std::vector<VkPhysicalDeviceGroupProperties> group_properties; |
| group_properties.resize(count); |
| for (auto& properties : group_properties) { |
| properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES; |
| properties.pNext = nullptr; |
| } |
| result = vkEnumeratePhysicalDeviceGroups(vkinstance, &count, |
| group_properties.data()); |
| if (result != VK_SUCCESS) { |
| vkDestroyInstance(vkinstance, nullptr); |
| return VkJsonInstance(); |
| } |
| for (auto properties : group_properties) { |
| device_group.properties = properties; |
| for (uint32_t i = 0; i < properties.physicalDeviceCount; ++i) { |
| device_group.device_inds.push_back( |
| device_map[properties.physicalDevices[i]]); |
| } |
| instance.device_groups.push_back(device_group); |
| } |
| |
| vkDestroyInstance(vkinstance, nullptr); |
| return instance; |
| } |