原文:https://forums.unrealengine.com/showthread.php?54448-Best-Practices-For-Running-On-The-PS4

Hey guys,

Since there are multiple ways to run your game on PS4 there's been some questions about best practices. Also a bit of confusion about how everything works. I wanted to write up a definitive post to lay out all the options, how stuff works, and my recommendations.
If there are any questions or something isn't clear, please let me know and I'll update the post.

Before I start I want to define a few terms:

  • Cooking : The process of turning cross-platform editor assets into platform-specific runtime assets.
  • Staging : The process of creating a directory on the PC which holds the runtime filesystem for your game. Necessary for packaging or deployment. When using UAT it is specified with -stage
  • Packaging : The process of creating a .pkg for installation on the PS4/device. When using UAT it is specified with -package
  • StageDir : This is the directory on your PC where the filesystem for your game is copied (staged) prior to packaging or deployment. It will be located under /YourProject/Saved/StagedBuilds/PS4
  • Deploy : The process of copying the StageDir to the device. (to /data/). Note that this is very different from installing a .pkg. Deployment simply copies files to /data/ for faster reading, it will not create a runnable application in the PS4 frontend.
  • UAT : "Unreal Automation Tool". The project in Visual Studios is just listed as 'Automation Tool'. This tool has many uses and is the supported method to create cooked builds for packaging or deployment.
  • /data : /data refers to the development-only data directory on the PS4's local harddrive. When passing paths to OS file functions (sceFios*) paths rooted at /data/ will read/write to the local device. See SCE/Orbis/documentation/pdf/en/SDK_doc/1st_read/Programming_Startup_Guide.pdf for more info.
  • /app0 : /app0 is the root path for reading files in shipping titles. However, in development it refers to the 'Working Directory' that you can set in Visual Studio, or in PS4 Neighborhood when launching from there. Not that this is NOT the same as 'File Serving Directory'. In an installed .pkg /app0 is the .pkg root. Again see the Startup_Guide for more info.
  • O drive : The PS4 SDK maps PS4 harddrives as O:/SomeIP/data/. You can access deployed files, or logs/screenshots written locally at runtime from here.
  • UFE : "Unreal FrontEnd". A work-in-progress tool to make launching games simpler. GUI application that helps avoid everyone having to deal with commandline tools.

With that out of the way, let's go over the various methods of running a game.

1. Deploy and Launch from the Editor
Also known as 'LaunchOn'. To do this you simply click the dropdown on the 'Launch' button in the editor and select your PS4.

What it does:
This method is the simplest, but currently the slowest for iteration. This process will use UAT to cook, stage, and deploy your game. It will then launch it for you with a commandline to load to the map you currently have open in the editor. This method was GREATLY improved in 4.7. The deploy is now 'iterative' so subsequent launches should only deploy modified data and be much much faster.
Internally it uses the SDK application orbis-run to launch the game. The working directory is set to YourProject/Build/PS4 so the OS can find any Trophy or Save data config files you may have.

Advantages:

  • Simple.
  • Guarantees that content changes are in your build. Good for content creators in this way.

Disadvantages:

  • Possibly still too slow for iteration on very large projects.

Recommended Use:

  • Content Creators on small to medium sized projects.

2. CookOnTheFly Server
What it does
Rather than cooking all of your content up front and staging/deploying it, you can run a server which the game will connect to and request files as needed. To launch such a server you must build your project under the 'Development Editor / x64' configuration. 
The server can be started by running UE4Editor.exe with a commandline to set up cookonthefly. 
e.g. "UE4Editor.exe "C:\Users\Marcus.Wassmer\Documents\Unreal Projects\UDNParticles\UDNParticles.uproject" -run=cook -targetplatform=PS4 -cookonthefly -log"
The server will start up and then simply wait for connections. As requests come in, it will cook requested files as necessary and serve them to the target.

When launching the game executable you must pass -filehostip=YourPCsIP as one of the parameters. This has several effects on the game runtime.

  • Files loaded by the engine go through the file server and are cached locally on /data/
  • Files will only be read by the engine from /data/ never /app0. The network file system simply copies files over the network to /data/ where they are finally read by the filesystem.
  • Cached files will be reused if possible on subsequent runs, saving you network copy time.
  • The OS will still automatically read certain system files (like trophy files) from /app0. These can't be served by the COTF server, so it's important to still have a valid Working Directory set if your title has implemented trophy support. The generated Visual Studio project will automatically set the WorkingDirectory to YourProject/Build/PS4. System files should go here. See ShooterGame for an example.

You can use CookOnTheFly when launching from Visual Studio, from PS4 Neighborhood, or from UFE.

