40

The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Embed Size (px)

Citation preview

Page 1: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft
Page 2: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

The Evolving Windows Gaming Platform

Chuck WalbournSoftware Design EngineerXNA Developer ConnectionMicrosoft

Page 3: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

A Brief History of Windows

Windows 3.1

16-bit operating system on top of MS-DOSWinG (most game developers used DOS extenders)286 (386 recommended)1 MB RAM (2 MB recommended)EGA video

Windows 95

32-bit operating system (extended MS-DOS), with some vestiges of 16-bit WindowsDirectX 1.0386DX 20-MHz (486 recommend)4 MB RAM (8 MB RAM recommended) VGA video (640 × 480)CD-ROM optional

Page 4: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

A Brief History of WindowsDirectX 5.2486DX 66-MHz (Pentium recommended)16 MB RAM (24 MB RAM recommended)VGA video (16-bit or 24-bit color recommended)CD-ROM optional

DirectX 7.1150-MHz Pentium (300-MHz Pentium II recommended)32 MB RAM (96 MB RAM recommended)VGACD-ROM or DVD drive

Page 5: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

A Brief History of Windows32-bit operating system based on NT codebase(basically “Home Edition” of Windows 2000 Professional)DirectX 8.1233-MHz (300 MHz recommend)64 MB RAM (128 MB RAM recommended)Super VGA video (800 × 600)CD-ROM or DVD drive

32-bit and 64-bit operating systems based on Windows Server 2003 SP1 code baseDirectX 10800-MHz 32-bit or x64 processor (1-GHz recommended)512 MB RAM (1 GB RAM recommended)DirectX 9 class video with 32 MB VRAM(WDDM, 128 MB VRAM, Pixel Shader 2.0, 32 bpp)DVD drive

Page 6: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

AgendaWindows Vista Overview

Windows Vista Service Pack 1Direct3D 10.1Rating System Changes

The 4 GB Limit

Page 7: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Windows Vista Gaming FeaturesGame Explorer

Parental Controls(Family Safety)

Windows Display Driver Model(WDDM)

Direct3D 10

Improved multi-channel audio

Improved widescreen support

Improved networking and IPv6 support

Page 8: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Some Internals HighlightsRDTSC-based scheduler accounting

New synchronization APIsSlim reader/writer locks, condition variables, more InterlockedXXX variants

Overhauled thread pool API

Dynamic kernel pool sizesKernel paged and non-paged pools no longer fixed sizes at boot

Multimedia Class Scheduler Service

Page 9: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Some Internals HighlightsSecurity Hardening for Services

SCM privilege settings, services firewall policy, automatic heap corruption termination

Many services disabled by default

Network-facing services hosted in distinct processes

Address Space Load RandomizationOpt-in for applications

/DYNAMICBASE linker switch in Visual Studio 2005 SP1

Applies to EXEs and DLLs

Just enable italong with /NXCOMPAT and /SAFESEH

Page 10: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Common Game Compat IssuesUser Account Control

You shouldn’t need admin rights to play a game!

Particularly important for MMOs / self-updaters to resolve

Working well with UAC includes:Embedded manifests with an execution level

SHGetFolderPath()

Authenticode signing

Do admin tasks only during setup

Do per-user tasks only during game

See DirectX SDK articles:“User Account Control for Game Developers”

“Installation Best Practices for Massively Multiplayer Online Games”

Page 11: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Common Game Compat Issues64-bit (x64) Compatibility

Does not require that your game be 64-bit native

Anti-cheat/copy-protection schemesUsually kernel-mode drivers, which must have 64-bit native Authenticode-signed versions

Poorly tested/written installations:Path assumptions

16-bit code stubs

Undocumented registry tricks

Otherwise, Wow64 works well

Page 12: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Common Game Compat IssuesWDDM / Desktop Windows Manager

“Fake full-screen” performance problems

