Anantha Kancherla Group Program Manager Microsoft Corporation PC04

Preview:

Citation preview

Writing Your Application to Shine on Modern Graphics Hardware DirectX for mainstream applications

Anantha KancherlaGroup Program ManagerMicrosoft Corporation

PC04

Agenda

Where is Graphics Hardware headed How does Win7 adapt to HW changes

The expanding role of DirectX in Windows 7

Addressing new graphics scenarios and fundamentals in Windows 7 timeframe

Increasing generalism. Array of SIMD ALUs Arithmetic, flow control, read,

write Some fixed function units such as

tessellation

Courtesy: Tom’s Hardware

Order of magnitude difference between low and high end

Windows 7's Usage of the GPU

Continues from Windows Vista… Media Center UI Video Playback Desktop Window Manager (DWM)

Windows 7 DWM uses Direct3D10.1 API Scales in performance all the way from low end

integrated to high end GPUs Shaders are used for blurs in the Glass Windows 7 cuts memory consumption is cut by

50% per window More and richer animations of the thumbnails

High DPI High Color

Description Horizontal Vertical Width (in) Panel DPI 15.4" WXGA 1280 768 15.4 9717" WXGA+ 1440 900 17 10014.1" WXGA 1280 768 14.1 10615.4" WXGA+ 1440 900 15.4 11013.3" WXGA 1280 768 13.3 11217" WSXGA+ 1680 1050 17 11714.1" WXGA+ 1440 900 14.1 12012.1" WXGA 1280 768 12.1 12313.3" WXGA+ 1440 900 13.3 12715.4" WSXGA+ 1680 1050 15.4 12917" WUXGA 1920 1200 17 13315.4" WUXGA 1920 1200 15.4 147

High DPI Displays are Common

Improvements in Windows UI & IE

Automatic configuration in OOBE

Promotion the Control Panel UI for DPI

High Color

Wider Gamut Bigger than sRGB eg. xvYCC, AdobeRGB

Higher precision Higher Dynamic Range

High Color

Wider Gamut Bigger than sRGB eg. xvYCC, AdobeRGB

Higher precision Higher Dynamic Range

Windows 7 Provides:Color Calibration ToolGamma LUT Loader

Systems configurations impact Graphics

Laptop sales are now >50% of PC sales

Overview of Changes in Windows 7To adapt to HW changes

Addresses ranges of GPU performance characteristics Cuts memory consumption by 50% per window

High DPI Number of changes in User Interface and IE

Color: Color Calibration Wizard and LUT Loader

Laptop scenarios Monitor hot plug detect

Now let us look at how you can take advantage of this powerful hardware…

Agenda

Where is Graphics Hardware headed How does Win7 adapt to HW changes

The expanding role of DirectX in Windows 7

Addressing new graphics scenarios and fundamentals in Windows 7 timeframe

Graphics APIs for Rich Client Applications

GDI GDI+ DirectX WPF

Native Development

Managed Development

Hardware Acceleration

ImmediateMode

PrimarilyRendering

Input, Focus, Events, Controls

DirectX: When the application needs control over features and performance

WPF: When the application needs richness but needs to be built quickly and there is no need for fine grained control over hw performance and features

GDI: When the application needs to work on all Microsoft OSs and the lowest common denominator functionality is sufficient

When to use which API

Incr

easi

ng H

W E

xplo

itive

ness

Originally designed for Games and to abstract HW

DX9 introduced Floating point shaders HLSL to program shaders Windows Vista adopted it for many features:

UI: Aero and MCE Image Processing: Windows Photo Gallery

DX10 was designed for more than games Clean API to minimize API overhead Consistent implementation across HW – No Caps Refactored Infrastructure API: DXGI

DirectX Evolution

DirectX == High Performance Graphics

Broad Usage of Direct3D Today

Typical user is someone who needs great performance and very custom/rich rendering

Mapping applications: Eg. VirtualEarth and Google Earth

UI and Application Frameworks: WPF, XNA

User Interfaces: MCE, Zune, DWM

Workstation Applications: Eg. Dassault Systèmes-3DLive, AutoDesk

Applications, Bentley Microstation, SoftImage XSI

Dassault Systèmes – 3DLive

3D Product LifeCycle Management with DirectX10

demo

Jean BuffetR&D Product ManagerDassault Systèmes

3DLive : feature at glance

Dassault Systèmes 3DLive

3DLive DirectX10 in Action on Windows 7

Demo

DS - 3D Visualization Objectives Providing “Life-like experience” of the virtual

product in 3D Ambiance, animation Realistic rendering (shaders like Car Paint, Sky shader) AAA game level rendering for CAD : Ambient Occlusion,

Full Scene AA, IBL, soft shadows, true transparency Best graphics performances to reach high interactivity (60

fps)

While matching CAD constraints Ability to manage large number of triangles (10 M tri to 100 M tri) : Level of Details, viewpoint-dependent tessellationAbility to manage hundreds of textures & shaders Reach an interactive frame rate (20 fps)Support of CAD-specific visualization mode : wireframe, outlines, hidden edges, hidden line removal

Developer journey from OpenGL to DirectX10 D3D10 is the right level of API for Dassault Systèmes 3D - PLM Applications

D3D9 were gaming oriented API New features proposed by D3D10 allowed developers to implement advanced 3D &

CAD-specific features “Geometry Shader” is the D3D10 answer for specific 3D entities

Line type, line thickness, 3D marker…

ChallengesTechnical Challenge

Full Shader pipe-line at application levelHaving a native Vertex Buffer/Index Buffer managementEmulate the OpenGL immediate mode in an efficient way

Review your design patternMore work at apps level but gives more room for optimizationGood opportunity to rework applicative architecture

Follow Up

http://www.3ds.com

http://www.3dvia.com

Area Existing API(s) Challenges

3D DX3…DX10 Not always available:•No HW•Server•Remoted

2D GDI, GDI+ Quality, Performance

Text GDI Quality, Not up to date

Imaging GDI, GDI+, WIC Extensive format support, Security

Device Control GDI Outdated notion of HW config

Current Platform Challenges

Area Existing API(s) Challenges

3D D3D3…D3D10 Not always available:•No HW•Server•Remoted

Direct3D 10.1

2D GDI, GDI+ Quality, Performance

Text GDI Quality, Not up to date

Imaging GDI, GDI+, WIC Extensive format support, Security

Updated WIC

Device Control GDI Outdated notion of HW config

DXGI 1.1

Advancing the platform

Area Existing API(s) Challenges

3D D3D3…D3D10 Not always available:•No HW•Server•Remoted

Direct3D 10.1

2D GDI, GDI+ Quality, Performance Direct2D

Text GDI Quality, Not up to date DirectWrite

Imaging GDI, GDI+, WIC Extensive format support, Security

Updated WIC

Device Control GDI Outdated notion of HW config

DXGI 1.1

Advancing the platform

Advancing the platform

Introducing…

Direct2DDirectWrite

DXGKernel

DXGI

Win32K

GDI+

USER

Direct3D 11Direct3D 10

DWMDirect2D

DirectWrite

GDI

WIC

DXVA

Microsoft Confidential

Hardware

Direct3D9

Properties of DirectX APIs

Primary focus: Large scale Win32 application developers with existing

codebases Designed around needs of Windows UI, Internet

Explorer, Microsoft Office Side-by-side components

Can mix-n-match Interface based APIs w/ C/C++ Hardware accelerated Immediate mode rendering Interops with older Win32 APIs Available on Windows Vista

Direct3D 10.1 is the Foundation

Always available: D3D10L9 for DX9 HW Full SW emulation when there is no HW Fully remoted via primitives and bitmaps

Supports GDI compatible color channel ordering

Direct3D 10 HW is a Premium Logo requirement in Vista

Direct3D 11: Increasing GPU Utility

Strict superset of Direct3D10 Runs on Direct3D 9, 10 and 11 HW New Graphics features

Improved multi-threading support (Need new HW) Tessellation (Need new HW) Subroutine support in shaders

Compute Shader Enables non-Graphics usages (GPGPU) Integrated with graphics for imaging usage Program with familiar HLSL and D3D resource model

PC03: Unlocking the GPU with Direct3D ES21: Windows 7 Presentation Virtualization: Graphics Remoting

( RDP) Today and Tomorrow

Direct2D: New in Windows 7

Rendering Focused Immediate Mode API: 2D Vectors & Geometry, Bitmaps and Text Hardware and Software Pipelines

Built for Performance on Direct3D 10.1 Interoperable with Direct3D and GDI High Quality Rendering:

Per Primitive Anti-Aliasing and MSAA via Direct3D

Remoted via Direct3D 10.1 Printing support via XPS

DirectWrite: New in Windows 7

Modern Typography Enables world-wide applications ClearType advances Works with any rendering technology Hardware accelerated via Direct2D

API Interop

All DirectX APIs interop with each other. Eg. D2D/D3D, DWrite/D2D etc.

DirectX APIs interop with GDI Interop between DX and GDI is high

performance in Win7 Directly blitting to front buffer via GDI can

cause unpredictable results GetDC() is the preferred way

DX/GDI Interop

//DX CodeCreateRenderTarget()Draw()Present()

// GDI CodeGetDC()DrawLine()ReleaseDC()

Windows Vista

Windows 7

Copy 1

Copy 2

More Details…

Direct2D, DirectWrite and Interop between APIs are covered in:

PC18: Introducing Direct2D and DirectWrite Hands on Lab: DirectX

Performance with DirectX

Very important to scale graphics content by HW Since GPUs vary widely in performance Identify min-bar and tiers of performance

Important to always respond Main loop should handle only input and rendering No disk or network I/O and computation in this loop

Have a benchmark mode in your application

PIX is a powerful performance debugging tool in DX SDK

