Skip to content

Support Atomics #442

Closed
Closed
@XAMPPRocky

Description

@XAMPPRocky

Currently if you try to use an atomic you get the following error.

Code

Playground

#![no_std]
#![feature(register_attr)]
#![register_attr(spirv)]

use core::sync::atomic::AtomicI32;

#[allow(unused_attributes)]
#[spirv(vertex)]
pub fn main_vs() {
    let atomic = AtomicI32::from(65);
    
    atomic.fetch_add(35, core::sync::atomic::Ordering::AcqRel);
    assert!(atomic.load(core::sync::atomic::Ordering::AcqRel) == 100);
}

Error

error: Cannot use AtomicOrdering=SequentiallyConsistent on Vulkan memory model. Check if AcquireRelease fits your needs.

error: Cannot use AtomicOrdering=SequentiallyConsistent on Vulkan memory model. Check if AcquireRelease fits your needs.

error: Cannot cast between pointer types
     |
     = note: from: *{Function} struct core::sync::atomic::AtomicI32 { v: i32 }
     = note: to: *{Function} u32
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: Cannot cast between pointer types
  --> D:\local\Temp\2b65e857-11aa-4ed1-a4a1-8dfa7f30591a\lib.rs:12:18
   |
12 |     let atomic = AtomicI32::new(65);
   |                  ^^^^^^^^^^^^^^^^^^
   |
   = note: from: *{Function} struct core::sync::atomic::AtomicI32 { v: i32 }
   = note: to: *{Function} u32

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: rust-langIssues specific to rust-lang/rust.t: enhancementA new feature or improvement to an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions