Skip to content

Commit bbaee48

Browse files
authored
WebGPURenderer: Fix change the current canvas samples (#31924)
1 parent 6dff7ce commit bbaee48

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/renderers/webgpu/WebGPUBackend.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,16 @@ class WebGPUBackend extends Backend {
328328
const renderer = this.renderer;
329329
const canvasTarget = renderer.getCanvasTarget();
330330
const canvasData = this.get( canvasTarget );
331+
const samples = renderer.currentSamples;
331332

332333
let descriptor = canvasData.descriptor;
333334

334-
if ( descriptor === undefined ) {
335+
if ( descriptor === undefined || canvasData.samples !== samples ) {
335336

336337
descriptor = {
337338
colorAttachments: [ {
338339
view: null
339-
} ],
340+
} ]
340341
};
341342

342343
if ( renderer.depth === true || renderer.stencil === true ) {
@@ -349,7 +350,7 @@ class WebGPUBackend extends Backend {
349350

350351
const colorAttachment = descriptor.colorAttachments[ 0 ];
351352

352-
if ( renderer.currentSamples > 0 ) {
353+
if ( samples > 0 ) {
353354

354355
colorAttachment.view = this.textureUtils.getColorBuffer().createView();
355356

@@ -360,12 +361,13 @@ class WebGPUBackend extends Backend {
360361
}
361362

362363
canvasData.descriptor = descriptor;
364+
canvasData.samples = samples;
363365

364366
}
365367

366368
const colorAttachment = descriptor.colorAttachments[ 0 ];
367369

368-
if ( renderer.currentSamples > 0 ) {
370+
if ( samples > 0 ) {
369371

370372
colorAttachment.resolveTarget = this.context.getCurrentTexture().createView();
371373

src/renderers/webgpu/utils/WebGPUTextureUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ class WebGPUTextureUtils {
470470

471471
if ( depthTextureGPU !== undefined ) {
472472

473-
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type ) {
473+
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type && depthTexture.samples === samples ) {
474474

475475
return depthTextureGPU;
476476

@@ -487,6 +487,7 @@ class WebGPUTextureUtils {
487487
depthTexture.type = type;
488488
depthTexture.image.width = width;
489489
depthTexture.image.height = height;
490+
depthTexture.samples = samples;
490491

491492
this.createTexture( depthTexture, { width, height } );
492493

0 commit comments

Comments
 (0)