I use chrome dev tool to profile my game, and found the function getshaderParameter function use too much time, this makes my game slow。
This is the picture from chrome dev tool, https://imgur.com/IAkvkIJ
and the call trace:
Obviously, this is related to render stuff, but I would like to know more about this function, why it takes so long time to execute, which exactly object in my scene cause this problem? which shader ?
Maybe related to show some more other object ? cause right after the timeline, the game about show another object.
I would like to hear from you guys
WebGLRenderingContext.getShaderParameter() is only called when a shader program is compiled. This normally happens when a material is used for the first time.
getShaderParameter() to verify the compilation status of shaders. If it was not successful, an error message is logged.
If you’re seeing it called frequently (e.g. after the scene has started rendering), are you setting
material.needsUpdate = true or creating materials during the render loop? Try to avoid both of those.
Yes, it is. so I make my preload object render once, so it will not consume much time when it shows again.
It will be great if the FBXLoader has the feature to preload material
WebGLRenderer.compile() might be the method you are looking for.
I guess I am suffering from the same problem. I already tried to do
WebGLRenderer.compile() before I start my application but now its the
getShaderInfoLog which sucks a lot of time.
What is this function doing?
And is there any way to execute it before I start rendering my application?
WebGLRenderingContext.getShaderInfoLog() is only used by the renderer when a shader program is created. It is used to retrieve the program log in order to evaluate and print warnings, debugging and compile information.
At one point (usually the rendering of the first frame) shader programs have to be compiled. There is no way around it.
WebGLRenderer.compile() is intended to avoid this overhead in the middle of your application since some materials might be used not from the beginning but at a later point.