# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/thunderbird/hotfix-wgpu-atomicu64.patch # Copyright (C) 2024 - 2025 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- sed 's,/third_party/,/comm&,' package/www/firefox/hotfix-wgpu-atomicu64.patch >> \ package/mail/thunderbird/hotfix-wgpu-atomicu64.patch --- firefox-143.0/gfx/wgpu_bindings/src/server.rs.vanilla 2025-09-16 11:40:33.753608297 +0200 +++ firefox-143.0/gfx/wgpu_bindings/src/server.rs 2025-09-16 11:41:38.860651845 +0200 @@ -2990,7 +2990,7 @@ self_id: id::QueueId, command_buffers: FfiSlice<'_, id::CommandBufferId>, mut error_buf: ErrorBuffer, -) -> u64 { +) -> usize { let result = global.queue_submit(self_id, command_buffers.as_slice()); match result { --- firefox-142.0/comm/third_party/rust/ash/src/device.rs 2025-08-11 20:04:45.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/ash/src/device.rs 2025-08-23 20:28:33.494874018 +0200 @@ -676,7 +676,7 @@ /// #[inline] - pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult { + pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult { let mut value = mem::MaybeUninit::uninit(); (self.device_fn_1_2.get_semaphore_counter_value)( self.handle(), --- firefox-142.0/comm/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs 2025-08-11 20:04:45.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs 2025-08-23 20:28:33.490098173 +0200 @@ -7,7 +7,7 @@ impl crate::khr::timeline_semaphore::Device { /// #[inline] - pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult { + pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult { let mut value = mem::MaybeUninit::uninit(); (self.fp.get_semaphore_counter_value_khr)(self.handle, semaphore, value.as_mut_ptr()) .assume_init_on_success(value) --- firefox-142.0/comm/third_party/rust/ash/src/extensions_generated.rs 2025-08-11 20:04:45.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/ash/src/extensions_generated.rs 2025-08-23 20:28:33.498873793 +0200 @@ -14711,7 +14711,7 @@ unsafe extern "system" fn get_semaphore_counter_value_khr( _device: crate::vk::Device, _semaphore: Semaphore, - _p_value: *mut u64, + _p_value: *mut usize, ) -> Result { panic!(concat!( "Unable to load ", --- firefox-142.0/comm/third_party/rust/ash/src/tables.rs 2025-08-11 20:04:44.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/ash/src/tables.rs 2025-08-23 20:28:33.499772657 +0200 @@ -3463,7 +3463,7 @@ unsafe extern "system" fn get_semaphore_counter_value( _device: crate::vk::Device, _semaphore: Semaphore, - _p_value: *mut u64, + _p_value: *mut usize, ) -> Result { panic!(concat!( "Unable to load ", --- firefox-142.0/comm/third_party/rust/ash/src/vk/definitions.rs 2025-08-11 20:04:45.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/ash/src/vk/definitions.rs 2025-08-23 20:39:53.723823836 +0200 @@ -12913,9 +12913,9 @@ pub s_type: StructureType, pub p_next: *const c_void, pub wait_semaphore_values_count: u32, - pub p_wait_semaphore_values: *const u64, + pub p_wait_semaphore_values: *const usize, pub signal_semaphore_values_count: u32, - pub p_signal_semaphore_values: *const u64, + pub p_signal_semaphore_values: *const usize, pub _marker: PhantomData<&'a ()>, } unsafe impl Send for D3D12FenceSubmitInfoKHR<'_> {} @@ -12940,13 +12940,13 @@ unsafe impl ExtendsSubmitInfo for D3D12FenceSubmitInfoKHR<'_> {} impl<'a> D3D12FenceSubmitInfoKHR<'a> { #[inline] - pub fn wait_semaphore_values(mut self, wait_semaphore_values: &'a [u64]) -> Self { + pub fn wait_semaphore_values(mut self, wait_semaphore_values: &'a [usize]) -> Self { self.wait_semaphore_values_count = wait_semaphore_values.len() as _; self.p_wait_semaphore_values = wait_semaphore_values.as_ptr(); self } #[inline] - pub fn signal_semaphore_values(mut self, signal_semaphore_values: &'a [u64]) -> Self { + pub fn signal_semaphore_values(mut self, signal_semaphore_values: &'a [usize]) -> Self { self.signal_semaphore_values_count = signal_semaphore_values.len() as _; self.p_signal_semaphore_values = signal_semaphore_values.as_ptr(); self @@ -21911,9 +21911,9 @@ pub s_type: StructureType, pub p_next: *const c_void, pub wait_semaphore_value_count: u32, - pub p_wait_semaphore_values: *const u64, + pub p_wait_semaphore_values: *const usize, pub signal_semaphore_value_count: u32, - pub p_signal_semaphore_values: *const u64, + pub p_signal_semaphore_values: *const usize, pub _marker: PhantomData<&'a ()>, } unsafe impl Send for TimelineSemaphoreSubmitInfo<'_> {} @@ -21939,13 +21939,13 @@ unsafe impl ExtendsBindSparseInfo for TimelineSemaphoreSubmitInfo<'_> {} impl<'a> TimelineSemaphoreSubmitInfo<'a> { #[inline] - pub fn wait_semaphore_values(mut self, wait_semaphore_values: &'a [u64]) -> Self { + pub fn wait_semaphore_values(mut self, wait_semaphore_values: &'a [usize]) -> Self { self.wait_semaphore_value_count = wait_semaphore_values.len() as _; self.p_wait_semaphore_values = wait_semaphore_values.as_ptr(); self } #[inline] - pub fn signal_semaphore_values(mut self, signal_semaphore_values: &'a [u64]) -> Self { + pub fn signal_semaphore_values(mut self, signal_semaphore_values: &'a [usize]) -> Self { self.signal_semaphore_value_count = signal_semaphore_values.len() as _; self.p_signal_semaphore_values = signal_semaphore_values.as_ptr(); self @@ -21962,7 +21962,7 @@ pub flags: SemaphoreWaitFlags, pub semaphore_count: u32, pub p_semaphores: *const Semaphore, - pub p_values: *const u64, + pub p_values: *const usize, pub _marker: PhantomData<&'a ()>, } unsafe impl Send for SemaphoreWaitInfo<'_> {} @@ -21997,7 +21997,7 @@ self } #[inline] - pub fn values(mut self, values: &'a [u64]) -> Self { + pub fn values(mut self, values: &'a [usize]) -> Self { self.semaphore_count = values.len() as _; self.p_values = values.as_ptr(); self @@ -22012,7 +22012,7 @@ pub s_type: StructureType, pub p_next: *const c_void, pub semaphore: Semaphore, - pub value: u64, + pub value: usize, pub _marker: PhantomData<&'a ()>, } unsafe impl Send for SemaphoreSignalInfo<'_> {} @@ -22039,7 +22039,7 @@ self } #[inline] - pub fn value(mut self, value: u64) -> Self { + pub fn value(mut self, value: usize) -> Self { self.value = value; self } --- firefox-142.0/comm/third_party/rust/ash/src/vk/extensions.rs 2025-08-11 20:04:45.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/ash/src/vk/extensions.rs 2025-08-23 20:28:33.493873793 +0200 @@ -5945,7 +5945,7 @@ pub type PFN_vkGetSemaphoreCounterValue = unsafe extern "system" fn( device: crate::vk::Device, semaphore: Semaphore, - p_value: *mut u64, + p_value: *mut usize, ) -> Result; #[allow(non_camel_case_types)] pub type PFN_vkWaitSemaphores = unsafe extern "system" fn( --- firefox-142.0/comm/third_party/rust/wgpu-core/src/command/ray_tracing.rs 2025-08-11 20:04:46.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-core/src/command/ray_tracing.rs 2025-08-23 20:30:50.700677785 +0200 @@ -1,7 +1,7 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec}; use core::{ cmp::max, - num::NonZeroU64, + num::NonZeroUsize, ops::{Deref, Range}, }; @@ -515,7 +515,7 @@ for action in &self.as_actions { match action { AsAction::Build(build) => { - let build_command_index = NonZeroU64::new( + let build_command_index = NonZeroUsize::new( command_index_guard.next_acceleration_structure_build_command_index, ) .unwrap(); --- firefox-142.0/comm/third_party/rust/wgpu-core/src/device/queue.rs 2025-08-11 20:04:46.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-core/src/device/queue.rs 2025-08-23 20:28:33.501072414 +0200 @@ -117,7 +117,7 @@ pub(crate) fn maintain( &self, - submission_index: u64, + submission_index: usize, snatch_guard: &SnatchGuard, ) -> ( SmallVec<[SubmittedWorkDoneClosure; 1]>, --- firefox-142.0/comm/third_party/rust/wgpu-core/src/device/resource.rs 2025-08-11 20:04:46.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-core/src/device/resource.rs 2025-08-23 20:15:29.514931369 +0200 @@ -58,10 +58,7 @@ ENTRYPOINT_FAILURE_ERROR, ZERO_BUFFER_SIZE, }; -#[cfg(supports_64bit_atomics)] -use core::sync::atomic::AtomicU64; -#[cfg(not(supports_64bit_atomics))] -use portable_atomic::AtomicU64; +use core::sync::atomic::AtomicUsize; pub(crate) struct CommandIndices { /// The index of the last command submission that was attempted. @@ -290,7 +287,7 @@ next_acceleration_structure_build_command_index: 1, }, ), - last_successful_submission_index: AtomicU64::new(0), + last_successful_submission_index: AtomicUsize::new(0), fence: RwLock::new(rank::DEVICE_FENCE, ManuallyDrop::new(fence)), snatchable_lock: unsafe { SnatchLock::new(rank::DEVICE_SNATCHABLE_LOCK) }, valid: AtomicBool::new(true), --- firefox-142.0/comm/third_party/rust/wgpu-core/src/resource.rs 2025-08-11 20:04:46.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-core/src/resource.rs 2025-08-23 20:31:32.843835169 +0200 @@ -3,7 +3,7 @@ borrow::Borrow, fmt, mem::{self, size_of, ManuallyDrop}, - num::NonZeroU64, + num::NonZeroUsize, ops::Range, ptr::NonNull, }; @@ -2019,7 +2019,7 @@ pub(crate) sizes: wgt::BlasGeometrySizeDescriptors, pub(crate) flags: wgt::AccelerationStructureFlags, pub(crate) update_mode: wgt::AccelerationStructureUpdateMode, - pub(crate) built_index: RwLock>, + pub(crate) built_index: RwLock>, pub(crate) handle: u64, /// The `label` from the descriptor used to create the resource. pub(crate) label: String, @@ -2170,7 +2170,7 @@ pub(crate) max_instance_count: u32, pub(crate) flags: wgt::AccelerationStructureFlags, pub(crate) update_mode: wgt::AccelerationStructureUpdateMode, - pub(crate) built_index: RwLock>, + pub(crate) built_index: RwLock>, pub(crate) dependencies: RwLock>>, pub(crate) instance_buffer: ManuallyDrop>, /// The `label` from the descriptor used to create the resource. --- firefox-142.0/comm/third_party/rust/wgpu-hal/src/lib.rs 2025-08-11 20:04:46.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-hal/src/lib.rs 2025-08-23 20:25:09.566233288 +0200 @@ -329,11 +329,8 @@ pub type Label<'a> = Option<&'a str>; pub type MemoryRange = Range; -pub type FenceValue = u64; -#[cfg(supports_64bit_atomics)] -pub type AtomicFenceValue = core::sync::atomic::AtomicU64; -#[cfg(not(supports_64bit_atomics))] -pub type AtomicFenceValue = portable_atomic::AtomicU64; +pub type FenceValue = usize; +pub type AtomicFenceValue = core::sync::atomic::AtomicUsize; /// A callback to signal that wgpu is no longer using a resource. #[cfg(any(gles, vulkan))] --- firefox-142.0/comm/third_party/rust/wgpu-hal/src/metal/device.rs 2025-08-11 20:04:45.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-hal/src/metal/device.rs 2025-08-23 20:15:01.634933416 +0200 @@ -1504,7 +1504,7 @@ None }; Ok(super::Fence { - completed_value: Arc::new(atomic::AtomicU64::new(0)), + completed_value: Arc::new(atomic::AtomicUsize::new(0)), pending_command_buffers: Vec::new(), shared_event, }) --- firefox-142.0/comm/third_party/rust/wgpu-hal/src/metal/mod.rs 2025-08-11 20:04:45.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-hal/src/metal/mod.rs 2025-08-23 20:15:09.851932813 +0200 @@ -896,7 +896,7 @@ #[derive(Debug)] pub struct Fence { - completed_value: Arc, + completed_value: Arc, /// The pending fence values have to be ascending. pending_command_buffers: Vec<(crate::FenceValue, metal::CommandBuffer)>, shared_event: Option, --- firefox-142.0/comm/third_party/rust/wgpu-hal/src/noop/mod.rs 2025-08-11 20:04:46.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-hal/src/noop/mod.rs 2025-08-23 20:15:37.400930790 +0200 @@ -3,10 +3,7 @@ use alloc::{string::String, vec, vec::Vec}; use core::{ptr, sync::atomic::Ordering, time::Duration}; -#[cfg(supports_64bit_atomics)] -use core::sync::atomic::AtomicU64; -#[cfg(not(supports_64bit_atomics))] -use portable_atomic::AtomicU64; +use core::sync::atomic::AtomicUsize; use crate::TlasInstance; @@ -25,7 +22,7 @@ #[derive(Debug)] pub struct Fence { - value: AtomicU64, + value: AtomicUsize, } type DeviceResult = Result; @@ -408,7 +405,7 @@ unsafe fn destroy_query_set(&self, set: Resource) {} unsafe fn create_fence(&self) -> DeviceResult { Ok(Fence { - value: AtomicU64::new(0), + value: AtomicUsize::new(0), }) } unsafe fn destroy_fence(&self, fence: Fence) {} --- firefox-142.0/comm/third_party/rust/wgpu-hal/src/vulkan/mod.rs 2025-08-11 20:04:45.000000000 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-hal/src/vulkan/mod.rs 2025-08-23 20:41:55.986011359 +0200 @@ -1436,7 +1436,7 @@ &self.device.raw } - pub fn add_signal_semaphore(&self, semaphore: vk::Semaphore, semaphore_value: Option) { + pub fn add_signal_semaphore(&self, semaphore: vk::Semaphore, semaphore_value: Option) { let mut guard = self.signal_semaphores.lock(); if let Some(value) = semaphore_value { guard.push_timeline(semaphore, value); --- firefox-146.0/comm/third_party/rust/wgpu-hal/src/vulkan/semaphore_list.rs.vanilla 2025-12-09 14:14:08.654821238 +0100 +++ firefox-146.0/comm/third_party/rust/wgpu-hal/src/vulkan/semaphore_list.rs 2025-12-09 14:15:50.093333716 +0100 @@ -42,7 +42,7 @@ /// Vulkan ignores these. /// /// [`semaphores`]: Self::semaphores - values: Vec, + values: Vec, /// Stage masks for wait semaphores. /// @@ -191,5 +191,5 @@ pub enum SemaphoreType { Binary(vk::Semaphore), - Timeline(vk::Semaphore, u64), + Timeline(vk::Semaphore, usize), } --- firefox-142.0/comm/third_party/rust/ash/src/vk/definitions.rs.vanilla 2025-08-23 21:02:58.803379028 +0200 +++ firefox-142.0/comm/third_party/rust/ash/src/vk/definitions.rs 2025-08-23 21:03:13.727721019 +0200 @@ -22024,7 +22024,7 @@ s_type: Self::STRUCTURE_TYPE, p_next: ::core::ptr::null(), semaphore: Semaphore::default(), - value: u64::default(), + value: usize::default(), _marker: PhantomData, } } --- firefox-142.0/comm/third_party/rust/wgpu-core/src/device/queue.rs.vanilla 2025-08-23 21:18:30.018660273 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-core/src/device/queue.rs 2025-08-23 21:19:04.663072620 +0200 @@ -2,7 +2,7 @@ use core::{ iter, mem::{self, ManuallyDrop}, - num::NonZeroU64, + num::NonZeroUsize, ptr::NonNull, sync::atomic::Ordering, }; @@ -1495,7 +1495,7 @@ let mut command_indices_lock = device.command_indices.write(); command_indices_lock.next_acceleration_structure_build_command_index += 1; let built_index = - NonZeroU64::new(command_indices_lock.next_acceleration_structure_build_command_index) + NonZeroUsize::new(command_indices_lock.next_acceleration_structure_build_command_index) .unwrap(); let new_blas = Arc::new(Blas { --- firefox-142.0/comm/third_party/rust/wgpu-core/src/device/resource.rs.vanilla 2025-08-23 21:22:11.656111100 +0200 +++ firefox-142.0/comm/third_party/rust/wgpu-core/src/device/resource.rs 2025-08-23 21:22:22.889894954 +0200 @@ -69,7 +69,7 @@ /// /// [`last_successful_submission_index`]: Device::last_successful_submission_index pub(crate) active_submission_index: hal::FenceValue, - pub(crate) next_acceleration_structure_build_command_index: u64, + pub(crate) next_acceleration_structure_build_command_index: usize, } /// Structure describing a logical device. Some members are internally mutable, --- firefox-146.0/comm/third_party/rust/wgpu-types/src/lib.rs.vanilla 2025-12-09 14:14:08.664176696 +0100 +++ firefox-146.0/comm/third_party/rust/wgpu-types/src/lib.rs 2025-12-09 14:16:22.159373290 +0100 @@ -4577,7 +4577,7 @@ /// The requested Wait timed out before the submission was completed. Timeout, /// The requested Wait was given a wrong submission index. - WrongSubmissionIndex(u64, u64), + WrongSubmissionIndex(usize, usize), } // This impl could be derived by `thiserror`, but by not doing so, we can reduce the number of --- firefox-146.0/comm/third_party/rust/wgpu-hal/src/vulkan/swapchain/native.rs.vanilla 2025-12-10 17:39:10.325048535 +0100 +++ firefox-146.0/comm/third_party/rust/wgpu-hal/src/vulkan/swapchain/native.rs 2025-12-10 17:39:32.840602012 +0100 @@ -883,7 +883,7 @@ } impl<'a> SwapchainSubmissionSemaphoreGuard for NativeSwapchainSubmissionSemaphoreGuard<'a> { - fn set_used_fence_value(&mut self, value: u64) { + fn set_used_fence_value(&mut self, value: usize) { self.acquire_semaphore_guard.set_used_fence_value(value); } --- firefox-146.0/comm/third_party/rust/wgpu-hal/src/vulkan/swapchain/mod.rs.vanilla 2025-12-10 18:41:10.255617525 +0100 +++ firefox-146.0/comm/third_party/rust/wgpu-hal/src/vulkan/swapchain/mod.rs 2025-12-10 18:41:16.364945912 +0100 @@ -94,7 +94,7 @@ /// Guard type for managing swapchain submission semaphores. pub(super) trait SwapchainSubmissionSemaphoreGuard { /// Sets the Fence value for this submission. - fn set_used_fence_value(&mut self, value: u64); + fn set_used_fence_value(&mut self, value: usize); /// Gets semaphores to wait on before doing GPU work for this swapchain texture. fn get_acquire_wait_semaphore(&mut self) -> Option;