shaderProcessor code parsing

Hi there,

I’m building an application to visualize IOT sensor data in different parts of building model. Building is loaded from gltfs and I want to add colors on top of existing materials. I have all materials as PBRMaterial. By modifying those as PBRCustomMaterial I was able set a shader for all those meshes and materials which need to be able to change dynamically. There’s quite high number of mesh/material pairs (>800). If I don’t force compile those at boot it will cause tens of seconds to minutes delays during actual use of the application. So, I need to force compile those all at boot. That takes now ~30…45s on desktop machine (AMD Ryzen 9 3900X) which is somehow tolerable but ~10 minutes when running on a four CPU core (1 y old AMD Ryzen 5) laptop. When I profile it I can see that top time spent (self time) is in getUniformBlockIndex (~20%), ShaderDefineExpression.infixToPostfix (5.7%), shaderProcessor._MoveCursor (4.1%), shaderProcessor._BuildSubExpression (4.1%), measureText (3.8%), shaderProcessor._BuildExpression (2.8%), shaderProcessor._ProcessIncludes (~2.2%).

I’m already stopping mainloop if user doesn’t move mouse.

Wonder if I’m doing this all wrong? Tried using shaderMaterial instead but coloring didn’t succeed. Obviously I’m now parsing the same shader code >800 times … and should do that only once. Sorry, don’t have PG.

Thanks for any advice!

This is impossible to know without a repro. It looks like the shader is not being cached for some reasons

1 Like