瀏覽代碼

Fix sample count invalid values

Popov72 4 年之前
父節點
當前提交
9febb85528
共有 2 個文件被更改,包括 20 次插入0 次删除
  1. 10 0
      src/Engines/WebGPU/webgpuTextureHelper.ts
  2. 10 0
      src/Engines/webgpuEngine.ts

+ 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;
 

+ 10 - 0
src/Engines/webgpuEngine.ts

@@ -2632,6 +2632,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 +2662,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) {