Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make shadow example runnable on iOS Android devices #2433

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions wgpu/examples/shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,17 @@ impl framework::Example for Example {

let entity_uniform_size = mem::size_of::<EntityUniforms>() as wgpu::BufferAddress;
let num_entities = 1 + cube_descs.len() as wgpu::BufferAddress;
let uniform_alignment =
device.limits().min_uniform_buffer_offset_alignment as wgpu::BufferAddress;
assert!(entity_uniform_size <= uniform_alignment);
// Make the `uniform_alignment` >= `entity_uniform_size` and aligned to `min_uniform_buffer_offset_alignment`.
let uniform_alignment = {
let alignment =
device.limits().min_uniform_buffer_offset_alignment as wgpu::BufferAddress;
let rem = entity_uniform_size % alignment;
if rem != 0 {
entity_uniform_size + alignment - rem
} else {
entity_uniform_size
}
};
// Note: dynamic uniform offsets also have to be aligned to `Limits::min_uniform_buffer_offset_alignment`.
let entity_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
Expand Down