1、Click to edit Master title style,Click to edit Master text styles,Second level,Third level,Fourth level,Fifth level,Building a High Performance 3D Games for Windows Phone,Adam Schaeffer,Microsoft Corporation,SESSION CODE:WPH308,锐普,PPT,论坛,chinakui,首发,Consistent sets of hardware capabilities defined b
2、y Microsoft,Windows Phone 7 Hardware,Resolution,Touch Input,CPU/GPU,RAM,Hardware keyboard is optional,锐普,PPT,论坛,chinakui,首发:,锐普,PPT,论坛,chinakui,首发:,The Evolution Of Programming,Low level control,Straight to the metal,Raw performance tuning,High level abstraction,Rely on compiler and runtime,Develope
3、r productivity,锐普,PPT,论坛,chinakui,首发:,Why C#r0 x0rz,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#,锐普,PPT,论坛,chinakui,首发:,.NET on Windows,U
4、sually within a few percent of native performance,Awesome generational garbage collection,Performance shootout:Raymond Chen vs.Rico Mariani,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 c
5、omputer,Unforgiving in-order CPU architecture,Requires custom VMX instructions for optimal math perf,Security architecture poses challenges for jitted code,锐普,PPT,论坛,chinakui,首发:,.NET on Windows Phone 7,In between Windows and Xbox 360,.NET Compact Framework,Keep an eye on garbage collection!,ARMv7 C
6、PU,More forgiving toward jitted code,ARM jitter is more mature than PPC,锐普,PPT,论坛,chinakui,首发:,Ways To Call Code,Instance method,Interface,Delegate/event,Reflection,Virtual method,锐普,PPT,论坛,chinakui,首发:,Choose Your Own Address,C+allows independent choice of,.NET,types dictate their allocation and us
7、age 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,锐普,PPT,论坛,chinakui,首发:,A Popular Myth,Oft-repeated wisdom,Value types live o
8、n the stack,Reference types live,on the heap,Value types live wherever they are declared,Reference types have two pieces,Memory allocated from the heap,A pointer to this heap memory,That is subtly,incorrect,锐普,PPT,论坛,chinakui,首发:,By default,prefer class over structure,Use struct for things that are,
9、class vs.struct,Small(,6,6,=,!=,6,10,+Fog,+4,+2,锐普,PPT,论坛,chinakui,首发:,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,Vertex Cost,Pixel Cost,One vertex light,55,4,Three
10、vertex lights,75,4,Three pixel lights,33,51,+Two bones,+7,+0,+Four bones,+13,+0,+Fog,+0,+2,锐普,PPT,论坛,chinakui,首发:,EnvironmentMapEffect,EnvironmentMapEffect,Oooh,shiny!,Diffuse texture+cube environment map,Cheap way to fake many complex lights,Fresnel term simulates behavior when light reaches,a surf
11、ace and some reflects,some penetrates,Vertex Cost,Pixel Cost,One light,32,6,Three lights,36,6,+Fresnel,+7,+0,+Specular,+0,+2,+Fog,+0,+2,锐普,PPT,论坛,chinakui,首发:,锐普,PPT,论坛,chinakui,首发:,A Balancing Act,Framerate,Number,of Pixels,Pixel Cost,锐普,PPT,论坛,chinakui,首发:,Balancing Framerate,Framerate,30 hz refre
12、sh rate,No point updating faster than the display!,Game.TargetElapsedTime=,TimeSpan.FromSeconds(1f/30);,锐普,PPT,论坛,chinakui,首发:,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 untext
13、ured with additive blending,Brighter areas indicate overdraw,锐普,PPT,论坛,chinakui,首发:,A Balancing Act,Number,of Pixels,800 x480 is 25%more pixels than Xbox 1,Great for text,Too many pixels for intensive games,800 x480=384,000 pixels,600 x360=216,000 pixels(56%),Dedicated hardware scaler,Does not consu
14、me any GPU,Higher quality than bilinear upsampling,锐普,PPT,论坛,chinakui,首发:,Scaler Demo,锐普,PPT,论坛,chinakui,首发:,XNA Framework API Cheat Sheet,Avoid,Prefer,RenderTargetUsage.PreserveContents,RenderTargetUsage.DiscardContents,device.BlendState=new BlendState.;,/At startup,static BlendState myState=new Bl
15、endState.;,/Per frame,Device.BlendState=myState;,VertexBuffer.SetData(.),device.DrawUserPrimitives(.);,/or,DynamicVertexBuffer.SetData(.,SetDataOptions.NoOverwrite);,锐普,PPT,论坛,chinakui,首发:,Summary,Great performance comes from great knowledge,Understand,Actions,Value types vs.reference types,Garbage
16、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,锐普,PPT,论坛,chinakui,首发:,2010 Microsoft Corporation.All rights reserved.Microsoft,Windows,Windows Vista
17、 and other product names are or may be registered trademarks and/or trademarks in the U.S.and/or other countries.,The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation.Because Microsoft must respond to c
18、hanging market conditions,it should not be interpreted to be a commitment on the part of Microsoft,and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.,MICROSOFT MAKES NO WARRANTIES,EXPRESS,IMPLIED OR STATUTORY,AS TO THE INFORMATION IN THIS PRESENTATION.,锐普,PPT,论坛,chinakui,首发:,Required Slide,锐普,PPT,论坛,chinakui,首发:,






