Parcourir la source

WebGPU: Set available only when able to requestAdapter().

Mr.doob il y a 2 ans
Parent
commit
bea24b475d
1 fichiers modifiés avec 15 ajouts et 1 suppressions
  1. 15 1
      examples/jsm/capabilities/WebGPU.js

+ 15 - 1
examples/jsm/capabilities/WebGPU.js

@@ -4,11 +4,25 @@ if ( window.GPUShaderStage === undefined ) {
 
 
 }
 }
 
 
+let isAvailable = false;
+
+if ( navigator.gpu !== undefined ) {
+
+	const adapter = await navigator.gpu.requestAdapter();
+
+	if ( adapter !== null ) {
+
+		isAvailable = true;
+
+	}
+
+}
+
 class WebGPU {
 class WebGPU {
 
 
 	static isAvailable() {
 	static isAvailable() {
 
 
-		return ( navigator.gpu !== undefined );
+		return isAvailable;
 
 
 	}
 	}