The DWM API can help hereDwmEnableComposition( DWM_EC_DISABLECOMPOSITION );

Assuming only DirectSound hardware buffers support surround sound formats

Include multichannel SOFTWARE audio buffers in your fallback chain!

Windows XP-era issuesHeaps (reads after free), undocumented registry keys, broken DirectX version checks, obsolete API usage, etc.

Microsoft Application Verifier will find most of these!

Page 13: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Removed ComponentsAfter security review and app compat analysis

DirectPlay VoiceDirect3D Retained ModeDirectInput8’s ConfigureDevices UIDirectSound HARDWARE buffersIndeo codecsWINHLP32.EXE (.HLP files)IPX/SPX, NetBEUI

Page 14: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Windows Best PracticesThe Games for Windows Technical Requirements cover Windows XP and Windows Vista best practices

Useful whether or not you carry the branding!

Includes links to detailed samples and articles in the DirectX SDK

Microsoft’s Application Verifier will find most of the “bad behavior” compatibility problems

Important for developers and test to use it!

Combined with proper use of the public Microsoft Symbol Server, an excellent way to find serious bugs

Page 15: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Windows Vista SP1Lots of performance and usability fixes

Gaming is mostly an issue of video driver performance, which has improved greatly over the past year

Application compatibility fixesMostly non-game products

Roll-up of hot fixes to date, including:KB940105 - The “WDDM VA Space Fix”KB936710, 945149 – Multi-GPU fixes

Page 16: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

WDDM VA: <= 256 MB VRAM

XPDM

WDDM

0 GB 2GB0 GB 2GB

CodeCode Private memoryPrivate memory ApertureAperture

CodeCode Private memoryPrivate memory WDDMWDDM

Page 17: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

WDDM VA: >256 MB VRAM

XPDM

WDDM

0 GB 2GB0 GB 2GB

CodeCode Private memoryPrivate memory ApertureAperture

CodeCode Private memoryPrivate memory WDDMWDDM

!!!!!!

Page 18: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

The WDDM VA Space IssueWith KB940105, WDDM only uses process VA for lockable POOL_DEFAULT allocations

Current video drivers needed in some cases for full effect of fixNote all WDDM VA is accounted for in your process working set

See Gamefest 2007 talk for details“Why Your Windows Game Won't Run In

2,147,352,576 Bytes”

Page 19: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Direct3D 10.1Minor update to Direct3D 10Requires Windows Vista SP1 and 10.1 hardwareStrict superset of Direct3D 10

All 10.1 devices must fully support 10Direct3D 10 interfaces work identically on both 10 and 10.1 device

Extends the 10.0 API with 3 new interfaces for 10.1 class hardware features

These new interfaces cannot becreated for 10 devices

New HLSL profiles

Page 20: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Direct3D 10.1Exposes new 10.1 class hardware features

MSAA per-sample shaders

MSAA depth read-back

Independent blend modes per render target

Cube map arrays

Render to block-compressed (BC) formats

If you don’t need these features, just use the Direct3D10 interfaces and 4.0 shader profiles

Will work with 10 and 10.1 class hardware equally

Page 21: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Direct3D 10.1 InterfacesID3D10Device1

Used to create new interfaces on 10.1 devices

ID3D10BlendState1D3D10_BLEND_DESC1 has full per-RT state

Direct3D10 only let you set blend-enable and RT write mask per RT

ID3D10ShaderResourceView1D3D10_SHADER_RESOURCE_VIEW_DESC1 adds texture cube map array support

All other new features are through HLSL 4.1 profiles

New profiles: vs_4_1, gs_4_1, ps_4_1, fx_4_1

D3D10Compile* methods only support HLSL 4.0

Must use D3DX10Compile* methods for HLSL 4.1

Page 22: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

HLSL 4.1 Shader ProfilesTextureCubeArray

New texture object for cube map arrays

GetRenderTargetSampleCount

