From 3b006f4fe28006d320c60fd2b4393fd3f27eacd7 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Tue, 27 Jul 2021 19:15:32 -0300 Subject: renderer_vulkan: Add setting to log pipeline statistics Use VK_KHR_pipeline_executable_properties when enabled and available to log statistics about the pipeline cache in a game. For example, this is on Turing GPUs when generating a pipeline cache from Super Smash Bros. Ultimate: Average pipeline statistics ========================================== Code size: 6433.167 Register count: 32.939 More advanced results could be presented, at the moment it's just an average of all 3D and compute pipelines. --- src/video_core/vulkan_common/vulkan_device.cpp | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/video_core/vulkan_common/vulkan_device.cpp') diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 44afdc1cd..8e56a89e1 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -526,6 +526,17 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR SetNext(next, workgroup_layout); } + VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR executable_properties; + if (khr_pipeline_executable_properties) { + LOG_INFO(Render_Vulkan, "Enabling shader feedback, expect slower shader build times"); + executable_properties = { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR, + .pNext = nullptr, + .pipelineExecutableInfo = VK_TRUE, + }; + SetNext(next, executable_properties); + } + if (!ext_depth_range_unrestricted) { LOG_INFO(Render_Vulkan, "Device doesn't support depth range unrestricted"); } @@ -824,6 +835,7 @@ std::vector Device::LoadExtensions(bool requires_surface) { bool has_khr_shader_float16_int8{}; bool has_khr_workgroup_memory_explicit_layout{}; + bool has_khr_pipeline_executable_properties{}; bool has_ext_subgroup_size_control{}; bool has_ext_transform_feedback{}; bool has_ext_custom_border_color{}; @@ -878,6 +890,10 @@ std::vector Device::LoadExtensions(bool requires_surface) { test(nv_device_diagnostics_config, VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, true); } + if (Settings::values.renderer_shader_feedback) { + test(has_khr_pipeline_executable_properties, + VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME, false); + } } VkPhysicalDeviceFeatures2KHR features{}; features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; @@ -1033,6 +1049,19 @@ std::vector Device::LoadExtensions(bool requires_surface) { khr_workgroup_memory_explicit_layout = true; } } + if (has_khr_pipeline_executable_properties) { + VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR executable_properties; + executable_properties.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR; + executable_properties.pNext = nullptr; + features.pNext = &executable_properties; + physical.GetFeatures2KHR(features); + + if (executable_properties.pipelineExecutableInfo) { + extensions.push_back(VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME); + khr_pipeline_executable_properties = true; + } + } if (khr_push_descriptor) { VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor; push_descriptor.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR; -- cgit v1.2.3