iPhone OpenGL 和 NSTimer 问题

发布于 2024-08-30 12:04:52 字数 639 浏览 1 评论 0原文

我有一个以 60hz 运行的 NSTimer。加载并渲染 OpenGL 场景后,我的游戏可以获得 60fps,稳定,一整天。然后,如果我重新编译应用程序,或重新加载它,它将获得 40fps。加载相同的资源。我多年来一直遇到这个问题,我只是想知道为什么。这太疯狂了,我想知道我是否应该放弃这个愚蠢的计时器。我的 3GS 负载之间的情况没有什么不同。有时它只会达到 40fps。显然,负载之间的时钟速率没有不同,因此在给定恒定场景的情况下,性能数据应该是恒定的。这是我的帧速率日志:

良好的负载::-)

FrameRate:61 帧率:61 帧率:61 帧率:60 帧率:60 帧率:61 帧率:60 帧率:60 帧率:61 帧率:60 FrameRate: 61

现在,我将继续什么都不做,重新编译并运行:

FrameRate: 43 帧率:50 帧率:45 帧率:48 帧率:40 帧率:45 帧率:42 帧率:41 帧率:42 帧率:44 帧率:41 帧速率:46

​​ ^- 视觉上的巨大差异。究竟是什么原因导致了这种情况呢?

场景的相同区域,相同的摄像机设置。没有变量是不同的。

[编辑] 有人提到,硬件解码器中未运行的音乐可能会导致这种情况,有时即使您进行了设置,解码器也不会接管。然而,我可以说,即使禁用音乐,也会发生这种情况[/编辑]

I have an NSTimer that runs at 60hz. With an OpenGL scene loaded and rendering, my game can get 60fps, solid, all day long.. Then if I go and recompile the app, or reload it, it will get 40fps. Same resources loaded. I've been running into this problem for years, and I just want to know why. It's crazy, and I want to know if I should just abandon this stupid Timer. Conditions are not different on my 3GS between loads. It will just get 40fps sometimes. Obviously the clockrate is not different between loads, so the performance figures should be constant given a constant scene. Here is a log of my framerates:

A good load: :-)

FrameRate: 61
FrameRate: 61
FrameRate: 61
FrameRate: 60
FrameRate: 60
FrameRate: 61
FrameRate: 60
FrameRate: 60
FrameRate: 61
FrameRate: 60
FrameRate: 61

Now, I'll go ahead and do nothing, recompile, and run:

FrameRate: 43
FrameRate: 50
FrameRate: 45
FrameRate: 48
FrameRate: 40
FrameRate: 45
FrameRate: 42
FrameRate: 41
FrameRate: 42
FrameRate: 44
FrameRate: 41
FrameRate: 46

^- Massive difference visually. What the flying heck could cause this?

SAME area of the scene, SAME camera setup. No variables are different.

[Edit] Some have mentioned that the music not running in the hardware decoder can cause this, and that sometimes the decoder will NOT take over even if you set it up to. However, I can say that even with music disabled, this happens [/Edit]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

被你宠の有点坏 2024-09-06 12:04:52

您是否尝试过使用 CADisplayLink 来代替?来自文档

CADisplayLink 对象是一个计时器
允许您的应用程序的对象
将其绘制同步到刷新
显示速率。

...

关联显示链接后
使用运行循环,选择器
当屏幕的
内容需要更新。

我个人没有使用过它,但看起来它可能会帮助您遇到较低帧速率的任何问题,即使它本身不会提高您的帧速率。

Have you tried using CADisplayLink instead? From the documentation:

A CADisplayLink object is a timer
object that allows your application to
synchronize its drawing to the refresh
rate of the display.

...

Once the display link is associated
with a run loop, the selector on the
target is called when the screen’s
contents need to be updated.

I haven't used it personally, but it looks like it might help any issues you have with the lower frame rate, even if it doesn't increase your frame rate per se.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文