Skip to content

Volatile Loads/Stores #513

Description

@voxelbee

I'm trying to use volatile loads and stores like so:

#[inline(always)]
pub fn get_item(&self, offset: u32) -> T {
    unsafe {
        let ptr = self
            .items
            .get_unchecked(((self.start_ticket + offset) % self.max_capacity) as usize);
        core::ptr::read_volatile(ptr)
    }
}

#[inline(always)]
pub fn set_item(&mut self, offset: u32, item: T) {
    unsafe {
        let ptr = self
            .items
            .get_unchecked_mut(((self.start_ticket + offset) % self.max_capacity) as usize);
        core::ptr::write_volatile(ptr, item);
    }
}

But when compiling I get an error saying this is not supported yet.

error: store_with_flags is not supported yet: MemFlags(VOLATILE)
      --> /home/peyton/.rustup/toolchains/nightly-2025-06-30-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:2180:9
       |
  2180 |         intrinsics::volatile_store(dst, src);
       |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It would be very useful to be able to specify this in loads. It seems like its possible in SPIRV using Memory Operands is there any way to do this currently?

System Info

  • SPIR-V: SPIRV-Tools v2025.4 v2025.4-0-g7f2d9ee9
    Targets:
    SPIR-V 1.0
    SPIR-V 1.1
    SPIR-V 1.2
    SPIR-V 1.3
    SPIR-V 1.4
    SPIR-V 1.5
    SPIR-V 1.6
    SPIR-V 1.2 (under OpenCL 2.2 Full Profile semantics)
    SPIR-V 1.0 (under Vulkan 1.0 semantics)
    SPIR-V 1.3 (under Vulkan 1.1 semantics)
    SPIR-V 1.4 (under Vulkan 1.1 semantics)
    SPIR-V 1.5 (under Vulkan 1.2 semantics)
    SPIR-V 1.6 (under Vulkan 1.3 semantics) SPIR-V 1.6 (under Vulkan 1.4 semantics)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions