已閱讀5頁,還剩28頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
Building a High Performance 3D Games for Windows Phone,Adam Schaeffer Microsoft Corporation,SESSION CODE: WPH308,銳普PPT論壇chinakui首發(fā),Consistent sets of hardware capabilities defined by Microsoft,Windows Phone 7 Hardware,Resolution Touch Input CPU / GPU RAM Hardware keyboard is optional,The CPU,The Evolution Of Programming,Low level control,Straight to the metal,Raw performance tuning,High level abstraction,Rely on compiler and runtime,Developer productivity,Why C# r0x0rz,Powerful and expressive,Type safety reduces hard-to-track-down bugs,Reflection,Initializer syntax,Great tooling (IntelliSense),Similar enough to C that learning and porting are easy,Blazingly fast compiles,C#,.NET on Windows,Usually within a few percent of native performance,Awesome generational garbage collection,Performance shootout: Raymond Chen vs. Rico Mariani /ricom/archive/2005/05/10/416151.aspx,.NET on Xbox 360,360,Significant delta between managed and native,.NET Compact Framework Simplistic mark-and-sweep garbage collection,Xbox is not a general purpose computer Unforgiving in-order CPU architecture Requires custom VMX instructions for optimal math perf Security architecture poses challenges for jitted code,.NET on Windows Phone 7,In between Windows and Xbox 360,.NET Compact Framework Keep an eye on garbage collection!,ARMv7 CPU More forgiving toward jitted code ARM jitter is more mature than PPC,Ways To Call Code,Instance method,Interface,Delegate / event,Reflection,Virtual method,Choose Your Own Address,C+ allows independent choice of,.NET types dictate their allocation and usage semantics,Data type The memory in which a type lives (placement new) How a type instance is referenced (T, T*, T&, const T&),Value types int, bool, struct, Vector3 Reference types class, array, string, delegate, boxed value types,A Popular Myth,Oft-repeated wisdom,Value types live on the stack,Reference types live on the heap,By default, prefer class over structure,Use struct for things that are,class vs. struct,Small (= 16 bytes),Short lived,Pass large structures by reference,Matrix a, b, c; c = Matrix.Multiply(a, b); / copies 192 bytes! Matrix.Multiply(ref a, ref b, out c);,Memory Management,Garbage collection is not optional Cant have type safety without automatic memory management,Mark and Sweep,Triggered per megabyte of allocation,1,Starts with root references (stack variables, statics),2,Recursively follows all references to see what other objects can be reached,3,Anything we didnt reach must be garbage,4,Compacts the heap, sliding live objects down to fill holes,5,Frameworks designed for performance,Frameworks designed for performance,Two Ways To Keep GC Happy,Make it run Less Often,If you never allocate, GC will never run,Make it Finish Quickly,Collection time is proportional to how many object references must be traversed,Use object pools,Simple heap = fast collection,Use value types and integer handles,GC.Collect,Explicitly forces a garbage collection,Use wisely to give yourself more headroom After loading During pauses in gameplay,Dont call every frame!,Avoiding Allocation,Beware of boxing,string vs. StringBuilder,Use WeakReference to track GC frequency /shawnhar/archive/2007/10/12/monitoring-the-garbage-collector.aspx,Use CLR Profiler on Windows See MIX10 talk: “Development and Debugging Tools for Windows Phone 7 Series”,Use .NET Reflector to peek behind the curtain /products/reflector/,The GPU,Plus hardware accelerated 2D sprite drawing,Five Configurable Effects,BasicEffect,SkinnedEffect,EnvironmentMapEffect,AlphaTestEffect,DualTextureEffect,BasicEffect,0-3 directional lights Blinn-Phong shading Optional texture Optional fog Optional vertex color,BasicEffect,DualTextureEffect,DualTextureEffect,For lightmaps, detail textures, decals Blends two textures Separate texture coordinates Modulate 2X combine mode (A*B*2) Good visuals at low pixel cost,AlphaTestEffect,For billboards and imposters Adds alpha test operations (pixel kill) Standard blending is free with all effects Only need alpha test if you want to disable depth/stencil writes,AlphaTestEffect,SkinnedEffect,SkinnedEffect,For animated models and instancing Game code animates bones on CPU Vertex skinning performed by GPU Up to 72 bones One, two, or four weights per vertex,EnvironmentMapEffect,EnvironmentMapEffect,Oooh, shiny! Diffuse texture + cube environment map Cheap way to fake many complex lights Fresnel term simulates behavior when light reaches a surface and some reflects, some penetrates,A Balancing Act,Framerate,Number of Pixels,Pixel Cost,Balancing Framerate,Framerate,30 hz refresh rate No point updating faster than the display! Game.TargetElapsedTime = TimeSpan.FromSeconds(1f / 30);,A Balancing Act,Pixel Cost,Prefer cheaper effects Minimize overdraw Many known algorithms: Distance, frustum, BSP, sort front to back Implement “overdraw x-ray mode” Draw untextured with additive blending Brighter areas indicate overdraw,A Balancing Act,Number of Pixels,800x480 is 25% more pixels than Xbox 1 Great for text Too many pixels for intensive games 800x480 = 384,000 pixels 600x360 = 216,000 pixels (56%) Dedicated hardware scaler Does not consume any GPU Higher quality than bilinear upsampling,Scaler Demo,XNA Framework API Cheat Sheet,Summary,Great performance comes from great knowledge,Understand,Actions,Value types vs. reference types Garbage collection C# compiler magic (foreach, iterator methods, closures) Cost of the different graphical effect options,Use CLR Profiler and .NET Reflector Render smaller than display resolution, rely on scaler, 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vis
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025民辦幼兒園教師聘用合同書范本
- 2025監(jiān)理工程師《合同管理》考點(diǎn)合同生效時(shí)間的規(guī)定
- 二零二五年度醫(yī)療項(xiàng)目項(xiàng)目經(jīng)理委托合同3篇
- 二零二五年度互聯(lián)網(wǎng)金融服務(wù)公司股權(quán)及業(yè)務(wù)轉(zhuǎn)讓合同3篇
- 2025年度紙裝修設(shè)計(jì)創(chuàng)新技術(shù)應(yīng)用合同3篇
- 2025年度企業(yè)財(cái)務(wù)分析與稅務(wù)籌劃咨詢服務(wù)合同2篇
- 2025年度醫(yī)療機(jī)構(gòu)與執(zhí)業(yè)藥師簽訂的藥品質(zhì)量追溯體系合作協(xié)議3篇
- 2025年度展臺(tái)搭建與展會(huì)現(xiàn)場布置合同3篇
- 二零二五年度軌道交通設(shè)備維修保養(yǎng)協(xié)議3篇
- 2025年度養(yǎng)殖技術(shù)培訓(xùn)與推廣合作合同3篇
- 2024新人教版英語七年級(jí)上單詞默寫表(小學(xué)部分)
- 電力拖動(dòng)教學(xué)講義
- 2024社保費(fèi)測試(五)專項(xiàng)試卷
- 招商會(huì)會(huì)議流程綱要
- 安全生產(chǎn)工作年終總結(jié)
- 2024-2025學(xué)年人教版七年級(jí)英語上冊(cè)各單元重點(diǎn)句子
- 信息技術(shù)行業(yè)數(shù)據(jù)安全HSE方案
- 中華護(hù)理學(xué)會(huì)團(tuán)體標(biāo)準(zhǔn)-氣管切開非機(jī)械通氣患者氣道護(hù)理
- 四川省成都市武侯區(qū)2023-2024學(xué)年七年級(jí)上學(xué)期1月期末語文試卷
- 兒科護(hù)理安全警示教育
- 2023-2024學(xué)年九年級(jí)上學(xué)期期末試卷及答案
評(píng)論
0/150
提交評(píng)論