-
Notifications
You must be signed in to change notification settings - Fork 329
Description
I don't know if we care about this but ..... As it is, the specified way to know if you got compat is to check for 'core-features-and-limits'
. If it doesn't exist you got compat mode ... EXCEPT it doesn't work in all shipping browsers. This means in these browsers, you have to do something else like
const adapter = navigator.gpu.requestAdapter({ featureLevel: 'compatibility' });
// ask for core (if it exists)
const device = adapter.requestDevice({ requiredFeatures: adapter.features });
// do I have core?
const isCore = device.features.has('core-features-and-limits') ||
device.limits.maxColorAttachments > 4; // <=--------- Needed because
// current browsers don't have
// 'core-features-and-limits'
The code above checks maxColorAttachments
. This only works if the user doesn't request the adapter's maxColorAttachments
, then they'd need to choose another some other limit to check for core vs compat or they'd need to use some other method like trying to create a cube-array and see if they get an validation error.
The idea was supposed to be that you wouldn't need a 2nd check like this. On the other hand,
sometimes you do need it today (like deciding not to use cube-array if you don't get core) and will need it for the next 6 months to a year, until all current browsers stop being used.
Code like this, showing up in samples and online code will likely get repeated forever. People copy and paste, and that gets copy and pasted and this kind of code self replicates.
Do we care and if so do we want some other solution. Previously, the fact that you got compat mode was explicit on the adapter. (was adapter.isCompatibilityMode
, then was adapter.featureLevel === 'compatibility'
. Now it's the absence of a feature but that feature is itself absent on current browsers.