Add some padding to the egui-wgpu uniform buffer for WebGL (#1671)

Required on Chromium
This commit is contained in:
Ashley 2022-05-28 18:41:01 +02:00 committed by GitHub
parent 2771c8c3e5
commit abff2dcae2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -104,6 +104,9 @@ impl ScreenDescriptor {
#[repr(C)]
struct UniformBuffer {
screen_size_in_points: [f32; 2],
// Uniform buffers need to be at least 16 bytes in WebGL.
// See https://github.com/gfx-rs/wgpu/issues/2072
_padding: [u32; 2],
}
/// Wraps the buffers and includes additional information.
@ -151,6 +154,7 @@ impl RenderPass {
label: Some("egui_uniform_buffer"),
contents: bytemuck::cast_slice(&[UniformBuffer {
screen_size_in_points: [0.0, 0.0],
_padding: Default::default(),
}]),
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
});
@ -661,6 +665,7 @@ impl RenderPass {
0,
bytemuck::cast_slice(&[UniformBuffer {
screen_size_in_points,
_padding: Default::default(),
}]),
);