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

Decouple glam from spirv-std, add const-generics feature flag. #476

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

XAMPPRocky
Copy link
Member

This PR removes glam as a dependency from spirv-std. Since we still use it for our tests, we currently have to patch it with a forked version of glam that contains the trait implementations we need until glam can depend on these changes directly. It also exports derivative::derive_impl as a hidden export so that glam can use it in its implementation.

This PR also introduces a new const-generics feature flag, and reintroduces some of the const generics in order to be able enforce the restrictions on these types through the Vector trait. Having these under a feature flag, will allow us to iterate and add condt generic code without affecting Ark until they are released on stable at the end of the month, and then we can remove it for primitives.

glam branch diff

@XAMPPRocky XAMPPRocky requested review from eddyb and khyperia March 8, 2021 12:01
@XAMPPRocky XAMPPRocky requested review from fu5ha and VZout as code owners March 8, 2021 12:01
@XAMPPRocky XAMPPRocky force-pushed the decouple-glam branch 2 times, most recently from b85d4f6 to 008ccc6 Compare March 8, 2021 12:04
@VZout VZout removed their request for review March 8, 2021 12:09
@XAMPPRocky XAMPPRocky force-pushed the decouple-glam branch 2 times, most recently from 0f48669 to e34f2ec Compare March 8, 2021 12:24
@fu5ha fu5ha removed their request for review March 8, 2021 20:35
crates/spirv-std/src/arch.rs Outdated Show resolved Hide resolved
examples/shaders/shared/Cargo.toml Outdated Show resolved Hide resolved
crates/spirv-std/src/derivative.rs Show resolved Hide resolved
crates/spirv-std/src/textures.rs Outdated Show resolved Hide resolved
@XAMPPRocky XAMPPRocky force-pushed the decouple-glam branch 9 times, most recently from a3be4c6 to f59221c Compare March 12, 2021 10:01
@XAMPPRocky XAMPPRocky requested a review from khyperia March 12, 2021 10:15
@XAMPPRocky
Copy link
Member Author

This should be ready for review. The main change is that I've added a new proc-macro called vectorized where it automatically creates a vector version of the function based on the arguments of the original function.

Copy link
Contributor

@eddyb eddyb left a comment

Choose a reason for hiding this comment

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

LGTM, modulo the concerns about whether the traits should be unsafe trait.

@XAMPPRocky
Copy link
Member Author

@khyperia This should be ready for a final review.

Copy link
Contributor

@khyperia khyperia left a comment

Choose a reason for hiding this comment

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

LGTM pending some outdated stuff

crates/spirv-builder/src/test/basic.rs Outdated Show resolved Hide resolved
crates/spirv-builder/src/test/basic.rs Outdated Show resolved Hide resolved
@XAMPPRocky XAMPPRocky enabled auto-merge (squash) March 16, 2021 08:27
@XAMPPRocky XAMPPRocky dismissed khyperia’s stale review March 16, 2021 08:51

Already approved.

@XAMPPRocky XAMPPRocky requested review from khyperia and eddyb March 16, 2021 08:51
@XAMPPRocky
Copy link
Member Author

I need one of you to give me the green checkmark to merge. 😄

Copy link
Contributor

@khyperia khyperia left a comment

Choose a reason for hiding this comment

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

approved pending two more things, sorry!

@@ -463,6 +463,9 @@ pub fn main() {
let vector = glam::Vec2::new(1.0, 2.0);
let element = unsafe { spirv_std::arch::vector_extract_dynamic(vector, 1) };
assert!(2.0 == element);
let uvector = glam::UVec2::new(1, 2);
let element: u32 = unsafe { spirv_std::arch::vector_extract_dynamic(uvector, 1) };
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, meant to include this in my comment too but didn't want to spam too many comments

Suggested change
let element: u32 = unsafe { spirv_std::arch::vector_extract_dynamic(uvector, 1) };
let element = unsafe { spirv_std::arch::vector_extract_dynamic(uvector, 1) };

Copy link
Member Author

Choose a reason for hiding this comment

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

Spam me with review comments 😄

@@ -568,7 +575,7 @@ fn image_read() {
val(r#"
#[spirv(fragment)]
pub fn main(image: UniformConstant<StorageImage2d>, mut output: Output<glam::Vec2>) {
let coords = image.read(glam::IVec2::new(0, 1));
let coords = image.read(glam::IVec2::new(0, 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: formatting

Suggested change
let coords = image.read(glam::IVec2::new(0, 1));
let coords = image.read(glam::IVec2::new(0, 1));

@XAMPPRocky XAMPPRocky merged commit 6e8453f into main Mar 16, 2021
@XAMPPRocky XAMPPRocky deleted the decouple-glam branch March 16, 2021 08:59
@khyperia
Copy link
Contributor

oh. silly me, didn't see the automerge enable, that's why I didn't approve in my previous comment :P

@XAMPPRocky
Copy link
Member Author

I'll make a followup PR for those

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.

3 participants