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 0f48b09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/re_renderer/shader/lines.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ 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 size all uniform buffers are 256bytes aligned in order to be sub-allocatable.
// But wgpu doesn't know this 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
4 changes: 4 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,10 @@ var color_texture: texture_2d<f32>;

struct DrawDataUniformBuffer {
size_boost_in_points: f32,
// In actuality there is way more padding than this since we size all uniform buffers are 256bytes aligned in order to be sub-allocatable.
// But wgpu doesn't know this 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 0f48b09

Please sign in to comment.