@@ -3038,6 +3038,102 @@ TEST_F(PositiveWsi, PresentTimings) {
30383038 }
30393039}
30403040
3041+ TEST_F (PositiveWsi, PresentTimingsCalibrateableTimeDomains) {
3042+ SetTargetApiVersion (VK_API_VERSION_1_1);
3043+ AddSurfaceExtension ();
3044+ AddRequiredExtensions (VK_KHR_SWAPCHAIN_EXTENSION_NAME);
3045+ AddRequiredExtensions (VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME);
3046+ AddRequiredExtensions (VK_EXT_PRESENT_TIMING_EXTENSION_NAME);
3047+ AddRequiredFeature (vkt::Feature::presentTiming);
3048+ RETURN_IF_SKIP (Init ());
3049+ RETURN_IF_SKIP (InitSurface ());
3050+ InitSwapchainInfo ();
3051+
3052+ if (IsPlatformMockICD ()) {
3053+ GTEST_SKIP () << " Skipping on mock icd because time domains cannot be queried." ;
3054+ }
3055+
3056+ VkSurfaceCapabilities2KHR capabilities2 = vku::InitStructHelper ();
3057+ VkPhysicalDeviceSurfaceInfo2KHR surface_info = vku::InitStructHelper ();
3058+ surface_info.surface = m_surface;
3059+ vk::GetPhysicalDeviceSurfaceCapabilities2KHR (gpu_, &surface_info, &capabilities2);
3060+
3061+ VkPresentTimingSurfaceCapabilitiesEXT present_timing_surface_capabilities = vku::InitStructHelper ();
3062+ VkSurfaceCapabilities2KHR surface_capabilities = vku::InitStructHelper (&present_timing_surface_capabilities);
3063+ vk::GetPhysicalDeviceSurfaceCapabilities2KHR (gpu_, &surface_info, &surface_capabilities);
3064+
3065+ uint32_t present_mode_count = 0 ;
3066+ vk::GetPhysicalDeviceSurfacePresentModesKHR (gpu_, m_surface, &present_mode_count, nullptr );
3067+ if (present_mode_count == 0 ) {
3068+ GTEST_SKIP () << " No present modes supported" ;
3069+ }
3070+
3071+ std::vector<VkPresentModeKHR> present_modes (present_mode_count);
3072+ vk::GetPhysicalDeviceSurfacePresentModesKHR (gpu_, m_surface, &present_mode_count, present_modes.data ());
3073+
3074+ VkSwapchainCreateInfoKHR swapchain_ci = vku::InitStructHelper ();
3075+ swapchain_ci.flags = VK_SWAPCHAIN_CREATE_PRESENT_TIMING_BIT_EXT | VK_SWAPCHAIN_CREATE_PRESENT_ID_2_BIT_KHR;
3076+ swapchain_ci.surface = m_surface;
3077+ swapchain_ci.minImageCount = m_surface_capabilities.minImageCount ;
3078+ swapchain_ci.imageFormat = m_surface_formats[0 ].format ;
3079+ swapchain_ci.imageColorSpace = m_surface_formats[0 ].colorSpace ;
3080+ swapchain_ci.imageExtent = m_surface_capabilities.minImageExtent ;
3081+ swapchain_ci.imageArrayLayers = 1 ;
3082+ swapchain_ci.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3083+ swapchain_ci.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
3084+ swapchain_ci.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
3085+ swapchain_ci.compositeAlpha = m_surface_composite_alpha;
3086+ swapchain_ci.presentMode = present_modes[0 ];
3087+ swapchain_ci.clipped = VK_FALSE;
3088+ swapchain_ci.oldSwapchain = 0 ;
3089+ vkt::Swapchain swapchain (*m_device, swapchain_ci);
3090+
3091+ uint32_t time_domain_count = 0u ;
3092+ vk::GetPhysicalDeviceCalibrateableTimeDomainsKHR (gpu_, &time_domain_count, nullptr );
3093+ std::vector<VkTimeDomainKHR> time_domains (time_domain_count);
3094+ vk::GetPhysicalDeviceCalibrateableTimeDomainsKHR (Gpu (), &time_domain_count, time_domains.data ());
3095+
3096+ VkTimeDomainKHR non_present_stage_time_domain = VK_TIME_DOMAIN_MAX_ENUM_KHR;
3097+ bool found = false ;
3098+ for (uint32_t i = 0 ; i < time_domain_count; ++i) {
3099+ if (time_domains[i] == VK_TIME_DOMAIN_PRESENT_STAGE_LOCAL_EXT) {
3100+ found = true ;
3101+ break ;
3102+ } else {
3103+ non_present_stage_time_domain = time_domains[i];
3104+ }
3105+ }
3106+ if (!found) {
3107+ GTEST_SKIP () << " VK_TIME_DOMAIN_PRESENT_STAGE_LOCAL_EXT not supported" ;
3108+ }
3109+
3110+ std::vector<VkPresentStageFlagsEXT> present_stages_to_test{VK_PRESENT_STAGE_QUEUE_OPERATIONS_END_BIT_EXT,
3111+ VK_PRESENT_STAGE_REQUEST_DEQUEUED_BIT_EXT};
3112+ if (non_present_stage_time_domain != VK_TIME_DOMAIN_MAX_ENUM_KHR) {
3113+ present_stages_to_test.push_back (0 );
3114+ }
3115+
3116+ std::vector<VkSwapchainCalibratedTimestampInfoEXT> swapchain_timestamp_infos (present_stages_to_test.size ());
3117+ std::vector<VkCalibratedTimestampInfoKHR> timestamp_infos (present_stages_to_test.size ());
3118+ for (size_t i = 0 ; i < present_stages_to_test.size (); i++) {
3119+ swapchain_timestamp_infos[i] = vku::InitStructHelper ();
3120+ swapchain_timestamp_infos[i].swapchain = swapchain;
3121+ swapchain_timestamp_infos[i].presentStage = present_stages_to_test[i];
3122+
3123+ timestamp_infos[i] = vku::InitStructHelper (&swapchain_timestamp_infos[i]);
3124+ timestamp_infos[i].timeDomain =
3125+ present_stages_to_test[i] ? VK_TIME_DOMAIN_PRESENT_STAGE_LOCAL_EXT : non_present_stage_time_domain;
3126+ }
3127+
3128+ // Disable this error for now; the spec incorrectly labelled this VUIDs as implicit, when in-fact it
3129+ // only applies when VkSwapchainCalibratedTimestampInfoEXT::presentStage is VK_TIME_DOMAIN_PRESENT_STAGE_LOCAL_EXT
3130+ m_errorMonitor->SetAllowedFailureMsg (" VUID-VkSwapchainCalibratedTimestampInfoEXT-presentStage-requiredbitmask" );
3131+
3132+ std::vector<uint64_t > timestamps (present_stages_to_test.size ());
3133+ uint64_t max_deviation{};
3134+ vk::GetCalibratedTimestampsKHR (device (), timestamp_infos.size (), timestamp_infos.data (), timestamps.data (), &max_deviation);
3135+ }
3136+
30413137TEST_F (PositiveWsi, PresentTimingsFull) {
30423138 SetTargetApiVersion (VK_API_VERSION_1_1);
30433139 AddSurfaceExtension ();
0 commit comments