|
|
@@ -77,39 +77,39 @@ class Bindings extends DataMap {
|
|
|
*/
|
|
|
getForRender( renderObject ) {
|
|
|
|
|
|
- return this._getBindings( renderObject, renderObject.getBindings() );
|
|
|
+ const bindings = renderObject.getBindings();
|
|
|
|
|
|
- }
|
|
|
+ for ( const bindGroup of bindings ) {
|
|
|
|
|
|
- /**
|
|
|
- * Returns the bind groups for the given compute node.
|
|
|
- *
|
|
|
- * @param {Node} computeNode - The compute node.
|
|
|
- * @return {Array<BindGroup>} The bind groups.
|
|
|
- */
|
|
|
- getForCompute( computeNode ) {
|
|
|
+ const groupData = this.get( bindGroup );
|
|
|
|
|
|
- return this._getBindings( computeNode, this.nodes.getForCompute( computeNode ).bindings );
|
|
|
+ if ( groupData.bindGroup === undefined ) {
|
|
|
|
|
|
- }
|
|
|
+ // each object defines an array of bindings (ubos, textures, samplers etc.)
|
|
|
|
|
|
- _getBindings( object, bindings ) {
|
|
|
+ this._init( bindGroup );
|
|
|
|
|
|
- const data = this.get( object );
|
|
|
+ this.backend.createBindings( bindGroup, bindings, 0 );
|
|
|
|
|
|
- if ( data.bindings !== bindings ) {
|
|
|
+ groupData.bindGroup = bindGroup;
|
|
|
|
|
|
- if ( data.bindings !== undefined ) {
|
|
|
+ }
|
|
|
|
|
|
- this._updateBindingsUsage( data.bindings, - 1 );
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ return bindings;
|
|
|
|
|
|
- this._updateBindingsUsage( bindings, 1 );
|
|
|
+ }
|
|
|
|
|
|
- data.bindings = bindings;
|
|
|
+ /**
|
|
|
+ * Returns the bind groups for the given compute node.
|
|
|
+ *
|
|
|
+ * @param {Node} computeNode - The compute node.
|
|
|
+ * @return {Array<BindGroup>} The bind groups.
|
|
|
+ */
|
|
|
+ getForCompute( computeNode ) {
|
|
|
|
|
|
- }
|
|
|
+ const bindings = this.nodes.getForCompute( computeNode ).bindings;
|
|
|
|
|
|
for ( const bindGroup of bindings ) {
|
|
|
|
|
|
@@ -160,7 +160,14 @@ class Bindings extends DataMap {
|
|
|
*/
|
|
|
deleteForCompute( computeNode ) {
|
|
|
|
|
|
- this._deleteBindings( computeNode );
|
|
|
+ const bindings = this.nodes.getForCompute( computeNode ).bindings;
|
|
|
+
|
|
|
+ for ( const bindGroup of bindings ) {
|
|
|
+
|
|
|
+ this.backend.deleteBindGroupData( bindGroup );
|
|
|
+ this.delete( bindGroup );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -171,57 +178,12 @@ class Bindings extends DataMap {
|
|
|
*/
|
|
|
deleteForRender( renderObject ) {
|
|
|
|
|
|
- this._deleteBindings( renderObject );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _deleteBindings( object ) {
|
|
|
-
|
|
|
- const data = this.get( object );
|
|
|
-
|
|
|
- if ( data.bindings !== undefined ) {
|
|
|
-
|
|
|
- this._updateBindingsUsage( data.bindings, - 1 );
|
|
|
-
|
|
|
- data.bindings = undefined;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _updateBindingsUsage( bindings, delta ) {
|
|
|
+ const bindings = renderObject.getBindings();
|
|
|
|
|
|
for ( const bindGroup of bindings ) {
|
|
|
|
|
|
- const groupData = this.get( bindGroup );
|
|
|
-
|
|
|
- groupData.usedTimes = ( groupData.usedTimes || 0 ) + delta;
|
|
|
-
|
|
|
- for ( const binding of bindGroup.bindings ) {
|
|
|
-
|
|
|
- if ( binding.isUniformBuffer ) {
|
|
|
-
|
|
|
- const bindingData = this.get( binding );
|
|
|
-
|
|
|
- bindingData.usedTimes = ( bindingData.usedTimes || 0 ) + delta;
|
|
|
-
|
|
|
- if ( bindingData.usedTimes === 0 ) {
|
|
|
-
|
|
|
- this.backend.destroyUniformBuffer( binding );
|
|
|
- this.delete( binding );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( groupData.usedTimes === 0 ) {
|
|
|
-
|
|
|
- this.backend.deleteBindGroupData( bindGroup );
|
|
|
- this.delete( bindGroup );
|
|
|
-
|
|
|
- }
|
|
|
+ this.backend.deleteBindGroupData( bindGroup );
|
|
|
+ this.delete( bindGroup );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -251,11 +213,7 @@ class Bindings extends DataMap {
|
|
|
|
|
|
for ( const binding of bindGroup.bindings ) {
|
|
|
|
|
|
- if ( binding.isUniformBuffer ) {
|
|
|
-
|
|
|
- this.backend.createUniformBuffer( binding );
|
|
|
-
|
|
|
- } else if ( binding.isSampledTexture ) {
|
|
|
+ if ( binding.isSampledTexture ) {
|
|
|
|
|
|
this.textures.updateTexture( binding.texture );
|
|
|
|