Add feature to control 16 byte alignment of uniforms.
This commit is contained in:
parent
2ac918d63a
commit
4fe9443feb
@ -26,7 +26,8 @@ bevy = { version = "0.8", default-features = false, features = [
|
|||||||
] }
|
] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["bevy_ui"]
|
default = ["align16", "bevy_ui"]
|
||||||
|
align16 = []
|
||||||
bevy_ui = ["bevy/bevy_ui", "bevy/bevy_sprite", "bevy/bevy_text"]
|
bevy_ui = ["bevy/bevy_ui", "bevy/bevy_sprite", "bevy/bevy_text"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
@ -6,17 +6,23 @@ struct VertexInput {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct OutlineViewUniform {
|
struct OutlineViewUniform {
|
||||||
|
#ifdef ALIGN_16
|
||||||
@align(16)
|
@align(16)
|
||||||
|
#endif
|
||||||
scale: vec2<f32>,
|
scale: vec2<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OutlineVertexUniform {
|
struct OutlineVertexUniform {
|
||||||
|
#ifdef ALIGN_16
|
||||||
@align(16)
|
@align(16)
|
||||||
|
#endif
|
||||||
width: f32,
|
width: f32,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OutlineFragmentUniform {
|
struct OutlineFragmentUniform {
|
||||||
|
#ifdef ALIGN_16
|
||||||
@align(16)
|
@align(16)
|
||||||
|
#endif
|
||||||
colour: vec4<f32>,
|
colour: vec4<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,17 +146,22 @@ impl SpecializedMeshPipeline for OutlinePipeline {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let shader_defs = if cfg!(feature = "align16") {
|
||||||
|
vec!["ALIGN_16".to_string()]
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
let buffers = vec![mesh_layout.get_layout(&buffer_attrs)?];
|
let buffers = vec![mesh_layout.get_layout(&buffer_attrs)?];
|
||||||
Ok(RenderPipelineDescriptor {
|
Ok(RenderPipelineDescriptor {
|
||||||
vertex: VertexState {
|
vertex: VertexState {
|
||||||
shader: shader.clone().typed::<Shader>(),
|
shader: shader.clone().typed::<Shader>(),
|
||||||
entry_point: "vertex".into(),
|
entry_point: "vertex".into(),
|
||||||
shader_defs: vec![],
|
shader_defs: shader_defs.clone(),
|
||||||
buffers,
|
buffers,
|
||||||
},
|
},
|
||||||
fragment: Some(FragmentState {
|
fragment: Some(FragmentState {
|
||||||
shader: shader.typed::<Shader>(),
|
shader: shader.typed::<Shader>(),
|
||||||
shader_defs: vec![],
|
shader_defs,
|
||||||
entry_point: "fragment".into(),
|
entry_point: "fragment".into(),
|
||||||
targets,
|
targets,
|
||||||
}),
|
}),
|
||||||
|
@ -17,7 +17,7 @@ use crate::{pipeline::OutlinePipeline, Outline};
|
|||||||
|
|
||||||
#[derive(Clone, Component, ShaderType)]
|
#[derive(Clone, Component, ShaderType)]
|
||||||
pub struct OutlineVertexUniform {
|
pub struct OutlineVertexUniform {
|
||||||
#[align(16)]
|
#[cfg_attr(feature = "align16", align(16))]
|
||||||
pub width: f32,
|
pub width: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use crate::pipeline::OutlinePipeline;
|
|||||||
|
|
||||||
#[derive(Clone, Component, ShaderType)]
|
#[derive(Clone, Component, ShaderType)]
|
||||||
pub struct OutlineViewUniform {
|
pub struct OutlineViewUniform {
|
||||||
#[align(16)]
|
#[cfg_attr(feature = "align16", align(16))]
|
||||||
scale: Vec2,
|
scale: Vec2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user