mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-12-01 19:24:11 +00:00
c3a9b9fd3e
* Accept `#[rust_gpu::spirv()]` attributes rather than `#[spirv()]` in backend * Implemented `#[spirv(..)]` proc macro attribute for all platforms that conditionally translates to `#[rust_gpu::spirv()]` based on platform * Changed `SpirvBuilder` to always apply `register_tool(rust_gpu)` attribute to shader crates * Updated docs * Added changelog
40 lines
1.4 KiB
Rust
40 lines
1.4 KiB
Rust
// revisions: normal via_intrinsic
|
|
// [normal] build-fail
|
|
// normalize-stderr-test "\S*/library/core/src/" -> "$$CORE_SRC/"
|
|
// [via_intrinsic] build-pass
|
|
// compile-flags: -C llvm-args=--disassemble-fn=ptr_copy::copy_via_raw_ptr
|
|
|
|
#![cfg_attr(via_intrinsic, feature(intrinsics))]
|
|
|
|
use spirv_std::spirv;
|
|
|
|
fn copy_via_raw_ptr(src: &f32, dst: &mut f32) {
|
|
#[cfg(via_intrinsic)]
|
|
{
|
|
extern "rust-intrinsic" {
|
|
fn copy<T>(src: *const T, dst: *mut T, count: usize);
|
|
}
|
|
unsafe { copy(src, dst, 1) }
|
|
}
|
|
|
|
#[cfg(normal)]
|
|
{
|
|
// FIXME(eddyb) `ptr::copy` doesn't currently work, and so the test uses
|
|
// the intrinsic for success and `ptr::copy` for failure, so that it can
|
|
// be switched back to `ptr::copy`-only when that starts succeeding,
|
|
// likely once https://github.com/rust-lang/rust/pull/86003 is reverted
|
|
// (and/or https://github.com/rust-lang/rust/pull/81238 is reattempted),
|
|
// which is blocked on https://github.com/rust-lang/rust/pull/86699.
|
|
unsafe { core::ptr::copy(src, dst, 1) }
|
|
}
|
|
}
|
|
#[spirv(fragment)]
|
|
pub fn main(i: f32, o: &mut f32) {
|
|
copy_via_raw_ptr(&i, o);
|
|
// FIXME(eddyb) above call results in inlining `copy_via_raw_ptr`,
|
|
// due to the to `Output` storage classe, so to get the disassembled
|
|
// function we also need `Function`-local pointers:
|
|
let (src, mut dst) = (0.0, 0.0);
|
|
copy_via_raw_ptr(&src, &mut dst);
|
|
}
|