




已閱讀5頁,還剩28頁未讀, 繼續免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
Building a High Performance 3D Games for Windows Phone,Adam Schaeffer Microsoft Corporation,SESSION CODE: WPH308,銳普PPT論壇chinakui首發,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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 七年級生物下冊 4.2.3 合理營養與食品安全教學設計 (新版)新人教版
- 人教版生物八年級下冊7.2.4人的性別遺傳 教學設計
- 人教版四年級下冊第4課 主題與背景教案
- 七年級生物上冊 第二單 第二章 第三節 動物的運動教學設計 (新版)濟南版
- 2024四川巴東弘發產業發展集團有限公司公開招聘工作人員1人筆試參考題庫附帶答案詳解
- 人教版八年級地理上冊:4.2 農業 教學設計
- 人教部編版三年級下冊3 荷花教案設計
- 七年級數學下冊 第二章 相交線與平行線 3 平行線的性質第2課時 平行線的判定與性質的綜合應用教學設計 (新版)北師大版
- 九年級道德與法治下冊 第一單元 我們共同的世界 第二課 構建人類命運共同體 第2框謀求互利共贏教學設計 新人教版
- 2024北京國家金融科技風險監控中心有限公司招聘10人筆試參考題庫附帶答案詳解
- 路基防護噴播植草掛網客土噴播植草施工作業指導書ztzyzd06
- 鋼筆字練習模板
- 撰寫課題申請書的五個關鍵(課堂PPT)
- 檸檬茶項目財務數據分析(參考范文)
- 預制渡槽吊裝施工方案_圖文
- 國家開放大學《會計學概論》章節測試參考答案
- sq1魔方還原教程
- 小升初個人簡歷表
- 集中空調衛生檔案目錄
- 錐套國際標準基本參數表
- 績效管理體系優化方案
評論
0/150
提交評論