mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Fix compilation for targets that don't have AtomicU64. (#7118)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
parent
37419a3690
commit
a26171b2a0
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -181,6 +181,14 @@ jobs:
|
|||||||
tier: 2
|
tier: 2
|
||||||
kind: no_std
|
kind: no_std
|
||||||
|
|
||||||
|
# 32-bit PowerPC Linux
|
||||||
|
# Included to test support for `portable-atomic`
|
||||||
|
- name: Linux ppc32
|
||||||
|
os: ubuntu-22.04
|
||||||
|
target: powerpc-unknown-linux-gnu
|
||||||
|
tier: 2
|
||||||
|
kind: wgpu-only
|
||||||
|
|
||||||
name: Clippy ${{ matrix.name }}
|
name: Clippy ${{ matrix.name }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
|||||||
21
Cargo.lock
generated
21
Cargo.lock
generated
@ -1305,7 +1305,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2004,7 +2004,7 @@ checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"hermit-abi",
|
"hermit-abi",
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2134,7 +2134,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.48.5",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3043,6 +3043,12 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"
|
checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "portable-atomic"
|
||||||
|
version = "1.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pp-rs"
|
name = "pp-rs"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@ -3336,7 +3342,7 @@ dependencies = [
|
|||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys",
|
"linux-raw-sys",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4005,7 +4011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "69fff37da548239c3bf9e64a12193d261e8b22b660991c6fd2df057c168f435f"
|
checksum = "69fff37da548239c3bf9e64a12193d261e8b22b660991c6fd2df057c168f435f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"windows-targets 0.48.5",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4507,6 +4513,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"naga",
|
"naga",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
|
"portable-atomic",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle 0.6.2",
|
"raw-window-handle 0.6.2",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@ -4551,6 +4558,7 @@ dependencies = [
|
|||||||
"naga",
|
"naga",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
|
"portable-atomic",
|
||||||
"profiling",
|
"profiling",
|
||||||
"raw-window-handle 0.6.2",
|
"raw-window-handle 0.6.2",
|
||||||
"ron",
|
"ron",
|
||||||
@ -4681,6 +4689,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"ordered-float",
|
"ordered-float",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
|
"portable-atomic",
|
||||||
"profiling",
|
"profiling",
|
||||||
"range-alloc",
|
"range-alloc",
|
||||||
"raw-window-handle 0.5.2",
|
"raw-window-handle 0.5.2",
|
||||||
@ -4804,7 +4813,7 @@ version = "0.1.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@ -135,6 +135,7 @@ pico-args = { version = "0.5.0", features = [
|
|||||||
] }
|
] }
|
||||||
png = "0.17.16"
|
png = "0.17.16"
|
||||||
pollster = "0.4"
|
pollster = "0.4"
|
||||||
|
portable-atomic = "1"
|
||||||
profiling = { version = "1", default-features = false }
|
profiling = { version = "1", default-features = false }
|
||||||
raw-window-handle = { version = "0.6", default-features = false }
|
raw-window-handle = { version = "0.6", default-features = false }
|
||||||
rayon = "1"
|
rayon = "1"
|
||||||
|
|||||||
@ -114,6 +114,9 @@ fragile-send-sync-non-atomic-wasm = [
|
|||||||
## Enable using the `mach-dxcompiler-rs` crate to compile DX12 shaders.
|
## Enable using the `mach-dxcompiler-rs` crate to compile DX12 shaders.
|
||||||
static-dxc = ["wgpu-hal/static-dxc"]
|
static-dxc = ["wgpu-hal/static-dxc"]
|
||||||
|
|
||||||
|
## Enable portable atomics on platforms that do not support 64bit atomics.
|
||||||
|
portable-atomic = ["dep:portable-atomic", "wgpu-hal/portable-atomic"]
|
||||||
|
|
||||||
#! ### Target Conditional Features
|
#! ### Target Conditional Features
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# Look to wgpu-hal's Cargo.toml for explaination how these features and the wgpu-core
|
# Look to wgpu-hal's Cargo.toml for explaination how these features and the wgpu-core
|
||||||
@ -179,5 +182,8 @@ serde = { workspace = true, features = ["default", "derive"], optional = true }
|
|||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||||
|
portable-atomic = { workspace = true, optional = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cfg_aliases.workspace = true
|
cfg_aliases.workspace = true
|
||||||
|
|||||||
@ -18,5 +18,7 @@ fn main() {
|
|||||||
all(target_vendor = "apple", feature = "vulkan-portability") // Vulkan Portability on Apple
|
all(target_vendor = "apple", feature = "vulkan-portability") // Vulkan Portability on Apple
|
||||||
) },
|
) },
|
||||||
metal: { all(target_vendor = "apple", feature = "metal") },
|
metal: { all(target_vendor = "apple", feature = "metal") },
|
||||||
|
|
||||||
|
supports_64bit_atomics: { target_has_atomic = "64" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use core::{
|
|||||||
fmt,
|
fmt,
|
||||||
mem::{self, ManuallyDrop},
|
mem::{self, ManuallyDrop},
|
||||||
num::NonZeroU32,
|
num::NonZeroU32,
|
||||||
sync::atomic::{AtomicBool, AtomicU64, Ordering},
|
sync::atomic::{AtomicBool, Ordering},
|
||||||
};
|
};
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
@ -57,6 +57,11 @@ use super::{
|
|||||||
ENTRYPOINT_FAILURE_ERROR, ZERO_BUFFER_SIZE,
|
ENTRYPOINT_FAILURE_ERROR, ZERO_BUFFER_SIZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(supports_64bit_atomics)]
|
||||||
|
use core::sync::atomic::AtomicU64;
|
||||||
|
#[cfg(not(supports_64bit_atomics))]
|
||||||
|
use portable_atomic::AtomicU64;
|
||||||
|
|
||||||
/// Structure describing a logical device. Some members are internally mutable,
|
/// Structure describing a logical device. Some members are internally mutable,
|
||||||
/// stored behind mutexes.
|
/// stored behind mutexes.
|
||||||
pub struct Device {
|
pub struct Device {
|
||||||
|
|||||||
@ -155,6 +155,7 @@ renderdoc = ["dep:libloading", "dep:renderdoc-sys", "dep:log"]
|
|||||||
fragile-send-sync-non-atomic-wasm = [
|
fragile-send-sync-non-atomic-wasm = [
|
||||||
"wgpu-types/fragile-send-sync-non-atomic-wasm",
|
"wgpu-types/fragile-send-sync-non-atomic-wasm",
|
||||||
]
|
]
|
||||||
|
portable-atomic = ["dep:portable-atomic"]
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
### Internal Debugging Features ###
|
### Internal Debugging Features ###
|
||||||
@ -300,6 +301,9 @@ khronos-egl = { workspace = true, optional = true, features = [
|
|||||||
# Note: it's unused by emscripten, but we keep it to have single code base in egl.rs
|
# Note: it's unused by emscripten, but we keep it to have single code base in egl.rs
|
||||||
libloading = { workspace = true, optional = true }
|
libloading = { workspace = true, optional = true }
|
||||||
|
|
||||||
|
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||||
|
portable-atomic = { workspace = true, optional = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cfg_aliases.workspace = true
|
cfg_aliases.workspace = true
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ fn main() {
|
|||||||
metal: { all(target_vendor = "apple", feature = "metal") },
|
metal: { all(target_vendor = "apple", feature = "metal") },
|
||||||
vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") },
|
vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") },
|
||||||
// ⚠️ Keep in sync with target.cfg() definition in Cargo.toml and cfg_alias in `wgpu` crate ⚠️
|
// ⚠️ Keep in sync with target.cfg() definition in Cargo.toml and cfg_alias in `wgpu` crate ⚠️
|
||||||
static_dxc: { all(target_os = "windows", feature = "static-dxc", not(target_arch = "aarch64")) }
|
static_dxc: { all(target_os = "windows", feature = "static-dxc", not(target_arch = "aarch64")) },
|
||||||
|
supports_64bit_atomics: { target_has_atomic = "64" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -317,7 +317,10 @@ pub const QUERY_SIZE: wgt::BufferAddress = 8;
|
|||||||
pub type Label<'a> = Option<&'a str>;
|
pub type Label<'a> = Option<&'a str>;
|
||||||
pub type MemoryRange = Range<wgt::BufferAddress>;
|
pub type MemoryRange = Range<wgt::BufferAddress>;
|
||||||
pub type FenceValue = u64;
|
pub type FenceValue = u64;
|
||||||
|
#[cfg(supports_64bit_atomics)]
|
||||||
pub type AtomicFenceValue = core::sync::atomic::AtomicU64;
|
pub type AtomicFenceValue = core::sync::atomic::AtomicU64;
|
||||||
|
#[cfg(not(supports_64bit_atomics))]
|
||||||
|
pub type AtomicFenceValue = portable_atomic::AtomicU64;
|
||||||
|
|
||||||
/// A callback to signal that wgpu is no longer using a resource.
|
/// A callback to signal that wgpu is no longer using a resource.
|
||||||
#[cfg(any(gles, vulkan))]
|
#[cfg(any(gles, vulkan))]
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
||||||
use alloc::{string::String, vec, vec::Vec};
|
use alloc::{string::String, vec, vec::Vec};
|
||||||
use core::{
|
use core::{ptr, sync::atomic::Ordering, time::Duration};
|
||||||
ptr,
|
|
||||||
sync::atomic::{AtomicU64, Ordering},
|
#[cfg(supports_64bit_atomics)]
|
||||||
time::Duration,
|
use core::sync::atomic::AtomicU64;
|
||||||
};
|
#[cfg(not(supports_64bit_atomics))]
|
||||||
|
use portable_atomic::AtomicU64;
|
||||||
|
|
||||||
use crate::TlasInstance;
|
use crate::TlasInstance;
|
||||||
|
|
||||||
|
|||||||
@ -179,6 +179,7 @@ wgpu-core = { workspace = true, features = [
|
|||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"renderdoc",
|
"renderdoc",
|
||||||
"indirect-validation",
|
"indirect-validation",
|
||||||
|
"portable-atomic",
|
||||||
] }
|
] }
|
||||||
wgpu-hal.workspace = true
|
wgpu-hal.workspace = true
|
||||||
|
|
||||||
@ -216,5 +217,8 @@ wgpu-hal.workspace = true
|
|||||||
|
|
||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||||
|
portable-atomic.workspace = true
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cfg_aliases.workspace = true
|
cfg_aliases.workspace = true
|
||||||
|
|||||||
@ -16,5 +16,6 @@ fn main() {
|
|||||||
naga: { any(feature = "naga-ir", feature = "spirv", feature = "glsl") },
|
naga: { any(feature = "naga-ir", feature = "spirv", feature = "glsl") },
|
||||||
// ⚠️ Keep in sync with target.cfg() definition in wgpu-hal/Cargo.toml and cfg_alias in `wgpu-hal` crate ⚠️
|
// ⚠️ Keep in sync with target.cfg() definition in wgpu-hal/Cargo.toml and cfg_alias in `wgpu-hal` crate ⚠️
|
||||||
static_dxc: { all(target_os = "windows", feature = "static-dxc", not(target_arch = "aarch64")) },
|
static_dxc: { all(target_os = "windows", feature = "static-dxc", not(target_arch = "aarch64")) },
|
||||||
|
supports_64bit_atomics: { target_has_atomic = "64" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,12 @@
|
|||||||
//!
|
//!
|
||||||
//! For types (like WebGPU) that don't have such a property, we generate an identifier and use that.
|
//! For types (like WebGPU) that don't have such a property, we generate an identifier and use that.
|
||||||
|
|
||||||
use core::{
|
#[cfg(supports_64bit_atomics)]
|
||||||
num::NonZeroU64,
|
pub use core::sync::atomic::AtomicU64;
|
||||||
sync::atomic::{AtomicU64, Ordering},
|
#[cfg(not(supports_64bit_atomics))]
|
||||||
};
|
pub use portable_atomic::AtomicU64;
|
||||||
|
|
||||||
|
use core::{num::NonZeroU64, sync::atomic::Ordering};
|
||||||
|
|
||||||
static NEXT_ID: AtomicU64 = AtomicU64::new(1);
|
static NEXT_ID: AtomicU64 = AtomicU64::new(1);
|
||||||
|
|
||||||
|
|||||||
@ -155,6 +155,22 @@ pub fn check_feature_dependencies(shell: Shell, arguments: Arguments) -> anyhow:
|
|||||||
default_features: false,
|
default_features: false,
|
||||||
search_terms: &[Search::Positive("glow")],
|
search_terms: &[Search::Positive("glow")],
|
||||||
},
|
},
|
||||||
|
Requirement {
|
||||||
|
human_readable_name: "x86-64 does not depend on portable-atomic",
|
||||||
|
target: "x86_64-unknown-linux-gnu",
|
||||||
|
packages: &["wgpu"],
|
||||||
|
features: &[],
|
||||||
|
default_features: false,
|
||||||
|
search_terms: &[Search::Negative("portable-atomic")],
|
||||||
|
},
|
||||||
|
Requirement {
|
||||||
|
human_readable_name: "ppc32 does depend on portable-atomic",
|
||||||
|
target: "powerpc-unknown-linux-gnu",
|
||||||
|
packages: &["wgpu"],
|
||||||
|
features: &[],
|
||||||
|
default_features: false,
|
||||||
|
search_terms: &[Search::Positive("portable-atomic")],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut any_failures = false;
|
let mut any_failures = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user