Browse Source

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js into master

David Catuhe 4 years ago
parent
commit
e02ea13bd0

+ 10 - 0
src/Engines/WebGPU/webgpuTextureHelper.ts

@@ -733,6 +733,11 @@ export class WebGPUTextureHelper {
     public createTexture(imageBitmap: ImageBitmap | { width: number, height: number, layers: number }, hasMipmaps = false, generateMipmaps = false, invertY = false, premultiplyAlpha = false, is3D = false, format: GPUTextureFormat = WebGPUConstants.TextureFormat.RGBA8Unorm,
         sampleCount = 1, commandEncoder?: GPUCommandEncoder, usage = -1): GPUTexture
     {
+        if (sampleCount > 1) {
+            // TODO WEBGPU for the time being, Chrome only accepts values of 1 or 4
+            sampleCount = 4;
+        }
+
         const layerCount = (imageBitmap as any).layers || 1;
         let textureSize = {
             width: imageBitmap.width,
@@ -767,6 +772,11 @@ export class WebGPUTextureHelper {
     public createCubeTexture(imageBitmaps: ImageBitmap[] | { width: number, height: number }, hasMipmaps = false, generateMipmaps = false, invertY = false, premultiplyAlpha = false, format: GPUTextureFormat = WebGPUConstants.TextureFormat.RGBA8Unorm,
         sampleCount = 1, commandEncoder?: GPUCommandEncoder, usage = -1): GPUTexture
     {
+        if (sampleCount > 1) {
+            // TODO WEBGPU for the time being, Chrome only accepts values of 1 or 4
+            sampleCount = 4;
+        }
+
         const width = WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps) ? imageBitmaps[0].width : imageBitmaps.width;
         const height = WebGPUTextureHelper.IsImageBitmapArray(imageBitmaps) ? imageBitmaps[0].height : imageBitmaps.height;
 

+ 3 - 0
src/Engines/engineFeatures.ts

@@ -48,6 +48,9 @@ export interface EngineFeatures {
     /** Indicates that synchronous texture reading is supported */
     supportSyncTextureRead: boolean;
 
+    /** Indicates that y should be inverted when dealing with bitmaps (notably in environment tools) */
+    needsInvertingBitmap: boolean;
+
     /** @hidden */
     _collectUbosUpdatedInFrame: boolean;
 }

+ 1 - 0
src/Engines/nativeEngine.ts

@@ -816,6 +816,7 @@ export class NativeEngine extends Engine {
             supportExtendedTextureFormats: false,
             supportSwitchCaseInShader: false,
             supportSyncTextureRead: false,
+            needsInvertingBitmap: true,
             _collectUbosUpdatedInFrame: false,
         };
 

+ 1 - 0
src/Engines/nullEngine.ts

@@ -162,6 +162,7 @@ export class NullEngine extends Engine {
             supportExtendedTextureFormats: false,
             supportSwitchCaseInShader: false,
             supportSyncTextureRead: false,
+            needsInvertingBitmap: false,
             _collectUbosUpdatedInFrame: false,
         };
 

+ 1 - 0
src/Engines/thinEngine.ts

@@ -1078,6 +1078,7 @@ export class ThinEngine {
             supportExtendedTextureFormats: this._webGLVersion !== 1,
             supportSwitchCaseInShader: this._webGLVersion !== 1,
             supportSyncTextureRead: true,
+            needsInvertingBitmap: true,
             _collectUbosUpdatedInFrame: false,
         };
     }

+ 11 - 0
src/Engines/webgpuEngine.ts

@@ -562,6 +562,7 @@ export class WebGPUEngine extends Engine {
             supportExtendedTextureFormats: true,
             supportSwitchCaseInShader: true,
             supportSyncTextureRead: false,
+            needsInvertingBitmap: false,
             _collectUbosUpdatedInFrame: true,
         };
     }
@@ -2632,6 +2633,11 @@ export class WebGPUEngine extends Engine {
 
         samples = Math.min(samples, this.getCaps().maxMSAASamples);
 
+        if (samples > 1) {
+            // TODO WEBGPU for the time being, Chrome only accepts values of 1 or 4
+            samples = 4;
+        }
+
         this._textureHelper.createMSAATexture(texture, samples);
 
         if (texture._depthStencilTexture) {
@@ -2657,6 +2663,11 @@ export class WebGPUEngine extends Engine {
 
         samples = Math.min(samples, this.getCaps().maxMSAASamples);
 
+        if (samples > 1) {
+            // TODO WEBGPU for the time being, Chrome only accepts values of 1 or 4
+            samples = 4;
+        }
+
         // Note that the last texture of textures is the depth texture (if the depth texture has been generated by the MRT class) and so the MSAA texture
         // will be recreated for this texture too. As a consequence, there's no need to explicitly recreate the MSAA texture for textures[0]._depthStencilTexture
         for (let i = 0; i < textures.length; ++i) {

+ 1 - 1
src/Misc/environmentTextureTools.ts

@@ -375,7 +375,7 @@ export class EnvironmentTextureTools {
                         // Uncompress the data to a RTT
                         rgbdPostProcess!.onApply = (effect) => {
                             effect._bindTexture("textureSampler", tempTexture);
-                            effect.setFloat2("scale", 1, (image instanceof ImageBitmap) ? -1 : 1);
+                            effect.setFloat2("scale", 1, engine._features.needsInvertingBitmap && (image instanceof ImageBitmap) ? -1 : 1);
                         };
 
                         if (!engine.scenes.length) {

+ 1 - 1
src/Shaders/background.vertex.fx

@@ -40,7 +40,7 @@ varying vec2 vDiffuseUV;
 #include<clipPlaneVertexDeclaration>
 
 #include<fogVertexDeclaration>
-#include<__decl__lightFragment>[0..maxSimultaneousLights]
+#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
 
 #ifdef REFLECTIONMAP_SKYBOX
 varying vec3 vPositionUVW;