Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Stats component needs to hook into the drawElementsInstanced, drawArraysInstanced, drawElementsInstancedANGLE, and drawArraysInstancedANGLE methods. #265

Open
jtabibito opened this issue Mar 6, 2024 · 0 comments

Comments

@jtabibito
Copy link
Contributor

jtabibito commented Mar 6, 2024

When I try to draw a mesh using GPU Instancing, the stats show 0 draw calls and 0 triangles.
Here is my solution.
`

if (gl instanceof WebGL2RenderingContext) {
  this.realDrawElementsInstanced = gl.drawElementsInstanced;
  this.realDrawArraysInstanced = gl.drawArraysInstanced;

  gl.drawElementsInstanced = this.hookedDrawElementsInstanced.bind(this);
  gl.drawArraysInstanced = this.hookedDrawArraysInstanced.bind(this);
} else {
  const ext = gl.getExtension("ANGLE_instanced_arrays");
  if (ext) {
    this.realDrawElementsInstanced = ext.drawElementsInstancedANGLE;
    this.realDrawArraysInstanced = ext.drawArraysInstancedANGLE;

    ext.drawElementsInstancedANGLE = this.hookedDrawElementsInstanced.bind(this);
    ext.drawArraysInstancedANGLE = this.hookedDrawArraysInstanced.bind(this);
  }
}

`

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

No branches or pull requests

1 participant