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

Performance problem when using WebGL2 #9743

Closed
genosage opened this issue Aug 21, 2021 · 1 comment
Closed

Performance problem when using WebGL2 #9743

genosage opened this issue Aug 21, 2021 · 1 comment

Comments

@genosage
Copy link

I noticed that the modernizeShader function can port shaders to GLSL 3.0. It did this by using replaceInSourceString and replaceInSourceRegex to replace strings which is String.prototype.replace() in deed.

This will cause severe performance problem when there are many draw calls. The shader cache can not handle this kind of situation because it can only get the keyword after combining shaders.

(A better way may be assigning an identifier and use it as the keyword to avoid calling replace functions each draw call.)

// ShaderCache.js
  var vertexShaderText = vertexShaderSource.createCombinedVertexShader(
    this._context
  );
  var fragmentShaderText = fragmentShaderSource.createCombinedFragmentShader(
    this._context
  );

  var keyword =
    vertexShaderText + fragmentShaderText + JSON.stringify(attributeLocations);
@ebogo1
Copy link
Contributor

ebogo1 commented Aug 26, 2021

Thanks @genosage - we're aware that modernizeShader needs to be reworked and it's part of our WebGL 2 roadmap: #797

I've added a comment there with your suggestion for future reference but I'll close this issue to avoid duplicates.

@ebogo1 ebogo1 closed this as completed Aug 26, 2021
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

2 participants