Jelajahi Sumber

Generic shader platform name

Sebastien Vandenberghe 6 tahun lalu
induk
melakukan
62aa7409fe
3 mengubah file dengan 15 tambahan dan 2 penghapusan
  1. 13 1
      src/Engines/engine.ts
  2. 1 0
      src/Engines/webgpuEngine.ts
  3. 1 1
      src/Materials/effect.ts

+ 13 - 1
src/Engines/engine.ts

@@ -959,8 +959,8 @@ export class Engine {
      */
     public readonly premultipliedAlpha: boolean = true;
 
+    /** @hidden */
     protected _isWebGPU: boolean = false;
-
     /**
      * Gets a boolean indicating if the engine runs in WebGPU or not.
      */
@@ -968,6 +968,15 @@ export class Engine {
         return this._isWebGPU;
     }
 
+    /** @hidden */
+    protected _shaderPlatformName: string;
+    /**
+     * Gets the shader platfrom name used by the effects.
+     */
+    public get shaderPlatformName: string {
+        return this._shaderPlatformName;
+    };
+
     /**
      * Creates a new engine
      * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
@@ -1070,10 +1079,12 @@ export class Engine {
                     this._gl = <any>(canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
                     if (this._gl) {
                         this._webGLVersion = 2.0;
+                        this._shaderPlatformName = "WEBGL2";
 
                         // Prevent weird browsers to lie :-)
                         if (!this._gl.deleteQuery) {
                             this._webGLVersion = 1.0;
+                            this._shaderPlatformName = "WEBGL1";
                         }
                     }
                 } catch (e) {
@@ -1139,6 +1150,7 @@ export class Engine {
 
             if (this._gl.renderbufferStorageMultisample) {
                 this._webGLVersion = 2.0;
+                this._shaderPlatformName = "WEBGL2";
             }
 
             const attributes = this._gl.getContextAttributes();

+ 1 - 0
src/Engines/webgpuEngine.ts

@@ -161,6 +161,7 @@ export class WebGPUEngine extends Engine {
         }
 
         this._isWebGPU = true;
+        this._shaderPlatformName = "WEBGPU";
 
         if (options.deterministicLockstep === undefined) {
             options.deterministicLockstep = false;

+ 1 - 1
src/Materials/effect.ts

@@ -380,7 +380,7 @@ export class Effect implements IDisposable {
             shadersRepository: Effect.ShadersRepository,
             includesShadersStore: Effect.IncludesShadersStore,
             version: (this._engine.webGLVersion * 100).toString(),
-            platformName: this._engine.isWebGPU ? "WEBGPU" : this._engine.webGLVersion >= 2 ? "WEBGL2" : "WEBGL1"
+            platformName: this._engine.shaderPlatformName
         };
 
         this._loadVertexShader(vertexSource, (vertexCode) => {