Skip to content

Commit d27205d

Browse files
Fix: Swapchain recreation - validation errors (KhronosGroup#1319)
* Fix: Incorrect enablement swapchain maintenance1 * Copyright * Introduces allow_maintenance1 to remove th dual use of has_maitenance1 * Improved comment
1 parent edfc68a commit d27205d

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

samples/api/swapchain_recreation/swapchain_recreation.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ SwapchainRecreation::SwapchainRecreation()
904904
else
905905
{
906906
LOGI("Disabling usage of VK_EXT_surface_maintenance1 due to USE_MAINTENANCE1=no");
907+
allow_maintenance1 = false;
907908
}
908909
}
909910

@@ -973,6 +974,17 @@ SwapchainRecreation::~SwapchainRecreation()
973974
}
974975
}
975976

977+
void SwapchainRecreation::request_gpu_features(vkb::PhysicalDevice &gpu)
978+
{
979+
if (allow_maintenance1)
980+
{
981+
REQUEST_OPTIONAL_FEATURE(gpu,
982+
VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT,
983+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT,
984+
swapchainMaintenance1);
985+
}
986+
}
987+
976988
std::unique_ptr<vkb::Device> SwapchainRecreation::create_device(vkb::PhysicalDevice &gpu)
977989
{
978990
std::unique_ptr<vkb::Device> device = vkb::VulkanSampleC::create_device(gpu);

samples/api/swapchain_recreation/swapchain_recreation.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2023-2024, Google
1+
/* Copyright (c) 2023-2025, Google
22
*
33
* SPDX-License-Identifier: Apache-2.0
44
*
@@ -112,8 +112,12 @@ class SwapchainRecreation : public vkb::VulkanSampleC
112112
/// Submission and present queue.
113113
const vkb::Queue *queue = nullptr;
114114

115+
/// Allow enabling VK_EXT_surface_maintenance1 and VK_EXT_swapchain_maintenance1.
116+
///
117+
/// Can be set to false by setting environment variable `USE_MAINTENANCE1=no`
118+
bool allow_maintenance1 = true;
115119
/// Whether the VK_EXT_surface_maintenance1 and VK_EXT_swapchain_maintenance1 extensions are
116-
/// to be used.
120+
/// enabled.
117121
bool has_maintenance1 = false;
118122

119123
/// Surface data.
@@ -168,6 +172,8 @@ class SwapchainRecreation : public vkb::VulkanSampleC
168172
// User toggles.
169173
bool recreate_swapchain_on_present_mode_change = false;
170174

175+
// from vkb::VulkanSample
176+
void request_gpu_features(vkb::PhysicalDevice &gpu) override;
171177
std::unique_ptr<vkb::Device> create_device(vkb::PhysicalDevice &gpu) override;
172178

173179
void get_queue();

0 commit comments

Comments
 (0)