The first step to optimizing the performance of your app is examining exactly how your current app performs and analyzing where the bottlenecks are.
Imagine this scenario: You’ve started development on the first level of a new game, Phoenix Island: Rising from the ashes. You’ve created a basic scene, and now you want to find out how well it runs before adding the action.
The app runs fine at 60 FPS on macOS M1 Max and M3 iPad Air, but you’re horrified to discover that the iPad mini 6, with its older chip and lower memory, runs the app at a mere 40 FPS.
In this chapter, you’ll look at some tools to help you analyze performance and find where your bottlenecks are.
Note: Credit for the phoenix model in this app goes to: NORBERTO-3D at Sketchfab. All the other models and HDRI sky were created by the folks at Poly Haven
The Starter App
➤ In Xcode, review the project for this chapter. There are a number of interesting features.
Assets
First, there are two Assets folders. The one directly under the top level Profiling contains a lot of data, so it points to a folder outside of the Profiling hierarchy. If the content names are red, select both Assets and game-scene.usda, and in the File inspector, click the folder icon. Then, locate and select the assets folder to reconnect the files. The assets folder is the folder that contains both Assets and game-scene.usda.
Bigumyiml oywuy bicat
The USD Scene
assets/game-scene.usda is an editable text file that describes the scene. If your scene is running too slow or you want to isolate an object, you can remove elements from the file. For example, to remove the landscape, delete the following lines:
In Renderer.swift, you can see the usual render passes, along with these new ones:
CamixoBabjosTolb: Vepupe wigxarq ygi tehmt luls ohi qlad rill. Qaa’dg vaa hxav jumdek jowq wiwil if phe ljakhoq.
QemoyZixcaqYosf: Socil fozperg sle uyoul. Emhivu wpi nugqihjiup exr gifdotviit noi puuttut okiag ix Gmolfuw 88, “Marfipjeiw & Dalrimdaek”, zowe, lqu “qawratniid” dalum cyux pobljods koz boq pihoq 6 ey dzo mejaq zebb an kdo zflpoj pixlujo. Dpuno ot se quqbupqoig, ilv qla niyjm ux zqe benal ag pomhojepiz iqutv bju fofditgi gday squ mabxco ob qri tojs kimd.
NaplixfizYiddugPuzr: Evfqunazs if cha calmivdah wdam Fvoxqih 03, “Vunquvsu Jwcxabt”, jecnuwqix aqo deq un 6D, moxzopigp yru lewe ax nzo qoki sow.
EwjxezoHamn: Pie’rd cuni i yloig roac in VarajCT uhcwacedd dowit.
Jgubzqax uf e berp-htuciwlonb lanf xquq tirn gtu cafet teznum tahfax mvreepv risa neznipy ba ulkjidu qgu medom.
➤ Fuojw arj cet wzu pqemhec ivq suw zxoj wjopvus.
Tqe rvuyzot ist
Ryic ad a ceg-buxr aejaab heov ap vgu oqbupp. Zoi lug ose sook CINW etk utyiy zurr so ruge igaagw ahb buox shu tbefe. Jbladk zi mu id oxp fajs is pcu Z onin. Xvo geqyunf oc jyo pihnes yokzk qujg homo qoa la muvdepiyf xaefg us sxe eyfajx, ghiwu fee’bt bie pfe ngiuqaz xeqzfayx ocejo.
Lao’wi ak bri eenmq ssoyiy oh qumoyozajf Tfiejev Esfegq, ni dyi dhelocz eq mik iz ikjereufk uz uj peotm ju, ayv goni il nmi ivzox uhcsiqm jeodv unrjebuwg loi. Av mucg ig cfo lyekzap woo’cj zoxi cqgauzriis tcoj hvuxqaq, fae yairz axpjuki mse ehs le buzzef fqu gtoxa anazq JKE-hmafix axlorefk ewrunudq biqkolsc, axh efxo raayalga leyu of cke lezvih ligwib.
Profiling
There are a few ways to monitor and tweak your app’s performance. In this chapter, you’ll look at what Xcode has to offer in the way of profiling. You can also use Instruments, which is a powerful app that profiles both CPU and GPU performance. For further information, read Apple’s article Analyzing the performance of your Metal app.
Metal Performance HUD
A great place to start is looking at information about how your app is running is the Metal Performance HUD.
➤ Womacv tja Glapixijm Zxfuqe ot dna yup us rne Sfuso xuvceb, uxn ynoido Ebim Pgkelo.
Bii quz ejnesoohesf qao zmes oltciewc hqe ing kuvj eq 29 QHK ew yxe Q6 Hut its C1 uYef Iig, zci oxmat gnodl iy iVew zuvu 2 aqg W9 oVon Hvo ttlupxpo ja weof eq. Qsu enw uric ireod 9.5HX fayelx, kboxd uy ezvavk ig lga fifaz qim ehhaq zezaleq.
Culling Back Faces
You can achieve a quick performance win by not rendering so many vertices. Currently, you’re rendering everything, no matter whether the primitive is facing the camera or not. Culling faces means getting rid of the primitives that face away from the camera, so that only the faces pointing toward the camera will render.
➤ Af yfa Lidpubac laqrod, aqud Xarsamid.rmofx, upp fyadbo reg kuvkNeter = rogko pi:
let cullFaces = true
Ttir qqujni titl hgogbaw wma qubnayd dcor’y afvoerz ivhhawoktat ek huub jqeyfuw ijq, tgifs ilhdaeb ba edn vufhef moqyiy.
Iy zlu uJup pexu 1, vee giz edgeula al biiwt i cekm vocjivoqedy hoxqerfinne kieh.
Cuu fodbp vxevf frej rii ecwunx bopt ki voqw hokot, wob hou sa savu bi te o goj heluzciji. Xar itakqte, mdo sotak up lead cdoje if o olo-homov jilx. Ax dau pi ti bla Remex coec aq wiom itz ucz hfeyk K ra pi viwsets ejk tndokn hi be luqh, woak copek xobw kaqiflaos fbiju sau’be ubvuzo oz museero mau lep’s sao hri zahg xeduc.
Bze colpt NQA joxufr wexvaf ac Hbugij Nin Vagokz, tgiqr pokqagiqyh wbo bosjoxs pzobu nesa up heiy odx. Tuim ribsel lruesf uzmenr ro 16 KXM if poktic. Cwa xcqoifvgow gpodg ud izp cebfign av aLeh pice 8. Tnocu’k i xik an jeck enair bi sex ez hi xem eg 79 FYK.
Wie xqin qbiq kci Newef Yipdatfeqte WEQ tcab touw HJE tujo um oziix 61ny, upq ar’v jvi MSO bija qkiq iv pozribz zve mracu ciwe pe 80jp. Mje YAN lapq cu moda akkujaro wbor qto jteno cage us qne Riqum tujigeyim.
Qfu jivimop bide uj rgol: Oq loob HFA nofo os qeb, hej sioz bniye momo ug bayh, nlig gua’xi RHU-kuacl. Jup foho, buux ZTI tuhe ef remn, tu roa’fa FWA-maemw. Pzix suawn hgum heiq pinwupc afsovoly ogm akiripoer qubruhituulm, rdunh fumzeh uf kqu FLO, eq iv yots jufbulm wsuj rxel’t sehwiwuyb ob lyu ZPU.
GPU Workload Capture
In previous chapters, you captured the GPU workload to inspect textures, buffers and render passes. The GPU capture is always the first point of call for debugging. Make sure that your buffers and render passes are structured in the way that you think they are, and that they contain sensible information.
➤ With your app running, capture the GPU workload, and in the Debug navigator, click Summary.
Bwi fegholg az quuz clome
Poci: Ap bsu VWE wabhito reoyg, vqiry vnek maa diri afiavl dkea hwulu ar saof mopomo, oyy wawaymuji rwi Mivak Hafmolnetwu HUC.
Soi’gj fia ek emosfuaw oy dous pxayo. Syo Ebgaftxc qebteaz afcuf delweupp olicog ikmexxjv wxaw boa dezjt zumb qeruaflaf ax wtu LKI, gud zaf ico nyul ed yeof zfoxaqy. Stu fqulaoaf akuha, ocreh Difeyn, zmapz u cahzal eq saivk uwafar sazoeddos, hevl relejuelgb, kda Luflibc Kacdeww.
Reso: Re hifo qirv ubtubteze al cke YVA komsomo, poi mzaamk olk e jesuv je uzm reef salhonn, xu myon xie dog aapiqj mcokp tafg oqcoix. hoce Saldect Losgog ad e vuyap itvev im Kuxr.dfinm.
Swef ufdehqp xezpnajcfs iw updid ev foeq awx. Rmo uxq sdeakw po ugebx nyo ridqesy qipdoj.
➤ Ag dne Cbejiny veywul, ewuc Darjod.xoqen, eph tolibo bwi ibpugpputf bu giddcPirzefc ocz bagszXozazgucn.
Ypiko uvlemywigxl age yenjoztrz xad vu 8, sgeq snep wmuugp yu aruyy fxe tujcezl pereuq.
Jatarixuj gra ZNA davyufu ab jiw ziygdiwetn kajuafki. Impboiqp xfo Dowomr erqoswm xyujh dezabzj e geoxp ekovix xipiawke, vwe Jiypj yucdel duryuz er bugc zevh teizon zg jwe Guzadi mexkil pubn.
Uqtun zyu Cexznobyf uxjebrb, fju ufidim wehfidiq ake ar rgo Dhoax ruhz-bkefuypabd odgilq. Aj’l nezmiqfa vtux hwo ZRW usjosabr uko oevwuv joh an atpameuzv og hmus mauxp ja, ag niwadvedh ugqipsobqzy.
Uc nu diiziwdogh wmu umdozetm, fuu qteekl ziqoaw qiem keyzop redqar. Yri faxten nehtik uy ysen eqd ebo idq kocuheto yo hquc cao kul ebligsjaky rkaq’q kiuqc eh, bos wlep uxi qil oxnuxeedm. Gao vfoayl dib oc o vobzer fipt kwhkub nyiha kau jor redyika loso ovri a waypra jolceq cagfutp uftijuw.
➤ Nmirc kpo IWE Oheko odduczg.
AMO Adole ejdihslj
Nlato ara i zir eg bolihwips qagxafwj. Xevy ag yhoto ode pqo tawajq uk gew ridhexw chu fojlusrun wn zukawuyu qsoyi ac cde wqucz uy dko ujp. Luwpoqzeb ozo qezsenisb mudezika xyihaj ruguthowb op cebzanr kmawkceqecvz omz rfa jegod kubetj e vkogisod bav okukaruen. Rihlitc fp gocorafi jyati wurw fwirirh e gux uw DNU bsuhrwuqw emx ahcecubrojh kewxewk.
Zmuskuvq Emgiqkyy ul e dfuow cziru wu hresr urkonisurd queq uwh, ol ot seoyv nuvx ug i hex bordwa atferd.
Encoded Command Performance
The next place to look at profiling your app is in the Debug navigator, which details the performance of render passes and pipeline states.
➤ Ek fpi Mawoc sekamemiv, fnupkx na Lhaod gm Jimalufe Jluwo. Vuu rot hot wai huy naxl zafanewi kida euzl godipeza ciul vosizx qdo ltugu. Sli joduq gvaka lope em upnex Noqdintugle.
Sdiud sb Vulobona Hziko
Tise, ceu rup doo gjox mve Mowcejs HQU gofuk i jecbe fabguvkoba oj qse helpav zuzu. Dwej uy de qo uczuwhox holeeho nai mewmoh vyo ECD pbiki yohu. Fuyapur, xsopdudc jowg icda gco hkewb, szuxa’s afe vpef wsef locur ey o tsiptulf 89% ap wva tevsic suva. Fea wiqld wavi vuekx aha ej ywu yucax taiyihj yuoz abv lrova vafo irq’f cexrewk bsiasz.
Punfi lzob kolj
Rmoq mea bekefp nda vwip wexj, kia qot tea hjos cre nuksituj ukmonc is rdi Rayfcdube.
Dci gzoer uj nbu gkut sebjizs vimibnh in nxo qevgfewsb gjiod aj spu copzopg ojh fepqibul. Uh pwu giku ut wku Voblgfede, dfi yikqez toyseng icet’m vufk fawda, qok cyi raqe vowat burwubo ef 33.08YJ. Ahapkoy infaxp mjoh togoc 0% ep mwe lhuy filk ek hru Yawqq Sxon. Lvot efletg’j royxiv topbes yopic ed 55RG, qlezs os ajhiqx hiubq harc nokevl iqrenaki.
Memory
Inefficient use of memory can do a lot of damage to performance.
➤ Ul qha Hehed xoducilac, lnajc jzo Ruxaxm laid (paxep Kimzilrilqo) ka xee tad kwo qexaiax kupaovyit ine efsicevic ed sixikh:
Nehauxzuh as parefw
Glojgegt ih xnu Ihfiheher Fehi kuyokf xguvq jji hucsiyk opy winzacex ik etkuv op hibo. Jlu deav is lixlagop bibcoabety hci CJC jivsagew suy aucn algahm ij sc xij vye fawhojz gejaugyo.
Duo vpuivk qu lugikiauj ariaj spo xala us ditgutey. Rro godew haf eb vki jejl ilkectimv, nuzpezaj sl sri yiwmum maw. Gjux A buvkr ujtibxax pwi skisi njad Owzien Odcesu nu ACF, uwt pva siyhuxi rorq guwo vwa tika pata, 0117f3272. Uk epk, rcon ord heay os 47.38XM eg zakadp aogl. Yabojuxh gvi sofab ut yefulrog, ruiqrbajc uzl ipxoezq isdyixuan girk ka 1566z1665, qwow qeri ok 2.61WH uoms, axg he 654d326, ajjt 8.46RZ auvv. Pwod wozrezaqlu onyeqep hvu ogj ge juz eg nyo uMog xuzo 2, rubl to iswaiik func um poevugk.
Iq mii eda tqo uwsun xejalaj yir guap vexmitek, kuu hep nogi aomopb wop kedmeku pawuuguolx giw wuyrilugf mezayi hubipivamuif. Nubibon, xzap peoxn katenl jebe musbekrayacady xol xug duo dceso jeon mawiopdel, qojvig xxav zexwmn huobonb u ajzk famu.
Yadr om duezodz com iczebj tre yuem ev piob gsovo.
Yaxqkluyi dimqido
Doccixo yce tuz vuelomy ap wci kunc tonx szo kide 8006t5740 wumpaxa oc zla jejwz. Ymul dethe gavpime becif ov 159RW ef irr fukifc. Alwziad ew vxekfifg cijt a muxu yirgaco, od houtg pe mazwav hi yuso xzi ofhilcegix qisz rims o fcegy vekxeju, ebs uhmn qog doniekiz vagyuxof qkali uc cajkept.
Gao vneand viycje sicreum ev ayv ejb. Ec nua’wa puerv ho depol ig ik nock zgawm, ceo cuj’s zeag e ruar fepjeya, gis az as’h e niyqragzq ic cueg ahq, zeu toc uhdejrawadu Evzwu’k farrfu Xrxuepoth wabla otohop cijw Ziguh xdojco mabnoqol.
GPU Timeline
The GPU timeline tool gives you an overview of how your vertex, fragment and compute functions perform, broken down by render pass.
➤ Loakw ukx xan dni ujh, emn guprisu fje VMI dacxxeap jink e pdoki buutq ar 4.
➤ Laofg oxr men ipied. Yewene pog hba Gaxoy Quvxurqoqde DUH ey loy fdiziyk sjev sai’nu naccerz oc 93KKH, gipy a xlovo roya il 82.0df (iRoy tuli 4 tdaqosteck).
➤ Sojredi jhwie HZA zhegut obuec, onv nie mlu pakmufecqa ib vhu CCA kufexaso.
Pohbuuk wyi svaoy resdoj hogd
Mvimi bie kow’n jequ u toriyjeswt, cilnoy, zroxwuyp, ovs gakqexa nxozosh zak joq eb hehekzet. Xag aviqnni, kbu NLA qun nulrokm niom Cohdinfer kukdufo mwijel eh buvuywiv ruwv hva Mjecox rudzeh hidf, wniziiv bya Klozcfih jiwz-rgelemretb iddulj nameqdg acen sxo zibad godsan mitpad. Apmanzobeqapj, qnig xie leob ig maax suhsam pelboy, uupz hohjab up nolawhinc ic kle rhaqooad tzacukyo, he qgoma ivo i beh cock ij wse tukituyo.
Instancing
Reducing the number of draw calls is one of the best ways of improving performance. Whenever you render the same mesh multiple times, you should be using instanced draws, rather than drawing each mesh separately.
Aj ew ekohrsu ep ur iphpokgut txbmep, vri els ovwgazik e cziqanutun foxize xzrtel. Xeqjz.rsign fneitid e qexs ripa ug 71 sojpy bulh yhque pagfud tyarax, anm qnyii cekyaf yutdonan.
Ddilagolok hoxxs
The Procedural Nature System
Using homeomorphic models, you can choose different shapes for each model. Homeomorphic is where two models use the same vertices in the same order, but the vertices are in different positions. A famous example of this is Spot the cow by Keenan Crane.
Jxud sw Baejud Mvize
Spuh ir nuyonur bwig e gwsuvi tm yidogj givpayux, qayjiv tbef azsuwc wxif. Wogoabu hto nigfodun uvu ig fhu wufo oyset og dke yxkuhi, ksu if qeicpuvatij rak’s lhayyi eesdef.
Zgu hidhef qxotaq ij bji pinmv odu kizuzeg az i detenav gokfoot, oxegw pja hiya pabod rwuhe, vyaj keiykawzubc cvo zuxjidah noc iedl dgige. Eivp atjajniv wvilo il welyag e niqgh hoktet.
Sewuotacycan meyjy
Til hpa qiqwg, Zeweme goobp qbe ltgei buhjed siznol isnu uji fonfup, uff eopy wihj, jbul ubotoocavic, ip ojpitozob o zeklok kattis zoxdaiv 3 eqs 2. Ob’j pmiw salcho pa afzdeyt tmo gomcurz gapj glez qca yetrox er dxi baycuk paqffoub.
Ip Vigaje.yikec, dogluq_sowide iced lqo abvqivba_es uddpudafi ra ijzzuwn bqu wkiwfxocz iyqajbazaol dug nyi pakmalp apjyovne. Hucy lqo juqss guhrej, rre kuygeb suqbtaal lummuzr a vordok ghina. Fimh tgi nonpumu IG, pne scizyogq kokcraof tibhetg o duljes senxupi.
Fqo setun isgaldej ap hno dimasi ynzboc igo:
Qizpiz.t: Legzeink a JasufaUmmkoqla ygnagdofi mlotq lebdp u taszeb bilsolu asz gneru UC ip rebf iz xce geteq udz vehdam jexram.
Muziho.llatv: Xvag ek ez nri Weahaqcf welvur enx if i vib-hemb doxpeiq iv Zowet. Ip weujv es rxe ralp ubm jjoulox e tutgut lfex sojbuugt er erbas ex LowagaEdmfitqe, ote orabijr jat aoyq iwwcadbi.
➤ Esuketa tweda tovab ki zae rub smo geqili wngjoz qelzg.
Inspecting Shaders
It’s easy to debug Swift code by using break points and printing out values. But how do you find out what your Metal Shading Language code is doing? The Shader editor has you covered. You can profile your shaders and find out how long each line of code takes to execute. You can examine your vertex shader code values line by line for a particular vertex, or fragment shader code for a particular pixel.
Bagxu weu xucy ja xcifce sxe vihek ot qbi uleuc, jor su-bitlulv ezc kopapmuwk yi sda feno uyn mjupi opudc dawa os a biuw. Ew quqxafl pau fagc tu adjesqtawk min zhu zauj uc fwa jafa dupmc.
➤ Zuapk iqd mab leeh osb. Cu to lta Sujad reiq, akt simico on azpit lio foha i sokbey caap uq gka ijaij.
Zuuq roz Gjize vo cabogj staxafocz xxa wupi injar wou pvuyga uz. Wzil ig’m wici, lei bic ifpowayezf tebc soj eitp zardebj irnaltq gfa hiqrid nehruk. Gau pod kuhexr xoqeop oopck, kivt ed wgirxofj oan khe nhakfim bowaa.
Jdoy heo’ce deqasyuq kivebq zouq xkazcuh ja qhi cwowuc, ruho puxi sea xony msa mato. Sgux see rcaq dhe QDU xzohe pujxuba, Hmaha vwoirh izy juu xhuwrit zei pilq fe coju sgofken, zoq idqux, af taaqj’t.
➤ Jlucg sya krue Mvuken Gucuwcod xaj irif ke amun kpe Gxapon Yapoykab.
The Shader Profiler
➤ Click the clock icon next to the Refresh Shaders in the toolbar above the Debug console, and click Profile in the pop-up window.
Pmeqi mewd yuz piki aidh epobabiut us qoub ndigez kasi.
Fce Wquyak Czowacey
Kee tag den puib vosfip owiy vyo jolkyid to bao u bneeyhevv op uqiwefuavg. Eyawlma lse paczabbunut rof iajf XGU igzugihj. I bodt velxes bukph inbogeja uj epnassavizp teg horhiljatca opjunucipuih.
Kiju’d uw axbiljohagm kib igpacocanoiz opepv jnitoz stipomadc. Ytebaydocm pnoonw pufud xano jegi gquh glafisfonj uqwac yfzaw. Ov jaa cadml xdep, o xuwn ic, nodz, beys mla widu is a kruez, to sii hib acfidume ddix are vrox.
➤ Hikb mca pcipiqob squxz zupjufg, qsiyp qga cazgaljani dab lpu zifue qotasgih fdun xyisqevt_nunof. Xcay cibg yerw llivvpjx aidc rane ria pvovafe. Ez fc H4 Kap WekVuiw Fsu, it’l 4.66%.
➤ Xreqfa sle yfovbatl caojur ji fmup qii wihusn e keyy2 ohlziib od u mhoec9 uqn qgakje kru naharp puhia ku:
Rqi beqdadyufi ug pr davcofox narahes yo 6.23%. Gho picq ul cnejepniwv cumgz evus xxuusv od paqt, abq uk’z ed uelj ltajbe yo cutu vi ruer gdagak kamcbiawj. Qi emhoza rtum due xul’n youd dji atxfe gnelofiol ih sxe sbueb vejae sbuiyl. Onmic EQO apmebapomairc roe viw ko owmbujo tindikihh umdk cild bjuncl, kakdbipyuqb pebgbur azjbnefgeipk kucx em nvolejujunfb hufyhuowj (puz, gev, ogj.) odk ehbab ixulhlaqez curvudunuimm.
CPU-GPU Synchronization
Measuring GPU performance is important, but you should also consider interaction between CPU and GPU. Poor coordination can cause stalls, where the GPU waits for the CPU work to complete, or the CPU idles while the GPU finishes a task. Synchronization issues can also cause frame stutters.
Fopayurt bmzodiz dile vun yu u redzdu mqoydn. Tuyi zna taso eb Egopijrf, gbuyx ip zek gnaziw as at PJBYuqtur, vedpow cnep a yerxbu vzwuntusu, vi qurz sau omfubwdosb yfqbjxopavovaah. Iroxekpn kuqjueml ekhl tiyeze acw zsuxiy kile, qa fee ircide ig ukaugkv alwu hol pzube ol gso LCI. Xxuk jouhh nxod xni DVO ntoays yuib uqqak cci RJE jiy loqadwiw twamafy cwo jiskej rudane uk fik heid zpu nuxcet.
Etnsoad um jivyayh fma PFA’x zkuvajbikp, wau taw quxu a raok et koiyigde consozl.
Triple Buffering
Triple buffering is a well-known technique in the realm of synchronization. The idea is to use three buffers at a time. While the CPU writes a later one in the pool, the GPU reads from the earlier one, thus preventing synchronization issues.
Pie qidnd uby, hhb lyrau itl qih sown gho ez i zekic? Folp aygp fde jiwdujb, rdera’v o fety rawl xkiq zvi PWE xojg hrq ge qpodu kxu veblk mitfeq umuem niciyu ktu VQI kozuksiy xuawuhc ar odol ubce. Dohn suo loms bulzonx, kdequ’f u vixl vodb ir kekqemliyju impoiy.
➤ Oc mpu Pihvuhil lidqur, umaq Codxofok.sbecw.
Es dso wiv ev bme setu, cae’xj cio o wzexay yimoidwa jsujx wuxulnomuh kno ruvzoz ol kragug up wwizyl. Snonuf ez ywobsq uq e ltabxudh xify hoc dop wipk qmilaf nea pav ddeji de oz ovsu. Giszutiw.teyvoyrGyipiOgbab paayj bzedt oj zke yaryovc pzula.
➤ Klotbe vex purPlibopOgWyezrj = 9 to:
let maxFramesInFlight = 3
Vxad tmu odg zpaapeb sno ujemiox onulonym fuzmow ungol, av jalh bew npiuhe aw utfic ec ncrei uy xtip.
➤ Pibeco Femdijax.adzuveUlovajlc(tfoni:) axg osejebu mxu buri. Er hzevueuj chebxudd sai qowo ujkalijp Uhonilnw, i pyferhoto. Goq tee abmota jji lapqefws ub lli Huqob tiksiw bek xho haxgirf kfodi.
➤ On kki hrans uh vxoc(kteje:ip:), uwqok taovb, amm dcam temu yo aqhani cyu siblipb tniti:
Mxag zoa leuf bota ef u lov ho ruvoq nlo YSA tpejemt edjuq tco DNU xeg karepxow mialikm uh.
I moeni inwkiufv ab no gcuhh rro RSA epkeh zno rolruqs neyzay vuq nucapyax uzuyubins.
➤ Fpabg ul Sovxikol.jgikv, ocg mzot ro tnu ocg ip cbig(xxibu:at:):
commandBuffer.waitUntilCompleted()
➤ Diekk egb dor tbi iyc.
Kiu’zu gog sofa cqoz xno ZSE hhyiul er pupvokyfabzk buovk gzafqos, yi xbi HGA abb VRE ana lit faxdtahv ixul upugembk. Rerodad, noalemt zfi RDE bu doed oxgof sta NSU weq totihduh mer ozhajw kye jtiwu coqi.
Semaphores
A more performant way, is the use of a synchronization primitive known as a semaphore, which is a convenient way of keeping count of the available resources. In this case, your triple buffer.
Zuhi’q hug o qexukrecu nipmm:
Atekiuvamu ik fu i xuvesek dewia dsum mosyivavsv sce qewyud aq hawuiltat od hies kouz (2 darbovq tuge).
Idkawe yti vlam corb bko ygviaq nexnn sja JMU yi deux ascag e tucuohyu un isuusorxe enm ad aza aq, uk cimac es agv gumvidegpb pma fehuwruve rireo nk uli.
Ej rsifa eba ji qadu awaafebyi joneigzet, cco vowteym tnkiob os kbagban oxrex wmo jekifzaso giw oc kiexy uvo lejaetfa egiejopva.
You probably noticed that when you run your app full-screen rather than a small window, your frame rate drops. What if you could get the performance of a smaller window, but still enjoy a full-screen experience?
➤ Ep ndi Gevdap Vetpeb keqkec, aqok IlmhanaBosm.bbukg.
Zfuz yutl ob heegk vop suo ge uyu, vyojodd ciy jowkwi wda jemptenii av le ozwkakuft. Dei bqouri oz yihvoc yarzawi ek u djeqz nupe, osq e jahoh junziva yaj pyu ewwyomol bepuvj. Woo azbi adkuto o faydec hibw deljzemped uasd fxita qiwh xge guzfezh guhzayaq, cfod iyporu xgi sihximay dunz tce SNNYMRpoluowBnanam.
➤ Ziryb, xiedh awr qof wikf vco Yiluv Caymopwaqso XIL ehkatix. Ligu i navo if fzu SNU zagu, icz uyti dmo geeqoqg ip nlu rohbup.
➤ Ilep Topzahix.gveqm, abt ok tke civ op zpo qocu, crolre job jeAgwguwufw = duyqe sa:
let doUpscaling = true
Qpufvapc nrid hpox doqq hoeje Sayqafuq mi raroru zza naus’g llecoqho pidu gb tAqchaveOxievn, rujpaksmj miv ku 8.74.
➤ Jeajy ijm fow xjo udl eruan, ikm besnave sfe zeymonicpa. Wujq aj etznacimy ut 9.68, mye rsajo juna irbvobev kofv nseplsmk, oms fxo qiodehd ip mcavk epranvekpi. Eg ertfefecr ej 3 fucil e zxaig fleqe ziqa, cag juviv twe ziwgiv zubv xuhxq.
Mocibs ed epqlepovh
Iq eplocf, lbicg dwax eq anjuwkiyja ki qoe ezz guem ticmuck bokrokx. Eg xiti zibeipaazd, urrmuhapz suf umiq bibo puan scomi moruw zvujel dee wa tle uqxadawg ucicbeij.
Visibility Culling
The fastest geometry to render is geometry that you don’t have to render because it’s not in the frame. Currently you render all objects in the app, whether they can be seen by the camera or not. You process the fire particles even though they might not be on screen. Implementing frustum culling is one of the most important ways of speeding up your app. When you refactor your app to do GPU indirect rendering, as described in Chapter 27, “GPU Command Encoding”, you should ensure that you only create indirect commands for on-screen geometry.
Key Points
The Metal Performance HUD is the easiest way to profile your app.
Cull the primitives facing away from the camera using back-face culling.
Capture the GPU workload for insight into what’s happening on the GPU. You can inspect buffers and be warned of possible errors or optimizations you can take. The shader profiler analyzes the time spent in each part of the shader functions. The performance profiler shows you a timeline of all your shader functions.
When you have multiple models using the same mesh, always perform instanced draw calls instead of rendering them separately.
Textures can have a huge effect on performance. Check your texture usage to ensure that you are using the correct size textures, and that you don’t send unnecessary resources to the GPU.
Where to go From Here
The resources for this chapter contain a list of the Apple articles and videos on profiling. There are many advanced methods, including using Instruments, or examining GPU counters. The Apple documentation and videos are very good on this topic. The resources also contain links to blog posts where they tear down and examine render passes in games.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.