Skip to content

Commit

Permalink
Fix web crash on missing uniform buffer padding
Browse files Browse the repository at this point in the history
The alignment is actually already there, but wgpu/Naga doesn't see it at this point.
  • Loading branch information
Wumpf committed Mar 23, 2023
1 parent 1802c20 commit c8d0b55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/re_renderer/shader/lines.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ var position_data_texture: texture_2d<u32>;

struct DrawDataUniformBuffer {
size_boost_in_points: f32,
// In actuality there is way more padding than this since we align all our uniform buffers to
// 256bytes in order to allow them to be buffer-suballocations.
// However, wgpu doesn't know this at this point and therefore requires `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`
// if we wouldn't add padding here, which isn't available on WebGL.
_padding: Vec4,
};
@group(1) @binding(2)
var<uniform> draw_data: DrawDataUniformBuffer;
Expand Down
5 changes: 5 additions & 0 deletions crates/re_renderer/shader/point_cloud.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ var color_texture: texture_2d<f32>;

struct DrawDataUniformBuffer {
size_boost_in_points: f32,
// In actuality there is way more padding than this since we align all our uniform buffers to
// 256bytes in order to allow them to be buffer-suballocations.
// However, wgpu doesn't know this at this point and therefore requires `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`
// if we wouldn't add padding here, which isn't available on WebGL.
_padding: Vec4,
};
@group(1) @binding(2)
var<uniform> draw_data: DrawDataUniformBuffer;
Expand Down

0 comments on commit c8d0b55

Please sign in to comment.