GetRenderTargetSamplePosition New ps_4_1 statements for per RT state sample access

Texture*.CalculateLevelOfDetail

Texture*.CalculateLevelOfDetailUnclamped New ps_4_1 statements for per MSAA sample access

Texture*.Gather

Texture2DMS*.GetSamplePosition Per MSAA sample access methods for x_4_1 profiles

Page 23: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Using Direct3D 10.1Requires a 10.1 capable video cardRequires Windows Vista SP1

10.1 class hardware will work as 10 class hardware on Windows Vista without the service pack

Use the current DirectX SDKNovember 2007 Tech Preview

March 2008 is RTM

D3DX10, HLSL10 compiler, SDKLayers, RefRast10, and DXUT support both 10 and 10.1

Page 24: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Using Direct3D 10.1Three basic design choices:

Only use Direct3D 10Works on 10 and 10.1 class hardware

Works on Windows Vista RTM or SP1

Only use Direct3D 10.1Works only on 10.1 class hardware

Works only on Windows Vista SP1

Support bothMost code will be identical

Requires some optional code paths for 10.1 featuresThese D3DX10 helpers can simplify this implementation

D3DX10CreateDeviceD3DX10CreateDeviceAndSwapChainD3DX10GetFeatureLevel1

Page 25: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Mixing 10 and 10.1#include “d3d10.h”

#include “d3dx10.h”

IDXGISwapChain *g_pSwapChain;

ID3D10Device *g_pDevice;

DXGI_SWAP_CHAIN_DESC sd;

// Set to desired values

HRESULT res = D3D10CreateDeviceAndSwapChain( NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pDevice );

if ( FAILED(res) ) // Error Handling

// Bind render target from swap chain

// Set up viewport

Page 26: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Mixing 10 and 10.1#include “d3d10_1.h”

#include “d3dx10.h”

IDXGISwapChain *g_pSwapChain;

ID3D10Device *g_pDevice;

DXGI_SWAP_CHAIN_DESC sd;

// Set to desired values

HRESULT res = D3DX10CreateDeviceAndSwapChain( NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pDevice );

if ( FAILED(res) ) // Error Handling

// Bind render target from swap chain

// Set up viewport

Page 27: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Mixing 10 and 10.1// Use g_pDevice in most places as a D3D10 device

// In places where you need D3D10.1 interfaces

ID3D10Device1 *pDevice1 = NULL;

hr = D3DX10GetFeatureLevel1( g_pDevice, &pDevice1 );

if (SUCCEEDED(hr))

{

// Use pDevice1 to perform D3D10.1 operations

}

else

{

// Otherwise only 10 interfaces are available

}

Page 28: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Direct3D 10 ResourcesGetting started with Direct3D 10

Sponsored Session on Friday 2:30pmD3D10: Getting from 0 to 60 Hz

Room 3016, Moscone West Hall

SIGGRAPH 2007 Course #5Introduction to Direct3D 10

Important performance guidanceGamefest 2007 talk“Windows to Reality: Getting the Most out of

Direct3D 10 Graphics in Your Games”

Page 29: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Rating System ChangesESRB new content descriptors

UI display change - “Online Rating Notice”“Mild” modified versions added (new GUIDs)If any “new” content descriptor GUIDs are populated in a GDF, then Windows Vista RTM shows it as “unrated”

Reminder: “unrated” games are not blocked by default, parents can change this setting

All existing ESRB ratings GDF data will continue to be displayed in SP1

Page 30: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Rating System ChangesSupport for Korean Game Ratings Board (GRB) system added

GRB rating data in the GDF is ignored by Windows Vista RTMExisting installations won’t change ratings systems

Windows Vista RTM Korean defaulted to ESRB

Windows Vista SP1 Korean defaults to GRB

If you have a GRB rating, populate it in your game’s GDF

Page 31: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

DirectX SDK Tools SupportGame Definition File Editor from DirectX SDK (November 2007) includes all of these SP1 changes

“Mild Language” and “Mild Lyrics” are missingDirectX SDK (March 2008) will have them all

GDF Trace is being updated for DirectX SDK (March 2008)

Page 32: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

The 4-GB LimitPhysical memory continues to grow

2 GB is common for laptops, but 4 GB is happening

4 GB is becoming common for desktops, 8 GB for workstations

Adapter cards use the 3 to 4 GB memory range

32-bit versions of Windows support up to 4 GB RAM

32-bit OSes in practice can’t really even use 4 GB

3.25, 3.33, or 3.5 GB useable RAM common with 4 GB RAM installed

Multiple video cards tie up more memory range

0 GB 3 GB 4 GB0 GB 3 GB 4 GB

AdaptersAdapters

Page 33: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

The 4-GB LimitOlder BIOS implementations were not as efficient in assigning adapter rangesIntel’s Physical Address Extension (PAE) gives the OS 36 bits of addressing instead of just 32 bits

In practice most drivers die horribly in 36-bit mode, so it’s only an option for high-end servers

Windows Vista SP1 System Control Panel changed to report “installed” RAM instead of “usable” RAM

Limitation still there

KB929605 explains the 4-GB issue in detail

Page 34: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Windows x64 (64-bit)x64 version of Windows XP

Based on Windows 2003 Server SP1 codebase

OEM only licensing

Limited driver coverage (many are still “Beta”)

128 GB of RAM

All editions of Windows Vista available in both x86 and x64 versions

Retail license allows either

Windows Vista Ultimate retail includes x64 media, otherwise use Alternative Media site

Microsoft logo programs mandate support for x64

8 to 128+ GB RAM

Page 35: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Actually, It’s a 2-GB LimitGames can’t even use 4 GB of RAM

A 32-bit application has 2 GB of virtual address spaceSome VA is tied up by other file mappings

XPDM aperture / WDDM video mappings

EXE / DLL code files

Alignment and basing fragments the ranges

Means only multiple applications and the OS can actually use more than 2 GB of physical memory

0 GB 2 GB 4 GB0 GB 2 GB 4 GB

User memoryUser memory Kernel memoryKernel memory

Page 36: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Breaking the 2-GB BarrierLarge Address Aware (LAA) 32-bit Application

Can extend your existing 32-bit applicationSome code and middleware pitfalls

3 GB of VA on Windows 32-bitNot really an option for consumer software due to special boot modes and stability impact

4 GB of VA on Windows 64-bit (x64)Works out of the box

64-bit (x64) Native Application

Runs only on Windows 64-bit (x64)To support 32-bit means two versions of the game

8 TB of VA (with defined bits for future growth)Poses porting challenges

Can’t use many deprecated technologies and APIsNo inline assembly, can use intrinsics or MASM x64All DLLs must be 64-bit native

Page 37: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Windows x64 AdvantagesFully supports >= 4 GB of physical RAM

No “missing memory” problem

LAA 32-bit applications get 4GB of VANo strange boot modes or stability problems

Full native support of both 32-bit and 64-bit applications

32-bit applications are not emulated

Best development platform

Page 38: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Managing the Transition

Page 39: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

Call to ActionWork well on Windows XP and Windows Vista

UAC and x64 compatibility are the most critical

Games for Windows technical requirements are the best guidelines available

Use the Application VerifierThat means developers, too, not just testers!

Support Windows Vista x64Windows XP x64 Edition is a “nice to have”

Basic compatibility should be straight-forward

Consider /LARGEADDRESSAWARE or a secondary 64-bit native version

Review “Why Your Windows Game Won't Run In 2,147,352,576 Bytes” from Gamefest 2007

Page 40: The Evolving Windows Gaming Platform Chuck Walbourn Software Design Engineer XNA Developer Connection Microsoft

© 2008 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

http://www.xna.com