Skip to content

Commit 5f061ea

Browse files
sampetterssonSam Pettersson
and
Sam Pettersson
authored
Fix Adreno 642L crash (#14937)
# Objective The Android example on Adreno 642L currently crashes on startup. Previous PRs #14176 and #13323 have adressed this specific crash occurring on some Adreno GPUs, that fix works as it should but isn't applied when to the GPU name contains a suffix like in the case of `642L`. ## Solution - Amending the logic to filter out any parts of the GPU name not containing digits thus enabling the fix on `642L`. ## Testing - Ran the Android example on a Nothing Phone 1. Before this change it crashed, after it works as intended. --------- Co-authored-by: Sam Pettersson <[email protected]>
1 parent 1690b28 commit 5f061ea

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

crates/bevy_render/src/batching/gpu_preprocessing.rs

+25-9
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,31 @@ impl FromWorld for GpuPreprocessingSupport {
226226
let adapter = world.resource::<RenderAdapter>();
227227
let device = world.resource::<RenderDevice>();
228228

229-
if device.limits().max_compute_workgroup_size_x == 0 ||
230-
// filter some Qualcomm devices on Android as they crash when using GPU preprocessing
231-
(cfg!(target_os = "android") && {
232-
let name = adapter.get_info().name;
233-
// filter out Adreno 730 and earlier GPUs (except 720, it's newer than 730)
234-
name.strip_prefix("Adreno (TM) ").is_some_and(|version|
235-
version != "720" && version.parse::<u16>().is_ok_and(|version| version <= 730)
236-
)
237-
})
229+
// filter some Qualcomm devices on Android as they crash when using GPU preprocessing.
230+
fn is_non_supported_android_device(adapter: &RenderAdapter) -> bool {
231+
if cfg!(target_os = "android") {
232+
let adapter_name = adapter.get_info().name;
233+
234+
// Filter out Adreno 730 and earlier GPUs (except 720, as it's newer than 730)
235+
// while also taking suffixes into account like Adreno 642L.
236+
let non_supported_adreno_model = |model: &str| -> bool {
237+
let model = model
238+
.chars()
239+
.map_while(|c| c.to_digit(10))
240+
.fold(0, |acc, digit| acc * 10 + digit);
241+
242+
model != 720 && model <= 730
243+
};
244+
245+
adapter_name
246+
.strip_prefix("Adreno (TM) ")
247+
.is_some_and(non_supported_adreno_model)
248+
} else {
249+
false
250+
}
251+
}
252+
253+
if device.limits().max_compute_workgroup_size_x == 0 || is_non_supported_android_device(adapter)
238254
{
239255
GpuPreprocessingSupport::None
240256
} else if !device

0 commit comments

Comments
 (0)