Skip to content

Commit 7dfc15e

Browse files
committed
More micro optimizations
1 parent 3e9fbb8 commit 7dfc15e

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

src/webgpu/p5.RendererWebGPU.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -864,22 +864,25 @@ function rendererWebGPU(p5, fn) {
864864
}
865865

866866
_getVertexBuffers(shader) {
867-
const buffers = [];
867+
if (!shader._vertexBuffers) {
868+
const buffers = [];
868869

869-
for (const attrName in shader.attributes) {
870-
const attr = shader.attributes[attrName];
871-
if (!attr || attr.location === -1) continue;
870+
for (const attrName in shader.attributes) {
871+
const attr = shader.attributes[attrName];
872+
if (!attr || attr.location === -1) continue;
872873

873-
// Get the vertex buffer info associated with this attribute
874-
const renderBuffer =
875-
this.buffers[shader.shaderType].find(buf => buf.attr === attrName) ||
876-
this.buffers.user.find(buf => buf.attr === attrName);
877-
if (!renderBuffer) continue;
874+
// Get the vertex buffer info associated with this attribute
875+
const renderBuffer =
876+
this.buffers[shader.shaderType].find(buf => buf.attr === attrName) ||
877+
this.buffers.user.find(buf => buf.attr === attrName);
878+
if (!renderBuffer) continue;
878879

879-
buffers.push(renderBuffer);
880+
buffers.push(renderBuffer);
881+
}
882+
shader._vertexBuffers = buffers;
880883
}
881884

882-
return buffers;
885+
return shader._vertexBuffers;
883886
}
884887

885888
_getFormatFromSize(size) {

0 commit comments

Comments
 (0)