maps: persist a Vulkan pipeline cache across launches
- Commit
d4f2efbbb7b745b550c48b2c421d64d80f49b065- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-11 21:43 UTC (2 months ago)
- Parents
b9f3674
Diff
library/map/src/main/rust/src/bridge.rs
diff --git a/library/map/src/main/rust/src/bridge.rs b/library/map/src/main/rust/src/bridge.rsindex 075eff9588..11dd751c70 100644--- a/library/map/src/main/rust/src/bridge.rs+++ b/library/map/src/main/rust/src/bridge.rs@@ -218,7 +218,14 @@ pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_create<'l>( } unsafe { ANativeWindow_acquire(window) }; - let renderer = match unsafe { Renderer::new(window, width.max(1) as u32, height.max(1) as u32) } {+ let renderer = match unsafe {+ Renderer::new(+ window,+ width.max(1) as u32,+ height.max(1) as u32,+ std::path::Path::new(&cache_dir),+ )+ } { Ok(r) => r, Err(e) => { log(&format!("Vulkan init failed: {e}"));
library/map/src/main/rust/src/lib.rs
diff --git a/library/map/src/main/rust/src/lib.rs b/library/map/src/main/rust/src/lib.rsindex 590b06cd3c..fc1b0c1919 100644--- a/library/map/src/main/rust/src/lib.rs+++ b/library/map/src/main/rust/src/lib.rs@@ -35,6 +35,7 @@ pub mod camera; pub mod marker; pub mod overlay;+pub mod pipeline_cache; pub mod style; pub mod tess; pub mod tile;
library/map/src/main/rust/src/pipeline_cache.rs
diff --git a/library/map/src/main/rust/src/pipeline_cache.rs b/library/map/src/main/rust/src/pipeline_cache.rsnew file mode 100644index 0000000000..5a0b15a5d8--- /dev/null+++ b/library/map/src/main/rust/src/pipeline_cache.rs@@ -0,0 +1,104 @@+//! Validating a persisted `VkPipelineCache` blob before it reaches the driver.+//!+//! The bytes of a pipeline cache are opaque driver output, and they are read back from a file that+//! may have been written by different hardware, a different driver version, or a launch that died+//! part-way through the write. Vulkan defines a fixed 32-byte header precisely so this can be+//! checked, and this module is that check.+//!+//! It lives outside [`crate::vulkan`], which is Android-only, because it is pure byte parsing of+//! untrusted input and therefore exactly the kind of thing the host test suite should cover. The+//! handle management that uses it is in [`crate::vulkan::cache`].++/// `VkPipelineCacheHeaderVersionOne`: length, version, vendor, device, then the 16-byte UUID.+pub const HEADER_BYTES: usize = 32;+/// `VK_PIPELINE_CACHE_HEADER_VERSION_ONE`, the only version defined.+const HEADER_VERSION_ONE: u32 = 1;++/// Whether `bytes` is a pipeline cache the device described by `vendor_id`, `device_id` and+/// `uuid` can actually use.+///+/// The driver is required to detect a foreign blob itself, but "required to detect" is not the+/// same as "safe to hand anything to on every implementation", and the header exists to be+/// checked. Vendor and device catch a blob copied from other hardware; `uuid` is the one that+/// catches a driver update on the *same* hardware, which is the common case and the one that+/// would otherwise feed a stale blob to the shader compiler on the first frame after a system+/// update.+pub fn usable(bytes: &[u8], vendor_id: u32, device_id: u32, uuid: &[u8; 16]) -> bool {+ if bytes.len() < HEADER_BYTES {+ return false;+ }+ let word =+ |at: usize| u32::from_le_bytes([bytes[at], bytes[at + 1], bytes[at + 2], bytes[at + 3]]);+ // A future header version is allowed to be longer than 32 bytes, but it can never be longer+ // than the blob carrying it — that combination means a truncated or corrupt file.+ if word(0) as usize > bytes.len() {+ return false;+ }+ word(4) == HEADER_VERSION_ONE+ && word(8) == vendor_id+ && word(12) == device_id+ && &bytes[16..HEADER_BYTES] == uuid+}++#[cfg(test)]+mod tests {+ use super::*;++ const VENDOR: u32 = 0x5143;+ const DEVICE: u32 = 0x6030_0001;+ const UUID: [u8; 16] = [7; 16];++ /// A header, followed by `payload` bytes standing in for the driver's own data.+ fn blob(length: u32, version: u32, vendor: u32, device: u32, uuid: [u8; 16], payload: usize) -> Vec<u8> {+ let mut bytes = Vec::new();+ bytes.extend_from_slice(&length.to_le_bytes());+ bytes.extend_from_slice(&version.to_le_bytes());+ bytes.extend_from_slice(&vendor.to_le_bytes());+ bytes.extend_from_slice(&device.to_le_bytes());+ bytes.extend_from_slice(&uuid);+ bytes.resize(HEADER_BYTES + payload, 0xAB);+ bytes+ }++ #[test]+ fn a_blob_written_by_this_device_is_usable() {+ assert!(usable(&blob(32, 1, VENDOR, DEVICE, UUID, 128), VENDOR, DEVICE, &UUID));+ }++ #[test]+ fn a_blob_from_other_hardware_is_rejected() {+ let vendor = blob(32, 1, 0x10DE, DEVICE, UUID, 128);+ assert!(!usable(&vendor, VENDOR, DEVICE, &UUID), "a different vendor must not be trusted");+ let device = blob(32, 1, VENDOR, 0x0000_0002, UUID, 128);+ assert!(!usable(&device, VENDOR, DEVICE, &UUID), "a different device must not be trusted");+ }++ /// The case a vendor/device check alone misses: same phone, driver updated under it.+ #[test]+ fn a_blob_from_an_older_driver_on_the_same_gpu_is_rejected() {+ let stale = blob(32, 1, VENDOR, DEVICE, [3; 16], 128);+ assert!(!usable(&stale, VENDOR, DEVICE, &UUID));+ }++ #[test]+ fn a_truncated_blob_is_rejected() {+ let full = blob(32, 1, VENDOR, DEVICE, UUID, 128);+ let short = &full[..HEADER_BYTES - 1];+ assert!(!usable(short, VENDOR, DEVICE, &UUID), "shorter than a header");+ // A header claiming a length the file does not contain: a part-written blob.+ let overrun = blob(4096, 1, VENDOR, DEVICE, UUID, 128);+ assert!(!usable(&overrun, VENDOR, DEVICE, &UUID), "header longer than the blob");+ }++ #[test]+ fn an_unknown_header_version_is_rejected() {+ let future = blob(32, 2, VENDOR, DEVICE, UUID, 128);+ assert!(!usable(&future, VENDOR, DEVICE, &UUID));+ }++ /// What a failed write leaves behind. Must read as "cold", not panic on the slicing above.+ #[test]+ fn an_empty_blob_is_rejected_without_panicking() {+ assert!(!usable(&[], VENDOR, DEVICE, &UUID));+ }+}
library/map/src/main/rust/src/vulkan/cache.rs
diff --git a/library/map/src/main/rust/src/vulkan/cache.rs b/library/map/src/main/rust/src/vulkan/cache.rsnew file mode 100644index 0000000000..9a13df4142--- /dev/null+++ b/library/map/src/main/rust/src/vulkan/cache.rs@@ -0,0 +1,138 @@+//! The `VkPipelineCache` and its blob on disk.+//!+//! Without a cache the driver compiles every shader at pipeline-creation time, and this renderer+//! creates twelve graphics pipelines plus the pick pipeline in one go — at startup, and again on+//! every [`rebuild`](crate::vulkan::renderer) a resize or rotation triggers. That work lands+//! inside a frame on the UI thread, which is where the multi-second stalls came from.+//!+//! The in-memory half of that is what `VkPipelineCache` is for, but on its own it only helps+//! within a session: the first resize after every cold start would still pay the full compile.+//! So the blob is written back to a file and reloaded on the next launch, which is the part that+//! actually removes the stall a user sees.+//!+//! Nothing here is fatal. A missing, unreadable, corrupt or foreign blob starts the cache empty,+//! and a cache the driver refuses to create at all leaves a null handle — which is precisely the+//! behaviour this module replaced, so the map still draws.+//!+//! The header check that decides whether a blob is usable is [`crate::pipeline_cache`], kept+//! outside this Android-only module so the host suite can cover it.++use ash::vk;+use std::path::{Path, PathBuf};++/// The blob, inside the directory Kotlin hands over.+const FILE_NAME: &str = "pipelines.bin";++pub struct ShaderCache {+ /// Passed to every `create_graphics_pipelines` call. Null when the driver would not give us+ /// one, which `vkCreateGraphicsPipelines` accepts as "no cache".+ handle: vk::PipelineCache,+ /// `None` when no directory was supplied, which makes this an in-memory cache.+ path: Option<PathBuf>,+ /// Size of the blob currently on disk, so [`persist`](Self::persist) can tell an unchanged+ /// cache from one the driver has added entries to. Zero when the file was absent or rejected,+ /// so the first write always happens.+ on_disk: usize,+}++impl ShaderCache {+ /// Load the blob from `dir` if there is a usable one there, and create the cache.+ ///+ /// # Safety+ ///+ /// `device` must be live, and `physical_device` the device it was created from.+ pub unsafe fn open(+ instance: &ash::Instance,+ physical_device: vk::PhysicalDevice,+ device: &ash::Device,+ dir: Option<&Path>,+ ) -> ShaderCache {+ let path = dir.map(|dir| dir.join(FILE_NAME));+ let properties = instance.get_physical_device_properties(physical_device);+ let blob = path.as_deref().and_then(|path| {+ let bytes = std::fs::read(path).ok()?;+ crate::pipeline_cache::usable(+ &bytes,+ properties.vendor_id,+ properties.device_id,+ &properties.pipeline_cache_uuid,+ )+ .then_some(bytes)+ });++ let mut info = vk::PipelineCacheCreateInfo::default();+ if let Some(bytes) = &blob {+ info = info.initial_data(bytes);+ }+ let handle = match device.create_pipeline_cache(&info, None) {+ Ok(handle) => handle,+ // The header said this blob belongs to this device and the driver still would not take+ // it. Retry empty rather than give up the cache: an in-memory one is worth having, and+ // the next `persist` replaces the file.+ Err(_) => device+ .create_pipeline_cache(&vk::PipelineCacheCreateInfo::default(), None)+ .unwrap_or_else(|_| vk::PipelineCache::null()),+ };++ let on_disk = if handle == vk::PipelineCache::null() {+ 0+ } else {+ blob.as_ref().map_or(0, |bytes| bytes.len())+ };+ ShaderCache { handle, path, on_disk }+ }++ pub fn handle(&self) -> vk::PipelineCache {+ self.handle+ }++ /// Write the cache back, if the driver has put anything new in it.+ ///+ /// The size check is what makes this safe to call from `rebuild`, which runs inside a frame:+ /// once the blob has settled — after the first cold run — every later call reads the data back+ /// and returns without touching the disk.+ ///+ /// Temp-then-rename, as [`crate::tile::cache`] writes its entries, so a launch that dies+ /// part-way through leaves the previous blob intact rather than a truncated one.+ ///+ /// # Safety+ ///+ /// `device` must be the live device this cache was opened on.+ pub unsafe fn persist(&mut self, device: &ash::Device) {+ let Some(path) = self.path.as_deref() else {+ return;+ };+ if self.handle == vk::PipelineCache::null() {+ return;+ }+ let Ok(data) = device.get_pipeline_cache_data(self.handle) else {+ return;+ };+ if data.len() == self.on_disk || data.is_empty() {+ return;+ }+ // The directory is a subdirectory of the one Kotlin hands over and will not exist on a+ // first run. Without this the write fails silently and the cache never persists at all —+ // a failure that looks exactly like a cache that works but never helps.+ if let Some(parent) = path.parent() {+ if std::fs::create_dir_all(parent).is_err() {+ return;+ }+ }+ let temp = path.with_extension("tmp");+ if std::fs::write(&temp, &data).is_ok() && std::fs::rename(&temp, path).is_ok() {+ self.on_disk = data.len();+ } else {+ let _ = std::fs::remove_file(&temp);+ }+ }++ /// # Safety+ ///+ /// The device must be idle, and no pipeline creation in flight.+ pub unsafe fn destroy(&self, device: &ash::Device) {+ if self.handle != vk::PipelineCache::null() {+ device.destroy_pipeline_cache(self.handle, None);+ }+ }+}
library/map/src/main/rust/src/vulkan/mod.rs
diff --git a/library/map/src/main/rust/src/vulkan/mod.rs b/library/map/src/main/rust/src/vulkan/mod.rsindex f59da00f3a..92e0adf696 100644--- a/library/map/src/main/rust/src/vulkan/mod.rs+++ b/library/map/src/main/rust/src/vulkan/mod.rs@@ -9,6 +9,7 @@ //! it inherits two black-screen fixes from it — see [`swapchain`]. pub mod buffers;+pub mod cache; pub mod context; pub mod images; pub mod pick;
library/map/src/main/rust/src/vulkan/pick.rs
diff --git a/library/map/src/main/rust/src/vulkan/pick.rs b/library/map/src/main/rust/src/vulkan/pick.rsindex 9040966a21..39aaa74925 100644--- a/library/map/src/main/rust/src/vulkan/pick.rs+++ b/library/map/src/main/rust/src/vulkan/pick.rs@@ -70,7 +70,7 @@ impl Pick { /// # Safety /// /// `context` must be live; call [`destroy`](Self::destroy) while the device is idle.- pub unsafe fn new(context: &Context) -> Result<Pick, String> {+ pub unsafe fn new(context: &Context, cache: vk::PipelineCache) -> Result<Pick, String> { let device = &context.device; // One colour attachment, cleared to "miss", stored, and left in TRANSFER_SRC so the pixel@@ -130,7 +130,7 @@ impl Pick { } }; - let pipeline = match build_pipeline(device, render_pass, layout) {+ let pipeline = match build_pipeline(device, cache, render_pass, layout) { Ok(p) => p, Err(e) => { device.destroy_pipeline_layout(layout, None);@@ -452,6 +452,7 @@ impl PickTarget { /// blend), no depth or stencil, writing the slot id. unsafe fn build_pipeline( device: &ash::Device,+ cache: vk::PipelineCache, render_pass: vk::RenderPass, layout: vk::PipelineLayout, ) -> Result<vk::Pipeline, String> {@@ -534,11 +535,7 @@ unsafe fn build_pipeline( .render_pass(render_pass) .subpass(0); - let result = device.create_graphics_pipelines(- vk::PipelineCache::null(),- std::slice::from_ref(&info),- None,- );+ let result = device.create_graphics_pipelines(cache, std::slice::from_ref(&info), None); device.destroy_shader_module(vert, None); device.destroy_shader_module(frag, None); result.map(|pipelines| pipelines[0]).map_err(|(_, e)| format!("pick create_graphics_pipelines {e:?}"))
library/map/src/main/rust/src/vulkan/pipeline.rs
diff --git a/library/map/src/main/rust/src/vulkan/pipeline.rs b/library/map/src/main/rust/src/vulkan/pipeline.rsindex c701c255df..68e2db3911 100644--- a/library/map/src/main/rust/src/vulkan/pipeline.rs+++ b/library/map/src/main/rust/src/vulkan/pipeline.rs@@ -241,11 +241,19 @@ impl Pipelines { /// descriptor set layout [`images::AtlasSet`] built — `None` on a host /// build that never creates pipelines (tests link this module for the /// [`Push`] size asserts only).+ ///+ /// `cache` is [`crate::vulkan::cache::ShaderCache`]'s handle, or+ /// [`vk::PipelineCache::null`] for no cache. Every one of the twelve pipelines below is built+ /// through it, and they share shader modules heavily — `fill` is also `depth`, `mask` and+ /// `scrim`, and `symbol`'s billboard vertex shader is also `icon`'s — so even a cold cache+ /// pays for itself within this one call: the driver populates it as it goes, and the repeats+ /// hit rather than recompile. pub unsafe fn new( device: &ash::Device, render_pass: vk::RenderPass, samples: vk::SampleCountFlags, atlas_layout: Option<vk::DescriptorSetLayout>,+ cache: vk::PipelineCache, ) -> Result<Pipelines, String> { let push_range = vk::PushConstantRange::default() .stage_flags(vk::ShaderStageFlags::VERTEX | vk::ShaderStageFlags::FRAGMENT)@@ -410,6 +418,7 @@ impl Pipelines { &fill_attributes, Stencil::Ignore, Depth::Off,+ cache, ); let line = build( device,@@ -422,6 +431,7 @@ impl Pipelines { &line_attributes, Stencil::Ignore, Depth::Off,+ cache, ); // Road carriageways. Same fixed-function state as `line` — a carriageway is flat basemap, // so depth stays off and layer order does the compositing exactly as it does for a stroke.@@ -438,6 +448,7 @@ impl Pipelines { &ribbon_attributes, Stencil::Ignore, Depth::Off,+ cache, ); // The depth-tested variant of `fill`: same shaders and vertex format, depth test + write // on. WS-A/WS-G draw their extruded/relief geometry through pipelines built like this so@@ -453,6 +464,7 @@ impl Pipelines { &fill_attributes, Stencil::Ignore, Depth::TestWrite,+ cache, ); // The 3D building pipeline: its own shaders and 7-float vertex, depth test + write on so // buildings occlude correctly. Push-only layout — colour is per-vertex, not a uniform.@@ -467,6 +479,7 @@ impl Pipelines { &building_attributes, Stencil::Ignore, Depth::TestWrite,+ cache, ); // The 3D terrain pipeline: its own shaders and 6-float vertex, depth test + write on so the // relief occludes correctly. Push-only layout — the ground colour is the pushed `earth`@@ -483,6 +496,7 @@ impl Pipelines { &terrain_attributes, Stencil::Ignore, Depth::TestWrite,+ cache, ); // The symbol pipeline needs the atlas descriptor set, so it gets its own@@ -529,6 +543,7 @@ impl Pipelines { &symbol_billboard_attributes, Stencil::Ignore, Depth::Off,+ cache, ); // POI icons: the billboard vertex shader (so they face the camera under tilt, exactly as // the text beside them does) paired with the sprite fragment shader (because an icon is a@@ -544,6 +559,7 @@ impl Pipelines { &symbol_billboard_attributes, Stencil::Ignore, Depth::Off,+ cache, ); let sprite = build( device,@@ -556,6 +572,7 @@ impl Pipelines { &symbol_attributes, Stencil::Ignore, Depth::Off,+ cache, ); // The overlay quad is position-only in -1..1, so it shares the fill vertex@@ -571,6 +588,7 @@ impl Pipelines { &fill_attributes, Stencil::Ignore, Depth::Off,+ cache, ); // The region mask and its scrim. Both are position-only quads/triangles in the same@@ -587,6 +605,7 @@ impl Pipelines { &fill_attributes, Stencil::Write, Depth::Off,+ cache, ); let scrim = build( device,@@ -599,6 +618,7 @@ impl Pipelines { &fill_attributes, Stencil::TestOutside, Depth::Off,+ cache, ); // The modules are only needed while the pipelines are being created.@@ -724,6 +744,7 @@ pub enum Depth { TestWrite, } +#[allow(clippy::too_many_arguments)] unsafe fn build( device: &ash::Device, layout: vk::PipelineLayout,@@ -735,6 +756,7 @@ unsafe fn build( attributes: &[vk::VertexInputAttributeDescription], stencil: Stencil, depth: Depth,+ cache: vk::PipelineCache, ) -> Result<vk::Pipeline, String> { let entry = c"main"; let stages = [@@ -847,7 +869,7 @@ unsafe fn build( .subpass(0); device- .create_graphics_pipelines(vk::PipelineCache::null(), std::slice::from_ref(&info), None)+ .create_graphics_pipelines(cache, std::slice::from_ref(&info), None) .map(|pipelines| pipelines[0]) .map_err(|(_, e)| format!("create_graphics_pipelines {e:?}")) }
library/map/src/main/rust/src/vulkan/renderer.rs
diff --git a/library/map/src/main/rust/src/vulkan/renderer.rs b/library/map/src/main/rust/src/vulkan/renderer.rsindex 94a3c40389..8d55f41cdf 100644--- a/library/map/src/main/rust/src/vulkan/renderer.rs+++ b/library/map/src/main/rust/src/vulkan/renderer.rs@@ -8,6 +8,7 @@ use crate::style::{Anchor, Layer, LayerKind, Palette}; use crate::tile::geometry::{self, TileMesh}; use crate::tile::select; use crate::vulkan::buffers::{Buffer, ScratchRing};+use crate::vulkan::cache::ShaderCache; use crate::vulkan::context::{ANativeWindow, Context}; use crate::vulkan::images::{AtlasSet, SampledImage}; use crate::vulkan::pick::Pick;@@ -378,6 +379,11 @@ pub struct Renderer { tiles: HashMap<u64, ResidentTile>, /// Retired buffers waiting for the frames that might still reference them. retiring: Vec<(usize, ResidentTile)>,+ /// The persistent shader-compilation cache, seeded from disk at startup and shared by every+ /// pipeline and by [`Pick`]. Outlives [`Pipelines`], which is destroyed and rebuilt whenever+ /// the render pass changes — that is the whole point, since the rebuild is what used to+ /// recompile twelve pipelines inside a frame.+ pipeline_cache: ShaderCache, /// Transient per-frame symbol buffers, same grace rule as `retiring`. transients: Vec<TransientBuffers>, /// One scratch bump allocator per frame in flight, which every symbol draw's geometry is@@ -488,15 +494,30 @@ impl Renderer { window: *mut ANativeWindow, width: u32, height: u32,+ cache_dir: &std::path::Path, ) -> Result<Renderer, String> { let context = Context::new(window)?; let swapchain = Swapchain::new(&context, width, height)?; let atlas_set = AtlasSet::new(&context.device)?;+ // Before any pipeline is created, so the very first launch's twelve compiles are the ones+ // that get recorded. Its own subdirectory of `cache_dir`, not `cache_dir` itself: the tile+ // range cache deletes every *file* in its directory when the archive origin changes+ // (`tile::cache::RangeCache::invalidate_on_origin_change`), so a blob there would be wiped+ // by an unrelated archive republish and read as a random cold start. That deletion is+ // `remove_file`, which does not recurse into a subdirectory.+ let cache_path = cache_dir.join("pipeline");+ let mut pipeline_cache = ShaderCache::open(+ &context.instance,+ context.physical_device,+ &context.device,+ Some(&cache_path),+ ); let pipelines = Pipelines::new( &context.device, swapchain.render_pass, swapchain.samples, Some(atlas_set.layout),+ pipeline_cache.handle(), )?; let pool_info = vk::CommandPoolCreateInfo::default()@@ -594,7 +615,11 @@ impl Renderer { // The offscreen id-buffer pass for tap picking. Self-contained and format-stable, so it is // built once here and survives swapchain rebuilds (only its target is resized).- let pick = Pick::new(&context)?;+ let pick = Pick::new(&context, pipeline_cache.handle())?;+ // Everything that compiles a shader has now run once. On a cold cache this is the write+ // that makes every later launch cheap; on a warm one the blob has not grown and this does+ // nothing.+ pipeline_cache.persist(&context.device); Ok(Renderer { context,@@ -610,6 +635,7 @@ impl Renderer { frame_index: 0, tiles: HashMap::new(), retiring: Vec::new(),+ pipeline_cache, transients: Vec::new(), scratch: (0..FRAMES_IN_FLIGHT).map(|_| ScratchRing::default()).collect(), window,@@ -3087,7 +3113,10 @@ impl Renderer { fn rebuild(&mut self) -> Result<(), String> { unsafe { let _ = self.context.device.device_wait_idle();- // The pipelines reference the old render pass, so they go with it.+ // The pipelines reference the old render pass, so they go with it. This is the+ // expensive part and the reason `pipeline_cache` exists: without it every one of the+ // twelve is recompiled from SPIR-V here, on the Choreographer callback, inside a+ // frame. self.pipelines.destroy(&self.context.device); self.swapchain.destroy(&self.context.device); self.swapchain = Swapchain::new(&self.context, self.width, self.height)?;@@ -3096,7 +3125,11 @@ impl Renderer { self.swapchain.render_pass, self.swapchain.samples, Some(self.atlas_set.layout),+ self.pipeline_cache.handle(), )?;+ // Only writes if the driver actually added something — a rebuild to the same sample+ // count adds nothing, so the steady state costs no I/O on the frame path.+ self.pipeline_cache.persist(&self.context.device); } self.width = self.swapchain.extent.width; self.height = self.swapchain.extent.height;@@ -3255,6 +3288,7 @@ impl Drop for Renderer { self.quad.vertices.destroy(&self.context.device); self.quad.indices.destroy(&self.context.device); self.pick.destroy(&self.context.device);+ self.pipeline_cache.destroy(&self.context.device); self.atlas_set.destroy(&self.context.device); self.pipelines.destroy(&self.context.device); self.swapchain.destroy(&self.context.device);