Sebastien Vandenberghe 6 年 前
コミット
b8e17ac882

+ 8 - 8
src/Engines/WebGPU/webgpuConstants.ts

@@ -1,13 +1,13 @@
 /** @hidden */
 export class WebGPUConstants {
-    public static readonly GPUCullMode_none: GPUCullMode = "none"
-    public static readonly GPUCullMode_front: GPUCullMode = "front"
+    public static readonly GPUCullMode_none: GPUCullMode = "none";
+    public static readonly GPUCullMode_front: GPUCullMode = "front";
     public static readonly GPUCullMode_back: GPUCullMode = "back";
 
     public static readonly GPUFrontFace_ccw: GPUFrontFace = "ccw";
     public static readonly GPUFrontFace_cw: GPUFrontFace = "cw";
 
-    public static readonly GPUIndexFormat_uint16: GPUIndexFormat = "uint16"
+    public static readonly GPUIndexFormat_uint16: GPUIndexFormat = "uint16";
     public static readonly GPUIndexFormat_uint32: GPUIndexFormat = "uint32";
 
     public static readonly GPULoadOp_clear: GPULoadOp = "clear";
@@ -18,9 +18,9 @@ export class WebGPUConstants {
     public static readonly GPUPrimitiveTopology_pointList: GPUPrimitiveTopology = "point-list";
     public static readonly GPUPrimitiveTopology_lineList: GPUPrimitiveTopology = "line-list";
     public static readonly GPUPrimitiveTopology_lineStrip: GPUPrimitiveTopology = "line-strip";
-    public static readonly GPUPrimitiveTopology_triangleList: GPUPrimitiveTopology = "triangle-list"
+    public static readonly GPUPrimitiveTopology_triangleList: GPUPrimitiveTopology = "triangle-list";
     public static readonly GPUPrimitiveTopology_triangleStrip: GPUPrimitiveTopology = "triangle-strip";
-    
+
     public static readonly GPUTextureDimension_1d: GPUTextureDimension = "1d";
     public static readonly GPUTextureDimension_2d: GPUTextureDimension = "2d";
     public static readonly GPUTextureDimension_3d: GPUTextureDimension = "3d";
@@ -79,7 +79,7 @@ export class WebGPUConstants {
     /* Depth and Stencil formats */
     public static readonly GPUTextureFormat_depth32float: GPUTextureFormat = "depth32float";
     public static readonly GPUTextureFormat_depth32floatStencil8: GPUTextureFormat = "depth32float-stencil8";
-      
+
     public static readonly GPUTextureViewDimension_1d: GPUTextureViewDimension = "1d";
     public static readonly GPUTextureViewDimension_2d: GPUTextureViewDimension = "2d";
     public static readonly GPUTextureViewDimension_2dArray: GPUTextureViewDimension = "2d-array";
@@ -89,7 +89,7 @@ export class WebGPUConstants {
 
     public static readonly GPUPowerPreference_lowPower: GPUPowerPreference = "low-power";
     public static readonly GPUPowerPreference_highPerformance: GPUPowerPreference = "high-performance";
-    
+
     public static readonly GPUVertexFormat_uchar: GPUVertexFormat = "uchar";
     public static readonly GPUVertexFormat_uchar2: GPUVertexFormat = "uchar2";
     public static readonly GPUVertexFormat_uchar3: GPUVertexFormat = "uchar3";
@@ -149,7 +149,7 @@ export class WebGPUConstants {
     public static readonly GPUBufferUsage_VERTEX = 32;
     public static readonly GPUBufferUsage_UNIFORM = 64;
     public static readonly GPUBufferUsage_STORAGE = 128;
-    
+
     public static readonly GPUColorWriteBits_NONE = 0;
     public static readonly GPUColorWriteBits_RED = 1;
     public static readonly GPUColorWriteBits_GREEN = 2;

+ 1 - 1
src/Engines/WebGPU/webgpuPipelineContext.ts

@@ -1,7 +1,7 @@
 import { IPipelineContext } from '../IPipelineContext';
 import { Nullable } from '../../types';
 import { WebGPUEngine } from '../webgpuEngine';
-import { InternalTexture } from 'Materials';
+import { InternalTexture } from '../../Materials/Textures/internalTexture';
 
 /** @hidden */
 export interface IWebGPUPipelineContextSamplerCache {

+ 3 - 3
src/Engines/engine.ts

@@ -985,7 +985,7 @@ export class Engine {
             if (antialias != null) {
                 options.antialias = antialias;
             }
-    
+
             if (options.preserveDrawingBuffer === undefined) {
                 options.preserveDrawingBuffer = false;
             }
@@ -997,11 +997,11 @@ export class Engine {
             if (options.deterministicLockstep === undefined) {
                 options.deterministicLockstep = false;
             }
-    
+
             if (options.lockstepMaxSteps === undefined) {
                 options.lockstepMaxSteps = 4;
             }
-    
+
             if (options.audioEngine === undefined) {
                 options.audioEngine = true;
             }

+ 21 - 21
src/Engines/webgpuEngine.ts

@@ -59,7 +59,7 @@ export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
      */
     deviceDescriptor?: GPUDeviceDescriptor;
 
-    /** 
+    /**
      * Defines the requested Swap Chain Format.
      */
     swapChainFormat?: GPUTextureFormat;
@@ -102,7 +102,7 @@ export class WebGPUEngine extends Engine {
     private _currentVertexBuffers: Nullable<{ [key: string]: Nullable<VertexBuffer> }> = null;
     private _currentIndexBuffer: Nullable<DataBuffer> = null;
     private __colorWrite = true;
-    private _uniformsBuffers: { [name: string]: WebGPUDataBuffer } = {}
+    private _uniformsBuffers: { [name: string]: WebGPUDataBuffer } = {};
 
     // Caches
     private _compiledStages: { [key: string]: GPURenderPipelineStageDescriptor } = {};
@@ -180,11 +180,11 @@ export class WebGPUEngine extends Engine {
         return (window as any).Shaderc(shadercOptions)
             .then((shaderc: any) => {
                 this._shaderc = shaderc;
-                return navigator.gpu!.requestAdapter(this._options)
+                return navigator.gpu!.requestAdapter(this._options);
             })
             .then((adapter: GPUAdapter) => {
                 this._adapter = adapter;
-                return this._adapter.requestDevice(this._options.deviceDescriptor)
+                return this._adapter.requestDevice(this._options.deviceDescriptor);
             })
             .then((device: GPUDevice) => this._device = device)
             .then(() => {
@@ -431,7 +431,7 @@ export class WebGPUEngine extends Engine {
             // After Migration to Canary
             // buffer.setSubData(dstByteOffset + offset, src, srcByteOffset + offset, maxChunk);
         }
-        
+
         const tempView = new Uint8Array(src.buffer.slice(chunkStart + offset, chunkEnd));
         buffer.setSubData(dstByteOffset + offset, tempView.buffer);
 
@@ -820,7 +820,7 @@ export class WebGPUEngine extends Engine {
 
     private _uploadMipMapsFromWebglTexture(mipMaps: number, webglEngineTexture: InternalTexture, gpuTexture: GPUTexture, width: number, height: number, face: number) {
         this._uploadFromWebglTexture(webglEngineTexture, gpuTexture, width, height, face);
-        
+
         let faceWidth = width;
         let faceHeight = height;
 
@@ -842,7 +842,7 @@ export class WebGPUEngine extends Engine {
 
         const textureView: GPUTextureCopyView = {
             texture: gpuTexture,
-            origin: { 
+            origin: {
                 x: 0,
                 y: 0,
                 z: 0
@@ -943,7 +943,7 @@ export class WebGPUEngine extends Engine {
                 sampleCount: 1,
                 size: textureExtent,
                 usage: WebGPUConstants.GPUTextureUsage_TRANSFER_DST | WebGPUConstants.GPUTextureUsage_SAMPLED
-            }
+            };
 
             const gpuTexture = this._device.createTexture(textureDescriptor);
             texture._webGPUTexture = gpuTexture;
@@ -974,8 +974,8 @@ export class WebGPUEngine extends Engine {
             if (onLoad) {
                 onLoad();
             }
-        }
-        webglEngineTexture = this._decodeEngine.createTexture(urlArg, noMipmap, invertY, scene, samplingMode, 
+        };
+        webglEngineTexture = this._decodeEngine.createTexture(urlArg, noMipmap, invertY, scene, samplingMode,
             onLoadInternal, onError, buffer, fallBack, format);
 
         this._internalTexturesCache.push(texture);
@@ -990,12 +990,12 @@ export class WebGPUEngine extends Engine {
         texture.generateMipMaps = !noMipmap;
         texture._lodGenerationScale = lodScale;
         texture._lodGenerationOffset = lodOffset;
-    
+
         if (!this._doNotHandleContextLost) {
             texture._extension = forcedExtension;
             texture._files = files;
         }
-    
+
         let webglEngineTexture: InternalTexture;
         const onLoadInternal = () => {
             texture.isReady = webglEngineTexture.isReady;
@@ -1028,7 +1028,7 @@ export class WebGPUEngine extends Engine {
                 sampleCount: 1,
                 size: textureExtent,
                 usage: WebGPUConstants.GPUTextureUsage_TRANSFER_DST | WebGPUConstants.GPUTextureUsage_SAMPLED
-            }
+            };
 
             const gpuTexture = this._device.createTexture(textureDescriptor);
             texture._webGPUTexture = gpuTexture;
@@ -1063,13 +1063,13 @@ export class WebGPUEngine extends Engine {
                 baseMipLevel: 0
             });
             webglEngineTexture.dispose();
-        }
+        };
         webglEngineTexture = this._decodeEngine.createCubeTexture(rootUrl, scene, files, noMipmap, onLoadInternal, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders);
 
         this._internalTexturesCache.push(texture);
-    
+
         return texture;
-    };
+    }
 
     public updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void {
         texture.samplingMode = samplingMode;
@@ -1334,7 +1334,7 @@ export class WebGPUEngine extends Engine {
     }
 
     private _getDepthStencilStateDescriptor(): GPUDepthStencilStateDescriptor {
-        // TODO. Depth State according to the cached state. 
+        // TODO. Depth State according to the cached state.
         // And the current render pass attachment setup.
         const stencilFrontBack: GPUStencilStateFaceDescriptor = {
             compare: this._getCompareFunction(this._stencilState.stencilFunc),
@@ -1377,7 +1377,7 @@ export class WebGPUEngine extends Engine {
     }
 
     private _getRasterizationStateDescriptor(): GPURasterizationStateDescriptor {
-        // TODO. Cull State according to the cached state. 
+        // TODO. Cull State according to the cached state.
         // And the current render pass attachment setup.
         return {
             frontFace: this._getFrontFace(),
@@ -1397,14 +1397,14 @@ export class WebGPUEngine extends Engine {
 
     private _getColorStateDescriptors(): GPUColorStateDescriptor[] {
         // TODO. Color State according to the cached blend state.
-        // And the current render pass attaschment setup. 
+        // And the current render pass attaschment setup.
         // Manage Multi render target.
         return [{
             format: this._options.swapChainFormat,
             // alphaBlend: {
             //     srcFactor: ,
             //     dstFactor: ,
-            //     operation: , 
+            //     operation: ,
             // },
             // colorBlend: {
             //     srcFactor: ,
@@ -1445,7 +1445,7 @@ export class WebGPUEngine extends Engine {
                         return WebGPUConstants.GPUVertexFormat_uint2;
                     case VertexBuffer.FLOAT:
                         return WebGPUConstants.GPUVertexFormat_float2;
-                };
+                }
             case VertexBuffer.NormalKind:
             case VertexBuffer.PositionKind:
                 switch (type) {

+ 2 - 2
src/Materials/effect.ts

@@ -871,13 +871,13 @@ export class Effect implements IDisposable {
                         const binding = matches[2];
                         // const type = matches[3];
                         const name = matches[4].replace("Texture", "");
-            
+
                         foundSamplers[name] = +binding;
                     }
 
                     let index: number;
                     for (index = 0; index < this._samplerList.length; index++) {
-                        const name = this._samplerList[index]
+                        const name = this._samplerList[index];
                         const sampler = foundSamplers[this._samplerList[index]];
 
                         if (sampler == null || sampler == undefined) {