Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { WebGPUCoordinateSystem, TimestampQuery, REVISION, HalfFloatType, Compat
import WebGPUTimestampQueryPool from './utils/WebGPUTimestampQueryPool.js';
import { warnOnce, error } from '../../utils.js';

const _clearValue = { r: 0, g: 0, b: 0, a: 1 };

/**
* A backend implementation targeting WebGPU.
*
Expand Down Expand Up @@ -682,7 +684,21 @@ class WebGPUBackend extends Backend {

if ( renderContext.clearColor ) {

colorAttachment.clearValue = i === 0 ? renderContext.clearColorValue : { r: 0, g: 0, b: 0, a: 1 };
if ( i === 0 ) {

colorAttachment.clearValue = renderContext.clearColorValue;

} else {

_clearValue.r = 0;
_clearValue.g = 0;
_clearValue.b = 0;
_clearValue.a = 1;

colorAttachment.clearValue = _clearValue;

}

colorAttachment.loadOp = GPULoadOp.Clear;

} else {
Expand Down Expand Up @@ -1224,15 +1240,18 @@ class WebGPUBackend extends Backend {

let colorAttachments = [];
let depthStencilAttachment;
let clearValue;

let supportsDepth;
let supportsStencil;

if ( color ) {

const clearColor = this.getClearColor();
clearValue = { r: clearColor.r, g: clearColor.g, b: clearColor.b, a: clearColor.a };

_clearValue.r = clearColor.r;
_clearValue.g = clearColor.g;
_clearValue.b = clearColor.b;
_clearValue.a = clearColor.a;

}

Expand All @@ -1249,7 +1268,7 @@ class WebGPUBackend extends Backend {

const colorAttachment = colorAttachments[ 0 ];

colorAttachment.clearValue = clearValue;
colorAttachment.clearValue = _clearValue;
colorAttachment.loadOp = GPULoadOp.Clear;
colorAttachment.storeOp = GPUStoreOp.Store;

Expand All @@ -1268,7 +1287,7 @@ class WebGPUBackend extends Backend {

const clearConfig = {
loadOp: color ? GPULoadOp.Clear : GPULoadOp.Load,
clearValue: color ? clearValue : undefined
clearValue: color ? _clearValue : undefined
};

if ( supportsDepth ) {
Expand Down