您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > 微软出品简洁色块型PPT
BuildingaHighPerformance3DGamesforWindowsPhoneAdamSchaefferMicrosoftCorporationSESSIONCODE:WPH308(IntelliSense)SimilarenoughtoCthatlearningandportingareeasyBlazinglyfastcompilesC#.NETonWindowsUsuallywithinafewpercentofnativeperformanceAwesomegenerationalgarbagecollectionPerformanceshootout:RaymondChenvs.RicoMariani!ARMv7CPUMoreforgivingtowardjittedcodeARMjitterismorematurethanPPCWaysToCallCodeInstancemethodInterfaceDelegate/eventReflectionVirtualmethodChooseYourOwnAddressC++allowsindependentchoiceof.NETtypesdictatetheirallocationandusagesemanticsDatatypeThememoryinwhichatypelives(placementnew)Howatypeinstanceisreferenced(T,T*,T&,constT&)Valuetypesint,bool,struct,Vector3Referencetypesclass,array,string,delegate,boxedvaluetypesAPopularMythOft-repeatedwisdomValuetypesliveonthestackReferencetypesliveontheheapValuetypeslivewherevertheyaredeclaredReferencetypeshavetwopiecesMemoryallocatedfromtheheapApointertothisheapmemoryThatissubtlyincorrectBydefault,preferclassoverstructureUsestructforthingsthatareclassvs.structSmall(=16bytes)ShortlivedPasslargestructuresbyreferenceMatrixa,b,c;c=Matrix.Multiply(a,b);//copies192bytes!Matrix.Multiply(refa,refb,outc);MemoryManagementC++.NETAllocateInitiallyfast,becomingslowerasfragmentationincreasesVeryfast,apartfromperiodicgarbagecollectionsFreeFastInstantaneousFragmentationIncreasesovertimeNoneCachecoherencyRequirescustomallocatorsThingsallocatedcloseintimearealsocloseinphysicallocationGarbagecollectionisnotoptionalCan’thavetypesafetywithoutautomaticmemorymanagementMarkandSweepTriggeredpermegabyteofallocation1Startswithrootreferences(stackvariables,statics)2Recursivelyfollowsallreferencestoseewhatotherobjectscanbereached3Anythingwedidn’treachmustbegarbage4Compactstheheap,slidingliveobjectsdowntofillholes5FrameworksdesignedforperformanceFrameworksdesignedforperformanceTwoWaysToKeepGCHappyMakeitrunLessOftenIfyouneverallocate,GCwillneverrunMakeitFinishQuicklyCollectiontimeisproportionaltohowmanyobjectreferencesmustbetraversedUseobjectpoolsSimpleheap=fastcollectionUsevaluetypesandintegerhandlesGC.CollectExplicitlyforcesagarbagecollectionUsewiselytogiveyourselfmoreheadroomAfterloadingDuringpausesingameplayDon’tcalleveryframe!AvoidingAllocationBewareofboxingstringvs.StringBuilderUseWeakReferencetotrackGCfrequency’10talk:“DevelopmentandDebuggingToolsforWindowsPhone7Series”Use.NETReflectortopeekbehindthecurtain•0-3directionallights•Blinn-Phongshading•Optionaltexture•Optionalfog•OptionalvertexcolorBasicEffectVertexCostPixelCostNolighting51Onevertexlight401Threevertexlights601Threepixellights1850+Texture+1+2+Fog+4+2DualTextureEffectDualTextureEffect•Forlightmaps,detailtextures,decals•Blendstwotextures•Separatetexturecoordinates•Modulate2Xcombinemode(A*B*2)•GoodvisualsatlowpixelcostVertexCostPixelCostTwoTextures76+Fog+4+2AlphaTestEffect•Forbillboardsandimposters•Addsalphatestoperations(pixelkill)•Standardblendingisfreewithalleffects•Onlyneedalphatestifyouwanttodisabledepth/stencilwritesAlphaTestEffectVertexCostPixelCost,=,=,66==,!=610+Fog+4+2SkinnedEffectSkinnedEffect•Foranimatedmodelsandinstancing•GamecodeanimatesbonesonCPU•VertexskinningperformedbyGPU•Upto72bones•One,two,orfourweightspervertexVertexCostPixelCostOnevertexlight554Threevertexlights754Threepixellights3351+Twobones+7+0+Fourbones+13+0+Fog+0+2EnvironmentMapEffectEnvironmentMapEffect•Oooh,shiny!•Diffusetexture+cubeenvironmentmap•Cheapwaytofakemanycomplexlights•Fresneltermsimulatesbehaviorwhenlightreachesasurfaceandsomereflects,somepenetratesVertexCostPixelCostOnelight326Threelights366+Fresnel+7+0+Specular+0+2+Fog+0+2ABalancingActFramerateNumberofPixelsPixelCostBalancingFramerateFramerate•30hzrefreshrate•Nopointupdatingfasterthanthedisplay!Game.TargetElapsedTime=TimeSpan.FromSeconds(1f/30);ABalancingActPixelCost•Prefercheapereffects•MinimizeoverdrawManyknownalgorithms:Distance,frustum,BSP,sortfr
本文标题:微软出品简洁色块型PPT
链接地址:https://www.777doc.com/doc-7884750 .html