From a18abddd33fe4f3ab1b01054df5111cb5b7a63af Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 5 Mar 2026 16:50:20 -0700 Subject: [PATCH] refactor: use `From` or `Into` for `u32` -> `u64` casts --- wgpu-hal/src/auxil/mod.rs | 2 +- wgpu-hal/src/dx12/adapter.rs | 7 ++++--- wgpu-hal/src/vulkan/adapter.rs | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/wgpu-hal/src/auxil/mod.rs b/wgpu-hal/src/auxil/mod.rs index 9a083e672..2639448cc 100644 --- a/wgpu-hal/src/auxil/mod.rs +++ b/wgpu-hal/src/auxil/mod.rs @@ -192,7 +192,7 @@ pub(crate) fn apply_hal_limits(mut limits: wgt::Limits) -> wgt::Limits { // Round some limits down to the WebGPU alignment requirement, to avoid // suggesting values that won't work. (In particular, the CTS queries limits // and then tests the exact limit value.) - limits.max_storage_buffer_binding_size &= !(wgt::STORAGE_BINDING_SIZE_ALIGNMENT - 1) as u64; + limits.max_storage_buffer_binding_size &= u64::from(!(wgt::STORAGE_BINDING_SIZE_ALIGNMENT - 1)); limits.max_vertex_buffer_array_stride &= !(wgt::VERTEX_ALIGNMENT as u32 - 1); limits diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index 41ef283e6..62598fc3e 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -808,9 +808,10 @@ impl super::Adapter { max_uniform_buffers_per_shader_stage: full_heap_count, max_binding_array_elements_per_shader_stage: full_heap_count, max_binding_array_sampler_elements_per_shader_stage: full_heap_count, - max_uniform_buffer_binding_size: - Direct3D12::D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT as u64 * 16, - max_storage_buffer_binding_size: auxil::MAX_I32_BINDING_SIZE as u64, + max_uniform_buffer_binding_size: u64::from( + Direct3D12::D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT, + ) * 16, + max_storage_buffer_binding_size: u64::from(auxil::MAX_I32_BINDING_SIZE), max_vertex_buffers: Direct3D12::D3D12_VS_INPUT_REGISTER_COUNT, max_vertex_attributes: Direct3D12::D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, max_vertex_buffer_array_stride: Direct3D12::D3D12_SO_BUFFER_MAX_STRIDE_IN_BYTES, diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 1a64536ed..951b07a57 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -1458,11 +1458,11 @@ impl PhysicalDeviceProperties { max_uniform_buffer_binding_size: limits .max_uniform_buffer_range .min(crate::auxil::MAX_I32_BINDING_SIZE) - as u64, + .into(), max_storage_buffer_binding_size: limits .max_storage_buffer_range .min(crate::auxil::MAX_I32_BINDING_SIZE) - as u64, + .into(), max_vertex_buffers: limits.max_vertex_input_bindings, max_vertex_attributes: limits.max_vertex_input_attributes, max_vertex_buffer_array_stride: limits.max_vertex_input_binding_stride,