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

Ideas for improving shader performance #10743

Open
ptrgags opened this issue Aug 31, 2022 · 0 comments
Open

Ideas for improving shader performance #10743

ptrgags opened this issue Aug 31, 2022 · 0 comments

Comments

@ptrgags
Copy link
Contributor

ptrgags commented Aug 31, 2022

Though I recently made some improvements to ShaderCache (see #10726), along the way I noticed a variety of things in ShaderProgram and other classes that could be improved, albeit some are more easy to change than others

  • ShaderSource has a function to remove comments with a regex substitution. Aside from preventing czm_.* in a comment from accidentally importing things, is this necessary? can it be moved to the build step that turns GLSL into JS files? I know the minification step already does something similar
  • using the czm_ to auto-import built-in functions is convenient, but the regex searching can be expensive for large strings. Could we change to an explicit include system? putting all the imports at the top of the GLSL file would probably be easier to parse than having to regex search the whole string
#import <czm_builtinFunction>
#import <czm_otherBuiltinFunction>
// ----
  • ...Or perhaps the ShaderSource could store a list of builtins separately from the shader text to avoid the post-processing step
  • For the new Model, I created ShaderBuilder, which was a convenient abstraction for building complex shaders, as it tracks separate lists for defines/attributes/varyings/uniforms/structs/functions/etc. Would it ever make sense to consolidate this with ShaderSource? It might help avoid some regex post-processing steps. Or is it only helpful for more complex cases?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment