Skip to content

Commit d78c8d9

Browse files
authored
WebGPURenderer: Render bundle work with multiple render targets (#31906)
1 parent 5a1c63c commit d78c8d9

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/renderers/webgpu/utils/WebGPUPipelineUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ class WebGPUPipelineUtils {
267267
const { utils, device } = backend;
268268

269269
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
270-
const colorFormat = utils.getCurrentColorFormat( renderContext );
270+
const colorFormats = utils.getCurrentColorFormats( renderContext );
271271
const sampleCount = this._getSampleCount( renderContext );
272272

273273
const descriptor = {
274-
label: label,
275-
colorFormats: [ colorFormat ],
274+
label,
275+
colorFormats,
276276
depthStencilFormat,
277277
sampleCount
278278
};

src/renderers/webgpu/utils/WebGPUUtils.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ class WebGPUUtils {
124124

125125
}
126126

127+
/**
128+
* Returns the GPU formats of all color attachments of the current render context.
129+
*
130+
* @param {RenderContext} renderContext - The render context.
131+
* @return {Array<string>} The GPU texture formats of all color attachments.
132+
*/
133+
getCurrentColorFormats( renderContext ) {
134+
135+
if ( renderContext.textures !== null ) {
136+
137+
return renderContext.textures.map( t => this.getTextureFormatGPU( t ) );
138+
139+
} else {
140+
141+
return [ this.getPreferredCanvasFormat() ]; // default context format
142+
143+
}
144+
145+
}
146+
127147
/**
128148
* Returns the output color space of the current render context.
129149
*

0 commit comments

Comments
 (0)