Advantages:

  • Initial launch time is faster than LaunchOn because you're only dealing with data you currently need.
  • If you leave the COTF Server running then all files will remain cached on /data/ and subsequent runs will simply read from local files.

Disadvantages:

  • Content changes require a restart of the COTF Server. If you do not pass -iterate when starting the server, the entire Cooked directory will be wiped and regenerated. However, -iterate does not have perfect dependency checking and can miss changes in some cases. -iterate is still being improved. If your content changes do not show up, try running the cooker again without -iterate
  • At boot there is time spent communicating with the server to clear any out of date files from the /data/ cache. This time scales with the size of the project.
  • Not available for Shipping/Test Builds.

Future Work

  • -iterate will be made reliable
  • The regular editor will be an active COTF server, so in the future you will not have to start a separate process for it.

Recommended Use:

  • Programmers on large projects that need to do targeted testing and don't want to wait for the whole project to cook.
  • Content Creators (using UFE to actually manage launching everything)

3. Reading from a Staged Directory
What it does:
This method requires the most manual setup, but is probably the second best for programmer iteration at the moment. The first step is to generate a StagedDir for you game that has a valid runtime filesystem. There are various ways to do this (packaging the project from the editor, using UFE) but they all simply run a UAT command for you. You can use UAT to stage a build for you like this:

"D:\dev\UE4\Engine\Build\BatchFiles>RunUAT BuildCookRun -project="D:\Working\UE4\Samples\Games\ShooterGame\ShooterGame.uproject" -ps4 -cook -stage -pak -cmdline=ShooterEntry -clientconfig=Development"

Such a command would generate ShooterGame/Saved/StagedBuilds/PS4/... with all the necessary files to run.

You can then set the Working Directory in the Visual Studio debugging params to this directory. The game will then treat this directory as /app0 and it should run without any other fuss. However, there is one gotcha here. The existence of a ue4commandline.txt file in the root of /app0 is used to decide to use /app0 as the file root. (See PS4Launch.cpp), so always add a -cmdline=yourstartupmap to your UAT command to generate one. (Or you can simply place a blank one in the directory yourself). This process will be improved in the future.

Again, you use either Visual Studio or PS4 Neighborhood to launch your game like this, you simply must set the Working Directory appropriately after UAT completes staging.

Advantages:

  • Very fast iteration if you aren't changing content.
  • No startup time penalty from talking to cookserver / checking cached files.

Disadvantages:

  • Very manual setup.
  • Slower load times than reading from data deployed to the O: directly because you're reading over the network.
  • Easy to run with out of date content if you forget to re-stage your build.

Recommended Use:

  • Programmers iterating on large projects with infrequent local content changes that are willing to trade longer load times to avoid an initial deployment period.

4. Reading only from Deployed Data
What it does:
This method is only for programmers. You must first get your data deployed onto the O: of the PS4. This can be done by using LaunchOn, running once with CookOnTheFly until you have cached all necessary data, or using a UAT commandline such as:

"D:\dev\UE4\Engine\Build\BatchFiles>RunUAT BuildCookRun -project="D:\Working\UE4\Samples\Games\ShooterGame\ShooterGame.uproject" -ps4 -cook -stage -pak -deploy -device=YourPS4Name -cmdline=ShooterEntry -clientconfig=Development"

Once the data has been deployed, when you run your game from VisualStudio simply pass -deployedbuild as a commandline argument to the game. The engine will now ONLY load data from the PS4 harddrive's /data directory. There is NO initial cost from talking to a cookserver, and there is no cost from reading files over the network. This will give you the fastest iteration times if your content is not changing. Be aware if you use cookonthefly for your initial deployment that you will ONLY be able to load content that you loaded during your COTF session. For example, if you use COTF and load Level1, then do a -deployedbuild run you will not be able to load Level2.

Advantages:

  • Very fast iteration if you aren't changing content.
  • No startup time penalty from talking to cookserver / checking cached files.
  • No penalty for reading files from the hostpc.

Disadvantages:

  • Easy to miss data you will want later if you use CookOnTheFly to cache the data.
  • Initial deployment time to copy all files to the PS4.
  • Easy to run with out of date content if you forget to re-deploy.

Recommended Use:

  • Programmers iterating on any project with infrequent local content changes.

Conclusion
TLDR:

  • Content Creators: LaunchOn for small projects, for larger projects Use UnrealFrontEnd to do CookOnTheFly.
  • Programmers: Use COTF or Deployed Data directly.

