Reputation: 357
In my GLSL code, I have large functions being called multiple times.
As an example, inside my perlin noise function I run a hash function many times.
float perlinNoise (...) {
...
float x0y0z0 = pcgUnit3(seedminX,seedminY,seedminZ);
float x0y0z1 = pcgUnit3(seedminX,seedminY,seedmaxZ);
float x0y1z0 = pcgUnit3(seedminX,seedmaxY,seedminZ);
float x0y1z1 = pcgUnit3(seedminX,seedmaxY,seedmaxZ);
float x1y0z0 = pcgUnit3(seedmaxX,seedminY,seedminZ);
float x1y0z1 = pcgUnit3(seedmaxX,seedminY,seedmaxZ);
float x1y1z0 = pcgUnit3(seedmaxX,seedmaxY,seedminZ);
float x1y1z1 = pcgUnit3(seedmaxX,seedmaxY,seedmaxZ);
...
}
In my procedural generation algorithm, I call the perlin noise function multiple times.
I notice that for every time I add a call to the perlin noise function, the compile time for the shaders takes longer. I think the problem is that glsl inlines the function calls, and thereby the shader code becomes very large.
Am I correct about the inlining, and if so, how do I prevent it from happening?
Upvotes: 0
Views: 758
Reputation: 131
On page 13 of the GLSL_ES_Specification_1.00 it is described, how to set pragma derectives
That would be the "inlining" case. "Am I correct about the inlining ..". For my knowlenge, no. Also not quite sure what is happening in the background. On Windows it gets transpiled to ANGEL, maybe have a look at the source could help.
In general: try to lower the precession, consider that three digits 1.000 could be "nice" enough. Floats can only store 5 -6 digits anyway. Avoid branching. That should be the First Aid Kid.
Some debugger tools out in the wild (please make your own research)
Optimizer
Upvotes: 1