getByteLength method
dynamic
getByteLength()
override
Implementation
getByteLength() {
int offset = 0; // global buffer offset in bytes
for (var i = 0, l = this.uniforms.length; i < l; i++) {
var uniform = this.uniforms[i];
// offset within a single chunk in bytes
var chunkOffset = offset % GPUChunkSize;
var remainingSizeInChunk = GPUChunkSize - chunkOffset;
// conformance tests
if (chunkOffset != 0 && (remainingSizeInChunk - uniform.boundary) < 0) {
// check for chunk overflow
offset += (GPUChunkSize - chunkOffset);
} else if (chunkOffset % uniform.boundary != 0) {
// check for correct alignment
offset += (chunkOffset % uniform.boundary).toInt();
}
uniform.offset = (offset ~/ this.bytesPerElement);
int _v = (uniform.itemSize * this.bytesPerElement).toInt();
offset += _v;
}
return offset;
}