mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 23:11:01 +01:00
refactor(hal): Remove unnecessary unsafe Send/Sync impls (#9580)
This commit is contained in:
1 parent
dd63d2244c
commit
1503796ad4
8 files changed
+36
-34
No files matched your search
@@ -1128,8 +1128,8 @@ pub struct Sampler {
|
||||
|
||||
impl crate::DynSampler for Sampler {}
|
||||
|
||||
unsafe impl Send for Sampler {}
|
||||
unsafe impl Sync for Sampler {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(Sampler: Send, Sync);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct QuerySet {
|
||||
|
||||
@@ -344,6 +344,11 @@ struct Inner {
|
||||
srgb_kind: SrgbFrameBufferKind,
|
||||
}
|
||||
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Send for Inner {}
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Sync for Inner {}
|
||||
|
||||
// Different calls to `eglGetPlatformDisplay` may return the same `Display`, making it a global
|
||||
// state of all our `EglContext`s. This forces us to track the number of such context to prevent
|
||||
// terminating the display if it's currently used by another `EglContext`.
|
||||
@@ -707,8 +712,8 @@ impl Instance {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for Instance {}
|
||||
unsafe impl Sync for Instance {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(Instance: Send, Sync);
|
||||
|
||||
impl crate::Instance for Instance {
|
||||
type A = super::Api;
|
||||
|
||||
@@ -692,6 +692,11 @@ struct PipelineInner {
|
||||
clip_distance_count: u32,
|
||||
}
|
||||
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Sync for PipelineInner {}
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Send for PipelineInner {}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct DepthState {
|
||||
function: u32,
|
||||
@@ -750,9 +755,7 @@ pub struct RenderPipeline {
|
||||
impl crate::DynRenderPipeline for RenderPipeline {}
|
||||
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Sync for RenderPipeline {}
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Send for RenderPipeline {}
|
||||
static_assertions::assert_impl_all!(RenderPipeline: Send, Sync);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ComputePipeline {
|
||||
@@ -762,9 +765,7 @@ pub struct ComputePipeline {
|
||||
impl crate::DynComputePipeline for ComputePipeline {}
|
||||
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Sync for ComputePipeline {}
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Send for ComputePipeline {}
|
||||
static_assertions::assert_impl_all!(ComputePipeline: Send, Sync);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct QuerySet {
|
||||
|
||||
@@ -107,9 +107,7 @@ impl Instance {
|
||||
}
|
||||
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Sync for Instance {}
|
||||
#[cfg(send_sync)]
|
||||
unsafe impl Send for Instance {}
|
||||
static_assertions::assert_impl_all!(Instance: Send, Sync);
|
||||
|
||||
impl crate::Instance for Instance {
|
||||
type A = super::Api;
|
||||
|
||||
@@ -41,8 +41,8 @@ pub struct AdapterContext {
|
||||
inner: Arc<Mutex<Inner>>,
|
||||
}
|
||||
|
||||
unsafe impl Sync for AdapterContext {}
|
||||
unsafe impl Send for AdapterContext {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(AdapterContext: Send, Sync);
|
||||
|
||||
impl AdapterContext {
|
||||
pub fn is_owned(&self) -> bool {
|
||||
@@ -182,8 +182,8 @@ pub struct Instance {
|
||||
inner: Arc<Mutex<Inner>>,
|
||||
}
|
||||
|
||||
unsafe impl Send for Instance {}
|
||||
unsafe impl Sync for Instance {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(Instance: Send, Sync);
|
||||
|
||||
fn load_gl_func(name: &str, module: Option<Foundation::HMODULE>) -> *const c_void {
|
||||
let addr = CString::new(name.as_bytes()).unwrap();
|
||||
|
||||
@@ -219,8 +219,6 @@
|
||||
clippy::single_match,
|
||||
// Push commands are more regular than macros.
|
||||
clippy::vec_init_then_push,
|
||||
// We unsafe impl `Send` for a reason.
|
||||
clippy::non_send_fields_in_send_ty,
|
||||
// TODO!
|
||||
clippy::missing_safety_doc,
|
||||
// It gets in the way a lot and does not prevent bugs in practice.
|
||||
|
||||
@@ -62,9 +62,6 @@ const MAX_ACCELERATION_STRUCTURES_PER_SHADER_STAGE: u32 = 1;
|
||||
// Use the end of the range for vertex buffers.
|
||||
pub const VERTEX_BUFFER_SLOT_START: u32 = 31 - 8;
|
||||
|
||||
unsafe impl Send for super::Adapter {}
|
||||
unsafe impl Sync for super::Adapter {}
|
||||
|
||||
impl super::Adapter {
|
||||
pub(super) fn new(shared: Arc<super::AdapterShared>) -> Self {
|
||||
Self { shared }
|
||||
|
||||
+15
-12
@@ -392,8 +392,8 @@ struct AdapterShared {
|
||||
presentation_timer: time::PresentationTimer,
|
||||
}
|
||||
|
||||
unsafe impl Send for AdapterShared {}
|
||||
unsafe impl Sync for AdapterShared {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(AdapterShared: Send, Sync);
|
||||
|
||||
impl AdapterShared {
|
||||
fn new(
|
||||
@@ -446,13 +446,16 @@ pub struct Adapter {
|
||||
shared: Arc<AdapterShared>,
|
||||
}
|
||||
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(Adapter: Send, Sync);
|
||||
|
||||
pub struct Queue {
|
||||
shared: Arc<QueueShared>,
|
||||
timestamp_period: f32,
|
||||
}
|
||||
|
||||
unsafe impl Send for Queue {}
|
||||
unsafe impl Sync for Queue {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(Queue: Send, Sync);
|
||||
|
||||
impl Queue {
|
||||
pub unsafe fn queue_from_raw(
|
||||
@@ -703,8 +706,8 @@ pub struct Sampler {
|
||||
|
||||
impl crate::DynSampler for Sampler {}
|
||||
|
||||
unsafe impl Send for Sampler {}
|
||||
unsafe impl Sync for Sampler {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(Sampler: Send, Sync);
|
||||
|
||||
impl Sampler {
|
||||
fn as_raw(&self) -> NonNull<ProtocolObject<dyn MTLSamplerState>> {
|
||||
@@ -887,8 +890,8 @@ pub struct PassthroughShader {
|
||||
pub num_workgroups: HashMap<String, (u32, u32, u32)>,
|
||||
}
|
||||
|
||||
unsafe impl Send for PassthroughShader {}
|
||||
unsafe impl Sync for PassthroughShader {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(PassthroughShader: Send, Sync);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ShaderModule {
|
||||
@@ -993,8 +996,8 @@ pub struct RenderPipeline {
|
||||
)>,
|
||||
}
|
||||
|
||||
unsafe impl Send for RenderPipeline {}
|
||||
unsafe impl Sync for RenderPipeline {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(RenderPipeline: Send, Sync);
|
||||
|
||||
impl crate::DynRenderPipeline for RenderPipeline {}
|
||||
|
||||
@@ -1004,8 +1007,8 @@ pub struct ComputePipeline {
|
||||
cs_info: PipelineStageInfo,
|
||||
}
|
||||
|
||||
unsafe impl Send for ComputePipeline {}
|
||||
unsafe impl Sync for ComputePipeline {}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(ComputePipeline: Send, Sync);
|
||||
|
||||
impl crate::DynComputePipeline for ComputePipeline {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user