From 6ac3cb9670ca4e8cba9ec822b93c7d175fe6195f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralph=20K=C3=BCpper?= Date: Tue, 9 Jun 2026 12:12:21 +0200 Subject: [PATCH] fix(android): raise uniform/storage buffer-binding limits to adapter max MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Android device was created from wgpu::Limits::downlevel_defaults() (which caps max_uniform_buffer_binding_size at 16KB) merged only with .using_resolution (which touches texture-dimension limits, not buffer-binding sizes). The renderer binds a 64KB uniform buffer for joint matrices ('joint_bg'), so on real mobile GPUs (e.g. Adreno) Device::create_bind_group aborts at init: wgpu error: Validation Error In Device::create_bind_group, label = 'joint_bg' Buffer binding 0 range 65536 exceeds max_*_buffer_binding_size limit 16384 Desktop (linux/macOS) uses Limits::default() (64KB binding), so it never hit this. Raise the uniform/storage buffer-binding sizes (and bind-group count) to the adapter's reported maximum — guaranteed-supported, matching desktop. Verified: cargo check --target aarch64-linux-android passes; a Perry Android build now launches + renders on an Adreno device instead of SIGABRT at init. --- native/android/src/lib.rs | 15 ++++++++++++++- package.json | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/native/android/src/lib.rs b/native/android/src/lib.rs index e5b89e8..c90d60a 100644 --- a/native/android/src/lib.rs +++ b/native/android/src/lib.rs @@ -184,8 +184,21 @@ pub extern "C" fn bloom_init_window(width: f64, height: f64, title_ptr: *const u } else { wgpu::ExperimentalFeatures::disabled() }; + let adapter_limits = adapter.limits(); let mut required_limits = wgpu::Limits::downlevel_defaults() - .using_resolution(adapter.limits()); + .using_resolution(adapter_limits.clone()); + // The renderer's `joint_bg` binds a 64KB uniform buffer, but + // downlevel_defaults caps uniform-buffer bindings at 16KB, so + // create_bind_group panics on mobile GPUs (e.g. Adreno) with + // "range 65536 exceeds max_*_buffer_binding_size limit 16384". Raise the + // buffer-binding sizes (and bind-group count) to the adapter's maximum; + // these are guaranteed-supported and match the desktop limits. + required_limits.max_uniform_buffer_binding_size = + adapter_limits.max_uniform_buffer_binding_size; + required_limits.max_storage_buffer_binding_size = + adapter_limits.max_storage_buffer_binding_size; + required_limits.max_bind_groups = + required_limits.max_bind_groups.max(5).min(adapter_limits.max_bind_groups); if required_features.intersects(rt_mask) { required_limits = required_limits .using_minimum_supported_acceleration_structure_values(); diff --git a/package.json b/package.json index ab77a80..8b12e74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bloomengine/engine", - "version": "0.4.14", + "version": "0.4.15", "description": "Bloom Engine: native TypeScript game engine compiled by Perry", "main": "src/index.ts", "types": "src/index.ts",