开发者

OpenGL performance on iPhone: glAlphaFuncx on the trace

This is kind of weird, but I noticed that up to 40 percents of the rendering time is spent inside glAlphaFuncx. I know that alpha testing is very expensive, but the interesting thing is I do not use it :) No single place of code uses alpha testing, neither do I invoke this function in any other way.

I also checked GL layer for blending on other sorts of stuff which might cause this to happen but it is what it is.

So, if anybody knows what might cause glAlphaFuncx to appear on the performance trace of CPU Sampler, I would be glad to hear it :)

Update: fixed the screenshot link: http://twitpic.com/2afxho/full

Update 2: the function that leads to invokation of glAlpaFuncx contains a single line:

[context presentRenderbuffer:GL_RENDERBUFFER_OES];

Update 3: I tried setting the breakpoint inside this function, but it seems it haven't be开发者_开发百科en invoked at all. I guess profiler is screwed up here...


It's weird that this function appears on a profiler trace, as you say you aren't using it. Try setting a breakpoint in glAlphaFuncx to see from where it is being called.

But anyway, that should not be a problem, glAlphaFunc will just set a state in the GL server side, it doesn't (or should) do any more processing than that. It shouldn't be a performance problem, maybe it's a bug in the GL implementation or in the profiler.

To be sure, you can disable alpha test with glDisable(GL_ALPHA_TEST).


From what I can see, glAlphaFuncx could just be taking the hit for setting up the rendering or pushing the pixels. It could be that it is run either first or last in the rendering.

Do you have an actual performance problem, or are you just trying to find pieces of code to slice off / optimize?

If so, you should set a breakpoint in glAlphaFuncx and see where it is called from and why. To do this, just bring up the debugger console and type "break glAlphaFuncx".


Have you tried explicitly disabling the use of alpha channels?

glDisable(GL_ALPHA_TEST);

http://www.khronos.org/opengles/documentation/opengles1_0/html/glEnable.html


Regardless of system, this sort of behaviour -- time spent presenting what's been drawn -- almost always indicates that the GPU is the bottleneck. Either you are drawing too much (if the framerate is a problem), or the CPU isn't doing enough (if the framerate is fine).

Actually, there's one other possibility -- that the amount of GPU work is fine, but the system is waiting for some kind of vertical retrace period. (That seems unlikely on a device that only ever has an LCD, and doesn't support a raster scan display, but maybe things still notionally work that way internally.) The upshot is still the same as far as the amount of CPU works goes, though, in that you've got time to do more stuff without affecting the frame rate.

I can't explain exactly why glAlphaFuncx specifically is appearing in the call stack, but if it doesn't appear ever to be actually getting called then I'd consider it a red herring until proven otherwise.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