日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

VR开发中性能问题—OculusWaitForGPU

發(fā)布時(shí)間:2024/8/26 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VR开发中性能问题—OculusWaitForGPU 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

http://blog.csdn.net/cartzhang/article/details/50788894

VR開發(fā)中性能問題—OculusWaitForGPU


本文章由cartzhang編寫,轉(zhuǎn)載請(qǐng)注明出處。 所有權(quán)利保留。?
文章鏈接:http://blog.csdn.net/cartzhang/article/details/50788894?
作者:cartzhang?

**

一、OculusWaitForGPU


在unity 5.3.0f4中測試,使用Unity提供的VR解決方案,直接在Build setting的Playersetting中,勾選使用Virtual Reality Supported,如下圖所示:
?
?

在運(yùn)行程序的Profile時(shí),你會(huì)發(fā)現(xiàn)OculusWaitForGPU 的占用時(shí)間特別高。?
如下圖:?

二、原因

先說配置:?
Unity 版本:Unity 5.3.0f4?
OC版本:0.8.0 beta的.?
是什么造成這個(gè)問題的呢??

網(wǎng)上搜索各種原因,如下:?
1. 有的說是因?yàn)?#xff0c;CPU在等待OC的GPU渲染數(shù)據(jù)返回。?
2. OC內(nèi)部API強(qiáng)制垂直同步,罪魁禍?zhǔn)资荱nity內(nèi)部集成的當(dāng)前OC驅(qū)動(dòng)。?
3. Unity個(gè)版本問題,不僅僅各個(gè)大版本,還有各個(gè)小版本之間,有個(gè)的f,有的是P。?

三、大致的解決方案

為啥說大致的解決方案呢?因?yàn)檎辛税胩?#xff0c;沒有具體的,也沒有誰說有個(gè)自己好用,別人也好用的方法。更重要的是OC官方說的方法,也是針對(duì)某個(gè)版本的暫時(shí)之用。?

故此,我總結(jié)的方法如下:?
1.使用64位模式。?
2.在GUp和shader的渲染處理優(yōu)化。?
3. 換OC版本試試,使用0.6.0.1,0.7版本的可能效率低。?
4. 5.3.0f4對(duì)VR來說不太好,可選擇5.2.3p3來解決多線程問題,也就是說你的換換其他版本來測試,安裝OC官方推薦版本來試試(下面會(huì)給出官方推薦版本連接)。?
5. 對(duì)于使用Untiy插件的觀眾:你的選擇有多了一個(gè)!!代碼來解決,自己修改 TimeWarp,但是OCulus官方說這個(gè)是暫時(shí)的,以后版本就不能這樣用 的。?
關(guān)于修改TimeWarp的代碼如下:?

using UnityEngine; using System.Runtime.InteropServices;/// <summary> /// Helper class to modify the internal Oculus TimeWarp values. /// </summary> public class OVRTimeWarp : MonoBehaviour { public enum VsyncMode { VSYNC_60FPS = 1, VSYNC_30FPS = 2, VSYNC_20FPS = 3 } #pragma warning disable 414 [SerializeField] VsyncMode targetFrameRate = VsyncMode.VSYNC_30FPS; #pragma warning restore #if (UNITY_ANDROID && !UNITY_EDITOR) [DllImport("OVRPlugin")] // Support to fix 60/30/20 FPS frame rate for consistency or power savings private static extern void OVR_TW_SetMinimumVsyncs( VsyncMode mode ); #endif /// <summary> /// Start modifying the TimeWarp /// </summary> void Start() { if (!OVRManager.isHmdPresent) { enabled = false; return; } #if (UNITY_ANDROID && !UNITY_EDITOR) Debug.LogWarning( "Setting TimeWarp Rate to: " + targetFrameRate ); OVR_TW_SetMinimumVsyncs( targetFrameRate ); #endif } }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43


看清楚了,這個(gè)是需要OC對(duì)Unity的插件的,因?yàn)榭吹嚼锩娴?

OVRManager
  • 1
  • 1


看到這個(gè)東西了吧,這個(gè)就是需要OVRManager.cs,也就是OC插件里帶的相機(jī)管理腳本。?
里面還有個(gè)宏定義,也就是說在安卓下使用。

#if (UNITY_ANDROID && !UNITY_EDITOR)[DllImport("OVRPlugin")]// Support to fix 60/30/20 FPS frame rate for consistency or power savingsprivate static extern void OVR_TW_SetMinimumVsyncs( VsyncMode mode ); #endif #if (UNITY_ANDROID && !UNITY_EDITOR) Debug.LogWarning( "Setting TimeWarp Rate to: " + targetFrameRate ); OVR_TW_SetMinimumVsyncs( targetFrameRate ); #endif
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11


什么是TimeWarp呢?這個(gè)問題,很好。簡單說就是:處理VR,提高幀率的一種手段。但是不是萬能的。?
具體參考如下:
?
http://xinreality.com/wiki/Timewarp?
http://www.myexception.cn/other/1883027.html?

里面講了TimeWarp的基本原理,時(shí)間扭曲和位置抖動(dòng)等,可以參考一下!!?
就這樣了。
?

最后,就是關(guān)于Unity版本推薦的OC官方網(wǎng):

https://forums.oculus.com/viewtopic.php?t=25882

四、參考鏈接

https://www.reddit.com/r/oculus/comments/3of567/huge_fps_hit_in_unity_with_vr_enabled/?
https://forums.oculus.com/viewtopic.php?f=37&t=27963&p=310144&hilit=OculusWaitforGPU#p310144?
http://forum.unity3d.com/threads/major-vr-performance-issue-oculuswaitforgpu-running-on-cpu.328442/

http://xinreality.com/wiki/Timewarp?
http://www.myexception.cn/other/1883027.html


重要更新:2016-07-28?
我們的解決方案:?
目前我們測試的低OculusWaitForGPU的版本為:5.3.2f1版本。當(dāng)然也不是說其他版本不行。?
只是我們沒有測試過。?

還有就是:目前對(duì)OCulus0.80.支持的最后版本為:?
Unity 5.3.4p4 and 5.4.0b15 were the last versions that supported PC SDK 0.8.!!!


就是這樣了。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

轉(zhuǎn)載于:https://www.cnblogs.com/jukan/p/6037628.html

總結(jié)

以上是生活随笔為你收集整理的VR开发中性能问题—OculusWaitForGPU的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。