فهرست منبع

Replace usage of webGLVersion

Popov72 4 سال پیش
والد
کامیت
0b11aae620
4فایلهای تغییر یافته به همراه9 افزوده شده و 2 حذف شده
  1. 3 0
      src/Engines/engineFeatures.ts
  2. 2 0
      src/Engines/thinEngine.ts
  3. 1 0
      src/Engines/webgpuEngine.ts
  4. 3 2
      src/Misc/basis.ts

+ 3 - 0
src/Engines/engineFeatures.ts

@@ -26,6 +26,9 @@ export interface EngineFeatures {
     /** Indicates that the Cascaded Shadow Map technic is supported */
     supportCSM: boolean;
 
+    /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
+    basisNeedsPOT: boolean;
+
     /** @hidden */
     _collectUbosUpdatedInFrame: boolean;
 }

+ 2 - 0
src/Engines/thinEngine.ts

@@ -184,6 +184,7 @@ export class ThinEngine {
         allowTexturePrefiltering: false,
         trackUbosInFrame: false,
         supportCSM: false,
+        basisNeedsPOT: false,
         _collectUbosUpdatedInFrame: false,
     };
 
@@ -734,6 +735,7 @@ export class ThinEngine {
         ThinEngine.Features.supportShadowSamplers = this._webGLVersion !== 1;
         ThinEngine.Features.allowTexturePrefiltering = this._webGLVersion !== 1;
         ThinEngine.Features.supportCSM = this._webGLVersion !== 1;
+        ThinEngine.Features.basisNeedsPOT = this._webGLVersion < 2;
 
         // Ensures a consistent color space unpacking of textures cross browser.
         this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);

+ 1 - 0
src/Engines/webgpuEngine.ts

@@ -246,6 +246,7 @@ export class WebGPUEngine extends Engine {
         ThinEngine.Features.allowTexturePrefiltering = true;
         ThinEngine.Features.trackUbosInFrame = true;
         ThinEngine.Features.supportCSM = true;
+        ThinEngine.Features.basisNeedsPOT = false;
         ThinEngine.Features._collectUbosUpdatedInFrame = true;
 
         options.deviceDescriptor = options.deviceDescriptor || { };

+ 3 - 2
src/Misc/basis.ts

@@ -5,6 +5,7 @@ import { InternalTexture, InternalTextureSource } from '../Materials/Textures/in
 import { Scalar } from '../Maths/math.scalar';
 import { Constants } from '../Engines/constants';
 import { Engine } from '../Engines/engine';
+import { ThinEngine } from '../Engines/thinEngine';
 
 /**
  * Info about the .basis files
@@ -195,7 +196,7 @@ export class BasisTools {
                 texture.type = Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
                 texture.format = Constants.TEXTUREFORMAT_RGB;
 
-                if (engine.webGLVersion < 2 && (Scalar.Log2(rootImage.width) % 1 !== 0 || Scalar.Log2(rootImage.height) % 1 !== 0)) {
+                if (ThinEngine.Features.basisNeedsPOT && (Scalar.Log2(rootImage.width) % 1 !== 0 || Scalar.Log2(rootImage.height) % 1 !== 0)) {
                     // Create non power of two texture
                     let source = new InternalTexture(engine, InternalTextureSource.Temp);
 
@@ -232,7 +233,7 @@ export class BasisTools {
                     engine._uploadCompressedDataToTextureDirectly(texture, BasisTools.GetInternalFormatFromBasisFormat(transcodeResult.format!), level.width, level.height, level.transcodedPixels, i, index);
                 });
 
-                if (engine.webGLVersion < 2 && (Scalar.Log2(texture.width) % 1 !== 0 || Scalar.Log2(texture.height) % 1 !== 0)) {
+                if (ThinEngine.Features.basisNeedsPOT && (Scalar.Log2(texture.width) % 1 !== 0 || Scalar.Log2(texture.height) % 1 !== 0)) {
                     Tools.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1.");
                     texture._cachedWrapU = Texture.CLAMP_ADDRESSMODE;
                     texture._cachedWrapV = Texture.CLAMP_ADDRESSMODE;