Skip to content

Commit

Permalink
Use WEBGL_provoking_vertex extension
Browse files Browse the repository at this point in the history
  • Loading branch information
StrandedKitty committed Dec 31, 2023
1 parent 1a26e23 commit 2caaab9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib/renderer/webgl2-renderer/WebGL2Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class WebGL2Renderer implements AbstractRenderer {
this.gl.enable(WebGL2Constants.BLEND);

this.initExtensions();
this.optimizeAssumingFlatsHaveSameFirstAndLastData();
}

private initExtensions(): void {
Expand All @@ -71,6 +72,17 @@ export default class WebGL2Renderer implements AbstractRenderer {
};
}

// See https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/
// Regarding performance issues when using Metal backend:
// https://bugs.chromium.org/p/chromium/issues/detail?id=1496807
private optimizeAssumingFlatsHaveSameFirstAndLastData(): void {
const epv = this.gl.getExtension('WEBGL_provoking_vertex');

if (epv) {
epv.provokingVertexWEBGL(epv.FIRST_VERTEX_CONVENTION_WEBGL);
}
}

public bindTexture(texture: WebGL2Texture): void {
if (this.boundTexture !== texture) {
texture.bind();
Expand Down

0 comments on commit 2caaab9

Please sign in to comment.