Add some padding to the egui-wgpu uniform buffer for WebGL
Required on Chromium
@@ -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(),
}]),
);
