10-20 second shader compile time on Windows

129 views
Skip to first unread message

Jason Knight

unread,
Jun 29, 2022, 12:47:47 PM6/29/22
to angleproject
We have a GLSL shader (for the Godot engine) that contains a very large Signed Distance Field function. This function is a long series of mathematical operations. This shader takes way too long to compile on windows machines.

I am looking into possible options for speeding this up. I'm not an expert in this field so my suggestions may be off base.

1. Is it possible to offline transpile the GLSL shader into something else that will compile faster on ANGLE/D3D?

2. Would running the GLSL shader through this shader optimizer improve things? https://github.com/aras-p/glsl-optimizer

Ken Russell

unread,
Jun 29, 2022, 2:38:04 PM6/29/22
to ja...@winterpixel.com, angleproject
Can you provide the source of the shader?

The compilation cost is likely in Microsoft's fxc, invoked by ANGLE, and some computationally expensive analyses and optimizations it performs. If this isn't straight-line code, we recommend trying unrolling any loops, especially those which sample textures.

In the past we've diagnosed compilation performance problems by cutting out portions of the shader, ignoring any correctness issues.

-Ken



--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angleproject/9d77d6ae-bec2-428d-b1fd-ca77714d7773n%40googlegroups.com.

Shahbaz Youssefi

unread,
Jul 4, 2022, 9:52:34 PM7/4/22
to angleproject
It would also help to look at the HLSL shader generated by ANGLE. Some corner case scenarios force ANGLE to go through gymnastics, and you'd want to avoid those! Keep an eye out for excessive code generation in HLSL.

Jason Knight

unread,
Jan 29, 2024, 5:22:37 PMJan 29
to angleproject

Sorry it took me so long to produce this. I wasnt sure if I wanted to share it at first, then I forgot about it. We render the terrain for our game Rocket Bot Royale using giant SDFs that we generate using a SDF editor that we built. This file ended up being very large, and specifically on windows it would take a very long time to compile. Here's the file for your reference, thanks, and good luck.
construction_3.sdf
Reply all
Reply to author
Forward
0 new messages