Long shader compile times on iPhone 3G S

Nibbie
Posts: 4
Joined: 2009.11
Post: #1
I am getting shader compile times of up to 8 seconds on the iPhone 3G S (OS 3.1.2). The 8 second example consists of an 18 line vertex shader and a 110 line fragment shader, plus a few #define lines. Shark on Mac OS X tells me that 96.7% of the time is being spent in response to glValidateProgram, of which nearly all goes into CompileShader in the IMGSGX535GLDriver library. An excerpt:

96.7%, glValidateProgram, OpenGLES
96.7%, glValidateProgramARB_Exec, GLEngine
96.7%, gldUpdateDispatch, IMGSGX535GLDriver
96.7%, glrLoadCurrentPipelinePrograms, IMGSGX535GLDriver
94.0%, glrUpdateFragmentProgramInline, IMGSGX535GLDriver
94.0%, glrUpdateCtxSysFragmentProgram, IMGSGX535GLDriver
93.9%, sgxUpdateCtxSysProgram, IMGSGX535GLDriver
93.9%, ppimgCompile, IMGSGX535GLDriver
93.9%, PVRUniFlexCompileToHw, IMGSGX535GLDriver
93.8%, CompileShader, IMGSGX535GLDriver

I have a detailed decomposition. As a point of comparison, when running on the iPhone simulator on a MacBook Pro, I get glValidateProgram durations of 0.0006 to 0.01 seconds.

I'm guessing there is some sort of super-linear (and maybe exponential) analysis going on during compilation in the IMGSGX535GL driver.

Strangely, I've been unable to find other reports of this problem of terribly slow compile times.

Any ideas on what's going on and how I can speed things up dramatically? I'm happy to share my shader programs if anyone is interested.

When I skip glValidateProgram, I get these same sort of delay, but during the first render call.

I am completely baffled, and I would sure appreciate help.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
File a bug. http://bugreport.apple.com/ . Include your shader code.
Quote this message in a reply
Sage
Posts: 1,234
Joined: 2002.10
Post: #3
conal Wrote:As a point of comparison, when running on the iPhone simulator on a MacBook Pro, I get glValidateProgram durations of 0.0006 to 0.01 seconds.

Comparing the compilation time in the simulator is not meaningful.

The simulator is a software renderer, and is able to draw immediately while shader JIT compilation is being done on a second thread. Hardware renderers can't do that.


In any event, file a bug.
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2009.11
Post: #4
arekkusu Wrote:The simulator is a software renderer, and is able to draw immediately while shader JIT compilation is being done on a second thread. Hardware renderers can't do that.

Do you mean that the simulator first renders via the GPU (some sort of GLSL interpreter) and then switches to GPU code once that code is generated? I've wondered why it's slow at first and then speeds up significantly.
Quote this message in a reply
Sage
Posts: 1,234
Joined: 2002.10
Post: #5
No, the simulator is always rendering via the CPU. From the programming guide:
Quote:(The) simulator provides an optimized software rasterizer that takes advantage of the vector processing capabilities of your Macintosh computer.

For this, and many other reasons, it's not meaningful to compare the simulator performance to any other renderer.
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2009.11
Post: #6
I submitted a bug report, but I can't tell whether it went through or not. I got back a message saying that I need Safari 1.0 or better. I'd submitted in Firefox, and i thought maybe it was telling me that Firefox wouldn't work. I redid in Safari (4.0.4), and i got the same result (saying I need Safari 1.0 or better).

Does anyone know how I can tell whether my report got into the bug tracking system or just got lost?
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2009.11
Post: #7
arekkusu: Thanks for the additional details about shader execution in the simulator. Please disregard my previous iPhone-vs-simulator comparisons.

Does anyone have info on these terribly long compilations times (e.g., 8 seconds for 120 uncrowded lines of shader)?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
You can tell if it worked because it will show up in "my originated bugs"
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #9
I have yet to see this on the iPhone, but on the Mac side, I've seen incredibly long (eg upwards of 30s) compilation times for some graphics hardware.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
please tell me *you* at least filed a bug...
Quote this message in a reply
Post Reply