Skip to content

Commit

Permalink
Preserve function abi in gpu_only macro (#617)
Browse files Browse the repository at this point in the history
* Preserve function abi in gpu_only macro
  • Loading branch information
msiglreith authored May 17, 2021
1 parent 943f09f commit fc268da
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/spirv-std/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,22 @@ pub fn gpu_only(_attr: TokenStream, item: TokenStream) -> TokenStream {

let fn_name = sig.ident.clone();

let sig = syn::Signature { abi: None, ..sig };
let sig_cpu = syn::Signature {
abi: None,
..sig.clone()
};

let output = quote::quote! {
// Don't warn on unused arguments on the CPU side.
#[cfg_attr(not(target_arch = "spirv"), allow(unused_variables))]
#[cfg(not(target_arch="spirv"))]
#[allow(unused_variables)]
#(#attrs)* #vis #sig_cpu {
unimplemented!(concat!("`", stringify!(#fn_name), "` is only available on SPIR-V platforms."))
}

#[cfg(target_arch="spirv")]
#(#attrs)* #vis #sig {
#[cfg(target_arch="spirv")] { #block }
#[cfg(not(target_arch="spirv"))] {
unimplemented!(concat!("`", stringify!(#fn_name), "` is only available on SPIR-V platforms."))
}
#block
}
};

Expand Down

0 comments on commit fc268da

Please sign in to comment.