Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ cpal = { path = "crates/vendor/cpal" }
[workspace.dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/triniwiz/wgpu"
rev = "e5c0aa02"
rev = "399344e78"



Expand All @@ -103,8 +103,8 @@ quick-xml = "0.34"
skia-safe = { git = "https://github.com/triniwiz/rust-skia", rev = "b9d29071cd8876b2447d58a14346b9fe6a5d21e2", features = ["textlayout"] }
itertools = "0.14.0"
ustr = "1.1.0"
wgpu-core = { git = "https://github.com/triniwiz/wgpu", rev = "e5c0aa02", features = ["wgsl"] }
wgpu-hal = { git = "https://github.com/triniwiz/wgpu", rev = "e5c0aa02" }
wgpu-core = { git = "https://github.com/triniwiz/wgpu", rev = "399344e78", features = ["wgsl"] }
wgpu-hal = { git = "https://github.com/triniwiz/wgpu", rev = "399344e78" }
ureq = "2.10.1"
jni = "0.21.1"
regex-lite = "0.1.9"
Expand Down
42 changes: 23 additions & 19 deletions crates/canvas-c/src/webgpu/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,28 +174,26 @@ pub unsafe extern "C" fn canvas_native_webgpu_request_adapter(
inner.request_adapter(&opts, wgt::Backends::METAL)
}

// Compatibility requests may get a core adapter: hardware Vulkan first, GL
// only without it.
#[cfg(target_os = "android")]
{
if options.feature_level == CanvasGPUFeatureLevel::Compatibility {
inner.request_adapter(&opts, wgt::Backends::GL)
} else {
let vulkan_adapter = inner.request_adapter(&opts, wgt::Backends::VULKAN);
let vulkan_adapter = inner.request_adapter(&opts, wgt::Backends::VULKAN);

let is_hardware_vulkan = vulkan_adapter.as_ref().map_or(false, |adapter| {
adapter.get_info().device_type != wgt::DeviceType::Cpu
});
let is_hardware_vulkan = vulkan_adapter.as_ref().map_or(false, |adapter| {
adapter.get_info().device_type != wgt::DeviceType::Cpu
});

if is_hardware_vulkan {
vulkan_adapter
if is_hardware_vulkan {
vulkan_adapter
} else {
let gl_adapter = inner.request_adapter(&opts, wgt::Backends::GL);
if gl_adapter.is_ok() {
// dropping the Arc releases it; there is no adapter_drop any more
drop(vulkan_adapter);
gl_adapter
} else {
let gl_adapter = inner.request_adapter(&opts, wgt::Backends::GL);
if gl_adapter.is_ok() {
// dropping the Arc releases it; there is no adapter_drop any more
drop(vulkan_adapter);
gl_adapter
} else {
vulkan_adapter
}
vulkan_adapter
}
}
}
Expand All @@ -213,15 +211,21 @@ pub unsafe extern "C" fn canvas_native_webgpu_request_adapter(

let adapter = adapter_id.map(|adapter| {
let mut features = build_features(adapter.features());
if options.feature_level != CanvasGPUFeatureLevel::Compatibility {
// Only the GL backend is limited to compatibility.
let feature_level = if adapter.get_info().backend == wgt::Backend::Gl {
options.feature_level
} else {
CanvasGPUFeatureLevel::Core
};
if feature_level != CanvasGPUFeatureLevel::Compatibility {
features.push("core-features-and-limits");
}
let limits = adapter.limits();
let ret = CanvasGPUAdapter {
instance,
adapter,
is_fallback_adapter: options.force_fallback_adapter,
feature_level: options.feature_level.into(),
feature_level: feature_level.into(),
features,
limits,
};
Expand Down
Loading