Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion examples/jsm/postprocessing/UnrealBloomPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class UnrealBloomPass extends Pass {
this.strength = strength;

/**
* The Bloom radius.
* The Bloom radius. Must be in the range `[0,1]`.
*
* @type {number}
*/
Expand Down
11 changes: 10 additions & 1 deletion examples/jsm/tsl/display/BloomNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class BloomNode extends TempNode {
this.strength = uniform( strength );

/**
* The radius of the bloom.
* The radius of the bloom. Must be in the range `[0,1]`.
*
* @type {UniformNode<float>}
*/
Expand Down Expand Up @@ -443,6 +443,15 @@ class BloomNode extends TempNode {

this._renderTargetBright.dispose();

if ( this._highPassFilterMaterial !== null ) this._highPassFilterMaterial.dispose();
if ( this._compositeMaterial !== null ) this._compositeMaterial.dispose();

for ( let i = 0; i < this._separableBlurMaterials.length; i ++ ) {

this._separableBlurMaterials[ i ].dispose();

}

}

/**
Expand Down
Binary file modified examples/screenshots/webgl_loader_texture_ktx.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/textures/compressed/normal.bc5.ktx
Binary file not shown.
Binary file added examples/textures/compressed/normal.eac_rg.ktx
Binary file not shown.
42 changes: 37 additions & 5 deletions examples/webgl_loader_texture_ktx.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
const formats = {
astc: renderer.extensions.has( 'WEBGL_compressed_texture_astc' ),
etc1: renderer.extensions.has( 'WEBGL_compressed_texture_etc1' ),
etc2: renderer.extensions.has( 'WEBGL_compressed_texture_etc' ),
s3tc: renderer.extensions.has( 'WEBGL_compressed_texture_s3tc' ),
pvrtc: renderer.extensions.has( 'WEBGL_compressed_texture_pvrtc' )
};
Expand All @@ -67,8 +68,15 @@

scene = new THREE.Scene();

const ambientLight = new THREE.AmbientLight( 0xffffff, 0.02 );
scene.add( ambientLight );

const pointLight = new THREE.PointLight( 0xffffff, 2, 0, 0 );
pointLight.position.z = - 300;
scene.add( pointLight );

const geometry = new THREE.BoxGeometry( 200, 200, 200 );
let material1, material2;
let material1, material2, material3;

// TODO: add cubemap support
const loader = new KTXLoader();
Expand Down Expand Up @@ -105,9 +113,13 @@
side: THREE.DoubleSide
} );
material2.map.colorSpace = THREE.SRGBColorSpace;
material3 = new THREE.MeshStandardMaterial( {
normalMap: loader.load( 'textures/compressed/normal.bc5.ktx' )
} );

meshes.push( new THREE.Mesh( geometry, material1 ) );
meshes.push( new THREE.Mesh( geometry, material2 ) );
meshes.push( new THREE.Mesh( geometry, material3 ) );

}

Expand All @@ -121,6 +133,16 @@

}

if ( formats.etc2 ) {

material1 = new THREE.MeshStandardMaterial( {
normalMap: loader.load( 'textures/compressed/normal.eac_rg.ktx' )
} );

meshes.push( new THREE.Mesh( geometry, material1 ) );

}

if ( formats.astc ) {

material1 = new THREE.MeshBasicMaterial( {
Expand All @@ -140,12 +162,22 @@

}

let x = - meshes.length / 2 * 150;
for ( let i = 0; i < meshes.length; ++ i, x += 300 ) {
let x0 = - Math.min( 4, meshes.length ) * 300 / 2 + 150;
for ( let i = 0; i < Math.min( 4, meshes.length ); ++ i, x0 += 300 ) {

const mesh = meshes[ i ];
mesh.position.x = x0;
mesh.position.y = 150;
scene.add( mesh );

}

let x1 = - ( meshes.length - 4 ) * 300 / 2 + 150;
for ( let i = 4; i < meshes.length; ++ i, x1 += 300 ) {

const mesh = meshes[ i ];
mesh.position.x = x;
mesh.position.y = 0;
mesh.position.x = x1;
mesh.position.y = - 150;
scene.add( mesh );

}
Expand Down
8 changes: 8 additions & 0 deletions src/renderers/common/Backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,14 @@ class Backend {

}

/**
* Delete GPU data associated with a bind group.
*
* @abstract
* @param {BindGroup} bindGroup - The bind group.
*/
deleteBindGroupData( /*bindGroup*/ ) { }

/**
* Frees internal resources.
*
Expand Down
2 changes: 2 additions & 0 deletions src/renderers/common/Bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class Bindings extends DataMap {

for ( const bindGroup of bindings ) {

this.backend.deleteBindGroupData( bindGroup );
this.delete( bindGroup );

}
Expand All @@ -181,6 +182,7 @@ class Bindings extends DataMap {

for ( const bindGroup of bindings ) {

this.backend.deleteBindGroupData( bindGroup );
this.delete( bindGroup );

}
Expand Down
46 changes: 45 additions & 1 deletion src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class WebGPUBackend extends Backend {

device.lost.then( ( info ) => {

if ( info.reason === 'destroyed' ) return;

const deviceLossInfo = {
api: 'WebGPU',
message: info.message || 'Unknown reason',
Expand Down Expand Up @@ -1665,7 +1667,9 @@ class WebGPUBackend extends Backend {

data[ 0 ] = i;

const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, bindingsData.layout );
const { layoutGPU } = bindingsData.layout;

const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, layoutGPU );

indexesGPU.push( bindGroupIndex );

Expand Down Expand Up @@ -2157,6 +2161,17 @@ class WebGPUBackend extends Backend {

}

/**
* Delete data associated with the current bind group.
*
* @param {BindGroup} bindGroup - The bind group.
*/
deleteBindGroupData( bindGroup ) {

this.bindingUtils.deleteBindGroupData( bindGroup );

}

// attributes

/**
Expand Down Expand Up @@ -2486,8 +2501,37 @@ class WebGPUBackend extends Backend {

dispose() {

this.bindingUtils.dispose();
this.textureUtils.dispose();

if ( this.occludedResolveCache ) {

for ( const buffer of this.occludedResolveCache.values() ) {

buffer.destroy();

}

this.occludedResolveCache.clear();

}

if ( this.timestampQueryPool ) {

for ( const queryPool of Object.values( this.timestampQueryPool ) ) {

if ( queryPool !== null ) queryPool.dispose();

}

}

if ( this.parameters.device === undefined && this.device !== null ) {

this.device.destroy();

}

}

}
Expand Down
Loading