Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Conversation

@VZout
Copy link
Member

@VZout VZout commented Dec 11, 2020

  • Reverts 06de5ba in favor of spirv-attrib
  • allows compiling spirv-std and shaders on the CPU with stable.
  • allows compiling shaders on the GPU from a stable repo without having to nest workspaces. (Requires custom builder)

This would be a huge step forward for ark integration.

@VZout VZout marked this pull request as ready for review December 11, 2020 14:09
@VZout VZout requested review from khyperia and removed request for fu5ha and khyperia December 11, 2020 14:11
Comment on lines +22 to -18
#[spirv(block)]
#[derive(Copy, Clone)]
#[allow(unused_attributes)]
#[spirv(block)]
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason for this, or just formatting?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can't put proc macros bellow derives.

let end = item_str[start..item_str.len()].find(")]");
item_str.replace_range(start..start + end.unwrap() + 2, "");
}
TokenStream::from_str(item_str.as_str()).unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

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

the quadratic reparse time here makes me sad, but, I'll leave this up to @eddyb if they think this is OK since they know more about proc macros than me

Copy link
Member Author

@VZout VZout Dec 14, 2020

Choose a reason for hiding this comment

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

"quadratic reparse time" makes me sound really smart. 👍

Comment on lines +11 to +15
while let Some(start) = item_str.find("#[spirv(") {
let end = item_str[start..item_str.len()].find(")]");
item_str.replace_range(start..start + end.unwrap() + 2, "");
}
TokenStream::from_str(item_str.as_str()).unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you implement this by looking for [...] groups instead (preceded by #), in the TokenStream? Using strings feels very error-prone.

Ideally you could/would use syn but that seems like it would be a lot more work.

use proc_macro::TokenStream;
use std::str::FromStr;

#[cfg(not(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.

This won't do anything, I don't think, Cargo will only ever compile this for the host.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it did compile it unless I put the crate behind a [target.dependency] thing

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep your right doesn't get compiled.

@mergify mergify bot merged commit 1bcb994 into main Dec 14, 2020
@mergify mergify bot deleted the stable branch December 14, 2020 09:50
@@ -0,0 +1,16 @@
#![cfg_attr(target_arch = "spirv", feature(register_attr), register_attr(spirv))]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this does anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not? It only registers the spriv attribute on spirv architecture.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh your right 👍

@VZout VZout mentioned this pull request Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants