From 0cd63e891dd9cd309ad83b7f09b0fa25fb3ef561 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 4 May 2021 13:32:53 -0700 Subject: [PATCH] turnip: Move the extension tables to tu_device.c Following intel's lead in 27d49670. In the dEQP-VK.info.* tests, this bumps apiVersion from 1.1.128 to 1.1.177. Part-of: --- src/freedreno/vulkan/meson.build | 12 +-- src/freedreno/vulkan/tu_device.c | 129 +++++++++++++++++++++-- src/freedreno/vulkan/tu_extensions.py | 141 -------------------------- src/freedreno/vulkan/tu_private.h | 1 - 4 files changed, 123 insertions(+), 160 deletions(-) delete mode 100644 src/freedreno/vulkan/tu_extensions.py diff --git a/src/freedreno/vulkan/meson.build b/src/freedreno/vulkan/meson.build index a90f3da7d2c..a4a5ea452e3 100644 --- a/src/freedreno/vulkan/meson.build +++ b/src/freedreno/vulkan/meson.build @@ -29,16 +29,6 @@ tu_entrypoints = custom_target( depend_files : vk_entrypoints_gen_depend_files, ) -tu_extensions_c = custom_target( - 'tu_extensions.c', - input : ['tu_extensions.py', vk_api_xml], - output : ['tu_extensions.c', 'tu_extensions.h'], - command : [ - prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--out-c', '@OUTPUT0@', - '--out-h', '@OUTPUT1@' - ], - depend_files : vk_extensions_gen, -) libtu_files = files( 'tu_clear_blit.c', @@ -117,7 +107,7 @@ endif libvulkan_freedreno = shared_library( 'vulkan_freedreno', - [libtu_files, tu_entrypoints, tu_extensions_c, freedreno_xml_header_files], + [libtu_files, tu_entrypoints, freedreno_xml_header_files], include_directories : [ inc_include, inc_src, diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 9d4be97e92d..91c9c6ca12e 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -44,11 +44,15 @@ /* for fd_get_driver/device_uuid() */ #include "freedreno/common/freedreno_uuid.h" -#define TU_HAS_SURFACE \ - (VK_USE_PLATFORM_WAYLAND_KHR || \ - VK_USE_PLATFORM_XCB_KHR || \ - VK_USE_PLATFORM_XLIB_KHR || \ - VK_USE_PLATFORM_DISPLAY_KHR) +#if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ + defined(VK_USE_PLATFORM_XCB_KHR) || \ + defined(VK_USE_PLATFORM_XLIB_KHR) || \ + defined(VK_USE_PLATFORM_DISPLAY_KHR) +#define TU_HAS_SURFACE 1 +#else +#define TU_HAS_SURFACE 0 +#endif + static int tu_device_get_cache_uuid(uint16_t family, void *uuid) @@ -66,6 +70,117 @@ tu_device_get_cache_uuid(uint16_t family, void *uuid) return 0; } +#define TU_API_VERSION VK_MAKE_VERSION(1, 1, VK_HEADER_VERSION) + +VkResult tu_EnumerateInstanceVersion(uint32_t *pApiVersion) +{ + *pApiVersion = TU_API_VERSION; + return VK_SUCCESS; +} + +static const struct vk_instance_extension_table tu_instance_extensions_supported = { + .KHR_device_group_creation = true, + .KHR_external_fence_capabilities = true, + .KHR_external_memory_capabilities = true, + .KHR_external_semaphore_capabilities = true, + .KHR_get_physical_device_properties2 = true, + .KHR_surface = TU_HAS_SURFACE, + .KHR_get_surface_capabilities2 = TU_HAS_SURFACE, + .EXT_debug_report = true, +#ifdef VK_USE_PLATFORM_WAYLAND_KHR + .KHR_wayland_surface = true, +#endif +#ifdef VK_USE_PLATFORM_XCB_KHR + .KHR_xcb_surface = true, +#endif +#ifdef VK_USE_PLATFORM_XLIB_KHR + .KHR_xlib_surface = true, +#endif +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT + .EXT_acquire_xlib_display = true, +#endif +#ifdef VK_USE_PLATFORM_DISPLAY_KHR + .KHR_display = true, + .KHR_get_display_properties2 = true, + .EXT_direct_mode_display = true, + .EXT_display_surface_counter = true, +#endif +}; + +static void +get_device_extensions(const struct tu_physical_device *device, + struct vk_device_extension_table *ext) +{ + *ext = (struct vk_device_extension_table) { + .KHR_16bit_storage = device->gpu_id >= 650, + .KHR_bind_memory2 = true, + .KHR_create_renderpass2 = true, + .KHR_dedicated_allocation = true, + .KHR_depth_stencil_resolve = true, + .KHR_descriptor_update_template = true, + .KHR_device_group = true, + .KHR_draw_indirect_count = true, + .KHR_external_fence = true, + .KHR_external_fence_fd = true, + .KHR_external_memory = true, + .KHR_external_memory_fd = true, + .KHR_external_semaphore = true, + .KHR_external_semaphore_fd = true, + .KHR_get_memory_requirements2 = true, + .KHR_incremental_present = TU_HAS_SURFACE, + .KHR_image_format_list = true, + .KHR_maintenance1 = true, + .KHR_maintenance2 = true, + .KHR_maintenance3 = true, + .KHR_multiview = true, + .KHR_performance_query = device->instance->debug_flags & TU_DEBUG_PERFC, + .KHR_pipeline_executable_properties = true, + .KHR_push_descriptor = true, + .KHR_relaxed_block_layout = true, + .KHR_sampler_mirror_clamp_to_edge = true, + .KHR_sampler_ycbcr_conversion = true, + .KHR_shader_draw_parameters = true, + .KHR_shader_float_controls = true, + .KHR_shader_float16_int8 = true, + .KHR_shader_terminate_invocation = true, + .KHR_spirv_1_4 = true, + .KHR_storage_buffer_storage_class = true, + .KHR_swapchain = TU_HAS_SURFACE, + .KHR_variable_pointers = true, + .KHR_vulkan_memory_model = true, +#ifdef VK_USE_PLATFORM_DISPLAY_KHR + .EXT_display_control = true, +#endif + .EXT_external_memory_dma_buf = true, + .EXT_image_drm_format_modifier = true, + .EXT_sample_locations = device->gpu_id == 650, + .EXT_sampler_filter_minmax = true, + .EXT_transform_feedback = true, + .EXT_4444_formats = true, + .EXT_conditional_rendering = true, + .EXT_custom_border_color = true, + .EXT_depth_clip_enable = true, + .EXT_descriptor_indexing = true, + .EXT_extended_dynamic_state = true, + .EXT_filter_cubic = device->gpu_id == 650, + .EXT_host_query_reset = true, + .EXT_index_type_uint8 = true, + .EXT_memory_budget = true, + .EXT_private_data = true, + .EXT_robustness2 = true, + .EXT_scalar_block_layout = true, + .EXT_separate_stencil_usage = true, + .EXT_shader_demote_to_helper_invocation = true, + .EXT_shader_stencil_export = true, + .EXT_shader_viewport_index_layer = true, + .EXT_vertex_attribute_divisor = true, +#ifdef ANDROID + .ANDROID_native_buffer = true, +#endif + .IMG_filter_cubic = device->gpu_id == 650, + }; +} + VkResult tu_physical_device_init(struct tu_physical_device *device, struct tu_instance *instance) @@ -108,7 +223,7 @@ tu_physical_device_init(struct tu_physical_device *device, fd_get_device_uuid(device->device_uuid, device->gpu_id); struct vk_device_extension_table supported_extensions; - tu_physical_device_get_supported_extensions(device, &supported_extensions); + get_device_extensions(device, &supported_extensions); struct vk_physical_device_dispatch_table dispatch_table; vk_physical_device_dispatch_table_from_entrypoints( @@ -775,7 +890,7 @@ tu_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, }; pProperties->properties = (VkPhysicalDeviceProperties) { - .apiVersion = tu_physical_device_api_version(pdevice), + .apiVersion = TU_API_VERSION, .driverVersion = vk_get_driver_version(), .vendorID = 0, /* TODO */ .deviceID = 0, diff --git a/src/freedreno/vulkan/tu_extensions.py b/src/freedreno/vulkan/tu_extensions.py deleted file mode 100644 index dcc2b61bdfd..00000000000 --- a/src/freedreno/vulkan/tu_extensions.py +++ /dev/null @@ -1,141 +0,0 @@ -COPYRIGHT = """\ -/* - * Copyright 2017 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -""" - -import argparse -import os.path -import re -import sys - -VULKAN_UTIL = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../vulkan/util')) -sys.path.append(VULKAN_UTIL) - -from vk_extensions import * -from vk_extensions_gen import * - -MAX_API_VERSION = '1.1.128' - -# On Android, we disable all surface and swapchain extensions. Android's Vulkan -# loader implements VK_KHR_surface and VK_KHR_swapchain, and applications -# cannot access the driver's implementation. Moreoever, if the driver exposes -# the those extension strings, then tests dEQP-VK.api.info.instance.extensions -# and dEQP-VK.api.info.device fail due to the duplicated strings. -EXTENSIONS = [ - Extension('VK_KHR_bind_memory2', 1, True), - Extension('VK_KHR_create_renderpass2', 1, True), - Extension('VK_KHR_dedicated_allocation', 1, True), - Extension('VK_KHR_get_display_properties2', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), - Extension('VK_KHR_get_memory_requirements2', 1, True), - Extension('VK_KHR_get_physical_device_properties2', 1, True), - Extension('VK_KHR_get_surface_capabilities2', 1, 'TU_HAS_SURFACE'), - Extension('VK_KHR_maintenance1', 1, True), - Extension('VK_KHR_maintenance2', 1, True), - Extension('VK_KHR_maintenance3', 1, True), - Extension('VK_KHR_sampler_mirror_clamp_to_edge', 1, True), - Extension('VK_KHR_sampler_ycbcr_conversion', 1, True), - Extension('VK_KHR_surface', 25, 'TU_HAS_SURFACE'), - Extension('VK_KHR_swapchain', 68, 'TU_HAS_SURFACE'), - Extension('VK_KHR_wayland_surface', 6, 'VK_USE_PLATFORM_WAYLAND_KHR'), - Extension('VK_KHR_xcb_surface', 6, 'VK_USE_PLATFORM_XCB_KHR'), - Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), - Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), - Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), - Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'), - Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), - Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), - Extension('VK_EXT_debug_report', 9, True), - Extension('VK_KHR_external_memory_capabilities', 1, True), - Extension('VK_KHR_external_memory', 1, True), - Extension('VK_KHR_external_memory_fd', 1, True), - Extension('VK_EXT_external_memory_dma_buf', 1, True), - Extension('VK_EXT_image_drm_format_modifier', 1, True), - Extension('VK_EXT_sample_locations', 1, 'device->gpu_id == 650'), - Extension('VK_EXT_sampler_filter_minmax', 1, True), - Extension('VK_EXT_transform_feedback', 1, True), - Extension('VK_ANDROID_native_buffer', 1, 'ANDROID'), - Extension('VK_KHR_external_fence', 1, True), - Extension('VK_KHR_external_fence_fd', 1, True), - Extension('VK_KHR_external_semaphore', 1, True), - Extension('VK_KHR_external_semaphore_capabilities', 1, True), - Extension('VK_KHR_external_semaphore_fd', 1, True), - Extension('VK_IMG_filter_cubic', 1, 'device->gpu_id == 650'), - Extension('VK_EXT_filter_cubic', 1, 'device->gpu_id == 650'), - Extension('VK_EXT_index_type_uint8', 1, True), - Extension('VK_EXT_vertex_attribute_divisor', 1, True), - Extension('VK_KHR_shader_draw_parameters', 1, True), - Extension('VK_KHR_variable_pointers', 1, True), - Extension('VK_EXT_private_data', 1, True), - Extension('VK_EXT_shader_stencil_export', 1, True), - Extension('VK_EXT_depth_clip_enable', 1, True), - Extension('VK_KHR_draw_indirect_count', 1, True), - Extension('VK_EXT_4444_formats', 1, True), - Extension('VK_EXT_conditional_rendering', 1, True), - Extension('VK_EXT_custom_border_color', 12, True), - Extension('VK_KHR_multiview', 1, True), - Extension('VK_EXT_host_query_reset', 1, True), - Extension('VK_EXT_separate_stencil_usage', 1, True), - Extension('VK_EXT_shader_viewport_index_layer', 1, True), - Extension('VK_EXT_extended_dynamic_state', 1, True), - Extension('VK_KHR_push_descriptor', 1, True), - Extension('VK_KHR_incremental_present', 1, 'TU_HAS_SURFACE'), - Extension('VK_KHR_image_format_list', 1, True), - Extension('VK_KHR_depth_stencil_resolve', 1, True), - Extension('VK_KHR_performance_query', 1, 'device->instance->debug_flags & TU_DEBUG_PERFC'), - Extension('VK_EXT_memory_budget', 1, True), - Extension('VK_KHR_device_group', 4, True), - Extension('VK_KHR_device_group_creation', 1, True), - Extension('VK_EXT_descriptor_indexing', 2, True), - Extension('VK_KHR_descriptor_update_template', 1, True), - Extension('VK_KHR_storage_buffer_storage_class', 1, True), - Extension('VK_KHR_external_fence_capabilities', 1, True), - Extension('VK_KHR_pipeline_executable_properties', 1, True), - Extension('VK_KHR_shader_float_controls', 1, True), - Extension('VK_KHR_shader_float16_int8', 1, True), - Extension('VK_KHR_16bit_storage', 1, 'device->gpu_id >= 650'), - Extension('VK_EXT_scalar_block_layout', 1, True), - Extension('VK_KHR_spirv_1_4', 1, True), - Extension('VK_KHR_relaxed_block_layout', 1, True), - Extension('VK_EXT_robustness2', 1, True), - Extension('VK_EXT_shader_demote_to_helper_invocation', 1, True), - Extension('VK_KHR_shader_terminate_invocation', 1, True), - Extension('VK_KHR_vulkan_memory_model', 3, True), -] - -MAX_API_VERSION = VkVersion(MAX_API_VERSION) -API_VERSIONS = [ ApiVersion(MAX_API_VERSION, True) ] - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - parser.add_argument('--out-c', help='Output C file.', required=True) - parser.add_argument('--out-h', help='Output H file.', required=True) - parser.add_argument('--xml', - help='Vulkan API XML file.', - required=True, - action='append', - dest='xml_files') - args = parser.parse_args() - - gen_extensions('tu', args.xml_files, API_VERSIONS, MAX_API_VERSION, - EXTENSIONS, args.out_c, args.out_h) diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 8fb56eaeb42..f8fd48aea27 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -74,7 +74,6 @@ #include "perfcntrs/freedreno_perfcntr.h" #include "tu_descriptor_set.h" -#include "tu_extensions.h" #include "tu_util.h" /* Pre-declarations needed for WSI entrypoints */