From: Josh Simmons Date: Sat, 5 Apr 2025 21:26:07 +0000 (+0200) Subject: misc: Update to Rust 2024 edition X-Git-Url: https://git.nega.tv//gitweb.cgi?a=commitdiff_plain;h=6b8ad2df212cfdcc456d9854160125f97596ab28;p=josh%2Fnarcissus misc: Update to Rust 2024 edition --- diff --git a/Cargo.lock b/Cargo.lock index d2bf7d2..645e795 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "blake3-smol" @@ -19,9 +19,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "fast-float2" @@ -31,9 +31,9 @@ checksum = "f8eb564c5c7423d25c886fb561d1e4ee69f72354d16918afa32c08811f6b6a55" [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -42,9 +42,9 @@ dependencies = [ [[package]] name = "gmp-mpfr-sys" -version = "1.6.2" +version = "1.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "362a6cc3cbe9f41aebe49c03b91aee8fa8fc69d32fb90533f6ed965a882e08e3" +checksum = "c66d61197a68f6323b9afa616cf83d55d69191e1bf364d4eb7d35ae18defe776" dependencies = [ "libc", "windows-sys", @@ -52,15 +52,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "narcissus-app" @@ -126,9 +126,30 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] [[package]] name = "rand" @@ -172,9 +193,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "sdl3-sys" -version = "0.1.2+SDL3-preview-3.1.6" +version = "0.4.7+SDL3-3.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48501d90bf219bf3126b26155c04834af300088432f98c6985aa8ad3a2441baa" +checksum = "f0d16a8a3623a4cb39a3661c81d9d4c5fd77ada27fc056e320b3651bf7bde1b1" [[package]] name = "shark" @@ -212,6 +233,23 @@ version = "0.1.0" name = "stb_truetype-sys" version = "0.1.0" +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + [[package]] name = "vulkan-sys" version = "0.1.0" @@ -224,18 +262,18 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -249,48 +287,68 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/engine/narcissus-app/Cargo.toml b/engine/narcissus-app/Cargo.toml index 089191d..8a6af0b 100644 --- a/engine/narcissus-app/Cargo.toml +++ b/engine/narcissus-app/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "narcissus-app" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,4 +10,4 @@ workspace = true [dependencies] narcissus-core = { path = "../narcissus-core" } -sdl3-sys = "0.1.2" \ No newline at end of file +sdl3-sys = "0.4.7" \ No newline at end of file diff --git a/engine/narcissus-core/Cargo.toml b/engine/narcissus-core/Cargo.toml index 2713a39..4a2d13a 100644 --- a/engine/narcissus-core/Cargo.toml +++ b/engine/narcissus-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "narcissus-core" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/engine/narcissus-core/src/arena.rs b/engine/narcissus-core/src/arena.rs index 3520edc..ef7779c 100644 --- a/engine/narcissus-core/src/arena.rs +++ b/engine/narcissus-core/src/arena.rs @@ -14,13 +14,13 @@ impl std::fmt::Display for AllocError { impl std::error::Error for AllocError {} #[inline(always)] -unsafe fn layout_from_size_align(size: usize, align: usize) -> Layout { +unsafe fn layout_from_size_align(size: usize, align: usize) -> Layout { unsafe { if cfg!(debug_assertions) { Layout::from_size_align(size, align).unwrap() } else { Layout::from_size_align_unchecked(size, align) } -} +}} /// Wrapper around a pointer to a page footer. /// @@ -66,9 +66,9 @@ impl PagePointer { } #[inline(always)] - unsafe fn as_ref<'a>(&self) -> &'a PageFooter { + unsafe fn as_ref<'a>(&self) -> &'a PageFooter { unsafe { &*self.as_ptr() - } + }} } #[repr(C)] @@ -131,11 +131,11 @@ impl PageFooter { /// This must only be called on pages which have no outstanding references to /// allocations, as it allows subsequent operations to allocate the same /// addresses. - unsafe fn reset(&self) { + unsafe fn reset(&self) { unsafe { self.bump.set(NonNull::new_unchecked( self.base.as_ptr().add(self.size - PAGE_FOOTER_SIZE), )); - } + }} } /// Special type for the empty page because static requires Sync. @@ -166,7 +166,7 @@ static EMPTY_PAGE: PageFooterSync = PageFooterSync(unsafe { /// /// `page` must refer to a valid page footer, or the empty page. #[cold] -unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option { +unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option { unsafe { let page_size = page.as_ref().size; // Double each allocated page to amortize allocation cost. let new_page_size = page_size * 2; @@ -203,7 +203,7 @@ unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option Option()); std::alloc::dealloc(p.as_ref().base.as_ptr(), layout); } -} +}} /// An allocation arena. /// @@ -648,7 +648,7 @@ impl HybridArena { /// the hybrid page. #[inline(never)] #[cold] - unsafe fn setup_hybrid_page(&self) { + unsafe fn setup_hybrid_page(&self) { unsafe { let base = self.data.as_ptr() as *mut u8; let bump = base.add(STACK_CAP); self.footer.set(PageFooter { @@ -661,7 +661,7 @@ impl HybridArena { debug_assert_eq!(bump as usize, self.footer.as_ptr() as usize); self.page_list_head .set(PagePointer::new_stack(self.footer.as_ptr())); - } + }} #[inline(never)] #[cold] diff --git a/engine/narcissus-core/src/libc.rs b/engine/narcissus-core/src/libc.rs index 24ec081..7ef2e07 100644 --- a/engine/narcissus-core/src/libc.rs +++ b/engine/narcissus-core/src/libc.rs @@ -430,7 +430,7 @@ pub const SYS_process_madvise: c_long = 440; pub const SYS_epoll_pwait2: c_long = 441; pub const SYS_mount_setattr: c_long = 442; -extern "C" { +unsafe extern "C" { pub fn syscall(num: c_long, ...) -> c_long; pub fn mmap( diff --git a/engine/narcissus-core/src/manual_arc.rs b/engine/narcissus-core/src/manual_arc.rs index f83e86a..e712a87 100644 --- a/engine/narcissus-core/src/manual_arc.rs +++ b/engine/narcissus-core/src/manual_arc.rs @@ -80,7 +80,7 @@ impl ManualArc { pub fn release(mut self) -> Release { #[cold] #[inline(never)] - unsafe fn release_slow(ptr: NonNull>) -> T { + unsafe fn release_slow(ptr: NonNull>) -> T { unsafe { // Ref-counting operations imply a full memory barrier on x86, but not in general. So // insert an acquire barrier on the slow path to ensure all modifications to inner are // visible before we call drop. @@ -94,7 +94,7 @@ impl ManualArc { drop(inner); value - } + }} // SAFETY: `release` consumes `self` so it's impossible to call twice on the same instance, // release is also the only function able to invalidate the pointer. Hence the pointer is diff --git a/engine/narcissus-core/src/ref_count.rs b/engine/narcissus-core/src/ref_count.rs index 1b8ba0b..af58e8d 100644 --- a/engine/narcissus-core/src/ref_count.rs +++ b/engine/narcissus-core/src/ref_count.rs @@ -136,11 +136,11 @@ impl Rc { /// dereferenced for the duration of the returned borrow. This is trivially the /// case if no such pointers exist, for example immediately after [`Arc::new`]. #[inline] - pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { + pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { unsafe { // We are careful to *not* create a reference covering the "count" fields, as // this would alias with concurrent access to the reference counts. &mut (*self.ptr.as_ptr()).value - } + }} #[inline] fn from_inner(ptr: NonNull>) -> Self { @@ -254,11 +254,11 @@ impl Arc { /// Any other [`Rc`] or [`Arc`] pointers to the same allocation must not be dereferenced for the duration of the /// returned borrow. This is trivially the case if no such pointers exist, for example immediately after /// [`Arc::new`]. - pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { + pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { unsafe { // We are careful to *not* create a reference covering the "count" fields, as // this would alias with concurrent access to the reference counts. &mut (*self.ptr.as_ptr()).value - } + }} fn from_inner(ptr: NonNull>) -> Self { Self { diff --git a/engine/narcissus-core/src/virtual_mem.rs b/engine/narcissus-core/src/virtual_mem.rs index 9b66001..f028eba 100644 --- a/engine/narcissus-core/src/virtual_mem.rs +++ b/engine/narcissus-core/src/virtual_mem.rs @@ -55,10 +55,10 @@ pub fn virtual_reserve(size: usize) -> Result<*mut std::ffi::c_void, MapError> { /// Panics if changing page permissions for the range fails. #[cold] #[inline(never)] -pub unsafe fn virtual_commit(ptr: *mut std::ffi::c_void, size: usize) { +pub unsafe fn virtual_commit(ptr: *mut std::ffi::c_void, size: usize) { unsafe { let result = libc::mprotect(ptr, size, libc::PROT_READ | libc::PROT_WRITE); assert!(result == 0); -} +}} /// Release a reserved or comitted virtual memory range. /// @@ -68,11 +68,11 @@ pub unsafe fn virtual_commit(ptr: *mut std::ffi::c_void, size: usize) { /// - `size` must be within range of that reservation. #[cold] #[inline(never)] -pub unsafe fn virtual_free(ptr: *mut std::ffi::c_void, size: usize) -> Result<(), MapError> { +pub unsafe fn virtual_free(ptr: *mut std::ffi::c_void, size: usize) -> Result<(), MapError> { unsafe { let result = libc::munmap(ptr, size); if result != 0 { Err(MapError::MapFailed) } else { Ok(()) } -} +}} diff --git a/engine/narcissus-core/src/virtual_vec/deque.rs b/engine/narcissus-core/src/virtual_vec/deque.rs index 44cae4a..7d0412a 100644 --- a/engine/narcissus-core/src/virtual_vec/deque.rs +++ b/engine/narcissus-core/src/virtual_vec/deque.rs @@ -71,27 +71,27 @@ impl VirtualDeque { /// Turn ptr into a slice #[inline] - unsafe fn buffer_as_slice(&self) -> &[T] { + unsafe fn buffer_as_slice(&self) -> &[T] { unsafe { slice::from_raw_parts(self.ptr(), self.cap()) - } + }} /// Turn ptr into a mut slice #[inline] - unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] { + unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] { unsafe { slice::from_raw_parts_mut(self.ptr(), self.cap()) - } + }} /// Moves an element out of the buffer #[inline] - unsafe fn buffer_read(&mut self, off: usize) -> T { + unsafe fn buffer_read(&mut self, off: usize) -> T { unsafe { ptr::read(self.ptr().add(off)) - } + }} /// Writes an element into the buffer, moving it. #[inline] - unsafe fn buffer_write(&mut self, off: usize, value: T) { + unsafe fn buffer_write(&mut self, off: usize, value: T) { unsafe { ptr::write(self.ptr().add(off), value); - } + }} pub fn len(&self) -> usize { count(self.tail, self.head, self.cap()) @@ -124,7 +124,7 @@ impl VirtualDeque { /// Copies a contiguous block of memory len long from src to dst #[inline] - unsafe fn copy(&self, dst: usize, src: usize, len: usize) { + unsafe fn copy(&self, dst: usize, src: usize, len: usize) { unsafe { debug_assert!( dst + len <= self.cap(), "cpy dst={} src={} len={} cap={}", @@ -142,11 +142,11 @@ impl VirtualDeque { self.cap() ); ptr::copy(self.ptr().add(src), self.ptr().add(dst), len); - } + }} /// Copies a contiguous block of memory len long from src to dst #[inline] - unsafe fn copy_nonoverlapping(&self, dst: usize, src: usize, len: usize) { + unsafe fn copy_nonoverlapping(&self, dst: usize, src: usize, len: usize) { unsafe { debug_assert!( dst + len <= self.cap(), "cno dst={} src={} len={} cap={}", @@ -164,12 +164,12 @@ impl VirtualDeque { self.cap() ); ptr::copy_nonoverlapping(self.ptr().add(src), self.ptr().add(dst), len); - } + }} /// Frobs the head and tail sections around to handle the fact that we /// just reallocated. Unsafe because it trusts old_capacity. #[inline] - unsafe fn handle_capacity_increase(&mut self, old_capacity: usize) { + unsafe fn handle_capacity_increase(&mut self, old_capacity: usize) { unsafe { let new_capacity = self.cap(); // Move the shortest contiguous section of the ring buffer @@ -204,7 +204,7 @@ impl VirtualDeque { debug_assert!(self.head < self.cap()); debug_assert!(self.tail < self.cap()); debug_assert!(self.cap().count_ones() == 1); - } + }} pub fn reserve_exact(&mut self, additional: usize) { self.reserve(additional); diff --git a/engine/narcissus-core/src/virtual_vec/vec.rs b/engine/narcissus-core/src/virtual_vec/vec.rs index 62f7aae..d4128f6 100644 --- a/engine/narcissus-core/src/virtual_vec/vec.rs +++ b/engine/narcissus-core/src/virtual_vec/vec.rs @@ -66,13 +66,13 @@ impl VirtualVec { } #[inline] - unsafe fn append_elements(&mut self, other: *const [T]) { + unsafe fn append_elements(&mut self, other: *const [T]) { unsafe { let count = (*other).len(); self.reserve(count); let len = self.len(); ptr::copy_nonoverlapping(other as *const T, self.as_mut_ptr().add(len), count); self.len += count; - } + }} pub fn clear(&mut self) { self.truncate(0) diff --git a/engine/narcissus-font/Cargo.toml b/engine/narcissus-font/Cargo.toml index 0c868de..1784953 100644 --- a/engine/narcissus-font/Cargo.toml +++ b/engine/narcissus-font/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "narcissus-font" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/engine/narcissus-gpu/Cargo.toml b/engine/narcissus-gpu/Cargo.toml index 5f9bdd7..8f1a973 100644 --- a/engine/narcissus-gpu/Cargo.toml +++ b/engine/narcissus-gpu/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "narcissus-gpu" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/engine/narcissus-gpu/src/backend/vulkan/allocator.rs b/engine/narcissus-gpu/src/backend/vulkan/allocator.rs index 29a3a4c..2460bfc 100644 --- a/engine/narcissus-gpu/src/backend/vulkan/allocator.rs +++ b/engine/narcissus-gpu/src/backend/vulkan/allocator.rs @@ -302,7 +302,7 @@ impl VulkanDevice { Some((memory, mapped_ptr)) } - unsafe fn free_super_block(&self, user_data: &VulkanSuperBlockInfo) { + unsafe fn free_super_block(&self, user_data: &VulkanSuperBlockInfo) { unsafe { self.device_fn .free_memory(self.device, user_data.memory, None); @@ -312,7 +312,7 @@ impl VulkanDevice { let size = self.allocator.tlsf_super_block_size[memory_heap_index.widen()]; self.allocator.stats.free(memory_heap_index, size); - } + }} pub fn allocate_memory( &self, diff --git a/engine/narcissus-gpu/src/backend/vulkan/libc.rs b/engine/narcissus-gpu/src/backend/vulkan/libc.rs index f761ff5..f595ad4 100644 --- a/engine/narcissus-gpu/src/backend/vulkan/libc.rs +++ b/engine/narcissus-gpu/src/backend/vulkan/libc.rs @@ -3,7 +3,7 @@ use std::os::raw::{c_char, c_int, c_void}; pub const RTLD_NOW: c_int = 0x2; pub const RTLD_LOCAL: c_int = 0; -extern "C" { +unsafe extern "C" { pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; } diff --git a/engine/narcissus-gpu/src/backend/vulkan/mod.rs b/engine/narcissus-gpu/src/backend/vulkan/mod.rs index 7477cdc..79e4261 100644 --- a/engine/narcissus-gpu/src/backend/vulkan/mod.rs +++ b/engine/narcissus-gpu/src/backend/vulkan/mod.rs @@ -2360,29 +2360,31 @@ impl Device for VulkanDevice { ptr: *const u8, len: usize, ) { - let len = u32::try_from(len).unwrap(); - - let cmd_encoder = self.cmd_encoder_mut(cmd_encoder); - let command_buffer = cmd_encoder.command_buffer; - - let VulkanBoundPipeline { - pipeline_layout, - pipeline_bind_point: _, - } = cmd_encoder - .bound_pipeline - .as_ref() - .expect("cannot push constants without a pipeline bound") - .clone(); - - let stage_flags = vulkan_shader_stage_flags(stage_flags); - self.device_fn.cmd_push_constants( - command_buffer, - pipeline_layout, - stage_flags, - offset, - len, - ptr as *const std::ffi::c_void, - ) + unsafe { + let len = u32::try_from(len).unwrap(); + + let cmd_encoder = self.cmd_encoder_mut(cmd_encoder); + let command_buffer = cmd_encoder.command_buffer; + + let VulkanBoundPipeline { + pipeline_layout, + pipeline_bind_point: _, + } = cmd_encoder + .bound_pipeline + .as_ref() + .expect("cannot push constants without a pipeline bound") + .clone(); + + let stage_flags = vulkan_shader_stage_flags(stage_flags); + self.device_fn.cmd_push_constants( + command_buffer, + pipeline_layout, + stage_flags, + offset, + len, + ptr as *const std::ffi::c_void, + ) + } } fn cmd_copy_buffer_to_image( diff --git a/engine/narcissus-gpu/src/mapped_buffer.rs b/engine/narcissus-gpu/src/mapped_buffer.rs index 638c429..c3d47c9 100644 --- a/engine/narcissus-gpu/src/mapped_buffer.rs +++ b/engine/narcissus-gpu/src/mapped_buffer.rs @@ -21,7 +21,7 @@ fn overflow() -> ! { /// This function will propagate undefined values from T, for example, padding /// bytes, so it's vital that no Rust reference to the written memory exists /// after writing a `T` which contains undefined values. -unsafe fn copy_from_with_offset(ptr: NonNull, len: usize, offset: usize, src: &T) { +unsafe fn copy_from_with_offset(ptr: NonNull, len: usize, offset: usize, src: &T) { unsafe { let size = std::mem::size_of_val(src); let Some(end) = offset.checked_add(size) else { @@ -50,7 +50,7 @@ unsafe fn copy_from_with_offset(ptr: NonNull, len: usize, offset: let src = src.add(offset); let dst = ptr.as_ptr(); std::ptr::copy_nonoverlapping(src, dst, count) -} +}} /// Persistent mapped buffer. /// diff --git a/engine/narcissus-image/Cargo.toml b/engine/narcissus-image/Cargo.toml index 26e4c8b..3638cec 100644 --- a/engine/narcissus-image/Cargo.toml +++ b/engine/narcissus-image/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "narcissus-image" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/engine/narcissus-maths/Cargo.toml b/engine/narcissus-maths/Cargo.toml index 6573c45..6da9f7e 100644 --- a/engine/narcissus-maths/Cargo.toml +++ b/engine/narcissus-maths/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "narcissus-maths" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/engine/narcissus-maths/src/lib.rs b/engine/narcissus-maths/src/lib.rs index 69eb438..8ed9834 100644 --- a/engine/narcissus-maths/src/lib.rs +++ b/engine/narcissus-maths/src/lib.rs @@ -4,7 +4,6 @@ mod exp; mod mat2; mod mat3; mod mat4; -mod next_after_f32; mod perlin; mod point2; mod point3; @@ -21,7 +20,6 @@ pub use exp::exp_f32; pub use mat2::Mat2; pub use mat3::Mat3; pub use mat4::Mat4; -pub use next_after_f32::next_after_f32; pub use perlin::{perlin_noise3, perlin_noise3_wrap, perlin_noise3_wrap_seed}; pub use point2::{point2, Point2}; pub use point3::{point3, Point3}; diff --git a/engine/narcissus-maths/src/mat4.rs b/engine/narcissus-maths/src/mat4.rs index 745aa4b..7663ae8 100644 --- a/engine/narcissus-maths/src/mat4.rs +++ b/engine/narcissus-maths/src/mat4.rs @@ -264,12 +264,12 @@ impl Mat4 { // SAFETY: Requires SSE2. #[inline] #[target_feature(enable = "sse2")] - unsafe fn transpose_sse2(self) -> Mat4 { + unsafe fn transpose_sse2(self) -> Mat4 { unsafe { use std::arch::x86_64::_MM_TRANSPOSE4_PS; let [mut row0, mut row1, mut row2, mut row3] = self.as_m128_array(); _MM_TRANSPOSE4_PS(&mut row0, &mut row1, &mut row2, &mut row3); Mat4::from_m128_array([row0, row1, row2, row3]) - } + }} /// Returns the transpose of `self`. #[must_use] @@ -337,7 +337,7 @@ impl Mat4 { #[allow(dead_code)] #[inline] #[target_feature(enable = "sse4.1")] - unsafe fn transform_vec4_sse41(&self, vec: Vec4) -> Vec4 { + unsafe fn transform_vec4_sse41(&self, vec: Vec4) -> Vec4 { unsafe { use std::arch::x86_64::{_mm_hadd_ps, _mm_mul_ps}; let vec = vec.into(); @@ -349,7 +349,7 @@ impl Mat4 { ); values.into() - } + }} /// Transforms the given [`Vec4`] `vec` by `self`. #[must_use] @@ -421,14 +421,14 @@ unsafe fn mul_mat4_sse2(lhs: Mat4, rhs: Mat4) -> Mat4 { #[allow(dead_code)] #[inline] #[target_feature(enable = "avx2")] -unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 { +unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 { unsafe { use std::arch::x86_64::{ __m128, __m256, _mm256_add_ps, _mm256_broadcast_ps, _mm256_loadu_ps, _mm256_mul_ps, _mm256_shuffle_ps, _mm256_storeu_ps, _mm256_zeroupper, }; #[inline(always)] - unsafe fn two_linear_combine(a: __m256, m: &[__m128; 4]) -> __m256 { + unsafe fn two_linear_combine(a: __m256, m: &[__m128; 4]) -> __m256 { unsafe { let m0 = _mm256_broadcast_ps(&m[0]); let m1 = _mm256_broadcast_ps(&m[1]); let m2 = _mm256_broadcast_ps(&m[2]); @@ -437,7 +437,7 @@ unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 { let r = _mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0x55), m1)); let r = _mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0xaa), m2)); _mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0xff), m3)) - } + }} _mm256_zeroupper(); @@ -452,7 +452,7 @@ unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 { _mm256_storeu_ps(&mut result.0[0], x0); _mm256_storeu_ps(&mut result.0[8], x1); result -} +}} impl std::ops::Mul for Mat4 { type Output = Mat4; diff --git a/engine/narcissus-maths/src/next_after_f32.rs b/engine/narcissus-maths/src/next_after_f32.rs deleted file mode 100644 index 7402c00..0000000 --- a/engine/narcissus-maths/src/next_after_f32.rs +++ /dev/null @@ -1,60 +0,0 @@ -/// Calculate the next representable floating-point value following x in the -/// direction of y. -/// -/// If y is less than x, these functions will return the largest representable -/// number less than x. -/// -/// # Returns -/// -/// On success, the function returns the next representable floating-point value -/// after x in the -/// direction of y. -/// -/// * If `x` equals `y`, then `y` is returned. -/// * If `x` or `y` is a `NaN`, a `NaN` is returned. -/// * If `x` is finite, and the result would overflow, a range error occurs, and -/// the function returns `inf` with the correct mathematical sign. -/// * If `x` is not equal to `y`, and the correct function result would be -/// subnormal, zero, or underflow, a range error occurs, and either the -/// correct value (if it can be represented), or `0.0`, is returned. -/// * If x equals y, the function returns y. -pub fn next_after_f32(x: f32, y: f32) -> f32 { - if x.is_nan() || y.is_nan() { - return x + y; - } - - let ux = x.to_bits(); - let uy = y.to_bits(); - - if ux == uy { - return y; - } - - let ax = ux & 0x7fff_ffff; - let ay = uy & 0x7fff_ffff; - - let ux = if ax == 0 { - if ay == 0 { - return y; - } - (uy & 0x8000_0000) | 1 - } else if ax > ay || ((ux ^ uy) & 0x8000_0000) != 0 { - ux - 1 - } else { - ux + 1 - }; - - let e = ux & 0x7f800000; - // Overflow if ux is infinite, and x is finite. - if e == 0x7f800000 { - return x + x; - } - // Force underflow if ux is subnormal or zero. - if e == 0 { - let mut force_eval = 0.0; - let val = f32::from_bits(ux); - unsafe { std::ptr::write_volatile(&mut force_eval, x * x + val * val) }; - } - - f32::from_bits(ux) -} diff --git a/engine/narcissus-maths/tests/exhaustive_f32.rs b/engine/narcissus-maths/tests/exhaustive_f32.rs index d14fe52..46e96e8 100644 --- a/engine/narcissus-maths/tests/exhaustive_f32.rs +++ b/engine/narcissus-maths/tests/exhaustive_f32.rs @@ -5,7 +5,7 @@ use std::{ sync::atomic::{AtomicUsize, Ordering}, }; -use narcissus_maths::{exp_f32, next_after_f32, sin_cos_pi_f32, tan_pi_f32}; +use narcissus_maths::{exp_f32, sin_cos_pi_f32, tan_pi_f32}; use gmp_mpfr_sys::mpfr; @@ -288,7 +288,13 @@ impl FloatCheck { } let err = our_value - ref_value; - let ulp = next_after_f32(ref_value, our_value) - ref_value; + let ulp = if ref_value > our_value { + ref_value.next_down() + } else if ref_value < our_value { + ref_value.next_up() + } else { + ref_value + } - ref_value; let err = (err / ulp).abs(); if err >= u32::MAX as f32 { u32::MAX diff --git a/engine/narcissus-maths/tests/next_after_f32.rs b/engine/narcissus-maths/tests/next_after_f32.rs deleted file mode 100644 index 46b7603..0000000 --- a/engine/narcissus-maths/tests/next_after_f32.rs +++ /dev/null @@ -1,44 +0,0 @@ -use narcissus_maths::next_after_f32; - -mod libc { - use std::os::raw::c_float; - - extern "C" { - pub fn nextafterf(x: c_float, y: c_float) -> c_float; - } -} - -#[inline(always)] -fn nextafterf(x: f32, y: f32) -> f32 { - unsafe { libc::nextafterf(x, y) } -} - -fn test_towards(y: f32) { - for u in 0..=0xffff_ffff_u32 { - let x = f32::from_bits(u); - let ours = next_after_f32(x, y); - let reference = nextafterf(x, y); - assert!( - ours == reference || (ours.is_nan() && reference.is_nan()), - "x ({u:X}): ours ({ours}) != reference ({reference})" - ); - } -} - -#[test] -#[ignore] -fn next_after_f32_to_zero() { - test_towards(0.0) -} - -#[test] -#[ignore] -fn next_after_f32_to_inf() { - test_towards(f32::INFINITY) -} - -#[test] -#[ignore] -fn next_after_f32_to_neg_inf() { - test_towards(f32::NEG_INFINITY) -} diff --git a/engine/narcissus-sqlite/Cargo.toml b/engine/narcissus-sqlite/Cargo.toml index 7d0b931..5727f5e 100644 --- a/engine/narcissus-sqlite/Cargo.toml +++ b/engine/narcissus-sqlite/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "narcissus-sqlite" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/engine/narcissus-sqlite/src/lib.rs b/engine/narcissus-sqlite/src/lib.rs index 6a6efac..cefd0f6 100644 --- a/engine/narcissus-sqlite/src/lib.rs +++ b/engine/narcissus-sqlite/src/lib.rs @@ -14,7 +14,7 @@ use sqlite_sys as ffi; static SQLITE_GLOBAL_INIT: OnceLock<()> = OnceLock::new(); #[cold] -unsafe fn initialize() { +unsafe fn initialize() { unsafe { let ret = ffi::sqlite3_initialize(); if ret != sqlite_sys::SQLITE_OK { panic!("error initializing sqlite: {:?}", Error::new(ret)); @@ -37,7 +37,7 @@ unsafe fn initialize() { panic!("error installing sqlite logger: {:?}", Error::new(ret)); } } -} +}} fn check_initalized() { SQLITE_GLOBAL_INIT.get_or_init(|| unsafe { initialize() }); diff --git a/engine/narcissus-world/Cargo.toml b/engine/narcissus-world/Cargo.toml index 54a5860..55093bd 100644 --- a/engine/narcissus-world/Cargo.toml +++ b/engine/narcissus-world/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "narcissus-world" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/external/blake3-smol/Cargo.toml b/external/blake3-smol/Cargo.toml index df38999..7a8516b 100644 --- a/external/blake3-smol/Cargo.toml +++ b/external/blake3-smol/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "blake3-smol" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/external/blake3-smol/src/ffi.rs b/external/blake3-smol/src/ffi.rs index 156730f..3fe4a9c 100644 --- a/external/blake3-smol/src/ffi.rs +++ b/external/blake3-smol/src/ffi.rs @@ -1,6 +1,6 @@ #[allow(dead_code)] -extern "C" { +unsafe extern "C" { pub fn blake3_compress_in_place_avx512( cv: *mut u32, block: *const u8, diff --git a/external/renderdoc-sys/Cargo.toml b/external/renderdoc-sys/Cargo.toml index 2fa16c6..272071e 100644 --- a/external/renderdoc-sys/Cargo.toml +++ b/external/renderdoc-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "renderdoc-sys" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/external/renderdoc-sys/src/lib.rs b/external/renderdoc-sys/src/lib.rs index c4ebafc..331045c 100644 --- a/external/renderdoc-sys/src/lib.rs +++ b/external/renderdoc-sys/src/lib.rs @@ -318,7 +318,7 @@ mod libc { pub const RTLD_NOW: c_int = 0x2; pub const RTLD_NOLOAD: c_int = 0x4; - extern "C" { + unsafe extern "C" { pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; } diff --git a/external/sqlite-sys/Cargo.toml b/external/sqlite-sys/Cargo.toml index 6de3e39..f308604 100644 --- a/external/sqlite-sys/Cargo.toml +++ b/external/sqlite-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sqlite-sys" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/external/sqlite-sys/src/lib.rs b/external/sqlite-sys/src/lib.rs index aa3aefe..3e51dab 100644 --- a/external/sqlite-sys/src/lib.rs +++ b/external/sqlite-sys/src/lib.rs @@ -323,7 +323,7 @@ impl Destructor { pub const SQLITE_STATIC: Destructor = unsafe { std::mem::transmute(0usize) }; pub const SQLITE_TRANSIENT: Destructor = unsafe { std::mem::transmute(!0usize) }; -extern "C" { +unsafe extern "C" { pub fn sqlite3_libversion_number() -> c_int; pub fn sqlite3_initialize() -> c_int; diff --git a/external/stb_image-sys/Cargo.toml b/external/stb_image-sys/Cargo.toml index a808a1a..4f6a43f 100644 --- a/external/stb_image-sys/Cargo.toml +++ b/external/stb_image-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "stb_image-sys" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/external/stb_image-sys/src/lib.rs b/external/stb_image-sys/src/lib.rs index 402bde3..4ce4845 100644 --- a/external/stb_image-sys/src/lib.rs +++ b/external/stb_image-sys/src/lib.rs @@ -21,7 +21,7 @@ pub struct stbi_io_callbacks { pub eof: extern "C" fn(user: *mut c_void) -> i32, } -extern "C" { +unsafe extern "C" { pub fn stbi_load_from_memory( buffer: *const c_uchar, len: c_int, diff --git a/external/stb_truetype-sys/Cargo.toml b/external/stb_truetype-sys/Cargo.toml index ea07747..3cdfe98 100644 --- a/external/stb_truetype-sys/Cargo.toml +++ b/external/stb_truetype-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "stb_truetype-sys" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/external/stb_truetype-sys/src/lib.rs b/external/stb_truetype-sys/src/lib.rs index 9a6a2de..51cf0ed 100644 --- a/external/stb_truetype-sys/src/lib.rs +++ b/external/stb_truetype-sys/src/lib.rs @@ -155,7 +155,7 @@ pub mod truetype { } } -extern "C" { +unsafe extern "C" { pub fn stbrp_pack_rects( context: *mut rectpack::Context, rects: *mut rectpack::Rect, diff --git a/external/vulkan-sys/Cargo.toml b/external/vulkan-sys/Cargo.toml index d6f3f1a..84d2e55 100644 --- a/external/vulkan-sys/Cargo.toml +++ b/external/vulkan-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "vulkan-sys" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/external/vulkan-sys/examples/triangle.rs b/external/vulkan-sys/examples/triangle.rs index be8460f..0925e11 100644 --- a/external/vulkan-sys/examples/triangle.rs +++ b/external/vulkan-sys/examples/triangle.rs @@ -8,7 +8,7 @@ mod libc { pub const RTLD_NOW: c_int = 0x2; pub const RTLD_LOCAL: c_int = 0; - extern "C" { + unsafe extern "C" { pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; } @@ -765,12 +765,14 @@ pub fn main() { #[inline] unsafe fn as_chunks_unchecked(slice: &[T]) -> &[[T; N]] { - debug_assert_ne!(N, 0); - debug_assert_eq!(slice.len() % N, 0); - let new_len = slice.len() / N; - // SAFETY: We cast a slice of `new_len * N` elements into - // a slice of `new_len` many `N` elements chunks. - std::slice::from_raw_parts(slice.as_ptr().cast(), new_len) + unsafe { + debug_assert_ne!(N, 0); + debug_assert_eq!(slice.len() % N, 0); + let new_len = slice.len() / N; + // SAFETY: We cast a slice of `new_len * N` elements into + // a slice of `new_len` many `N` elements chunks. + std::slice::from_raw_parts(slice.as_ptr().cast(), new_len) + } } print!("\x1b[2J"); diff --git a/external/vulkan-sys/src/lib.rs b/external/vulkan-sys/src/lib.rs index 9be6402..42f8ee6 100644 --- a/external/vulkan-sys/src/lib.rs +++ b/external/vulkan-sys/src/lib.rs @@ -318,7 +318,7 @@ pub struct GlobalFunctions { } impl GlobalFunctions { - pub unsafe fn new(get_proc_addr: *mut c_void) -> Self { + pub unsafe fn new(get_proc_addr: *mut c_void) -> Self { unsafe { let get_instance_proc_addr = transmute::<_, FnGetInstanceProcAddr>(get_proc_addr); Self { get_instance_proc_addr, @@ -339,7 +339,7 @@ impl GlobalFunctions { .expect("failed to load vkCreateInstance"), ), } - } + }} #[inline] pub unsafe fn get_instance_proc_addr( diff --git a/title/shark-shaders/Cargo.toml b/title/shark-shaders/Cargo.toml index a5702d5..64c2798 100644 --- a/title/shark-shaders/Cargo.toml +++ b/title/shark-shaders/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "shark-shaders" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/title/shark/Cargo.toml b/title/shark/Cargo.toml index f456765..b450cad 100644 --- a/title/shark/Cargo.toml +++ b/title/shark/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "shark" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/title/shark/src/main.rs b/title/shark/src/main.rs index 9d5e215..8529445 100644 --- a/title/shark/src/main.rs +++ b/title/shark/src/main.rs @@ -196,7 +196,8 @@ impl<'a> UiState<'a> { pub fn main() { #[cfg(debug_assertions)] if std::env::var("RUST_BACKTRACE").is_err() { - std::env::set_var("RUST_BACKTRACE", "1") + // SAFETY: Called on the main thread before other threads are spawned. + unsafe { std::env::set_var("RUST_BACKTRACE", "1") } } let renderdoc = rdoc::RenderdocApi1_5_0::load(); @@ -208,7 +209,8 @@ pub fn main() { // Hot new SDL 3 environment variables! && std::env::var("SDL_VIDEO_DRIVER").is_err() { - std::env::set_var("SDL_VIDEODRIVER", "wayland") + // SAFETY: Called on the main thread before other threads are spawned. + unsafe { std::env::set_var("SDL_VIDEODRIVER", "wayland") } } let ui_scale_override =