Procházet zdrojové kódy

Renderer: Make `hasCompatibility()` more predictable. (#33087)

Co-authored-by: sunag <sunagbrasil@gmail.com>
Michael Herzog před 2 měsíci
rodič
revize
f443051898

+ 7 - 2
src/renderers/common/Renderer.js

@@ -3369,14 +3369,19 @@ class Renderer {
 	}
 
 	/**
-	 * Checks if the given compatibility is supported by the selected backend. If the
-	 * renderer has not been initialized, this method always returns `false`.
+	 * Checks if the given compatibility is supported by the selected backend.
 	 *
 	 * @param {string} name - The compatibility's name.
 	 * @return {boolean} Whether the compatibility is supported or not.
 	 */
 	hasCompatibility( name ) {
 
+		if ( this._initialized === false ) {
+
+			throw new Error( 'Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.' );
+
+		}
+
 		return this.backend.hasCompatibility( name );
 
 	}

+ 2 - 2
src/renderers/webgpu/WebGPUBackend.js

@@ -2539,9 +2539,9 @@ class WebGPUBackend extends Backend {
 	 */
 	hasCompatibility( name ) {
 
-		if ( this._compatibility[ Compatibility.TEXTURE_COMPARE ] !== undefined ) {
+		if ( this._compatibility[ name ] !== undefined ) {
 
-			return this._compatibility[ Compatibility.TEXTURE_COMPARE ];
+			return this._compatibility[ name ];
 
 		}
 

粤ICP备19079148号