From 27d496706eb4a2e923b291cc014979026eb0c381 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 29 Jan 2021 22:40:39 -0600 Subject: [PATCH] anv: Move extension tables to anv_device.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Lionel Landwerlin Reviewed-by: Bas Nieuwenhuizen Tested-by: Tapani Pälli Part-of: --- src/intel/Android.vulkan.mk | 18 --- src/intel/Makefile.sources | 4 +- src/intel/vulkan/anv_device.c | 195 +++++++++++++++++++++++-- src/intel/vulkan/anv_extensions_gen.py | 70 --------- src/intel/vulkan/anv_private.h | 6 - src/intel/vulkan/meson.build | 34 +---- 6 files changed, 192 insertions(+), 135 deletions(-) delete mode 100644 src/intel/vulkan/anv_extensions_gen.py diff --git a/src/intel/Android.vulkan.mk b/src/intel/Android.vulkan.mk index 3954c1e3b0f..0aa3e65f72c 100644 --- a/src/intel/Android.vulkan.mk +++ b/src/intel/Android.vulkan.mk @@ -24,8 +24,6 @@ include $(CLEAR_VARS) include $(LOCAL_PATH)/Makefile.sources VK_ENTRYPOINTS_GEN_SCRIPT := $(MESA_TOP)/src/vulkan/util/vk_entrypoints_gen.py -ANV_EXTENSIONS_GEN_SCRIPT := $(LOCAL_PATH)/vulkan/anv_extensions_gen.py -ANV_EXTENSIONS_SCRIPT := $(LOCAL_PATH)/vulkan/anv_extensions.py VULKAN_API_XML := $(MESA_TOP)/src/vulkan/registry/vk.xml VULKAN_COMMON_INCLUDES := \ @@ -256,22 +254,6 @@ $(intermediates)/vulkan/anv_entrypoints.c: $(VK_ENTRYPOINTS_GEN_SCRIPT) \ $(intermediates)/vulkan/anv_entrypoints.h: $(intermediates)/vulkan/anv_entrypoints.c -$(intermediates)/vulkan/anv_extensions.c: $(ANV_EXTENSIONS_GEN_SCRIPT) \ - $(ANV_EXTENSIONS_SCRIPT) \ - $(VULKAN_API_XML) - @mkdir -p $(dir $@) - $(MESA_PYTHON2) $(ANV_EXTENSIONS_GEN_SCRIPT) \ - --xml $(VULKAN_API_XML) \ - --out-c $@ - -$(intermediates)/vulkan/anv_extensions.h: $(ANV_EXTENSIONS_GEN_SCRIPT) \ - $(ANV_EXTENSIONS_SCRIPT) \ - $(VULKAN_API_XML) - @mkdir -p $(dir $@) - $(MESA_PYTHON2) $(ANV_EXTENSIONS_GEN_SCRIPT) \ - --xml $(VULKAN_API_XML) \ - --out-h $@ - LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES) LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES) diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources index c26ca40119c..737f73abf23 100644 --- a/src/intel/Makefile.sources +++ b/src/intel/Makefile.sources @@ -307,9 +307,7 @@ VULKAN_GEM_STUB_FILES := \ VULKAN_GENERATED_FILES := \ vulkan/anv_entrypoints.c \ - vulkan/anv_entrypoints.h \ - vulkan/anv_extensions.c \ - vulkan/anv_extensions.h + vulkan/anv_entrypoints.h VULKAN_GENX_FILES := \ vulkan/genX_blorp_exec.c \ diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 4349f8f79ea..b694f48a5e8 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -49,6 +49,7 @@ #include "common/gen_defines.h" #include "common/gen_uuid.h" #include "compiler/glsl_types.h" +#include "perf/gen_perf.h" #include "genxml/gen7_pack.h" @@ -134,6 +135,186 @@ anv_compute_heap_size(int fd, uint64_t gtt_size) return MIN2(available_ram, available_gtt); } +#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 ANV_USE_WSI_PLATFORM +#endif + +#ifdef ANDROID +#define ANV_API_VERSION VK_MAKE_VERSION(1, 1, VK_HEADER_VERSION) +#else +#define ANV_API_VERSION VK_MAKE_VERSION(1, 2, VK_HEADER_VERSION) +#endif + +VkResult anv_EnumerateInstanceVersion( + uint32_t* pApiVersion) +{ + *pApiVersion = ANV_API_VERSION; + return VK_SUCCESS; +} + +static const struct vk_instance_extension_table instance_extensions = { + .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, + .EXT_debug_report = true, + +#ifdef ANV_USE_WSI_PLATFORM + .KHR_get_surface_capabilities2 = true, + .KHR_surface = true, + .KHR_surface_protected_capabilities = true, +#endif +#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 anv_physical_device *device, + struct vk_device_extension_table *ext) +{ + *ext = (struct vk_device_extension_table) { + .KHR_8bit_storage = device->info.gen >= 8, + .KHR_16bit_storage = device->info.gen >= 8, + .KHR_bind_memory2 = true, + .KHR_buffer_device_address = device->has_a64_buffer_access, + .KHR_copy_commands2 = true, + .KHR_create_renderpass2 = true, + .KHR_dedicated_allocation = true, + .KHR_deferred_host_operations = true, + .KHR_depth_stencil_resolve = true, + .KHR_descriptor_update_template = true, + .KHR_device_group = true, + .KHR_draw_indirect_count = true, + .KHR_driver_properties = true, + .KHR_external_fence = device->has_syncobj_wait, + .KHR_external_fence_fd = device->has_syncobj_wait, + .KHR_external_memory = true, + .KHR_external_memory_fd = true, + .KHR_external_semaphore = true, + .KHR_external_semaphore_fd = true, + .KHR_get_memory_requirements2 = true, + .KHR_image_format_list = true, + .KHR_imageless_framebuffer = true, +#ifdef ANV_USE_WSI_PLATFORM + .KHR_incremental_present = true, +#endif + .KHR_maintenance1 = true, + .KHR_maintenance2 = true, + .KHR_maintenance3 = true, + .KHR_multiview = true, + .KHR_performance_query = + device->use_softpin && device->perf && + (device->perf->i915_perf_version >= 3 || + INTEL_DEBUG & DEBUG_NO_OACONFIG) && + device->use_call_secondary, + .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_separate_depth_stencil_layouts = true, + .KHR_shader_atomic_int64 = device->info.gen >= 9 && + device->use_softpin, + .KHR_shader_clock = true, + .KHR_shader_draw_parameters = true, + .KHR_shader_float16_int8 = device->info.gen >= 8, + .KHR_shader_float_controls = device->info.gen >= 8, + .KHR_shader_non_semantic_info = true, + .KHR_shader_subgroup_extended_types = device->info.gen >= 8, + .KHR_shader_terminate_invocation = true, + .KHR_spirv_1_4 = true, + .KHR_storage_buffer_storage_class = true, +#ifdef ANV_USE_WSI_PLATFORM + .KHR_swapchain = true, + .KHR_swapchain_mutable_format = true, +#endif + .KHR_timeline_semaphore = true, + .KHR_uniform_buffer_standard_layout = true, + .KHR_variable_pointers = true, + .KHR_vulkan_memory_model = true, + .KHR_workgroup_memory_explicit_layout = true, + .KHR_zero_initialize_workgroup_memory = true, + .EXT_4444_formats = true, + .EXT_buffer_device_address = device->has_a64_buffer_access, + .EXT_calibrated_timestamps = device->has_reg_timestamp, + .EXT_conditional_rendering = device->info.gen >= 8 || + device->info.is_haswell, + .EXT_custom_border_color = device->info.gen >= 8, + .EXT_depth_clip_enable = true, + .EXT_descriptor_indexing = device->has_a64_buffer_access && + device->has_bindless_images, +#ifdef VK_USE_PLATFORM_DISPLAY_KHR + .EXT_display_control = true, +#endif + .EXT_extended_dynamic_state = true, + .EXT_external_memory_dma_buf = true, + .EXT_external_memory_host = true, + .EXT_fragment_shader_interlock = device->info.gen >= 9, + .EXT_global_priority = device->has_context_priority, + .EXT_host_query_reset = true, + .EXT_image_robustness = true, + .EXT_index_type_uint8 = true, + .EXT_inline_uniform_block = true, + .EXT_line_rasterization = true, + .EXT_memory_budget = device->has_mem_available, + .EXT_pci_bus_info = true, + .EXT_pipeline_creation_cache_control = true, + .EXT_pipeline_creation_feedback = true, + .EXT_post_depth_coverage = device->info.gen >= 9, + .EXT_private_data = true, +#ifdef ANDROID + .EXT_queue_family_foreign = ANDROID, +#endif + .EXT_robustness2 = true, + .EXT_sample_locations = true, + .EXT_sampler_filter_minmax = device->info.gen >= 9, + .EXT_scalar_block_layout = true, + .EXT_separate_stencil_usage = true, + .EXT_shader_atomic_float = true, + .EXT_shader_demote_to_helper_invocation = true, + .EXT_shader_stencil_export = device->info.gen >= 9, + .EXT_shader_subgroup_ballot = true, + .EXT_shader_subgroup_vote = true, + .EXT_shader_viewport_index_layer = true, + .EXT_subgroup_size_control = true, + .EXT_texel_buffer_alignment = true, + .EXT_transform_feedback = true, + .EXT_vertex_attribute_divisor = true, + .EXT_ycbcr_image_arrays = true, +#ifdef ANDROID + .ANDROID_external_memory_android_hardware_buffer = true, + .ANDROID_native_buffer = true, +#endif + .GOOGLE_decorate_string = true, + .GOOGLE_hlsl_functionality1 = true, + .GOOGLE_user_type = true, + .INTEL_performance_query = device->perf && + device->perf->i915_perf_version >= 3, + .INTEL_shader_integer_functions2 = device->info.gen >= 8, + .NV_compute_shader_derivatives = true, + }; +} + static VkResult anv_physical_device_init_heaps(struct anv_physical_device *device, int fd) { @@ -607,9 +788,7 @@ anv_physical_device_try_create(struct anv_instance *instance, anv_measure_device_init(device); - anv_physical_device_get_supported_extensions(device, - &device->vk.supported_extensions); - + get_device_extensions(device, &device->vk.supported_extensions); device->local_fd = fd; @@ -685,7 +864,7 @@ VkResult anv_EnumerateInstanceExtensionProperties( return vk_error(VK_ERROR_LAYER_NOT_PRESENT); return vk_enumerate_instance_extension_properties( - &anv_instance_extensions_supported, pPropertyCount, pProperties); + &instance_extensions, pPropertyCount, pProperties); } static void @@ -723,10 +902,8 @@ VkResult anv_CreateInstance( vk_instance_dispatch_table_from_entrypoints( &dispatch_table, &anv_instance_entrypoints, true); - result = vk_instance_init(&instance->vk, - &anv_instance_extensions_supported, - &dispatch_table, - pCreateInfo, pAllocator); + result = vk_instance_init(&instance->vk, &instance_extensions, + &dispatch_table, pCreateInfo, pAllocator); if (result != VK_SUCCESS) { vk_free(pAllocator, instance); return vk_error(result); @@ -1623,7 +1800,7 @@ void anv_GetPhysicalDeviceProperties( }; *pProperties = (VkPhysicalDeviceProperties) { - .apiVersion = anv_physical_device_api_version(pdevice), + .apiVersion = ANV_API_VERSION, .driverVersion = vk_get_driver_version(), .vendorID = 0x8086, .deviceID = pdevice->info.chipset_id, diff --git a/src/intel/vulkan/anv_extensions_gen.py b/src/intel/vulkan/anv_extensions_gen.py deleted file mode 100644 index 07a684d8388..00000000000 --- a/src/intel/vulkan/anv_extensions_gen.py +++ /dev/null @@ -1,70 +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 os.path -import re -import sys -import xml.etree.ElementTree as et - -from anv_extensions import * - -VULKAN_UTIL = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../vulkan/util')) -sys.path.append(VULKAN_UTIL) - -from vk_extensions_gen import * - -def get_xml_patch_version(xml_file): - xml = et.parse(xml_file) - for d in xml.findall('.types/type'): - if d.get('category', None) != 'define': - continue - - name = d.find('.name') - if name.text != 'VK_HEADER_VERSION': - continue; - - return name.tail.strip() - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - parser.add_argument('--out-c', help='Output C file.') - parser.add_argument('--out-h', help='Output H file.') - parser.add_argument('--xml', - help='Vulkan API XML file.', - required=True, - action='append', - dest='xml_files') - args = parser.parse_args() - - includes = [ - "perf/gen_perf.h" - ] - - max_version = MAX_API_VERSION - max_version.patch = int(get_xml_patch_version(args.xml_files[0])) - - gen_extensions('anv', args.xml_files, API_VERSIONS, max_version, - EXTENSIONS, args.out_c, args.out_h, includes) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 97b4265968f..367c7bd13c5 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -91,7 +91,6 @@ struct gen_perf_query_result; #include "anv_android.h" #include "anv_entrypoints.h" -#include "anv_extensions.h" #include "isl/isl.h" #include "dev/gen_debug.h" @@ -1094,11 +1093,6 @@ struct anv_instance { VkResult anv_init_wsi(struct anv_physical_device *physical_device); void anv_finish_wsi(struct anv_physical_device *physical_device); -extern const struct vk_instance_extension_table anv_instance_extensions_supported; -uint32_t anv_physical_device_api_version(struct anv_physical_device *dev); -bool anv_physical_device_extension_supported(struct anv_physical_device *dev, - const char *name); - struct anv_queue_submit { struct anv_cmd_buffer * cmd_buffer; diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index d3d72d5a15a..0116c6c1030 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -18,8 +18,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -anv_extensions_py = files('anv_extensions.py') - anv_entrypoints = custom_target( 'anv_entrypoints', input : [vk_entrypoints_gen, vk_api_xml], @@ -34,28 +32,6 @@ anv_entrypoints = custom_target( ], ) -anv_extensions_c = custom_target( - 'anv_extensions.c', - input : ['anv_extensions_gen.py', vk_api_xml], - output : 'anv_extensions.c', - command : [ - prog_python, '@INPUT0@', '--xml', '@INPUT1@', - '--out-c', '@OUTPUT@', - ], - depend_files : [anv_extensions_py, vk_extensions_gen], -) - -anv_extensions_h = custom_target( - 'anv_extensions.h', - input : ['anv_extensions_gen.py', vk_api_xml], - output : 'anv_extensions.h', - command : [ - prog_python, '@INPUT0@', '--xml', '@INPUT1@', - '--out-h', '@OUTPUT@', - ], - depend_files : anv_extensions_py, -) - intel_icd = custom_target( 'intel_icd', input : [vk_icd_gen, vk_api_xml], @@ -88,7 +64,7 @@ foreach g : [['70', ['gen7_cmd_buffer.c']], ['75', ['gen7_cmd_buffer.c']], _gen = g[0] libanv_gen_libs += static_library( 'anv_gen@0@'.format(_gen), - [anv_gen_files, g[1], anv_entrypoints[0], anv_extensions_h], + [anv_gen_files, g[1], anv_entrypoints[0]], include_directories : [ inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_compiler, inc_intel, inc_vulkan_wsi, ], @@ -181,7 +157,7 @@ endif libanv_common = static_library( 'anv_common', [ - libanv_files, anv_entrypoints, anv_extensions_c, anv_extensions_h, sha1_h, + libanv_files, anv_entrypoints, sha1_h, gen_xml_pack, ], include_directories : [ @@ -195,7 +171,7 @@ libanv_common = static_library( libvulkan_intel = shared_library( 'vulkan_intel', - [files('anv_gem.c'), anv_entrypoints[0], anv_extensions_h], + [files('anv_gem.c'), anv_entrypoints[0]], include_directories : [ inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_intel, inc_compiler, inc_vulkan_wsi, ], @@ -230,7 +206,7 @@ endif if with_tests libvulkan_intel_test = static_library( 'vulkan_intel_test', - [files('anv_gem_stubs.c'), anv_entrypoints[0], anv_extensions_h], + [files('anv_gem_stubs.c'), anv_entrypoints[0]], include_directories : [ inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_intel, inc_compiler, inc_vulkan_wsi, ], @@ -254,7 +230,7 @@ if with_tests 'anv_@0@'.format(t), executable( t, - ['tests/@0@.c'.format(t), anv_entrypoints[0], anv_extensions_h], + ['tests/@0@.c'.format(t), anv_entrypoints[0]], c_args : [ c_sse2_args ], link_with : libvulkan_intel_test, dependencies : [dep_libdrm, dep_thread, dep_m, dep_valgrind, idep_vulkan_util, ],