低性能,当执行eglSwapBuffer和eglMakeCurrent [英] Low performance when execute eglSwapBuffer and eglMakeCurrent

查看:5628
本文介绍了低性能,当执行eglSwapBuffer和eglMakeCurrent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Android统一的插件,允许用户记录他/她的游戏
我的解决方案概述:

I'm developing an Android Unity Plugin that allows user to record his/her gameplay
Overview of my solution:

  • 在使用OpenGL FrameBufferObject(FBO),以统一渲染屏幕外该FBO
  • 获取屏幕外纹理这个FBO然后用2目的:
    • 渲染视频表面
    • 重绘设备屏幕
    • Using OpenGl FrameBufferObject (FBO) to make Unity render offscreen to this FBO
    • Get the offscreen texture of this FBO then using for 2 purposes:
      • Render to video surface
      • Redraw to device screen
      • 绑定我的FBO
      • 渲染场景FBO(团结code)
      • 解除我的FBO
      • 设置了视频面
        • 在配置面尺寸(执行第一次只)
        • 在保存EGL状态
        • 进行视频表面电流
        • bind my FBO
        • render scene to FBO (Unity code)
        • unbind my FBO
        • set up video surface
          • configure surface size (execute first time only)
          • save egl state
          • make video surface current
          • 设置presentation时间的视频帧
          • 从视频表面的交换缓冲区默认的窗口
          • 在恢复EGL状态
          • 请默认表面电流

          我的问题是性能,同时记录并不好。 FPS起伏,从60到40的三星Galaxy S4。我试图记录进行渲染操作,并认识到,最影响性能的操作是进行视频表面电流操作和交换缓冲从视频中表面为默认窗口操作时间。下面是他们的code

          My issue is performance while recording is not good. FPS downs from 60 to 40 on Samsung Galaxy S4. I tried to record execute time of render operations and recognize that the most affect performance operations are make video surface current operation and swap buffer from video surface to default window operation. Below is their code

          public void makeCurrent()
          {
           if (!EGL14.eglMakeCurrent(this.mEGLDisplay, this.mEGLSurface, this.mEGLSurface, this.mEGLContext))
            throw new RuntimeException("eglMakeCurrent failed");
          }
          
          public boolean swapBuffers()
          {
           return EGL14.eglSwapBuffers(this.mEGLDisplay, this.mEGLSurface);
          }
          

          执行时间使当前的操作为1〜18毫秒
             执行的交换缓冲区运行时间为4〜14毫秒
             执行其他操作的时间一般为0〜1毫秒是
             如何提高这些业务的表现呢?
             任何帮助将大大AP preciated!

          Execute time of make current operation is 1 ~ 18 ms
          Execute time of swap buffers operation is 4 ~ 14 ms
          Execute time of other operations is usually 0 ~ 1 ms
          How to improve performance of these operations?
          Any help will be greatly appreciated!

          推荐答案

          很多OpenGL调用都是assync,有的电话可能会导致OpenGL的等待排队的操作来执行。所以,你看到的时候是因为你正在做的实际调用之前执行的其他呼叫。

          A lot of OpenGL calls are assync, and some calls may cause the OpenGL wait the queued operations to execute. So the times you are seen are because of the other calls that execute before the actual call you are doing.

          这篇关于低性能,当执行eglSwapBuffer和eglMakeCurrent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