Best Practices For Running On The PS4的更多相关文章

  1. UE4开发PSVR游戏流程

    先与sony的开发者关系部建立联系,展示工作室/公司制作PSVR游戏的构想和计划以及制作实力,如果对方觉得你提供的信息具有说服力,则会提供开发者资格,和你签署NDA,给你租借开发机和测试机(免费). ...

  2. 怎么提高ArcGIS for Desktop10.x的性能

    Esri新公布了一篇提高ArcGIS for Desktop10.x的性能的文章.大家能够关注一下 http://support.esri.com/en/knowledgebase/techartic ...

  3. EXPDP导数报ORA-00942案例

    使用数据泵(expdp)导数时遇到了ORA-31626 & ORA-00942 错误,数据库版本为Oracle Database 10g Release 10.2.0.5.0,具体错误如下所示 ...

  4. 【译】Permissions Best Practices Android M权限最佳做法

    Permissions Best Practices PreviousNext In this document Consider Using an Intent Don't Overwhelm th ...

  5. VMWare File Format Learning && Use VHD File To Boot VMWare && CoreOS Docker Configuration And Running

    目录 . Virtual Machine Introduce . Vmware Image File Format . VHD File Format . Convert VHD File Into ...

  6. Celery - Best Practices

    If you've worked with Django at some point you probably had the need for some background processing ...

  7. Async/Await - Best Practices in Asynchronous Programming z

    These days there’s a wealth of information about the new async and await support in the Microsoft .N ...

  8. advanced dom scripting dynamic web design techniques Part One DOM SCRIPTING IN DETAIL CHAPTER 1 DO IT RIGHT WITH BEST PRACTICES

    You’re excited; your client is excited. All is well. You’ve just launched the client’s latest websit ...

  9. ORC Creation Best Practices

    Short Description: ORC Creation Best Practices with examples and references. Article Synopsis. ORC i ...

随机推荐

  1. numpy多维数组

    1 多维数组的切片用法 c = np.array([[[0,1,2],[4,5,6],[8,7,5],[10,11,12]],[[6,2,3],[9,8,34],[100,101,102],[110, ...

  2. SpringMvc @ModelAttribute 的用法

    参考:Spring 3.x 企业应用开发实战   第15章:SpringMvc  页码:532 ModelAttribute 从字面上解释就是模型的属性. 对于MVC框架来说是模型数据是最重要的,因为 ...

  3. IntelliJ IDEA的常用设置

    1.设置IDEA主题样式 ①设置方法: ②效果:设置为Darcula之后整体的风格就是暗黑主题,如上图. 2.设置编辑区主题 ①设置方法: 注:由于IDEA自带的编辑区主题比较少,想要更多的编辑区主题 ...

  4. vue 父子component生命周期

    如今前端框架都流行组件化,页面元素都可以使用组件进行高度概括,那么处理组件之间的关系就如同处理页面架构一样重要.正确理解组件之间的关系,才能让代码按照我们与预料方式工作.最近参与了一个Vue.js的项 ...

  5. sql 语句 的一些优化小总结

    1.用exists 代替 in 原理:exists 是存在一个即返回一个 而in是做全盘扫描得出所有条件内的数据 (高效) and exists (select 'x' from Person whe ...

  6. Prometheus + AlertManager 邮件报警

    安装 wget https://github.com/prometheus/alertmanager/releases/download/v0.13.0/alertmanager-0.13.0.lin ...

  7. [Vim] 03 凡人进阶

    目录 0. 前言 1. 按下 Esc, 进入编辑模式 (1) 定位 (2) 删除 1) 不进入插入模式的删除 2) 进入插入模式的删除 3. 10 个特殊字符 4. 在 gVim 下执行命令 (1) ...

  8. HDFS网络拓扑概念及机架感知(副本节点选择)

    网络拓扑概念 在本地网络中,两个节点被称为“彼此近邻”是什么意思?在海量数据处理中,其主要限制因素是节点之间数据的传输速率——带宽很稀缺.这里将两个节点间的带宽作为距离的衡量标准. 节点距离:两个节点 ...

  9. poj_1995 Raising Modulo Numbers (快速幂)

    [题目链接] http://poj.org/problem?id=1995 [算法] 基本快速幂(二进制思想) 注意两个int相乘可能溢出,加(long long)但是相乘不要加括号,不然会先溢出在类 ...

  10. 2019 Multi-University Training Contest 4 - 1010 - Minimal Power of Prime

    http://acm.hdu.edu.cn/showproblem.php?pid=6623 题意,给50000个1e18级别的数N,求它质因数分解里面的最小的指数(不算0) 比赛的时候给划了一个1e ...