DeviceFeatures
Quick answer
DeviceFeatures reports optional capabilities of the active backend through device.features. Check a single flag with has('timer-query') or enumerate everything with keys(), then gate code paths accordingly. Features answer whether a technique exists at all, while DeviceLimits gives the numeric ceilings.
device. features → DeviceFeatures
Key points
- has(feature) returns whether the backend exposes that capability.
- keys() enumerates every feature name available on this device.
- Typical flags include 'texture-compression-bc' and 'timer-query'.
Example
function requireFeatures(device, required) {
const missing = required.filter(function (feature) {
return !device.features.has(feature);
});
if (missing.length) {
console.warn('缺少设备特性', missing);
return false;
}
return true;
}
/* 需要的特性名从配置或常量表里读,不在这里硬编码 */
const ok = requireFeatures(device, config.requiredFeatures);const list = [];
for (const feature of device.features) {
list.push(feature);
}
console.log(list.length, list);
Notes
- The same call can be supported on WebGPU but missing on the WebGL fallback.
- Assuming a feature from browser support instead of device.features breaks fallback paths.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). DeviceFeatures. https://www.jingweizhi.com/en/lumagl/api/device-features.html (accessed 2026-11-03).