Skip to content

Commit

Permalink
Force binding sizes to be multiples of 16 on webgl
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Jun 25, 2022
1 parent 7375acb commit 28c659f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2807,6 +2807,14 @@ impl<A: HalApi> Device<A> {
self.require_features(wgt::Features::MULTIVIEW)?;
}

for (_, size) in &shader_binding_sizes {
if size.get() % 16 != 0 {
self.require_downlevel_flags(
wgt::DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED,
)?;
}
}

let late_sized_buffer_groups =
Device::make_late_sized_buffer_groups(&shader_binding_sizes, layout, &*bgl_guard);

Expand Down
4 changes: 4 additions & 0 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ impl super::Adapter {
wgt::DownlevelFlags::ANISOTROPIC_FILTERING,
extensions.contains("EXT_texture_filter_anisotropic"),
);
downlevel_flags.set(
wgt::DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED,
!cfg!(target_arch = "wasm32"),
);

let is_ext_color_buffer_float_supported = extensions.contains("EXT_color_buffer_float");

Expand Down
5 changes: 5 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,11 @@ bitflags::bitflags! {
/// Supports all the texture usages described in WebGPU. If this isn't supported, you
/// should call `get_texture_format_features` to get how you can use textures of a given format
const WEBGPU_TEXTURE_FORMAT_SUPPORT = 1 << 14;

/// Supports buffer bindings with sizes that aren't a multiple of 16.
///
/// WebGL doesn't support this.
const BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED = 1 << 15;
}
}

Expand Down

0 comments on commit 28c659f

Please sign in to comment.