Skip to content

Commit

Permalink
WebGLUniformsGroups: Fix buffer offset calculation. (mrdoob#28834)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Jul 8, 2024
1 parent 4c14bb1 commit 5457a9d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/renderers/webgl/WebGLUniformsGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,27 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {

const info = getUniformSize( value );

// Calculate the chunk offset
const chunkOffsetUniform = offset % chunkSize;
const chunkOffset = offset % chunkSize; // offset in the current chunk
const chunkPadding = chunkOffset % info.boundary; // required padding to match boundary
const chunkStart = chunkOffset + chunkPadding; // the start position in the current chunk for the data

offset += chunkPadding;

// Check for chunk overflow
if ( chunkOffsetUniform !== 0 && ( chunkSize - chunkOffsetUniform ) < info.boundary ) {
if ( chunkStart !== 0 && ( chunkSize - chunkStart ) < info.storage ) {

// Add padding and adjust offset
offset += ( chunkSize - chunkOffsetUniform );
offset += ( chunkSize - chunkStart );

}

// the following two properties will be used for partial buffer updates

uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT );
uniform.__offset = offset;


// Update the global offset
offset += info.storage;


}

}
Expand Down

0 comments on commit 5457a9d

Please sign in to comment.