Skip to content

Performance improvements for WebGL shape drawing#7287

Merged
davepagurek merged 1 commit into
processing:mainfrom
davepagurek:model-perf
Sep 24, 2024
Merged

Performance improvements for WebGL shape drawing#7287
davepagurek merged 1 commit into
processing:mainfrom
davepagurek:model-perf

Conversation

@davepagurek
Copy link
Copy Markdown
Contributor

Resolves #7237

This makes two changes:

  • We no longer create edges on models that don't have any, meaning if you never create strokes, you never have to incur the cost of calculating them.
  • Fixes a shape drawing special case: we can draw individual triangles without tessellation, but what should have been an = was an === so it wasn't being applied, oops 😬

I tested with this https://editor.p5js.org/davepagurek/sketches/vmiMgGi5s which makes a new geometry and draws it each frame. The perf I got was:

Chrome

  • No stroke changes: 5fps
  • Skip strokes: 11fps
  • Add triangle check: 12fps

Firefox

  • No changes: 4fps
  • Skip strokes: 8fps
  • Add triangle check: 9fps

I didn't make the other change requested in the issue to make buildGeometry update the line vertex data when you add a new shape. This is because when we add it, we have to transform every vertex anyway. This is probably not less work than just recreating it, and if you do any other operation (e.g. add this geometry into another geometry), you'd be doing more work overall by transforming twice.

PR Checklist

this.immediateMode.shapeMode === constants.TESS
) {
this.immediateMode.shapeMode === constants.TRIANGLES;
this.immediateMode.shapeMode = constants.TRIANGLES;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@perminder-17
Copy link
Copy Markdown
Collaborator

This PR also fixes issue: #6318. Thanks;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long time spent in _edgesToVertices when assembling shapes into composite models

2 participants