简体   繁体   English

glDrawElements过多导致fps低? OpenGL ES1.1(iPhone)

[英]Too many glDrawElements cause for low fps? OpenGL ES1.1 ( iPhone )

I am developing a 2D Tile based game and currently struggling with performance issue as I am getting around 10 - 15 FPS even when running on iPad 3. OpenGL ES Frame capture reveals that I am making call to glDrawElements 689 times per frame! 我正在开发基于2D Tile的游戏,并且目前在性能问题上挣扎,即使在iPad 3上运行时,我的FPS约为10-15FPS。OpenGLES帧捕获显示我每帧调用glDrawElements 689次! Is that a lot? 那很多吗 Could it be the case of low performance? 可能是性能低下的情况吗?

Should I stack everything in one huge array and perform 1 draw call? 我是否应该将所有内容堆叠到一个巨大的数组中并执行1次抽签? will it make any difference? 有什么不同吗?

At this point in time, you are currently limited by your command issue(assuming), if you run opengl performance detective ( it's under xcode (right click, open developer tools) you may have to download it through preferences ). 目前,您目前受到命令问题(假设)的限制,如果您运行opengl性能检测程序(它位于xcode(右键单击,打开开发人员工具)下,则可能必须通过首选项进行下载)。

Your goal is to be limited by fill rate at the end of the day, here are some tips to help you get there 您的目标是在一天结束时受到填充率的限制,这里有一些技巧可以帮助您到达目的地

Sort all sprites by Draw Depth Blend Mode Texture ID 按“绘制深度混合模式纹理ID”对所有精灵进行排序

Once sorted, Pack all sprites into one vertex buffer object and an index buffer object. 排序后,将所有精灵打包到一个顶点缓冲区对象和一个索引缓冲区对象中。

When ever your draw depth, blend mode, or texture ID change, it's time to make a new draw call and bind those resources. 每当绘制深度,混合模式或纹理ID发生变化时,就该进行新的绘制调用并绑定这些资源。

Also keep in mind that your sprites should have your vertices flatted on the cpu side (pos x mvp ) and you should not be sending over matrices and any other attributes such as color, should be part of the vertex. 还请记住,子画面的顶点应在cpu侧变平(pos x mvp),并且不应该通过矩阵发送,并且任何其他属性(例如颜色)都应该是顶点的一部分。

Typical vertex 典型顶点

{
    float pos[3]
    int color
    float uv[2]
}

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

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