mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 00:04:15 +00:00
Automatically derive Pod
and Zeroable
for structs generated by vulkano-shaders (#2117)
This commit is contained in:
parent
daa139dd53
commit
41a37735d1
@ -210,10 +210,5 @@ void main() {
|
||||
f_color.rgb = push_constants.color.rgb * in_diffuse;
|
||||
f_color.a = 1.0;
|
||||
}",
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -235,10 +235,5 @@ void main() {
|
||||
f_color.rgb = light_percent * push_constants.color.rgb * in_diffuse;
|
||||
f_color.a = 1.0;
|
||||
}",
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -267,10 +267,5 @@ void main() {
|
||||
f_color.rgb = push_constants.color.rgb * light_percent * in_diffuse;
|
||||
f_color.a = 1.0;
|
||||
}",
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -257,10 +257,5 @@ void main() {
|
||||
);
|
||||
imageStore(img, ivec2(gl_GlobalInvocationID.xy), write_color);
|
||||
}",
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -265,10 +265,5 @@ void main() {
|
||||
compute_color();
|
||||
}
|
||||
}",
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -113,11 +113,6 @@ fn main() {
|
||||
}
|
||||
}
|
||||
",
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,11 +177,6 @@ fn main() {
|
||||
"
|
||||
}
|
||||
},
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
|
||||
// The macro will create the following things in this module:
|
||||
|
@ -262,11 +262,6 @@ fn main() {
|
||||
verticies[index].vel = vel * exp(friction * push.delta_time);
|
||||
}
|
||||
",
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
}
|
||||
// Vertex shader determines color and is run once per particle.
|
||||
|
@ -456,11 +456,6 @@ mod vs {
|
||||
vulkano_shaders::shader! {
|
||||
ty: "vertex",
|
||||
path: "src/bin/teapot/vert.glsl",
|
||||
types_meta: {
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[derive(Clone, Copy, Zeroable, Pod)]
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,8 +419,6 @@ enum SourceKind {
|
||||
|
||||
struct TypesMeta {
|
||||
custom_derives: Vec<SynPath>,
|
||||
clone: bool,
|
||||
copy: bool,
|
||||
display: bool,
|
||||
debug: bool,
|
||||
default: bool,
|
||||
@ -433,9 +431,12 @@ impl Default for TypesMeta {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
custom_derives: vec![],
|
||||
clone: true,
|
||||
copy: true,
|
||||
custom_derives: vec![
|
||||
parse_quote! { Clone },
|
||||
parse_quote! { Copy },
|
||||
parse_quote! { bytemuck::Pod },
|
||||
parse_quote! { bytemuck::Zeroable },
|
||||
],
|
||||
partial_eq: false,
|
||||
debug: false,
|
||||
display: false,
|
||||
@ -451,8 +452,6 @@ impl TypesMeta {
|
||||
fn empty() -> Self {
|
||||
Self {
|
||||
custom_derives: Vec::new(),
|
||||
clone: false,
|
||||
copy: false,
|
||||
partial_eq: false,
|
||||
debug: false,
|
||||
display: false,
|
||||
@ -791,26 +790,6 @@ impl Parse for MacroInput {
|
||||
path.get_ident()
|
||||
{
|
||||
match derive_ident.to_string().as_str() {
|
||||
"Clone" => {
|
||||
if meta.default {
|
||||
return Err(in_brackets
|
||||
.error("Duplicate Clone derive"));
|
||||
}
|
||||
|
||||
meta.clone = true;
|
||||
|
||||
false
|
||||
}
|
||||
"Copy" => {
|
||||
if meta.copy {
|
||||
return Err(in_brackets
|
||||
.error("Duplicate Copy derive"));
|
||||
}
|
||||
|
||||
meta.copy = true;
|
||||
|
||||
false
|
||||
}
|
||||
"PartialEq" => {
|
||||
if meta.partial_eq {
|
||||
return Err(in_brackets
|
||||
@ -861,7 +840,7 @@ impl Parse for MacroInput {
|
||||
if meta
|
||||
.custom_derives
|
||||
.iter()
|
||||
.any(|candidate| candidate.eq(&path))
|
||||
.any(|candidate| *candidate == path)
|
||||
{
|
||||
return Err(
|
||||
in_braces.error("Duplicate derive declaration")
|
||||
|
@ -220,14 +220,6 @@ fn register_struct(
|
||||
fn write_derives(types_meta: &TypesMeta) -> TokenStream {
|
||||
let mut derives = vec![];
|
||||
|
||||
if types_meta.clone {
|
||||
derives.push(quote! { Clone });
|
||||
}
|
||||
|
||||
if types_meta.copy {
|
||||
derives.push(quote! { Copy });
|
||||
}
|
||||
|
||||
derives.extend(
|
||||
types_meta
|
||||
.custom_derives
|
||||
|
Loading…
Reference in New Issue
Block a user