diff --git a/layer/VkLayer_window_system_integration.json b/layer/VkLayer_window_system_integration.json index accf319..8ff1815 100644 --- a/layer/VkLayer_window_system_integration.json +++ b/layer/VkLayer_window_system_integration.json @@ -15,7 +15,8 @@ {"name" : "VK_KHR_wayland_surface", "spec_version" : "6"}, {"name" : "VK_KHR_surface", "spec_version" : "25"}, {"name" : "VK_KHR_display", "spec_version" : "23"}, - {"name" : "VK_KHR_get_surface_capabilities2", "spec_version" : "1"} + {"name" : "VK_KHR_get_surface_capabilities2", "spec_version" : "1"}, + {"name" : "VK_EXT_surface_maintenance1", "spec_version" : "1"} ], "device_extensions": [ {"name": "VK_KHR_shared_presentable_image", "spec_version": "1", "entrypoints": ["vkGetSwapchainStatusKHR"]}, @@ -34,7 +35,8 @@ "vkGetDeviceGroupSurfacePresentModesKHR", "vkGetPhysicalDevicePresentRectanglesKHR" ] - } + }, + {"name": "VK_EXT_swapchain_maintenance1", "spec_version": "1"} ], "disable_environment": { "DISABLE_WSI_LAYER": "1" diff --git a/layer/layer.cpp b/layer/layer.cpp index b0337e9..f7b040c 100644 --- a/layer/layer.cpp +++ b/layer/layer.cpp @@ -311,6 +311,15 @@ VKAPI_ATTR VkResult create_device(VkPhysicalDevice physicalDevice, const VkDevic } #endif + auto *physical_device_swapchain_maintenance1_features = + util::find_extension( + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT, pCreateInfo->pNext); + if (physical_device_swapchain_maintenance1_features != nullptr) + { + layer::device_private_data::get(*pDevice).set_swapchain_maintenance1_enabled( + physical_device_swapchain_maintenance1_features->swapchainMaintenance1); + } + return VK_SUCCESS; } @@ -415,6 +424,14 @@ wsi_layer_vkGetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, instance.has_image_compression_support(physicalDevice); } #endif + + auto *physical_device_swapchain_maintenance1_features = + util::find_extension( + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT, pFeatures->pNext); + if (physical_device_swapchain_maintenance1_features != nullptr) + { + physical_device_swapchain_maintenance1_features->swapchainMaintenance1 = true; + } } #define GET_PROC_ADDR(func) \ diff --git a/layer/private_data.cpp b/layer/private_data.cpp index a9ff876..f723b98 100644 --- a/layer/private_data.cpp +++ b/layer/private_data.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, 2024 Arm Limited. + * Copyright (c) 2018-2024 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -395,6 +395,7 @@ device_private_data::device_private_data(instance_private_data &inst_data, VkPhy #if WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN , compression_control_enabled{ false } #endif /* WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN */ + , swapchain_maintenance1_enabled{ false } /* clang-format on */ { } @@ -546,4 +547,15 @@ bool device_private_data::is_swapchain_compression_control_enabled() const return compression_control_enabled; } #endif /* WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN */ + +void device_private_data::set_swapchain_maintenance1_enabled(bool enable) +{ + swapchain_maintenance1_enabled = enable; +} + +bool device_private_data::is_swapchain_maintenance1_enabled() const +{ + return swapchain_maintenance1_enabled; +} + } /* namespace layer */ diff --git a/layer/private_data.hpp b/layer/private_data.hpp index 5e52d7e..db79999 100644 --- a/layer/private_data.hpp +++ b/layer/private_data.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, 2024 Arm Limited. + * Copyright (c) 2018-2024 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -803,6 +803,20 @@ public: bool is_swapchain_compression_control_enabled() const; #endif /* WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN */ + /** + * @brief Selectively enable/disable the swapchain maintenance1 features for this device. + * + * @param enable Value to set swapchain_maintenance1_enabled member variable. + */ + void set_swapchain_maintenance1_enabled(bool enable); + + /** + * @brief Check whether the swapchain maintenance1 features are enabled for this device. + * + * @return true if enabled, false otherwise. + */ + bool is_swapchain_maintenance1_enabled() const; + private: /* Allow util::allocator to access the private constructor */ friend util::allocator; @@ -845,6 +859,11 @@ private: */ bool compression_control_enabled; #endif /* WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN */ + + /** + * @brief Stores whether the device has enabled support for the swapchain maintenance1 features. + */ + bool swapchain_maintenance1_enabled; }; } /* namespace layer */