Procházet zdrojové kódy

Use dstLevel = 0 by default (#30618)

ZonkyPop před 10 měsíci
rodič
revize
7284747f79
1 změnil soubory, kde provedl 40 přidání a 16 odebrání
  1. 40 16
      src/renderers/webgpu/WebGPUBackend.js

+ 40 - 16
src/renderers/webgpu/WebGPUBackend.js

@@ -1871,38 +1871,56 @@ class WebGPUBackend extends Backend {
 	 *
 	 *
 	 * @param {Texture} srcTexture - The source texture.
 	 * @param {Texture} srcTexture - The source texture.
 	 * @param {Texture} dstTexture - The destination texture.
 	 * @param {Texture} dstTexture - The destination texture.
-	 * @param {?Vector4} [srcRegion=null] - The region of the source texture to copy.
+	 * @param {?(Box3|Box2)} [srcRegion=null] - The region of the source texture to copy.
 	 * @param {?(Vector2|Vector3)} [dstPosition=null] - The destination position of the copy.
 	 * @param {?(Vector2|Vector3)} [dstPosition=null] - The destination position of the copy.
-	 * @param {number} [level=0] - The mip level to copy.
+	 * @param {number} [srcLevel=0] - The mipmap level to copy.
+	 * @param {number} [dstLevel=0] - The destination mip level to copy to.
 	 */
 	 */
-	copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
+	copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = 0 ) {
 
 
 		let dstX = 0;
 		let dstX = 0;
 		let dstY = 0;
 		let dstY = 0;
-		let dstLayer = 0;
+		let dstZ = 0;
 
 
 		let srcX = 0;
 		let srcX = 0;
 		let srcY = 0;
 		let srcY = 0;
-		let srcLayer = 0;
+		let srcZ = 0;
 
 
 		let srcWidth = srcTexture.image.width;
 		let srcWidth = srcTexture.image.width;
 		let srcHeight = srcTexture.image.height;
 		let srcHeight = srcTexture.image.height;
+		let srcDepth = 1;
+
 
 
 		if ( srcRegion !== null ) {
 		if ( srcRegion !== null ) {
 
 
-			srcX = srcRegion.x;
-			srcY = srcRegion.y;
-			srcLayer = srcRegion.z || 0;
-			srcWidth = srcRegion.width;
-			srcHeight = srcRegion.height;
+			if ( srcRegion.isBox3 === true ) {
+
+				srcX = srcRegion.min.x;
+				srcY = srcRegion.min.y;
+				srcZ = srcRegion.min.z;
+				srcWidth = srcRegion.max.x - srcRegion.min.x;
+				srcHeight = srcRegion.max.y - srcRegion.min.y;
+				srcDepth = srcRegion.max.z - srcRegion.min.z;
+
+			} else {
+
+				// Assume it's a Box2
+				srcX = srcRegion.min.x;
+				srcY = srcRegion.min.y;
+				srcWidth = srcRegion.max.x - srcRegion.min.x;
+				srcHeight = srcRegion.max.y - srcRegion.min.y;
+				srcDepth = 1;
+
+			}
 
 
 		}
 		}
 
 
+
 		if ( dstPosition !== null ) {
 		if ( dstPosition !== null ) {
 
 
 			dstX = dstPosition.x;
 			dstX = dstPosition.x;
 			dstY = dstPosition.y;
 			dstY = dstPosition.y;
-			dstLayer = dstPosition.z || 0;
+			dstZ = dstPosition.z || 0;
 
 
 		}
 		}
 
 
@@ -1914,23 +1932,29 @@ class WebGPUBackend extends Backend {
 		encoder.copyTextureToTexture(
 		encoder.copyTextureToTexture(
 			{
 			{
 				texture: sourceGPU,
 				texture: sourceGPU,
-				mipLevel: level,
-				origin: { x: srcX, y: srcY, z: srcLayer }
+				mipLevel: srcLevel,
+				origin: { x: srcX, y: srcY, z: srcZ }
 			},
 			},
 			{
 			{
 				texture: destinationGPU,
 				texture: destinationGPU,
-				mipLevel: level,
-				origin: { x: dstX, y: dstY, z: dstLayer }
+				mipLevel: dstLevel,
+				origin: { x: dstX, y: dstY, z: dstZ }
 			},
 			},
 			[
 			[
 				srcWidth,
 				srcWidth,
 				srcHeight,
 				srcHeight,
-				1
+				srcDepth
 			]
 			]
 		);
 		);
 
 
 		this.device.queue.submit( [ encoder.finish() ] );
 		this.device.queue.submit( [ encoder.finish() ] );
 
 
+		if ( dstLevel === 0 && dstTexture.generateMipmaps ) {
+
+			this.textureUtils.generateMipmaps( dstTexture );
+
+		}
+
 	}
 	}
 
 
 	/**
 	/**

粤ICP备19079148号