Просмотр исходного кода

WebGPURenderer: Render bundle work with multiple render targets (#31906)

Berthur 9 месяцев назад
Родитель
Сommit
d78c8d9a9d

+ 3 - 3
src/renderers/webgpu/utils/WebGPUPipelineUtils.js

@@ -267,12 +267,12 @@ class WebGPUPipelineUtils {
 		const { utils, device } = backend;
 
 		const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
-		const colorFormat = utils.getCurrentColorFormat( renderContext );
+		const colorFormats = utils.getCurrentColorFormats( renderContext );
 		const sampleCount = this._getSampleCount( renderContext );
 
 		const descriptor = {
-			label: label,
-			colorFormats: [ colorFormat ],
+			label,
+			colorFormats,
 			depthStencilFormat,
 			sampleCount
 		};

+ 20 - 0
src/renderers/webgpu/utils/WebGPUUtils.js

@@ -124,6 +124,26 @@ class WebGPUUtils {
 
 	}
 
+	/**
+	 * Returns the GPU formats of all color attachments of the current render context.
+	 *
+	 * @param {RenderContext} renderContext - The render context.
+	 * @return {Array<string>} The GPU texture formats of all color attachments.
+	 */
+	getCurrentColorFormats( renderContext ) {
+
+		if ( renderContext.textures !== null ) {
+
+			return renderContext.textures.map( t => this.getTextureFormatGPU( t ) );
+
+		} else {
+
+			return [ this.getPreferredCanvasFormat() ]; // default context format
+
+		}
+
+	}
+
 	/**
 	 * Returns the output color space of the current render context.
 	 *

粤ICP备19079148号