Fix alignment in triangle pipeline of iced_wgpu
This commit is contained in:
parent
df157ef616
commit
9c98502e10
@ -224,11 +224,9 @@ impl Pipeline {
|
|||||||
|
|
||||||
// We upload everything upfront
|
// We upload everything upfront
|
||||||
for (origin, mesh) in meshes {
|
for (origin, mesh) in meshes {
|
||||||
let transform = Uniforms {
|
let transform = (transformation
|
||||||
transform: (transformation
|
* Transformation::translate(origin.x, origin.y))
|
||||||
* Transformation::translate(origin.x, origin.y))
|
.into();
|
||||||
.into(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let vertex_buffer = device
|
let vertex_buffer = device
|
||||||
.create_buffer_mapped(
|
.create_buffer_mapped(
|
||||||
@ -357,12 +355,28 @@ impl Pipeline {
|
|||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
struct Uniforms {
|
struct Uniforms {
|
||||||
transform: [f32; 16],
|
transform: [f32; 16],
|
||||||
|
// We need to align this to 256 bytes to please `wgpu`...
|
||||||
|
// TODO: Be smarter and stop wasting memory!
|
||||||
|
_padding_a: [f32; 32],
|
||||||
|
_padding_b: [f32; 16],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Uniforms {
|
impl Default for Uniforms {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
transform: *Transformation::identity().as_ref(),
|
transform: *Transformation::identity().as_ref(),
|
||||||
|
_padding_a: [0.0; 32],
|
||||||
|
_padding_b: [0.0; 16],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Transformation> for Uniforms {
|
||||||
|
fn from(transformation: Transformation) -> Uniforms {
|
||||||
|
Self {
|
||||||
|
transform: transformation.into(),
|
||||||
|
_padding_a: [0.0; 32],
|
||||||
|
_padding_b: [0.0; 16],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user