-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - Update vendored Crevice to 0.8.0 + PR for arrays #3059
Closed
+1,846
−668
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
[package] | ||
name = "crevice" | ||
description = "Create GLSL-compatible versions of structs with explicitly-initialized padding" | ||
version = "0.6.0" | ||
edition = "2018" | ||
version = "0.8.0" | ||
edition = "2021" | ||
authors = ["Lucien Greathouse <me@lpghatguy.com>"] | ||
documentation = "https://docs.rs/crevice" | ||
homepage = "https://github.com/LPGhatguy/crevice" | ||
repository = "https://github.com/LPGhatguy/crevice" | ||
readme = "README.md" | ||
keywords = ["glsl", "std140", "std430"] | ||
license = "MIT OR Apache-2.0" | ||
# resolver = "2" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[features] | ||
default = ["std"] | ||
std = [] | ||
|
||
# [workspace] | ||
# members = ["crevice-derive", "crevice-tests"] | ||
# default-members = ["crevice-derive", "crevice-tests"] | ||
|
||
[dependencies] | ||
crevice-derive = { version = "0.6.0", path = "crevice-derive" } | ||
crevice-derive = { version = "0.8.0", path = "crevice-derive" } | ||
|
||
bytemuck = "1.4.1" | ||
mint = "0.5.5" | ||
glam = "0.15.1" | ||
mint = "0.5.8" | ||
|
||
cgmath = { version = "0.18.0", optional = true } | ||
glam = { version = "0.20.0", features = ["mint"], optional = true } | ||
nalgebra = { version = "0.29.0", features = ["mint"], optional = true } | ||
|
||
[dev-dependencies] | ||
crevice-derive = { version = "0.6.0", path = "crevice-derive" } | ||
insta = "0.16.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use proc_macro2::{Literal, TokenStream}; | ||
use quote::quote; | ||
use syn::{parse_quote, Data, DeriveInput, Fields, Path}; | ||
|
||
pub fn emit(input: DeriveInput) -> TokenStream { | ||
let fields = match &input.data { | ||
Data::Struct(data) => match &data.fields { | ||
Fields::Named(fields) => fields, | ||
Fields::Unnamed(_) => panic!("Tuple structs are not supported"), | ||
Fields::Unit => panic!("Unit structs are not supported"), | ||
}, | ||
Data::Enum(_) | Data::Union(_) => panic!("Only structs are supported"), | ||
}; | ||
|
||
let base_trait_path: Path = parse_quote!(::crevice::glsl::Glsl); | ||
let struct_trait_path: Path = parse_quote!(::crevice::glsl::GlslStruct); | ||
|
||
let name = input.ident; | ||
let name_str = Literal::string(&name.to_string()); | ||
|
||
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); | ||
|
||
let glsl_fields = fields.named.iter().map(|field| { | ||
let field_ty = &field.ty; | ||
let field_name_str = Literal::string(&field.ident.as_ref().unwrap().to_string()); | ||
let field_as = quote! {<#field_ty as ::crevice::glsl::GlslArray>}; | ||
|
||
quote! { | ||
s.push_str("\t"); | ||
s.push_str(#field_as::NAME); | ||
s.push_str(" "); | ||
s.push_str(#field_name_str); | ||
<#field_as::ArraySize as ::crevice::glsl::DimensionList>::push_to_string(s); | ||
s.push_str(";\n"); | ||
} | ||
}); | ||
|
||
quote! { | ||
unsafe impl #impl_generics #base_trait_path for #name #ty_generics #where_clause { | ||
const NAME: &'static str = #name_str; | ||
} | ||
|
||
unsafe impl #impl_generics #struct_trait_path for #name #ty_generics #where_clause { | ||
fn enumerate_fields(s: &mut String) { | ||
#( #glsl_fields )* | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifying a version here will make cargo use the non-vendored version when publishing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 3 dependencies on crevice in Bevy crates, it was the only one not specifying a version so I added it for consistency.
Before Bevy release, Cart will also have to rename it to "bevy_crevice" or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That depends whether we even need to vendor it anymore. I think we should at least try it from crates.io after the recent rewrite and see if it fits our needs or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, it's missing the array PR. once that's merged and released we wouldn't need to vendor it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! :)