Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gpu_only proc macro #392

Merged
merged 1 commit into from
Jan 25, 2021
Merged

Add gpu_only proc macro #392

merged 1 commit into from
Jan 25, 2021

Conversation

XAMPPRocky
Copy link
Member

@XAMPPRocky XAMPPRocky commented Jan 22, 2021

This PR adds a #[gpu_only] macro to spirv-std-macros, which essentially expands to the following. Which we were doing a lot in the code already, and will only add more in the future.

#[gpu_only]
fn foo() {
    // SPIR-V fn body.
}

// Generates

fn foo() {
     #[cfg(target_arch = "spriv")] {
        // SPIR-V fn body.
     }
     
     #[cfg(not(target_arch = "spriv"))] {
         unimplemented!()
     }
}

crates/spirv-std/src/textures.rs Outdated Show resolved Hide resolved
pub fn demote_to_helper_invocation() {
#[cfg(target_arch = "spirv")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just calling out the change of semantics here for others, but I probably don't care either way.

@khyperia
Copy link
Contributor

how does this handle unused argument warnings on the CPU?

Comment on lines +45 to +46
// Don't warn on unused arguments on the CPU side.
#[cfg_attr(not(target_arch = "spirv"), allow(unused_variables))]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this handle unused argument warnings on the CPU?

It adds allow(unused_variables) when compiled for CPU targets.

@XAMPPRocky XAMPPRocky merged commit 353bb96 into main Jan 25, 2021
@XAMPPRocky XAMPPRocky deleted the gpu-macro branch January 25, 2021 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants