Adam Schaeffer Microsoft Corporation SESSION CODE: WPH308.

Slides:



Advertisements
Similar presentations
Dan Fernandez Twitter:Danielfe Blog: blogs.msdn.com/danielfe/ Clint Rutkas Twitter:ClintRutkas Blog:betterthaneveryone.com Microsoft Corporation SESSION.
Advertisements

Joe Marini Principal Program Manager, Windows Phone Microsoft Corporation SESSION CODE: WPH310.
Introduction to .NET Framework
Välkommen till Sommarkollo Introduce XNA Game Studio Express Make A Game!
COMPUTER GRAPHICS CS 482 – FALL 2014 NOVEMBER 10, 2014 GRAPHICS HARDWARE GRAPHICS PROCESSING UNITS PARALLELISM.
Programming Languages and Paradigms
DEV300: A Tiny CPU and OS in C# Scott Hanselman Technology Evangelist/Architect Corillian Corporation
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
3D Graphics Processor Architecture Victor Moya. PhD Project Research on architecture improvements for future Graphic Processor Units (GPUs). Research.
Run time vs. Compile time
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
7 Windows Phone 7 2. Windows Phone 7 for Business 1. About Windows Phone 7 3. Windows Phone 7 for Consumer 4. Windows Phone 7 for the Developer Welcome.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Computer Science – Game DesignUC Santa Cruz Adapted from Jim Whitehead’s slides Shaders Feb 18, 2011 Creative Commons Attribution 3.0 (Except copyrighted.
DotNET A Developer’s Perspective Mike Litzkow University of Wisconsin - MadisonOne.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
Khalid Siddiqui Senior Architect, Mobility Center of Excellence Microsoft Corporation SESSION CODE: WPH311.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
Augusto Valdez Senior Product Manager Mobile Communications Business SESSION CODE: WPH202.
Ashwin Sarin Program Manager Microsoft Corporation SESSION CODE: COS204.
Lecture 10 : Introduction to Java Virtual Machine
Adam Schaeffer Microsoft Corporation SESSION CODE: WPH307.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Boris Jabes Senior Program Manager Microsoft Corporation SESSION CODE: DEV319 Scale & Productivity in Visual C
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Dan Swett Program Manager Microsoft Corporation SESSION CODE: OSP216.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
Hoang Anh Viet Hà Nội University of Technology Chapter 1. Introduction to C# Programming.
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
Suhail Dutta Program Manager Microsoft Corporation SESSION CODE: DEV402.
Rob Tiffany Mobility Architect Microsoft Corporation MOB401.
WPH310. Free Phone! Windows Phone 7 as a Game Platform Free Tools to Build Great Games The Game Loop Input on Windows Phone 7 Building a Game with Your.
COMP3190: Principle of Programming Languages
Jeff King Senior Program Manager, Visual Studio Microsoft Corporation SESSION CODE: WEB305.
Lori Dirks Expression Community Manager Microsoft Corporation SESSION CODE: WEB309.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Vineet Sarda Senior Consultant Microsoft Corporation SESSION CODE: WCL302.
Chris Mayo Microsoft Corporation SESSION CODE: UNC207.
1 9/6/05CS360 Windows Programming CS360 Windows Programming.
Olivier Bloch Technical Evangelist Microsoft Corporation SESSION CODE: WEM308.
Younus Aftab Program Manager Microsoft Corporation SESSION CODE: WSV324.
Object Oriented Software Development 4. C# data types, objects and references.
SESSION CODE: MGT205 Chris Harris Program Manager Microsoft Corporation.
Introducing Visual Studio 2010: What It Is and Why You Should Care
BIO202 | Building Effective Data Visualizations and Maps with Microsoft SQL Server 2008 Reporting Services BIU08-INT | Using.
Ted Pattison Author / Instructor Critical Path Training SESSION CODE: OSP315.
Session 1 C# Basics.
Martin Woodward Program Manager Microsoft Corporation SESSION CODE: DEV308.
Drew Lytle Principal Program Manager Microsoft Corporation SESSION CODE: WPH203.
DEV394.NET Framework: Migrating To Managed Code Adam Nathan QA Lead Richard Lander Program Manager Microsoft Corporation.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
“WALK IN” SLIDE. August Taming the CLR: How to Write Really Fast Managed Code Rico Mariani Architect Developer Division Performance Team Microsoft.
David A. Carley Senior SDE Microsoft Corporation SESSION CODE: DEV318.
Session 02 Module 3: Statements and Operators Module 4: Programming constructs Module 5: Arrays.
John R. Durant Senior Product Manager Microsoft Corporation SESSION CODE: OSP313.
Maarten Struys Windows Phone Evangelist Alten PTS SESSION CODE: WPH303.
Rob Tiffany Mobility Architect Microsoft Corporation SESSION CODE: WPH306.
A Detailed Introduction To Visual Studio.NET CRB Tech ReviewsCRB Tech Reviews introduces you to the world of Visual.
Microsoft Silverlight Performance on Windows Phone
Excel Services Deployment and Administration
9/18/2018 7:26 AM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Tech Ed North America /1/2019 2:58 AM Required Slide
What’s new for Silverlight & XNA developers in Windows Phone Mango
.Net Framework Details Imran Rashid CTO at ManiWeber Technologies.
Presentation transcript:

Adam Schaeffer Microsoft Corporation SESSION CODE: WPH308

Consistent sets of hardware capabilities defined by Microsoft Resolution Touch Input CPU / GPU RAM Hardware keyboard is optional

Low level control Straight to the metal Raw performance tuning High level abstraction Rely on compiler and runtime Developer productivity

for (EntityList::iterator it = entities.begin(); it != entities.end(); it++) { ICollidable* col = dynamic_cast (*it); if (col) pendingCollisions.push_back(new CollisionInfo(col)); }

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#

Usually within a few percent of native performance Awesome generational garbage collection Performance shootout: Raymond Chen vs. Rico Mariani

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

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

Instance method Interface Delegate / event Reflection Virtual method

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

Value types live on 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

By default, prefer class over structure Small (<= 16 bytes) Short lived Matrix a, b, c; c = Matrix.Multiply(a, b); // copies 192 bytes! Matrix.Multiply(ref a, ref b, out c); Matrix a, b, c; c = Matrix.Multiply(a, b); // copies 192 bytes! Matrix.Multiply(ref a, ref b, out c);

C++.NET AllocateInitially fast, becoming slower as fragmentation increases Very fast, apart from periodic garbage collections FreeFastInstantaneous FragmentationIncreases over timeNone Cache coherencyRequires custom allocatorsThings allocated close in time are also close in physical location Garbage collection is not optional Can’t have type safety without automatic memory management

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 didn’t reach must be garbage 4 Compacts the heap, sliding live objects down to fill holes 5

Frameworks designed for performance 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 poolsSimple heap = fast collection Use value types and integer handles

Explicitly forces a garbage collection Use wisely to give yourself more headroom After loading During pauses in gameplay Don’t call every frame!

Beware of boxing string vs. StringBuilder Use WeakReference to track GC frequency Use CLR Profiler on Windows See MIX’10 talk: “Development and Debugging Tools for Windows Phone 7 Series” Use.NET Reflector to peek behind the curtain

foreach (var x in collection) DoStuff(x); becomes: var enumerator = collection.GetEnumerator(); while (enumerator.MoveNext()) DoStuff(enumerator.Current); Is the enumerator a value type? Array, List, and most XNA types are fine Some collection types create garbage

IEnumerable Think() { while (true) { Heading = ChooseRandomDirection(); while (ElapsedTime < 23) yield return Action.WalkForward; yield return Action.LookAround; if (Vector3.Distance(Position, Enemy.Position) < 42) { yield return Action.LoadWeapon; yield return Action.FireWeapon; }

[CompilerGenerated] private sealed class d__0 : IEnumerable { private int <>1__state; private Action <>2__current; private bool MoveNext() { switch (this.<>1__state) { case 0: this.<>1__state = -1; break; case 1: goto Label_0073; case 2: this.<>1__state = -1; if (Vector3.Distance(this.<>4__this.Position,... break; this.<>2__current = Action.LoadWeapon; this.<>1__state = 3; return true; case 3: this.<>1__state = -1; this.<>2__current = Action.FireWeapon; this.<>1__state = 4; return true; case 4: this.<>1__state = -1; break; default: return false; } this.<>4__this.Heading = ChooseRandomDirection(); while (this.<>4__this.ElapsedTime < 23f) { this.<>2__current = Action.WalkForward; this.<>1__state = 1; return true; Label_0073: this.<>1__state = -1; } this.<>2__current = Action.LookAround; this.<>1__state = 2; return true; }

Plus hardware accelerated 2D sprite drawing BasicEffectSkinnedEffectEnvironmentMapEffectAlphaTestEffectDualTextureEffect

0-3 directional lights Blinn-Phong shading Optional texture Optional fog Optional vertex color BasicEffect Vertex CostPixel Cost No lighting51 One vertex light401 Three vertex lights601 Three pixel lights Texture Fog+4+2

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 Vertex CostPixel Cost Two Textures76 + Fog+4+2

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 Vertex CostPixel Cost =, >66 ==, !=610 + Fog+4+2

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 CostPixel Cost One vertex light554 Three vertex lights754 Three pixel lights Two bones Four bones Fog+0+2

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 Vertex CostPixel Cost One light326 Three lights366 + Fresnel Specular Fog+0+2

Framerate Number of Pixels Pixel Cost

Framerate 30 hz refresh rate No point updating faster than the display! Game.TargetElapsedTime = TimeSpan.FromSeconds(1f / 30);

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

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

AvoidPrefer RenderTargetUsage.PreserveContentsRenderTargetUsage.DiscardContents device.BlendState = new BlendState {...};// At startup static BlendState myState = new BlendState {...}; // Per frame Device.BlendState = myState; VertexBuffer.SetData(...)device.DrawUserPrimitives(...); // or DynamicVertexBuffer.SetData(..., SetDataOptions.NoOverwrite);

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

Monday WPH202Deploying Windows Phone 7 with Exchange Server and SharePoint Server WPH301WP7: Deploy Microsoft Forefront Unified Access Gateway for Access Control to SharePoint, Exchange and more. Tuesday WPH302Overview of the Windows Phone 7 Application Platform WPH313Windows Phone 7 Architecture Deep Dive WPH304An In-Depth view at Building Applications for WP7 with Silverlight (Part 1) WPH305An In-Depth view at Building Applications for WP7 with Silverlight (Part 2) WPH306Developing Occasionally Connected Applications for Windows Phone 7

Wednesday WPH310Designing and Developing for the Rich Mobile Web WPH311Developing Mobile Code Today that will run on WP 7 Tomorrow WPH309Silverlight performance on Windows Phone WPH307Building Windows Phone Games with XNA WPH308Building a High Performance 3D Game for Windows Phone Thursday WPH303Understanding the Windows Phone 7 Development Tools WPH314Learn Windows Phone 7 Development by Creating a Robotic T-Shirt Cannon WPH312Understanding Marketplace and Making Money with WP7 Applications

* Restrictions apply please see contest rules for eligibility and restrictions. Contest rules are displayed in the Technical Learning Center at the WPH info counter.

Monday WPH301WP7: Deploy Microsoft Forefront Unified Access Gateway for Access Control to SharePoint, Exchange and more. WPH202Deploying Windows Phone 7 with Exchange Server and SharePoint Server Tuesday WPH203Overview of the Windows Phone 7 Application Platform WPH313Windows Phone 7 Architecture Deep Dive WPH304An In-Depth view at Building Applications for WP7 with Silverlight (Part 1) WPH305An In-Depth view at Building Applications for WP7 with Silverlight (Part 2) WPH306Developing Occasionally Connected Applications for Windows Phone 7

Wednesday WPH310Designing and Developing for the Rich Mobile Web WPH311Developing Mobile Code Today that will run on WP 7 Tomorrow WPH309Silverlight performance on Windows Phone WPH307Building Windows Phone Games with XNA WPH308Building a High Performance 3D Game for Windows Phone Thursday WPH303Understanding the Windows Phone 7 Development Tools WPH314Learn Windows Phone 7 Development by Creating a Robotic T-Shirt Cannon WPH312Understanding Marketplace and Making Money with WP7 Applications

Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31 st You can also register at the North America 2011 kiosk located at registration Join us in Atlanta next year