PIX

demo

GDI+ in Win7

GDI+ is largely unchanged. Except: v1.1 is default

CMYK support Effects (Blur, Sharpen, Tint etc.) GDI+ 1.1 uses WIC for image loading

v1.0 is deprecated can be forced via manifest

DirectX Going Ahead

DirectX is for all applications that need high performance graphics, not just games Windows 7 Desktop itself is now built on

Direct3D 10.1 Direct3D 10.1 is the Foundation API Two new DirectX APIs in Win7

Direct2D and DirectWrite PIX in DX SDK helps with tuning

performance Longer term DirectX APIs will replace GDI

functionality

Agenda

Where is Graphics Hardware headed How does Win7 adapt to HW changes

The expanding role of DirectX in Windows 7

Addressing new graphics scenarios and fundamentals in Windows 7 timeframe

High Color

Areas of Application

Primarily Imaging Applications Medical Visualization Presentation Photography CAD

Windows7 High Color Support

3 new formats added in WIC, WCS and DXGI Works in full-screen and overlay mode

10 bpc sRGB 10 bpc XR 16bpc HDR

Precision Higher (Medical, Technical)

Same as 8-bit High

Gamut sRGB (below current camera sensors)

Matches current cameras, TVs (eg. xvYCC)Covers human vision

High

Dynamic Range Low Low High

Power/Perf requirements

Same as 8-bit Same as 8-bit High

Dynamic HW Changes

Common Scenarios

Laptop docking/un-docking USB Displays plug/un-plug Other full-screen exclusive mode

applications launching Hybrid laptops where GPUs switch

Dynamic System Changes GDI Applications

Heed WM_DISPLAYCHANGE message Tells you when the resolution has changed Always stick with the desktop resolution

Unless for perf Adapt your layout if needed

Heed WM_DEVICECHANGE message Tells you when laptop docks/undocks

Dynamic System Changes DX Applications

Monitor via return value from IDXGISwapChain::Present() API and respond based on the return code: DXGI_STATUS_OCCLUDED - Wait DXGI_STATUS_MODE_CHANGED – “Reset” adapt to the new mode DXGI_ERROR_DEVICE_REMOVED – Stop rendering and wait for

WM_DEVICECHANGE message to re-enumerate HW and re-create device.

IDXGISwapChain::GetDeviceRemovedReason() returns: DXGI_ERROR_DEVICE_HUNG or DXGI_ERROR_DEVICE_RESET for

HW hangs DXGI_ERROR_REMOTE_DISCONNECT tells the app if the network

dropped off

Graphics Fundamental: High DPI

This was very surprising to us…

Monitor Max Resolution

% Set to Maximum

1280X1024 56%1400X1050 79%1600X1200 32%1680X1050 66%1920X1050 39%1920X1200 78%Avg. set to default 55%

User's Chosen Resolution

% using that resolution

640X480 1%800X600 7%1024X768 57%1280X1024 3%1600X1200 32%Total 100.00%

Details Users with Max Resolution of 1600X1200

Almost half of all of users are not

configuring their display to native

resolution (!)

Users are lowering their screen resolution to get larger text…

High DPI Issues

Clipped Text

Layout Issues & Image Size Issues

Pixilated BitmapsLayout Issues

Blurry UI

Mismatched Font Sizes

DPI Virtualization

Feature introduced in Vista, Applies to apps which do not declare DPI awareness

Via manifest or via SetProcessDPIAware() Win32 subsystem returns system metrics calls as if the app were

running at 96 DPI (values returned from GetSystemMetrics(), GetDeviceCaps, DEFAULT_GUI_FONT, etc.)

DWM scales the application window when it composes the desktop

DPI Virtualization is a stop-gap, not a solution

High DPI Hands on Lab

High DPI Solutions

White-paper for fixing desktop applications http://go.microsoft.com/fwlink/?LinkID=12958

8

White-paper on how to use IE8 zoom functionality to fix web apps http://msdn.microsoft.com/en-us/library/cc84

9094.aspx

Summary

Graphics HW these days are extremely powerful

Used properly, tremendous end-user benefits can be realized

However it is important to be aware of the diversity of the PCs out there

Adapt your application to take advantage of this power yet insulate it from the diversity via DirectX APIs

Call to Action

Learn to use DirectX APIs to create rich client applications

Take advantage of new functionality afforded by Win7 such as High Color

Make your application robust against dynamic system changes

Address High DPI issues in your applications

Attend the other DirectX sessions: PC18: Introducing Direct2D and DirectWrite PC03: Unlocking the GPU with Direct3D

Hands on Lab has a number of DirectX tutorials

Dgtsig @ Microsoft.com

http://msdn.microsoft.com/DirectX

Follow Up

Evals & Recordings

Please fill

out your

evaluation for

this session at:

This session will be available as a recording at:

www.microsoftpdc.com

Please use the microphones provided

Q&A

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista 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 changing 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.

Recommended