feat(vulkan): select readback-capable swapchains
This commit is contained in:
@@ -241,6 +241,7 @@ impl VulkanSmokeRenderer {
|
||||
enabled_extension_count: 0,
|
||||
swapchain_extent: (0, 0),
|
||||
swapchain_image_count: 0,
|
||||
swapchain_image_usage: 0,
|
||||
},
|
||||
};
|
||||
renderer.rebuild_swapchain_resources(false)?;
|
||||
@@ -268,6 +269,7 @@ impl VulkanSmokeRenderer {
|
||||
.unwrap_or(u32::MAX),
|
||||
swapchain_extent: swapchain_ref.report.plan.extent,
|
||||
swapchain_image_count: swapchain_ref.report.image_count,
|
||||
swapchain_image_usage: swapchain_ref.report.plan.image_usage,
|
||||
};
|
||||
Ok(renderer)
|
||||
}
|
||||
@@ -571,11 +573,13 @@ impl VulkanSmokeRenderer {
|
||||
let frame_sync = create_frame_sync(device)?;
|
||||
let swapchain_extent = self.swapchain_ref()?.report.plan.extent;
|
||||
let swapchain_image_count = self.swapchain_ref()?.report.image_count;
|
||||
let swapchain_image_usage = self.swapchain_ref()?.report.plan.image_usage;
|
||||
let resources = resources.commit();
|
||||
self.images_in_flight = vec![vk::Fence::null(); resources.image_views.len()];
|
||||
self.frame_sync = frame_sync;
|
||||
self.report.swapchain_extent = swapchain_extent;
|
||||
self.report.swapchain_image_count = swapchain_image_count;
|
||||
self.report.swapchain_image_usage = swapchain_image_usage;
|
||||
self.swapchain_resources = Some(resources);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -457,6 +457,8 @@ pub struct VulkanSmokeRendererReport {
|
||||
pub swapchain_extent: (u32, u32),
|
||||
/// Current swapchain image count.
|
||||
pub swapchain_image_count: u32,
|
||||
/// Current swapchain image-usage flags as raw Vulkan bits.
|
||||
pub swapchain_image_usage: u32,
|
||||
}
|
||||
|
||||
/// Measured validation counters from the live smoke loop.
|
||||
|
||||
@@ -185,7 +185,7 @@ pub fn create_vulkan_swapchain_probe_for_extent(
|
||||
height: plan.extent.1,
|
||||
})
|
||||
.image_array_layers(1)
|
||||
.image_usage(vk::ImageUsageFlags::COLOR_ATTACHMENT)
|
||||
.image_usage(vk::ImageUsageFlags::from_raw(plan.image_usage))
|
||||
.image_sharing_mode(sharing_mode)
|
||||
.queue_family_indices(&queue_family_indices)
|
||||
.pre_transform(raw_capabilities.current_transform)
|
||||
|
||||
@@ -94,6 +94,7 @@ fn frame_submission_plan_json_is_stable() -> Result<(), RenderError> {
|
||||
},
|
||||
present_mode: vk::PresentModeKHR::FIFO.as_raw(),
|
||||
image_count: 3,
|
||||
image_usage: vk::ImageUsageFlags::COLOR_ATTACHMENT.as_raw(),
|
||||
};
|
||||
|
||||
let plan = plan_vulkan_frame_submission(&swapchain, &commands)?;
|
||||
@@ -543,6 +544,23 @@ fn swapchain_plan_prefers_srgb_mailbox_and_clamps_extent() {
|
||||
assert_eq!(plan.present_mode, vk::PresentModeKHR::MAILBOX.as_raw());
|
||||
assert_eq!(plan.extent, (1024, 720));
|
||||
assert_eq!(plan.image_count, 3);
|
||||
assert_eq!(
|
||||
plan.image_usage,
|
||||
vk::ImageUsageFlags::COLOR_ATTACHMENT.as_raw()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn swapchain_plan_enables_transfer_source_when_surface_supports_it() {
|
||||
let mut request = swapchain_request();
|
||||
request.capabilities.supported_usage_flags |= vk::ImageUsageFlags::TRANSFER_SRC.as_raw();
|
||||
|
||||
let plan = plan_vulkan_swapchain(&request).expect("swapchain plan");
|
||||
|
||||
assert_eq!(
|
||||
plan.image_usage,
|
||||
(vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::TRANSFER_SRC).as_raw()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -606,7 +624,7 @@ fn swapchain_plan_json_and_recreation_reports_are_stable() {
|
||||
let plan = plan_vulkan_swapchain(&swapchain_request()).expect("swapchain plan");
|
||||
assert_eq!(
|
||||
render_swapchain_plan_json(&plan),
|
||||
"{\"schema\":1,\"extent\":[1024,720],\"format\":50,\"color_space\":0,\"present_mode\":1,\"image_count\":3}"
|
||||
"{\"schema\":1,\"extent\":[1024,720],\"format\":50,\"color_space\":0,\"present_mode\":1,\"image_count\":3,\"image_usage\":16}"
|
||||
);
|
||||
|
||||
let report = swapchain_recreation_report(
|
||||
|
||||
Reference in New Issue
Block a user