Skip to content

Commit

Permalink
Fix web crash on missing uniform buffer padding (#1699)
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 authored Mar 23, 2023
1 parent ccd907c commit 6e4ddaf
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

1 comment on commit 6e4ddaf

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: 6e4ddaf Previous: 1802c20 Ratio
datastore/insert/batch/rects/insert 554386 ns/iter (± 2668) 558040 ns/iter (± 2726) 0.99
datastore/latest_at/batch/rects/query 1879 ns/iter (± 8) 1869 ns/iter (± 5) 1.01
datastore/latest_at/missing_components/primary 288 ns/iter (± 0) 287 ns/iter (± 0) 1.00
datastore/latest_at/missing_components/secondaries 440 ns/iter (± 1) 456 ns/iter (± 0) 0.96
datastore/range/batch/rects/query 151829 ns/iter (± 535) 153037 ns/iter (± 237) 0.99
mono_points_arrow/generate_message_bundles 50479457 ns/iter (± 790654) 52357104 ns/iter (± 640637) 0.96
mono_points_arrow/generate_messages 134935769 ns/iter (± 1182651) 136205204 ns/iter (± 1313776) 0.99
mono_points_arrow/encode_log_msg 167153280 ns/iter (± 598278) 171213456 ns/iter (± 1741778) 0.98
mono_points_arrow/encode_total 354994844 ns/iter (± 1336970) 362883755 ns/iter (± 2060012) 0.98
mono_points_arrow/decode_log_msg 187046236 ns/iter (± 1045895) 189752854 ns/iter (± 4013520) 0.99
mono_points_arrow/decode_message_bundles 71967598 ns/iter (± 880957) 75254710 ns/iter (± 1140876) 0.96
mono_points_arrow/decode_total 254088789 ns/iter (± 1633199) 259499357 ns/iter (± 2333802) 0.98
batch_points_arrow/generate_message_bundles 341021 ns/iter (± 1530) 341982 ns/iter (± 553) 1.00
batch_points_arrow/generate_messages 6274 ns/iter (± 37) 6228 ns/iter (± 13) 1.01
batch_points_arrow/encode_log_msg 374497 ns/iter (± 8603) 372885 ns/iter (± 1494) 1.00
batch_points_arrow/encode_total 733510 ns/iter (± 3314) 746449 ns/iter (± 4228) 0.98
batch_points_arrow/decode_log_msg 344901 ns/iter (± 1061) 354317 ns/iter (± 1692) 0.97
batch_points_arrow/decode_message_bundles 2043 ns/iter (± 9) 2018 ns/iter (± 8) 1.01
batch_points_arrow/decode_total 353392 ns/iter (± 1167) 360005 ns/iter (± 2070) 0.98
arrow_mono_points/insert 6880523644 ns/iter (± 13711923) 7101183936 ns/iter (± 48000479) 0.97
arrow_mono_points/query 1830781 ns/iter (± 16862) 1847772 ns/iter (± 25156) 0.99
arrow_batch_points/insert 2673906 ns/iter (± 11319) 2738045 ns/iter (± 81908) 0.98
arrow_batch_points/query 16155 ns/iter (± 109) 16152 ns/iter (± 40) 1.00
arrow_batch_vecs/insert 42684 ns/iter (± 197) 43144 ns/iter (± 226) 0.99
arrow_batch_vecs/query 389424 ns/iter (± 1669) 389549 ns/iter (± 596) 1.00
tuid/Tuid::random 34 ns/iter (± 0) 34 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.