|
@@ -54,7 +54,8 @@ class WebGPUBackend extends Backend {
|
|
|
this.context = null;
|
|
|
this.colorBuffer = null;
|
|
|
|
|
|
- this.depthBuffers = new WeakMap();
|
|
|
+ this.defaultDepthTexture = new DepthTexture();
|
|
|
+ this.defaultDepthTexture.name = 'depthBuffer';
|
|
|
|
|
|
this.utils = new WebGPUUtils( this );
|
|
|
this.attributeUtils = new WebGPUAttributeUtils( this );
|
|
@@ -753,63 +754,49 @@ class WebGPUBackend extends Backend {
|
|
|
|
|
|
_getDepthBufferGPU( renderContext ) {
|
|
|
|
|
|
- const { depthBuffers } = this;
|
|
|
const { width, height } = this.getDrawingBufferSize();
|
|
|
|
|
|
- let depthTexture = depthBuffers.get( renderContext );
|
|
|
+ const depthTexture = this.defaultDepthTexture;
|
|
|
+ const depthTextureGPU = this.get( depthTexture ).texture;
|
|
|
|
|
|
- if ( depthTexture !== undefined && depthTexture.image.width === width && depthTexture.image.height === height ) {
|
|
|
+ let format, type;
|
|
|
|
|
|
- return this.get( depthTexture ).texture;
|
|
|
+ if ( renderContext.stencil ) {
|
|
|
|
|
|
- }
|
|
|
+ format = DepthStencilFormat;
|
|
|
+ type = UnsignedInt248Type;
|
|
|
|
|
|
- this._destroyDepthBufferGPU( renderContext );
|
|
|
+ } else if ( renderContext.depth ) {
|
|
|
|
|
|
- depthTexture = new DepthTexture();
|
|
|
- depthTexture.name = 'depthBuffer';
|
|
|
+ format = DepthFormat;
|
|
|
+ type = UnsignedIntType;
|
|
|
|
|
|
- if ( renderContext.stencil ) {
|
|
|
+ }
|
|
|
|
|
|
- depthTexture = new DepthTexture();
|
|
|
- depthTexture.format = DepthStencilFormat;
|
|
|
- depthTexture.type = UnsignedInt248Type;
|
|
|
+ if ( depthTextureGPU !== undefined ) {
|
|
|
|
|
|
- } else if ( renderContext.depth ) {
|
|
|
+ if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type ) {
|
|
|
|
|
|
- depthTexture = new DepthTexture();
|
|
|
- depthTexture.format = DepthFormat;
|
|
|
- depthTexture.type = UnsignedIntType;
|
|
|
+ return depthTextureGPU;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.textureUtils.destroyTexture( depthTexture );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ depthTexture.name = 'depthBuffer';
|
|
|
+ depthTexture.format = format;
|
|
|
+ depthTexture.type = type;
|
|
|
depthTexture.image.width = width;
|
|
|
depthTexture.image.height = height;
|
|
|
|
|
|
this.textureUtils.createTexture( depthTexture, { sampleCount: this.parameters.sampleCount } );
|
|
|
|
|
|
- depthBuffers.set( renderContext, depthTexture );
|
|
|
-
|
|
|
return this.get( depthTexture ).texture;
|
|
|
|
|
|
}
|
|
|
|
|
|
- _destroyDepthBufferGPU( renderContext ) {
|
|
|
-
|
|
|
- const { depthBuffers } = this;
|
|
|
-
|
|
|
- const depthTexture = depthBuffers.get( renderContext );
|
|
|
-
|
|
|
- if ( depthTexture !== undefined ) {
|
|
|
-
|
|
|
- this.textureUtils.destroyTexture( depthTexture );
|
|
|
-
|
|
|
- depthBuffers.delete( renderContext );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
_configureContext() {
|
|
|
|
|
|
this.context.configure( {
|