简体   繁体   English

在iPhone中将OpenGL与UIKit混合使用时,确切的性能成本是多少?

[英]What is the exact performance cost when mixing OpenGL with UIKit in iPhone?

I need to make a design decision of how to approach an app which needs to render few 3D objects on top of an image texture. 我需要对如何处理需要在图像纹理顶部渲染少量3D对象的应用程序做出设计决策。 Result needs to be rendered and saved as an UIImage. 结果需要呈现并保存为UIImage。 Graphical design (client) expects standard UIKit controls to manipulate 3D world. 图形设计(客户端)希望标准UIKit控件能够操纵3D世界。

OpenGL view (CAEAGLLayer layer) needs to be inside UIScrollView for cheap and natural scroll and zooming implementation. OpenGL视图(CAEAGLLayer层)需要位于UIScrollView内,以实现便宜自然的滚动和缩放实现。 There are just few extra controls to manipulate rotation scale and transition of the few 3D objects. 仅有少量额外的控件可操纵旋转比例和少数3D对象的过渡。 There is not many triangles expected (100-200 at most) and 2-3 textures (1 mask). 预期三角形(最多100-200个)和2-3个纹理(1个蒙版)的三角形不多。 It does not even have to be refreshed constantly, just when some transformations and zoom changes. 甚至在某些转换和缩放更改时,它甚至不必经常刷新。 CAEAGLLayer does not need to be opaque. CAEAGLLayer不必是不透明的。

I would go with Core Animation solution but rendering 3D transformed CALayers to CGContextRef is not supported (neither is masking). 我将使用Core Animation解决方案,但不支持将3D转换的CALayers渲染到CGContextRef(也不屏蔽)。

What is real performance cost when putting CAEAGLLayer inside UIScrollView and mixing it with few UIKit views? 将CAEAGLLayer放入UIScrollView并将其与少量UIKit视图混合时,真正的性能成本是多少? How much triangles per second can I expect to be rendered with smooth frame rate (30fps will do), so I can make the best decision possible? 我可以期望每秒以平滑的帧速率(每秒30帧)来渲染多少个三角形,这样我才能做出最佳决定?

I know there are similar questions out there already, but none of the answers provides specific numbers, which could help with estimating expected rendering results. 我知道那里已经有类似的问题,但是没有一个答案提供具体的数字,这可能有助于估计预期的渲染结果。

Per Allan Schaffer, who gives the WWDC and WWDC on tour OpenGL speeches, OpenGL itself is not so much a special case — it's that anything that changes will cause everything on top of it to be recomposited. 在WWDC和WWDC的OpenGL演讲中向WWDC和WWDC致辞的Allan Schaffer认为,OpenGL本身并不是什么特别的情况-凡是发生变化的东西都将导致其上的所有内容重新组合。 I spoke to him specifically about an app with a live updating video view underneath a live updating OpenGL view and he said that sort of thing is the pathological worst case. 我特别跟他谈过一个应用程序,该应用程序在实时更新的OpenGL视图下具有实时更新的视频视图,他说这种事情是最糟糕的情况。 It's generally not that expensive to throw a few quite static views on top, such as using a UILabel to display the current score over an OpenGL game. 通常,在顶部放置一些非常静态的视图并不昂贵,例如使用UILabel在OpenGL游戏中显示当前得分。

In your case, I think you can probably largely avoid the problem. 就您而言,我认为您可以在很大程度上避免此问题。 Don't put the GL view inside the scroll view, but rather make the scroll view non-opaque and put the GL view behind it. 不要将GL视图放在滚动视图中,而要使滚动视图不透明并将GL视图放在它的后面。 Catch scrollViewDidScroll: (and the corresponding zoom messages) and make related OpenGL adjustments. 捕获scrollViewDidScroll:和相应的缩放消息)并进行相关的OpenGL调整。 I can speak from experience and say I've done exactly that on an iPad 1 with no performance issues. 我可以根据经验说,我已经在iPad 1上做到了这一点,没有任何性能问题。 Particularly for the sort of model you're talking about I don't imagine a problem. 特别是对于您正在谈论的那种模型,我认为没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM