Skip to content

Commit cc30c11

Browse files
authored
Permit zero-temporary-value buffer binding
When using custom 3D renderers, p5 can support much larger models, but this particular bit of code showed up as a hotspot: I was passing in a Float32 already, and it was getting cloned. Without this change, my particular workload runs at 7-12 fps. With it 45-50fps. In principle p5 can make use of this itself, though having webGL ready representations as the source of truth is a much larger change - but even so, taking steps in that direction seems broadly useful.
1 parent c06ad37 commit cc30c11

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/webgl/p5.RendererGL.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,12 @@ p5.RendererGL.prototype._bindBuffer = function(
13371337
if (!target) target = this.GL.ARRAY_BUFFER;
13381338
this.GL.bindBuffer(target, buffer);
13391339
if (values !== undefined) {
1340-
const data = new (type || Float32Array)(values);
1340+
let data;
1341+
if (ArrayBuffer.isView(values) ) {
1342+
data = values;
1343+
} else {
1344+
data = new (type || Float32Array)(values);
1345+
}
13411346
this.GL.bufferData(target, data, usage || this.GL.STATIC_DRAW);
13421347
}
13431348
};

0 commit comments

Comments
 (0)