YouTube2Text

DD2018: Mikkel Gjol - Inside shipping on iOS — Transcript

by Digital Dragons · 6,762 words · 931 segments · language en · Watch on YouTube

Full transcript

  1. 0:00[Music]
  2. 0:34thank you very much thank you all for
  3. 0:37arriving very early for Sebastian's talk
  4. 0:39about beautiful real-time ray machi
  5. 0:42after this session until then I'll be
  6. 0:44talking about our the inside shipping
  7. 0:47and how we did that on my ways and then
  8. 0:49now I'll round it off with a little bit
  9. 0:51of real-time ray tracing just to sort of
  10. 0:52warm you up for Sebastian story fluids
  11. 0:55so I'm from ma played it played it did a
  12. 0:59game called limbo a couple years ago in
  13. 1:022012 we then are released inside in 2016
  14. 1:08so I'm not going to talk about how we
  15. 1:10actually made this game I'm just going
  16. 1:12to talk about how we ship them which is
  17. 1:14something we've done quite a lot over
  18. 1:16the last couple of years so we initially
  19. 1:18we've shipped on five different
  20. 1:20platforms or four and switches almost
  21. 1:22there so we kind of feel by now that
  22. 1:27we're pretty good at at actually going
  23. 1:29through that process so that's what I'll
  24. 1:31talk about so the agenda for today is
  25. 1:34I'll also go over the rough approach to
  26. 1:39how we week about that the tools that we
  27. 1:41use that we've built most of those few I
  28. 1:45were specifically sales and then a
  29. 1:46little bit on the the child architecture
  30. 1:49of the mobile devices so of course I
  31. 1:52didn't I didn't actually do all the
  32. 1:54porting and building and stuff myself
  33. 1:56so inside was obviously made by plated
  34. 2:00and the iOS port was worked on by by all
  35. 2:03these beautiful people so for the iOS
  36. 2:07port our target was to have the exact
  37. 2:10same game running so we didn't want to
  38. 2:11do like a mobile conversion of the game
  39. 2:14the way we achieved that was primarily
  40. 2:16are to lower the resolution a little bit
  41. 2:18and run it at 30fps rather than 60 we
  42. 2:21also did a little bit of optimization
  43. 2:23but to be honest we were kind of
  44. 2:25surprised by how fast the devices are so
  45. 2:30sort of the high-end mobile CPUs and
  46. 2:32GPUs are roughly on par with laptops
  47. 2:35which sort of service our back
  48. 2:38so one of the things that we did have to
  49. 2:42do was to cut one gigabyte
  50. 2:45one gig about memory devices so
  51. 2:48being a console game and not wanting to
  52. 2:52cut any content we did have to use quite
  53. 2:56a lot of memory and the devices
  54. 2:58unfortunately there's no way to actually
  55. 3:00filter for that in the App Store's of
  56. 3:02what we ended up doing was making the
  57. 3:05initial part of the game a trial and
  58. 3:06then have this upsell point with in-app
  59. 3:09purchases that way people could they
  60. 3:13could still download the game and then
  61. 3:14as they had downloaded the game we could
  62. 3:15check how much memory was available on
  63. 3:17the device and then we could either run
  64. 3:19the full game or we could run this
  65. 3:21beautiful trial screen oh sorry not
  66. 3:24trial screen but sort of we're really
  67. 3:26sorry we we can't run on your device
  68. 3:28screen and and hopefully people would be
  69. 3:30less unhappy with that they of course
  70. 3:34still disappointed but at least they
  71. 3:35didn't pay for all the disappointment so
  72. 3:39as we started thinking about the the
  73. 3:41mobile port we were just finished with
  74. 3:45our the the the main releases the
  75. 3:47console releases so those weren't really
  76. 3:50ports we just sort of had PlayStation
  77. 3:52and Xbox running alongside PC for at
  78. 3:54least the last couple years of
  79. 3:56production to make sure that that the
  80. 3:59work we were doing actually worked
  81. 4:00everywhere so after releasing those we
  82. 4:04did we some patched up those releases
  83. 4:06and then we started upgrading so we're
  84. 4:07running unity and we started upgrading
  85. 4:09unity from the the custom 5.0 that we
  86. 4:12released consoles on through 5.6 so so
  87. 4:18that was this was sort of an initial
  88. 4:20upgrade of unity we we do have source
  89. 4:23code for unity so we had made some
  90. 4:24changes of course we had to sort of move
  91. 4:27those over as well we removed some of
  92. 4:29the updates like the multi-threaded
  93. 4:32renderer are seeing as that was actually
  94. 4:34integrated oh rather unity had done it
  95. 4:36themselves since then so there was no
  96. 4:38use for that but there's a bit of work
  97. 4:40for that as well
  98. 4:41we then did an initial iOS port just to
  99. 4:45make sure that it actually ran and to
  100. 4:48sort of gauge how much work was we
  101. 4:52needed to how much work we needed to do
  102. 4:54to actually get that that running so our
  103. 4:56initial our initial impression
  104. 5:01no the like as soon as we had actually
  105. 5:03made that port we see that it was
  106. 5:04running quite a bit beyond expectation
  107. 5:06we thought we had to do a lot of work
  108. 5:09and it was running everything was broken
  109. 5:11and it didn't look right at all but we
  110. 5:15could play through the game and it was
  111. 5:16hitting around 30 FPS so we were pretty
  112. 5:19confident that we could actually make
  113. 5:21that work within a reasonable amount of
  114. 5:23time and that was the better part of a
  115. 5:26year of bug fixing bugs from the you to
  116. 5:30upgrade the box from shaders they were
  117. 5:33being very specific about what they were
  118. 5:34doing on the platforms that they were on
  119. 5:38some relating to to unity as well sorry
  120. 5:42to iOS as well the majority of box we
  121. 5:46encountered I have to say was from
  122. 5:48upgrading immunity in part because we
  123. 5:51were doing things that were way too
  124. 5:53specific and in part because unity sort
  125. 5:57of updated some things as they should
  126. 5:59and optimize things but we were just
  127. 6:00being very specific on on the the use of
  128. 6:04of unity at the time of course alongside
  129. 6:09this we were doing external actual game
  130. 6:12work integrating with the App Store one
  131. 6:15came censor for achievements actually
  132. 6:17doing the touch interface for for the
  133. 6:20game and and that sort of thing all
  134. 6:23right some was we told a little bit
  135. 6:25about profiling because that was a big
  136. 6:28part of the reporting as well so we
  137. 6:33actually did a presentation at unite
  138. 6:35last year and if you're interested in
  139. 6:36sort of way more detail then I should go
  140. 6:39watch that one some on YouTube from you
  141. 6:42know I think I said that all right
  142. 6:45so initially when we moved to a new
  143. 6:47platform the first thing we need to know
  144. 6:49and sort of the easiest things know is
  145. 6:50what's the actual performance that we
  146. 6:52have on the device so we can sort of
  147. 6:54know how much do we need to to optimize
  148. 7:00to actually get device running second
  149. 7:02thing then when we know that the
  150. 7:03performance is bad which is usually the
  151. 7:05case we then need to know what are the
  152. 7:07actual bottlenecks and what causes sort
  153. 7:10of specific issues and then when we
  154. 7:12optimized this
  155. 7:15specific area then we need to know if it
  156. 7:16was actually faster than the ending that
  157. 7:18we just changed stuff and it didn't
  158. 7:20change anything so what we do is this on
  159. 7:24the top we have the full inside game as
  160. 7:27its laid out and at the bottom you can
  161. 7:29see the performance at any point in the
  162. 7:32game our cream is of course fast enough
  163. 7:34which is usually below 60 milliseconds
  164. 7:37and orange and red if it's if it's
  165. 7:39really bad so left to write the full
  166. 7:42game let's try the for gaming in
  167. 7:44profiling underneath so the way we
  168. 7:45generate this is we use qele qele is our
  169. 7:48QA guy we record every playthrough he
  170. 7:52does and then we can play that back on
  171. 7:55automate it on devices so yeah so what
  172. 8:02does is record everything that he does
  173. 8:05and then we play that back and then we
  174. 8:07do profiling on these runs we can do
  175. 8:10that sort of every night it's it's
  176. 8:12pretty easy so we can sort of get a
  177. 8:14history of of performance over time we
  178. 8:18can also do if we receive a new piece of
  179. 8:22hardware we can just run this I mean if
  180. 8:24that completes we're sort of pretty sure
  181. 8:26that it works
  182. 8:28of course it catches crashes and that's
  183. 8:31all thing as well so what we get out of
  184. 8:33that is as you can see at the top we
  185. 8:36have this very small history I think
  186. 8:39that we can click and then click through
  187. 8:41all the dates that we have captures from
  188. 8:44and we have all the usual unity
  189. 8:47profiling stats so CPU time all the
  190. 8:51renderings tests memory and then for
  191. 8:54every point in the game we also have
  192. 8:56full call stack with instrumented
  193. 8:58profiling of that and then at the bottom
  194. 9:00of screenshots we actually know which
  195. 9:02part of the game we are we're currently
  196. 9:03looking at we also get this present we
  197. 9:10also do this presentation which again is
  198. 9:12all the other statistics along with the
  199. 9:18GPU time what we call class time which
  200. 9:21is how long did a frame actually reside
  201. 9:24on the screen so we can see if we missed
  202. 9:28a frame or not so the the bread spikes
  203. 9:30in the third row are our mists frames
  204. 9:35where we actually dropped frames then we
  205. 9:39have the full memory and the in the
  206. 9:41middle and then below we can see what
  207. 9:43content sort of streaming details what
  208. 9:45contents actually are loaded in at any
  209. 9:47point um and below are audio events and
  210. 9:51that's all thing alright so that gives
  211. 9:55us a pretty good overview of the
  212. 9:58performance in the game so we can kind
  213. 10:00of dive into specific areas and figuring
  214. 10:01out why they're slow so one thing to
  215. 10:04note is that these are not primarily
  216. 10:07gaming devices they are made for I
  217. 10:10suppose primarily for other things
  218. 10:13including Facebook and cute kittens and
  219. 10:16that sort of thing so quite often when
  220. 10:19you're profiling you will get
  221. 10:20interrupted by our background services
  222. 10:23that we'll do other things so of course
  223. 10:27this makes perfect sense for mobile our
  224. 10:29platform and it's not something we can
  225. 10:31actually change out in the wild but
  226. 10:33while profiling it makes sense to sort
  227. 10:35of clean the device of everything and
  228. 10:38turn off Wi-Fi and mobile dates and all
  229. 10:41those things so we actually have sort of
  230. 10:44less noise while profiling so the the
  231. 10:48second thing that's interesting is that
  232. 10:50it's of course if the the device will of
  233. 10:56course our throttle the the CPU our
  234. 10:58primary for two reasons one is if it
  235. 11:01gets too warm it will will reduce the
  236. 11:03speed to cool down and the second is
  237. 11:06that it will second thing is that it
  238. 11:08will do so just to save battery so it's
  239. 11:11trying to run at the lowest clock
  240. 11:12frequency that I can so an interesting
  241. 11:15thing that happened was that our
  242. 11:17external our QA our company called EMC
  243. 11:20they came back to playing that the
  244. 11:22devices were getting uncomfortably hot
  245. 11:23regions of course what we did as all
  246. 11:26good engineers is that we went out in
  247. 11:27port and industrial great thermometer
  248. 11:29freaked out was uncomfortably hot meant
  249. 11:31and so that's actually quite cool so
  250. 11:36it's around four degrees that you start
  251. 11:38so sort of stop sweating and feeling
  252. 11:40like okay maybe my
  253. 11:42phone won't actually survive this and a
  254. 11:44curious consequence of that is that we
  255. 11:46actually have to target the game not at
  256. 11:48device spec but at human spec which is
  257. 11:51so much lower so as an example the
  258. 11:54iPhone X we can actually run that at
  259. 11:57sixth of the entire game at 60fps
  260. 11:58without any problem but it gets really
  261. 12:01warm and and yeah we decided to run it
  262. 12:07at thirty instead and then have a cool
  263. 12:08device that people were happy with and
  264. 12:10not feeling like we were breaking their
  265. 12:12their phone although it's it's quite
  266. 12:14fine surrounded hada so we get into this
  267. 12:18scenario where we we sort of want to hit
  268. 12:22like a middle section when when
  269. 12:26profiling so we want to not have the
  270. 12:29device too warm so that it's that's
  271. 12:32thermal throttling we also don't want to
  272. 12:34run it at too low a workload so that it
  273. 12:38starts battery saving sort of different
  274. 12:42approaches apparently Carmack has a
  275. 12:45fridge next to his desks that he puts
  276. 12:48the phones in we had a guy from Apple
  277. 12:50who just sort of took the phone and put
  278. 12:52him in a bowl of water because it was
  279. 12:54certified for that so that should be
  280. 12:56fine I won't recommend either of those
  281. 12:58um primarily though because I don't
  282. 13:00actually think that that area is really
  283. 13:04there I suppose like the device will
  284. 13:07always try to battery safe it will
  285. 13:09always try to run it the lowest possible
  286. 13:10frequency so the the CPU frequency will
  287. 13:14will always vary and implication of this
  288. 13:17of course is that sorry so an
  289. 13:25implication of this of course is that if
  290. 13:27you optimize something to make it twice
  291. 13:30as fast then you may not actually see
  292. 13:32that on the that the profile times maybe
  293. 13:37it just reduces the CPU speed so we kind
  294. 13:41of need to know what the CPU speed is is
  295. 13:43so we did this or in-game overlay where
  296. 13:48we can see the CPU speed along with all
  297. 13:51the other metrics that we had before as
  298. 13:53well and the way we do that
  299. 13:55is that we at startup we try to reserve
  300. 14:01assuming that device is not overheating
  301. 14:03then we run the some workload we run
  302. 14:07that a lot of times so that we are
  303. 14:10pretty sure that the frequency is as at
  304. 14:13its maximum and then we time that a
  305. 14:16couple of times and then we figure out
  306. 14:17what the eff absolute fastest execution
  307. 14:22execution speed was for that void load
  308. 14:24that way we think that we have the the
  309. 14:27fastest that this device can possibly
  310. 14:29run and then at one time while we're
  311. 14:31profiling we then run the same workload
  312. 14:33though a lot fewer times and then again
  313. 14:36pick the best of those and then we think
  314. 14:39that we have a an estimate for the
  315. 14:42current speed and then by comparing to
  316. 14:44the fastest speed we can then figure out
  317. 14:46what the CPU current CPU speed is
  318. 14:49roughly and that seems to work pretty
  319. 14:51well so we all did that for this for the
  320. 14:55CPU it count looks like the GPU is doing
  321. 14:57something similar this is running at
  322. 14:5930fps I think and now we can kind of see
  323. 15:01these sort of waves on the GPU that kind
  324. 15:04of indicate that it may be over quite a
  325. 15:09long time actually turning this U or GPU
  326. 15:12speed up and down as well um this is
  327. 15:14something that's also affecting us when
  328. 15:16we're doing profiling even in in Xcode
  329. 15:20but just apples are tool to to do
  330. 15:25profiling so on the left and on the
  331. 15:28right are you have ten different samples
  332. 15:32in Xcode where we have a full frame of
  333. 15:35insight and we are trying to profile our
  334. 15:38the how fast a single drawn call this
  335. 15:42and it's around 1 and 1/2 milliseconds
  336. 15:43on the left and but the variance of that
  337. 15:46is around half a millisecond so that's
  338. 15:48that's quite a long time so in on the
  339. 15:51right we then try to optimize that by
  340. 15:53removing half the math that's in the
  341. 15:55shader and we didn't see statistically
  342. 15:57that it's faster but unfortunately sort
  343. 16:01of a single sample is not enough so the
  344. 16:04you know like the fast iteration of
  345. 16:05changing source code within Xcode
  346. 16:08and then recompiling is a bit hard to to
  347. 16:13get functional so for bigger things what
  348. 16:16we did was that we actually looked at
  349. 16:18the full
  350. 16:19GPU capture of the entire game so we we
  351. 16:23captured the whole thing and then we
  352. 16:24kind of visually inspects it one versus
  353. 16:26the other and I'll get back to this a
  354. 16:28little bit so I suppose the takeaway
  355. 16:33from this is that it was actually pretty
  356. 16:35hard to get sort of concrete performance
  357. 16:37metrics if you're wise and CPU wise as
  358. 16:41well the device that we found that was
  359. 16:43the most stable was the new Apple TV has
  360. 16:46an active crew on it so at least dozen
  361. 16:49thermal throttles recently was very
  362. 16:52handy for us to know the CPU scaling was
  363. 16:54a lot of things that we we sort of
  364. 16:55fiddled were unable to find otherwise
  365. 17:00and of course these tools that would get
  366. 17:04us the performance and the entire game
  367. 17:06was were very helpful all right so one
  368. 17:10thing that we did actually found that we
  369. 17:12could see you next coat is that every
  370. 17:15time you load a shader on the the shader
  371. 17:21will get recompile through what's called
  372. 17:22or actually that that is that's not true
  373. 17:26so the first time you load a shader it
  374. 17:28will get recompile to what's called
  375. 17:30metal on its rigid representation and
  376. 17:32then all subsequent are notes of the
  377. 17:35game will just use all the cash from the
  378. 17:37first load but then as you draw
  379. 17:40something with that shader the first
  380. 17:42time it will then patch up and recompile
  381. 17:45the shader and Swedish representation to
  382. 17:48match the blend state and render target
  383. 17:51States and verse six formats for that so
  384. 17:56that would generate a stall sort of
  385. 17:59throughout the game the first time we
  386. 18:00were using every shader so of course we
  387. 18:02did as has been done for a number of
  388. 18:05years we warmed up all the shaders for
  389. 18:08that
  390. 18:08so we first needed to gather all the
  391. 18:12different variants of every shader that
  392. 18:13was used throughout the entire game so
  393. 18:15we did that in in playthroughs before
  394. 18:18actually doing the build and then
  395. 18:21collecting those for the warm up and
  396. 18:24then rendering triangles and with no an
  397. 18:29off-screen render target and rendering
  398. 18:31triangles with all the variants of
  399. 18:32shaders to sort of show the the driver
  400. 18:35and all the variants of all the shaders
  401. 18:37that we we would come about um of course
  402. 18:40meant that we added some time to the the
  403. 18:42initial load time which was quite long
  404. 18:45on the first load one of the reasons was
  405. 18:47that the driver was converting from the
  406. 18:50mesosphere language into this
  407. 18:51intermediate representation fortunately
  408. 18:53you can generate that yourself so we
  409. 18:57ended up storing that on disk instead
  410. 18:59then loading that doing the warm-up and
  411. 19:02then we we didn't get any any sort of
  412. 19:05stalls during the game at least we only
  413. 19:08had this this overhead of initial or
  414. 19:11warm-up right so also a little bit of
  415. 19:15our about finding our visual errors are
  416. 19:18quite often that this is where porting
  417. 19:23work starts so idea box will represent
  418. 19:26themselves as performance issues or as
  419. 19:29visual books or both so what we do for
  420. 19:33that is that we have a an ulcerated
  421. 19:35screegit tool as well it takes a callus
  422. 19:38our proof Kelly's playthrough and then
  423. 19:41every couple meters it will note that
  424. 19:43and then do a screenshot dumb that's
  425. 19:45disk and then load a new place so that
  426. 19:47gives us the option of comparing between
  427. 19:53any you know any platform we can compare
  428. 19:56that to a platform that we think is
  429. 20:01correct so that's not actually that that
  430. 20:07easier thing to do so we have these two
  431. 20:09images we want to know what what the
  432. 20:10difference between them is so what we
  433. 20:12ended up doing on console was we kind of
  434. 20:14sort of loaded one and then flipped to
  435. 20:16the other one sort of went back and
  436. 20:18forth a couple times and we sort of see
  437. 20:20that this student the right that's
  438. 20:22disappearing of course with a full
  439. 20:25playthrough then ends up with a lot of
  440. 20:28time spent just comparing these things
  441. 20:31we kind of wanted to automate that as
  442. 20:32well
  443. 20:33the problem is that the game is only
  444. 20:35almost deterministic so we have some
  445. 20:38animation and Pascal's and even some
  446. 20:41characters in the game that are
  447. 20:43generated depending on the time that the
  448. 20:46game started so it's not it's not sort
  449. 20:51of fully deterministic so we kind of
  450. 20:52have to to handle that so what we do is
  451. 20:58that we have a set of reference images
  452. 21:00so for every pixel we have all the
  453. 21:02values that pixel can can be in in our
  454. 21:06reference images we then generate a
  455. 21:08bounding box around those and then that
  456. 21:11sort of gives us this was most inverse
  457. 21:15confidence map that will tell us which
  458. 21:17areas of the image will of this location
  459. 21:21will typically change the most when we
  460. 21:25then want to test our new platform we
  461. 21:27can then compare that to to these
  462. 21:29reference images we can do that by just
  463. 21:31calculating this through the bounding
  464. 21:33box of all these reference images that
  465. 21:37gives us a an error that looks like this
  466. 21:39where we can see the dude on the right
  467. 21:41is what's missing or there was those
  468. 21:43arrows there that's also quite a bit of
  469. 21:46noise in that image which we've spent a
  470. 21:49lot of time introducing inside they're
  471. 21:52not really conductive to actually
  472. 21:54finding the error so what we do is we
  473. 21:56medium Phillip and then we sort of sum
  474. 21:58the top ten errors in pixels and then
  475. 22:03then you set as the error of the image
  476. 22:06from the image it's one thing that the
  477. 22:09confidence map doesn't handle is sort of
  478. 22:13very large scale changes so as you can
  479. 22:16see here the the leaves are moving and
  480. 22:20that's kind of fine but we have all
  481. 22:21these dots which are particles are sort
  482. 22:24of moving around the image um so rather
  483. 22:26than have an infinite number of
  484. 22:29reference reference images and then
  485. 22:31ending up with dots everywhere and just
  486. 22:33all white which would mean that we
  487. 22:35couldn't actually check anything what we
  488. 22:36do is that we have an additional
  489. 22:39reference image we then compare that to
  490. 22:41the other reference images to sort of
  491. 22:43get a usual error in a specific spot so
  492. 22:46these particles will all have like a
  493. 22:50base error and we need to know that to
  494. 22:52compare a different platform to those
  495. 22:55alright so what we get from that then is
  496. 22:58it's it spits out a HTML page are sorted
  497. 23:03by error where we can see the error
  498. 23:06image and a reference image and the test
  499. 23:09image and then we can kind of open those
  500. 23:12in two different tabs and then go back
  501. 23:13and forth so that doesn't seem like much
  502. 23:15progress but at least now the salsa let
  503. 23:17me know which images to look at and it's
  504. 23:20it's far less than the 1,300 errors that
  505. 23:24that we had initially all right so of
  506. 23:27course there's some things it doesn't
  507. 23:29handle unfortunately there's some things
  508. 23:30it doesn't handle so for example if we
  509. 23:32have our figuring like light like this
  510. 23:35then the all the pixels within that
  511. 23:38light can essentially assume any R or
  512. 23:41any color or any intensity at least so
  513. 23:44it becomes pretty hard to actually go
  514. 23:46and find our errors within that region
  515. 23:48because any pixel value is valid all
  516. 23:55right so I'll talk a little bit about
  517. 23:56rendering because I can and you all
  518. 23:58y'all here so most of the optimization
  519. 24:02we did on the GPU side are not overly
  520. 24:06interesting sort of grunt grunt work
  521. 24:09optimization the one thing that that
  522. 24:12might be a bit interesting is that the
  523. 24:15mobile platforms it's health
  524. 24:17architecture I'm not going to go too
  525. 24:20much into that and what that means I'll
  526. 24:22just talk about what that meant for
  527. 24:24force with inside so primarily it meant
  528. 24:26that we had to switch render pass render
  529. 24:29targets less weight needed fewer render
  530. 24:32passes so switching render targets less
  531. 24:34often and then it's also required that
  532. 24:37for the tile you actually manage which
  533. 24:41basically and out of that tile issues
  534. 24:45which render targets so this is what our
  535. 24:48console pipeline look like the graphics
  536. 24:51pipeline so the first thing that we
  537. 24:53notice is that our the shadow maps and
  538. 24:56the lights are interleaved
  539. 24:58we did that so we only needed a single
  540. 25:00shadow map and with that then rendered
  541. 25:02slit render the light with that shadow
  542. 25:04map and and so on so forth so of course
  543. 25:07that then flushes the full light buffer
  544. 25:10in and out of tiles
  545. 25:13so instead pre-rendering the shadow maps
  546. 25:17that means that we yeah that we don't
  547. 25:21need to do that I'll be able to see that
  548. 25:22and the light buffers face our resident
  549. 25:26on tile our second thing of course is
  550. 25:28the cream volumetric pre-rendering
  551. 25:30that's also sort of wedged in between
  552. 25:33the final pass and the Seleucids pass
  553. 25:35both of them accessing the the back
  554. 25:37buffer so again just moving that before
  555. 25:39the final pass then means that the back
  556. 25:42buffer can stay rested them just during
  557. 25:44the final and translucency passes then
  558. 25:48of course there's the post effects that
  559. 25:50then change Brent the target 21 times
  560. 25:52because we're doing this bloom filter
  561. 25:54that's generating a mid map pyramid so
  562. 25:59fortunately those render targets are
  563. 26:02pretty small so bent with ysus it's not
  564. 26:04that bad there is an overhead on the
  565. 26:08driver side of route 2 and 1/2
  566. 26:10milliseconds on the on the CPU that
  567. 26:13would go away if we converted all the
  568. 26:15post effects passes to computer instead
  569. 26:18which which we probably should but there
  570. 26:22was nowhere to be overhead that we could
  571. 26:24see all right so the second thing sorry
  572. 26:32the second thing we needed to do was to
  573. 26:34actually set up all the what's called
  574. 26:36all the the loads and stalls for the the
  575. 26:42tile for every so we set it up on render
  576. 26:45parcels and we do that so that you sort
  577. 26:51of manually can control which what
  578. 26:54places like whether or not you actually
  579. 26:55need to load the data from a render
  580. 26:57target or and if you if you mainly set
  581. 26:59up whether you are you change it as you
  582. 27:02write it out to the whether you need to
  583. 27:04write it out to the render target
  584. 27:05afterwards as well um so yeah so
  585. 27:11so I suppose it's pretty obvious in a
  586. 27:17way so the lights all guess we'll start
  587. 27:21from start so the base pass generates a
  588. 27:23depth buffer and then the light pass
  589. 27:25will then render lights and check
  590. 27:27against that depth buffer so of course
  591. 27:29it doesn't actually modify the depth
  592. 27:31buffer just reads the data and checks
  593. 27:34like geometry against that and then
  594. 27:35writes to the Lightning buffer so
  595. 27:37there's no really no need to to write
  596. 27:40the depth buffer out again which it sort
  597. 27:42of would by by default same thing goes
  598. 27:45for the final pass and the transit pass
  599. 27:48they all just read from the depth buffer
  600. 27:50and do depth comparison but there are
  601. 27:51not actually modifying the depth buffer
  602. 27:53so again no need to write those out so
  603. 28:00uh the way actually check all these
  604. 28:03things is that you look in Xcode it has
  605. 28:05stats for that where you can see it's
  606. 28:07good things to sort of go go through all
  607. 28:09your render passes to see whether
  608. 28:11they're doing what you expect them to do
  609. 28:13if it's necessary to do all the loads
  610. 28:15and stores that are that they do you can
  611. 28:21also see all the load and stop and with
  612. 28:23and and look at that so after doing all
  613. 28:26the reshuffling of the passes and the
  614. 28:29low slow optimization we sort of have
  615. 28:31the load bandwidth and not quite half
  616. 28:35this the store bandwidth so what I say
  617. 28:38that actually means for the game well
  618. 28:40that means that we cannot get this this
  619. 28:43graph from the entire game which is sort
  620. 28:45of this is how we we sort of inspect the
  621. 28:48things we looked at in when like well
  622. 28:50this this parts kind of better on this
  623. 28:51back part is is worse um so all in all
  624. 28:55it looked better so fortunately my
  625. 28:57flight here was delayed so I had time to
  626. 28:59actually run some stats on it and we see
  627. 29:03that it did actually are sort of
  628. 29:06significantly improve or significant a
  629. 29:08couple of milliseconds
  630. 29:09around a couple milliseconds improvement
  631. 29:11and doing this work it's not too much
  632. 29:13work either so I say that that pays off
  633. 29:17okay
  634. 29:18so for one one interesting thing about
  635. 29:22releasing on mobile
  636. 29:24releasing a console game on mobile is
  637. 29:26that now your game is being played
  638. 29:28everywhere like rather than only on
  639. 29:31televisions it's actually being played
  640. 29:32in a bus or outside or elsewhere so one
  641. 29:37thing that we did was that we chose to
  642. 29:40brighten the entire game it's quite a
  643. 29:42dark game to begin with so we chose
  644. 29:46through to brighten entire thing up and
  645. 29:48we did that for a couple reasons like
  646. 29:50one was so the people could actually
  647. 29:52play it so that they could get the game
  648. 29:54bright enough to see what was going on
  649. 29:56then secondarily of course if you if you
  650. 30:00brighten the game then you don't have to
  651. 30:01increase the backlight brightness as
  652. 30:04much so you're also saving battery and
  653. 30:06finally because you're not increasing
  654. 30:08the backlight brightness as much then
  655. 30:11it's not generating as much heat so you
  656. 30:14then get better performance so it kind
  657. 30:17of makes sense to look at that in sort
  658. 30:19of a separate separate way and the way
  659. 30:21we the sort of the function we use to do
  660. 30:23that is the same that we used for
  661. 30:25in-game brightness which is just
  662. 30:29multiplying up the the color values and
  663. 30:31then doing this soft minimum with one
  664. 30:34which which has worked quite well for us
  665. 30:38then of course in the end we then just
  666. 30:40fit the final function with a polynomial
  667. 30:42polynomial so that it's it's as fast as
  668. 30:45we can sort of get it all right I'll
  669. 30:48talk a little bit about a an issue we
  670. 30:50had on the ship game which was this it
  671. 30:54was one of the few things that we didn't
  672. 30:57manage to fix for console hmm so yeah so
  673. 31:04this the struct side is obviously our
  674. 31:06aliasing horribly you see on the right
  675. 31:08that the temple and say guessing that we
  676. 31:10usually didn't fix that at all
  677. 31:12the reason for the the problem of course
  678. 31:17is under sampling and we're using
  679. 31:20uniform samples across we do
  680. 31:25rasterization so we're getting uniform
  681. 31:27samples of the truck side as well
  682. 31:35rasterizing host when we're doing the
  683. 31:37temporal anti-aliasing
  684. 31:38still use uniform samples we just get a
  685. 31:40lot of them which causes the temporal
  686. 31:45anti-aliasing to then not pick anything
  687. 31:48from the history buffer the reason why
  688. 31:51does this is that our temple
  689. 31:53anti-aliasing solutions solution uses
  690. 31:56this local neighborhood color clamping
  691. 31:59so it looks every pixel looks at its
  692. 32:01neighborhood and all values that are
  693. 32:03present in the neighborhood accepts it
  694. 32:08from from the history buffer of course
  695. 32:11if you look at on the left the pattern
  696. 32:13that's generally about the seventh
  697. 32:14assembling is quite wide so the local
  698. 32:17pixel neighborhood becomes almost
  699. 32:20uniform in color which means that we are
  700. 32:23not actually accepting anything from the
  701. 32:25history profile we just end up with with
  702. 32:27this under sampling these on the
  703. 32:30sampling artifacts so if we turn off the
  704. 32:32neighborhood clamping as in the middle
  705. 32:35then we can see that right it converges
  706. 32:37nicely but of course then if we start
  707. 32:40moving the picture around we get
  708. 32:42terrible ghosting so our solution to
  709. 32:45this of course then is to kill the
  710. 32:47sampling unfortunately that's not
  711. 32:49something that we can do with with
  712. 32:53breast isolation and the fixed-function
  713. 32:55rasterization so what we did then was to
  714. 33:00choose through rate race the truck side
  715. 33:03instead and sort of patch that up and
  716. 33:05render it afterwards that way we can
  717. 33:08always manually choose the array offset
  718. 33:12within a pixel and then and that that
  719. 33:16way did of the the samples that we do so
  720. 33:21I should mention that that we just like
  721. 33:24this is not integrated in the pipeline
  722. 33:26as such we're just regular rendering it
  723. 33:28afterwards and sort of manually putting
  724. 33:31all lights and decals and anything else
  725. 33:33that interacts with the truck side
  726. 33:35within the shader so it's it's not
  727. 33:37really a the most prettiest solution so
  728. 33:42in order to do this we manually modeled
  729. 33:47are the side of the truck
  730. 33:52the procedural planes so we first figure
  731. 33:56out what a groove
  732. 33:58we're in along the the truck side and
  733. 34:00then as we know that we the the t0 like
  734. 34:05the first intersection we can just get
  735. 34:06from the position on the truck side and
  736. 34:08then we can calculate the intersection
  737. 34:11with the bottom plane just by the ankle
  738. 34:14of the of the Ray that we we send out
  739. 34:20then we do for intersection with the
  740. 34:22sides of the grooves of the truck and
  741. 34:25then we can then figure out where we are
  742. 34:28hitting it so that results in something
  743. 34:32like this so in the middle you have the
  744. 34:34jittered version where we are ray
  745. 34:36tracing we're using the the procedural
  746. 34:38geometry for the truck side and then on
  747. 34:41the right as we're applying a simple
  748. 34:42anti-aliasing to that every pixel in its
  749. 34:46pixel neighborhood will see quite a lot
  750. 34:48of variance and then it will accept
  751. 34:51values again from the from the history
  752. 34:54buffer
  753. 34:55so one thing we noticed was that it
  754. 34:58wasn't actually aliasing in the
  755. 35:00y-direction so we could get away with
  756. 35:02only sort of multi sampling or
  757. 35:04horizontally so other than chittering
  758. 35:06we're also doing four samples to a sort
  759. 35:10of decrease our cost sorry to decrease
  760. 35:15our idea seing as much as possible but
  761. 35:19only horizontally then of course we
  762. 35:22don't need to calculate everything per
  763. 35:23sample so some of the things we are
  764. 35:25evaluating are ones like the projected
  765. 35:28light textures we are only evaluating
  766. 35:31those at the surface and then we're just
  767. 35:34reusing those between samples so one
  768. 35:38thing to note of course is that we
  769. 35:40didn't actually have to do all this
  770. 35:43through ray tracing we could have just
  771. 35:45used some text-based displacement method
  772. 35:48instead we just do this as we figured it
  773. 35:53was faster rather than doing sort of
  774. 35:55cheated samples in the displacement
  775. 35:58section many samples and it also turned
  776. 36:01out to be pretty fast we didn't actually
  777. 36:02implement a text-based version
  778. 36:05honestly can't say whether it was faster
  779. 36:07but it was fast enough for our use right
  780. 36:11so yeah it's only I suppose what are our
  781. 36:15main takeaways I guess was that this
  782. 36:20these are actually platforms that can
  783. 36:21run for quality console games we were
  784. 36:24kind of surprised by the speed of these
  785. 36:28these devices the the second thing thing
  786. 36:33is that it is really hard to actually
  787. 36:36profile on them and it it takes quite a
  788. 36:39lot of effort and it's been a great
  789. 36:41benefit for us to have the tools that
  790. 36:44were used also for consoles to sort of
  791. 36:48al-qaida's in the profiling for these
  792. 36:50platforms as well
  793. 36:51we found we used the screenshot or
  794. 36:54comparison tool quite a lot and actually
  795. 36:56making sure that all devices looked
  796. 36:58correct we would sort of do playthroughs
  797. 37:00and look at the game and look compared
  798. 37:03to console versions and say yeah like it
  799. 37:06looks looks about right and then we run
  800. 37:09a screenshot so and we would have like
  801. 37:1020 bucks that we didn't visually notice
  802. 37:14and of course the the tiles are
  803. 37:17rendering optimizations reasonably easy
  804. 37:21to approach so I think makes sense to
  805. 37:25spend time doing that I'd like to thank
  806. 37:29all these people who helped us out with
  807. 37:31the port and thanks to you guys for
  808. 37:34listening I hope some of this was a well
  809. 37:37made sense and maybe even some of it was
  810. 37:40interesting um if at any point during
  811. 37:43this presentation you thought I can do
  812. 37:45that better please do and yeah a lot
  813. 37:52more for questions if you have it thank
  814. 37:54you
  815. 37:55[Applause]
  816. 37:59so please come enough some questions -
  817. 38:03Myka McHale hi thank thanks you guys
  818. 38:16thanks for a great presentation
  819. 38:18did you actually test the optimizations
  820. 38:22and modifications you did back on
  821. 38:24consoles and other platforms so do these
  822. 38:27optimizations only work for iOS do they
  823. 38:30hurt the other platforms so we have no
  824. 38:34we haven't
  825. 38:34back ported are those so most of the
  826. 38:40optimizations that we did like all the
  827. 38:41grunt work that applies to all all the
  828. 38:44platforms pretty much we didn't test the
  829. 38:47child optimizations and I like the Xbox
  830. 38:50has also has like a all the embedded RAM
  831. 38:55that you're rendering - so there might
  832. 38:57be advantages and doing similar things
  833. 39:00there okay thank you
  834. 39:02suppose the difference there is that you
  835. 39:04can actually do it asynchronously like
  836. 39:06flush the yes ran back and forth yeah of
  837. 39:08course you need a little bit more memory
  838. 39:10for the shadow Maps and so mother yeah
  839. 39:12yeah okay thank you goes anything else
  840. 39:18yeah hi thank you for the talk so I have
  841. 39:28question about testing by Kyle so you
  842. 39:31how did you record it and then play it
  843. 39:34again on different devices and how did
  844. 39:38you set up all the devices you needed to
  845. 39:41play through tonight and then get
  846. 39:43results so yeah so so two things I
  847. 39:53suppose like the first is we we just
  848. 39:56record input and we also record position
  849. 39:59so we we play back the input are that at
  850. 40:03Kelly makes and then if we if he gets if
  851. 40:07it gets too far from
  852. 40:09the location that we recorded which over
  853. 40:11teleport the main character back to
  854. 40:12there so we're sure that it doesn't get
  855. 40:14too far off sync um even so for iOS we
  856. 40:19didn't actually do the automated
  857. 40:20playback at night we did that for all
  858. 40:22four consoles we did that manually we
  859. 40:25just start that manually on devices for
  860. 40:31testing or rather we had Kelly do it so
  861. 40:40when you are profiling on mobile devices
  862. 40:42have you had any performance drop downs
  863. 40:45just because you are profiling because
  864. 40:47you have to run development build some
  865. 40:49debug information all the statistics and
  866. 40:52screenshots it sounds like it will take
  867. 40:55quite a bit of CPU time we we're not
  868. 41:01seeing so I think we're streaming so
  869. 41:06it's not that much memory that we're
  870. 41:09using for just recording our CPU times
  871. 41:11and that sort of thing so I don't think
  872. 41:14our system are probably has some
  873. 41:18overhead but another thing we haven't
  874. 41:20noticed Innova it's pretty hard to
  875. 41:21actually notice that as well because we
  876. 41:23would then have to proof all that I
  877. 41:25suppose um one thing that we have
  878. 41:27noticed is that are attaching Xcode so
  879. 41:31the device makes a big difference so
  880. 41:33while we're doing these profiling is we
  881. 41:35[Music]
  882. 41:37deploy to the device then pH Xcode then
  883. 41:40run all the profiling that makes it
  884. 41:42significant difference so you never had
  885. 41:44situations like it runs just fine in
  886. 41:47release builds but runs slowly when
  887. 41:50surely so so we are so that for units it
  888. 41:55has two modes as the development mode
  889. 41:56and a master mode and we we kind of try
  890. 41:59to make the development build as like
  891. 42:01fast enough then we know that the master
  892. 42:03build is even faster so yes there's
  893. 42:06definitely difference between the final
  894. 42:08release and a development but generally
  895. 42:11what we see is that it's it's just
  896. 42:12uniformly faster mainly on the CPU side
  897. 42:16thanks
  898. 42:21[Music]
  899. 42:23hi I was wondering for the screen
  900. 42:26screenshot comparison things where did
  901. 42:30you consider or did you even try to like
  902. 42:34instead of just comparing like endframe
  903. 42:36screenshots 11-1 the full scene is
  904. 42:38composite and so on just like trying to
  905. 42:39compare intermediate render targets like
  906. 42:42gee buffers for instance they could also
  907. 42:44like reveal some some of the issues
  908. 42:46while significantly I guess
  909. 42:49significantly lowering the noise from
  910. 42:51introduced by you know further things
  911. 42:53down the render pipeline yeah would be a
  912. 42:55really good idea to also get make it
  913. 42:58easier to immediately figure out what
  914. 43:00the problem was I suppose so
  915. 43:03the advantage of this well the the the
  916. 43:06thing that this does is that it just
  917. 43:08tells us which parts of the game we
  918. 43:10should look into and I suppose what
  919. 43:12you're proposing would also help us in
  920. 43:14actually finding the error yeah yeah
  921. 43:17yeah that will be a brilliant extension
  922. 43:20to this what so what we usually do is we
  923. 43:23just figure out okay this area is broken
  924. 43:25and then we load up the game and to a an
  925. 43:29Xcode capture or something that was
  926. 43:31something simpler all right now thank
  927. 43:33you yes thanks cool um how much time do
  928. 43:44we have left we have three minutes left
  929. 43:47so yeah so let's thank you mica one more
  930. 43:51time and thank you very much I love you
  931. 43:54[Applause]

About this transcript

This page contains the full transcript of DD2018: Mikkel Gjol - Inside shipping on iOS by Digital Dragons, generated from the public captions YouTube serves with the video. The transcript has 6,762 words across 931 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.