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: 20 additions & 9 deletions src/renderers/common/UniformsGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ class UniformsGroup extends UniformBuffer {
*/
this._updateRangeCache = new Map();

/**
* Uniform indices whose range has already been pushed into `updateRanges`
* during the current update cycle. Reset on `clearUpdateRanges()`.
*
* @private
* @type {Set<number>}
*/
this._addedIndices = new Set();

}

/**
Expand All @@ -66,29 +75,31 @@ class UniformsGroup extends UniformBuffer {

const index = uniform.index;

if ( this._updateRangeCache.has( index ) !== true ) {
if ( this._addedIndices.has( index ) ) return;

const updateRanges = this.updateRanges;
let range = this._updateRangeCache.get( index );

const start = uniform.offset;
const count = uniform.itemSize;

const range = { start, count };

updateRanges.push( range );
if ( range === undefined ) {

range = { start: 0, count: 0 };
this._updateRangeCache.set( index, range );

}

range.start = uniform.offset;
range.count = uniform.itemSize;

this._addedIndices.add( index );
this.updateRanges.push( range );

}

/**
* Clears all update ranges of this buffer.
*/
clearUpdateRanges() {

this._updateRangeCache.clear();
this._addedIndices.clear();

super.clearUpdateRanges();

Expand Down
Loading