Browse Source

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

Mr.doob 2 năm trước cách đây
mục cha
commit
bea24b475d
1 tập tin đã thay đổi với 15 bổ sung1 xóa
  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 {
 
 	static isAvailable() {
 
-		return ( navigator.gpu !== undefined );
+		return isAvailable;
 
 	}