Precompiled shaders

Quick question, is support being added to compile shaders offline and have the game load the compiled version?

In theory, that’s not hard. But is it really worth the trouble? Have you measured how much time is being spent in shader compilation?

I imagine shader compilation on the fly is pretty cheap when you look at the big picture. I was more interested in compiling the shaders to verify they have no errors prior to runtime as well as having the ability to distribute a non-human readable version.

These concerns are pretty low priority, i was basically asking out of curiosity more than anything else :slight_smile:

The thing is that the shaders are custom-compiled to each target hardware. The compiled result of a shader for your graphics card will be different thatn the compiled result for my graphics card–and maybe different still for graphics card “Foo XF 9200” that will be released next month. So it would be difficult to distribute an application with nothing but precompiled shaders.

If we were to add precompiled shader support to Panda, we’d probably do it in such a way that the shader is compiled once for your hardware, and the result of that cached for future sessions. This way you wouldn’t have to anticipate every possible hardware configuration, but you’d still need to distribute the shader source.

As to verifying that the shaders have no compilation errors, well, the best way to do that is to run the shaders anyway–since you also want to test that they have no logic errors, right? :slight_smile:

David

Ah, I understand. No worries then. I didnt realize that the shader compiled differently for each video card.

I should mention that you can use “cgc.exe” (it’s a program from nvidia, but it’s bundled with panda) to test your shaders. This is very helpful to see what kind of code it’s generating, for optimization purposes.