core: indirect draw passes, device feature list, drop handles-specific bundle heuristics

Amp-Thread-ID: https://ampcode.com/threads/T-01a0b2dd-db32-712d-99ce-12ce4a86d979
Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
Amp
2026-09-18 05:31:11 +00:00
co-authored by heaust
parent dda602c4a2
commit 49c80a209e
11 changed files with 123 additions and 56 deletions
+21 -1
View File
@@ -8,9 +8,19 @@ pub struct Wgpu {
pub width: u32,
pub height: u32,
pub timestamp_queries: bool,
/// Optional features the device was created with, in WebGPU spelling.
pub features: Vec<&'static str>,
pub adapter: String,
}
const OPTIONAL_FEATURES: [(wgpu::Features, &str); 2] = [
(wgpu::Features::TIMESTAMP_QUERY, "timestamp-query"),
(
wgpu::Features::INDIRECT_FIRST_INSTANCE,
"indirect-first-instance",
),
];
impl Wgpu {
pub async fn new(canvas: web_sys::OffscreenCanvas) -> Result<Self, String> {
let width = canvas.width();
@@ -33,7 +43,12 @@ impl Wgpu {
})
.await
.map_err(|_| "WEBGPU_UNAVAILABLE")?;
let required_features = adapter.features() & wgpu::Features::TIMESTAMP_QUERY;
let required_features = OPTIONAL_FEATURES
.iter()
.fold(wgpu::Features::empty(), |features, (feature, _)| {
features | *feature
})
& adapter.features();
let info = adapter.get_info();
let adapter_name = if info.name.is_empty() {
format!("{:?} · {:?}", info.device_type, info.backend)
@@ -65,6 +80,11 @@ impl Wgpu {
width,
height,
timestamp_queries: required_features.contains(wgpu::Features::TIMESTAMP_QUERY),
features: OPTIONAL_FEATURES
.iter()
.filter(|(feature, _)| required_features.contains(*feature))
.map(|(_, name)| *name)
.collect(),
adapter: adapter_name,
})
}