版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Building a High Performance 3D Games for Windows PhoneAdam SchaefferMicrosoft CorporationSESSION CODE: WPH308锐普PPT论坛chinakui首发Consistent sets of hardware capabilities defined by MicrosoftWindows Phone 7 HardwareResolutionTouch InputCPU / GPURAMHardware keyboard is optional锐普PPT论坛chinakui首发:锐普PPT论坛ch
2、inakui首发:The Evolution Of ProgrammingLow level controlStraight to the metalRaw performance tuningHigh level abstractionRely on compiler and runtimeDeveloper productivity锐普PPT论坛chinakui首发:Why C# r0 x0rzPowerful and expressiveType safety reduces hard-to-track-down bugsReflectionInitializer syntaxGreat
3、 tooling (IntelliSense)Similar enough to C that learning and porting are easyBlazingly fast compilesC#锐普PPT论坛chinakui首发:.NET on WindowsUsually within a few percent of native performanceAwesome generational garbage collectionPerformance shootout: Raymond Chen vs. Rico Mariani锐普PPT论坛chinakui首发:.NET on
4、 Xbox 360360Significant delta between managed and native.NET Compact FrameworkSimplistic mark-and-sweep garbage collectionXbox is not a general purpose computerUnforgiving in-order CPU architectureRequires custom VMX instructions for optimal math perfSecurity architecture poses challenges for jitted
5、 code锐普PPT论坛chinakui首发:.NET on Windows Phone 7In between Windows and Xbox 360.NET Compact FrameworkKeep an eye on garbage collection!ARMv7 CPUMore forgiving toward jitted codeARM jitter is more mature than PPC锐普PPT论坛chinakui首发:Ways To Call CodeInstance methodInterfaceDelegate / eventReflectionVirtua
6、l method锐普PPT论坛chinakui首发:Choose Your Own AddressC+ allows independent choice of.NET types dictate their allocation and usage semanticsData typeThe memory in which a type lives (placement new)How a type instance is referenced (T, T*, T&, const T&)Value typesint, bool, struct, Vector3Reference typesc
7、lass, array, string, delegate, boxed value types锐普PPT论坛chinakui首发:A Popular MythOft-repeated wisdomValue types live on the stackReference types live on the heapValue types live wherever they are declaredReference types have two piecesMemory allocated from the heapA pointer to this heap memoryThat is
8、 subtly incorrect锐普PPT论坛chinakui首发:By default, prefer class over structureUse struct for things that areclass vs. structSmall (= 16 bytes)Short livedPass large structures by referenceMatrix a, b, c;c = Matrix.Multiply(a, b); / copies 192 bytes!Matrix.Multiply(ref a, ref b, out c);锐普PPT论坛chinakui首发:M
9、emory ManagementGarbage collection is not optionalCant have type safety without automatic memory management锐普PPT论坛chinakui首发:Mark and SweepTriggered per megabyte of allocation1Starts with root references (stack variables, statics)2Recursively follows all references to see what other objects can be r
10、eached3Anything we didnt reach must be garbage4Compacts the heap, sliding live objects down to fill holes5锐普PPT论坛chinakui首发:Frameworks designed for performanceFrameworks designed for performanceTwo Ways To Keep GC HappyMake it run Less OftenIf you never allocate, GC will never runMake it Finish Quic
11、klyCollection time is proportional to how many object references must be traversedUse object poolsSimple heap = fast collectionUse value types and integer handles锐普PPT论坛chinakui首发:GC.CollectExplicitly forces a garbage collectionUse wisely to give yourself more headroomAfter loadingDuring pauses in g
12、ameplayDont call every frame!锐普PPT论坛chinakui首发:Avoiding AllocationBeware of boxingstring vs. StringBuilderUse WeakReference to track GC frequencyUse CLR Profiler on WindowsSee MIX10 talk: “Development and Debugging Tools for Windows Phone 7 Series”Use .NET Reflector to peek behind the curtain锐普PPT论坛
13、chinakui首发:The GPU锐普PPT论坛chinakui首发:Plus hardware accelerated 2D sprite drawingFive Configurable EffectsBasicEffectSkinnedEffectEnvironmentMapEffectAlphaTestEffectDualTextureEffect锐普PPT论坛chinakui首发:BasicEffect0-3 directional lightsBlinn-Phong shadingOptional textureOptional fogOptional vertex colorB
14、asicEffect锐普PPT论坛chinakui首发:DualTextureEffectDualTextureEffectFor lightmaps, detail textures, decalsBlends two texturesSeparate texture coordinatesModulate 2X combine mode (A*B*2)Good visuals at low pixel cost锐普PPT论坛chinakui首发:AlphaTestEffectFor billboards and impostersAdds alpha test operations (pi
15、xel kill)Standard blending is free with all effectsOnly need alpha test if you want to disable depth/stencil writesAlphaTestEffect锐普PPT论坛chinakui首发:SkinnedEffectSkinnedEffectFor animated models and instancingGame code animates bones on CPUVertex skinning performed by GPUUp to 72 bonesOne, two, or fo
16、ur weights per vertex锐普PPT论坛chinakui首发:EnvironmentMapEffectEnvironmentMapEffectOooh, shiny!Diffuse texture + cube environment mapCheap way to fake many complex lightsFresnel term simulates behavior when light reaches a surface and some reflects, some penetrates锐普PPT论坛chinakui首发:锐普PPT论坛chinakui首发:A B
17、alancing ActFramerateNumberof PixelsPixel Cost锐普PPT论坛chinakui首发:Balancing FramerateFramerate30 hz refresh rateNo point updating faster than the display! Game.TargetElapsedTime = TimeSpan.FromSeconds(1f / 30);锐普PPT论坛chinakui首发:A Balancing ActPixel CostPrefer cheaper effectsMinimize overdrawMany known
18、 algorithms:Distance, frustum, BSP, sort front to backImplement “overdraw x-ray mode” Draw untextured with additive blendingBrighter areas indicate overdraw锐普PPT论坛chinakui首发:A Balancing ActNumberof Pixels800 x480 is 25% more pixels than Xbox 1Great for textToo many pixels for intensive games800 x480
19、 = 384,000 pixels600 x360 = 216,000 pixels (56%)Dedicated hardware scalerDoes not consume any GPUHigher quality than bilinear upsampling锐普PPT论坛chinakui首发:Scaler Demo锐普PPT论坛chinakui首发:XNA Framework API Cheat SheetAvoidPreferRenderTargetUsage.PreserveContentsRenderTargetUsage.DiscardContentsdevice.Ble
20、ndState = new BlendState .;/ At startupstatic BlendState myState = new BlendState .;/ Per frameDevice.BlendState = myState;VertexBuffer.SetData(.)device.DrawUserPrimitives(.);/ orDynamicVertexBuffer.SetData(., SetDataOptions.NoOverwrite);锐普PPT论坛chinakui首发:SummaryGreat performance comes from great kn
21、owledgeUnderstandActionsValue types vs. reference typesGarbage collectionC# compiler magic (foreach, iterator methods, closures)Cost of the different graphical effect optionsUse CLR Profiler and .NET ReflectorRender smaller than display resolution, rely on scaler锐普PPT论坛chinakui首发: 2010 Microsoft Corporation. All rights reserv
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年康复专科护士理论考试题
- 应急疫苗接种策略与效果评估
- 小儿保健知识课件
- 干细胞外泌体递送系统的优化策略
- 帕金森病DBS治疗中的神经递质变化
- 工作场所健康环境的设计标准
- 医疗保险创新模式探讨
- 妇幼保健护理工作重点与措施
- 医院临床诊疗沟通礼仪
- 医疗资源配置与医疗改革
- 购物中心招商策略与运营管理
- 药品共线生产质量风险管理指南(官方2023版)
- 2025中级客房服务员资格考试题库及答案(浓缩300题)
- 2025年教科新版九年级历史上册阶段测试试卷含答案
- 中高净值人群财富管理法律服务白皮书
- 血透尿毒症脑病
- 巴彦淖尔市老年康复护理院朗润园网点建设项目环境影响报告表(2021年新版环评)
- 黑龙江省哈尔滨八中2025届高二上数学期末学业水平测试模拟试题含解析
- 小学三年级上册数学期末测试卷(综合卷)
- 油脂科技有限公司年产3万吨油酸项目环评可研资料环境影响
- 软件工程师生涯人物访谈报告
评论
0/150
提交评论