modern graphics using windows 7 and direct3d 11 hardware

51
Modern Graphics Using Windows 7 and Direct3D 11 Hardware Michael Oneppo CL15

Upload: shiloh

Post on 24-Feb-2016

91 views

Category:

Documents


0 download

DESCRIPTION

CL15. Modern Graphics Using Windows 7 and Direct3D 11 Hardware. Michael Oneppo. Agenda. Windows 7 Direct3D Review Direct3D 10 Review Expanding Reach: D3D10Level9 and WARP HLSL & Shaders Direct3D 11 Multi-Threading Tessellation. DirectCompute. Direct3D 11 also offers DirectCompute - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Modern Graphics Using Windows 7 and Direct3D 11 HardwareMichael Oneppo

CL15

Page 2: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Agenda> Windows 7 Direct3D Review

> Direct3D 10 Review> Expanding Reach: D3D10Level9 and

WARP> HLSL & Shaders

> Direct3D 11> Multi-Threading> Tessellation

Page 3: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

DirectCompute> Direct3D 11 also offers DirectCompute> Meant for general purpose

programming on the GPU (GPGPU)

> P09-16 “DirectX11 DirectCompute”Chas BoydThursday, 11:30 AM, 408A

> DirectCompute Hands-on Lab> Running every day!

Page 4: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

When To Use Direct3D> Direct3D is a low-level, programmable

rasterizer> Bare-bones, meant for getting the

best performance possible> Use for

> High-performance, high-quality 3D> Utmost control over the GPU

Page 5: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Agenda> Windows 7 Direct3D Review

> Direct3D 10 Review> Expanding Reach: D3D10Level9 and

WARP> HLSL & Shaders

> Direct3D 11> Multi-Threading> Tessellation

Page 6: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Input Assembler• Fixed-function• Takes in vertices• Does tasks like indexing,

instancing

Review: The D3D10 PipelineInput

Assembler

VertexShader

Rasterizer/Interpolator

PixelShader

GeometryShader

OutputMerger

Vertex Buffer

Index Buffer

Texture

Texture

Depth/Stencil

Texture

Render Target

Stream Output

Vertex Shader• Programmable• Performs an operation on

each vertex produced by the input assemblerOutput Merger• Fixed-function• Combines the output of pixels into a rendered image• Blending• Depth Testing• Stenciling

Geometry Shader• Programmable• Performs an operation on

primitive (triangle, line segment, or point)

Rasterizer• Fixed-function• Converts primitives to pixelsPixel Shader• Programmable• Computes the color value of each pixel

Page 7: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Expanding Reach: Direct3D10 Level 9

Page 8: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Review: D3D10Level9 & Feature Levels> Direct3D 9 hardware had hundreds of

individual capabilities or “CAPS”> Ultra fine-grained feature control

> D3D10 Level 9 offers just 3 levels> FeatureLevel9_1> FeatureLevel9_2> FeatureLevel9_3

Page 9: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Feature Level 9_1: Shader model 2.0Intel 965, Geforce FXOlder S3 PartsSIS Mirage

Feature Level 9_2: Shader model 2.0Some additional features (next slide)ATI 9800ATI X200

Feature Level 9_3:Shader model 3.0 NV 6800 +ATI 1x00 series +

Super set

Super set

Page 10: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

D3D10Level9 Feature Level Codes

static const D3D10_FEATURE_LEVEL1 levelAttempts[] ={ D3D10_FEATURE_LEVEL_10_1,

D3D10_FEATURE_LEVEL_10_0, D3D10_FEATURE_LEVEL_9_3, D3D10_FEATURE_LEVEL_9_2,

D3D10_FEATURE_LEVEL_9_1,};

Page 11: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

D3D10Level9 Device Creation

for (UINT level = 0; level < ARRAY_SIZE(levelAttempts); level++)

{ hr = D3D10CreateDevice1( pAdapter, DriverType, Software, Flags, levelAttempts[level], D3D10_1_SDK_VERSION, &spDevice );

if (SUCCEEDED(hr))break;

}

Page 12: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Direct3D 10 Level 9 and DirectX> Also accessible through Direct3D 11> Direct2D automatically uses Direct3D

10 Level 9

Page 13: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

WARP 10

Page 14: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Our Criteria for WARP Development> 100% conformant with Direct3D10

Spec> Performance

> Fast enough for most mainstream scenarios

> Scales very well with the number of cores on your system

> Tested against many sophisticated applications> Games> CAD software

Page 15: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

How WARP fits in

if !(SUCCEEDED(hr)){

hr = D3D10CreateDevice1(NULL,D3D10_DRIVER_TYPE_WARP,NULL,0,D3D10_FEATURE_LEVEL_10_1,D3D10_1_SDK_VERSION,&pDevice

);}

Page 16: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

ShadersThe heart and soul of modern graphics

programming

Page 17: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

What is a Shader?> A script that tells a programmable

stage of the graphics hardware what calculations to do to achieve a material, transformation, or effect

> Written in HLSL> C++-like language that is designed for

this task> Has a huge number of convenience

features that exploit core features of the graphics card

> No pointers > Builtin variables (float4, matrix, etc)> Intrinsic functions (mul, normalize, etc)

Page 18: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Example Shader

float4 PSFloorEffect( PSSceneIn input ) : SV_TARGET{

float2 tex = float2( input.Tex.x, input.Tex.y + g_fElapsedTime*.097 );

tex.x += sin( input.Tex.y*40 )*0.001;tex.y += sin( input.Tex.y*60 )*0.001;

float4 color = BoxFilter( g_samLinearClampU, tex, 7 );

return float4( color.xyz * 0.999f, 1 );}

Page 19: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Agenda> Windows 7 Direct3D Review

> Direct3D 10 Review> Expanding Reach: D3D10Level9 and

WARP> HLSL & Shaders

> Direct3D 11> Multi-Threading> Tessellation

Page 20: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Multi-Threading

Page 21: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

D3D11 Design Goals> Asynchronous resource loading

> Upload resources, create shaders, create state objects in parallel

> Concurrent with rendering> Multithreaded draw & state

submission> Spread out render work across many

threads

Page 22: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Devices and Contexts> D3D device functionality now split into

three separate interfaces> Device, Immediate Context, Deferred

Context> Device has free threaded resource

creation> Immediate Context is your single primary

device for state, draws, and queries> Deferred Contexts are your per-thread

devices for state & draws

Page 23: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

D3D11 Interfaces

ImmediateContext

Device

DrawPrim

DrawPrim

DrawPrim

DrawPrim

DrawPrim

CreateTexture

CreateVB

CreateShader

CreateShader

CreateTexture

CreateVB

CreateShader

CreateIB

Render Thread Load Thread 2Load Thread 1

Page 24: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Deferred Contexts> Can create many deferred contexts

> Each one is single threaded (thread unsafe)> Deferred context generates a Command

List> Command list is consumed by Immediate or

Deferred contexts> No read-backs or downloads from the

GPU> Queries> Resource locking

> Lock with DISCARD is supported on deferred contexts

Page 25: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

D3D11 InterfacesImmediate

ContextDeferredContext

DeferredContext

Command List Command List

DrawPrim

DrawPrim

DrawPrim

DrawPrim

DrawPrim

DrawPrim

DrawPrim

DrawPrim

DrawPrim

Execute

Execute

Page 26: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

State Inheritance> Command lists are optimized for single

use> Less optimized for precompiled usage

scenarios> No state is inherited from immediate

context> Deferred contexts start out with default

state> Dynamic state can be injected via

resources> Constant buffers, textures, queries, VBs,

etc.

Page 27: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

State Inheritance> State recorded in a command list does

not affect immediate context at all> Can optionally persist immediate context

state> Fastest performance: reset immediate

context state after command list execution, when executing command lists back-to-back

Page 28: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

D3D11 on D3D10> D3D11 API is available on D3D10

hardware & drivers> D3D10 drivers can be updated to

better support some D3D11 features> Works on Windows Vista too!

Page 29: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Tessellation

Why Tessellate?

Page 30: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Pre-Tesselated Mesh: ~5500 kB

Asset Size: Comparison

Sub-D Mesh: ~130 kB

Page 31: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

More Reasons> Continuous level of detail> Skin at the control mesh level> Faster dynamic computations at the

control mesh level> Cloth> Collisions

Page 32: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Direct3D 11 Tessellation Design

Page 33: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

InputAssembler

VertexShader

Vertex Buffer

Index Buffer

Texture

GeometryShader Texture

Stream OutputRasterizer/Interpolator

PixelShader

OutputMerger

Depth/Stencil

Texture

Render Target

HullShader Texture

DomainShader Texture

Tessellator

Page 34: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

New Primitives

Page 35: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Hull Shader> Operates per input primitive

> E.g. patch> Computes control point transforms

> E.g. Basis Change> Computes tessellation factors per edge

of generated patches

Page 36: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Tessellator> Inputs

> Takes in “Tessellation Factors” provided by the Hull shader

> Tess factors per-side in the range of [2.0..64.0]

> Outputs> UV or UVW domain points> Connectivity of those points (tris, lines)> No adjacency information

> Many possible partitioning schemes

Page 37: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Domain Shader> Operates on each point generated by

the tessellator> Gets ALL control points as input

> Control points and patch constant data are passed directly to the domain shader

> Evaluate primitive surface to compute position of points> Convert from U,V space into positions,

tangents

Page 38: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

InputAssembler

VertexShader

Vertex Buffer

Index Buffer

Texture

GeometryShader Texture

Stream Output

HullShader Texture

DomainShader Texture

Tessellator

Page 39: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Basic Tessellation

Hull Shaders & Domain Shaders

demo

Page 40: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

This is a lot…> There’s a lot of complexity here,

but it’s worth it> D3D11 can target almost any

surface algorithm you want> Bezier> NURBs> Dynamic and static tessellation> Displacement> Subdivision

and more…

Page 41: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

No Compromise: Details & Performance!> Low poly count for high

performance> High poly count for

refined detail> Iteratively refine to

produce a smooth limit surface

> Modern implementations allow for creases and other hard edges

> Detail can be layered on with displacement & normal maps

Page 42: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

FBX Format: Industry Momentum

> Data transport for geometry, textures & lighting and animation

> Integration with most common digital content creation (DCC) applications

> Support for Direct3D 11 Tessellation for “round trip” iterations> Create in your application of choice> Export via FBX> Review in DX rendering engine

Page 43: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

SubD11 (a.k.a. “Sebastian”)

demo

Page 44: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

The Platform Update for Windows Vista> Down-level availability of key Windows

7 features on Windows Vista> Available on Windows Update> More information:

> http://support.microsoft.com/kb/971644

44

Page 45: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Additional Resources> DirectX on MSDN:

> http://msdn.microsoft.com/directx> Windows 7 SDK:

> http://msdn.microsoft.com/windows> August 2009 DirectX SDK:

> http://msdn.microsoft.com/directx/sdk

Page 46: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation

forms online atMicrosoftPDC.com

Page 47: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Learn More On Channel 9> Expand your PDC experience through

Channel 9

> Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses

channel9.msdn.com/learnBuilt by Developers for Developers….

Page 48: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

© 2009 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.

Page 49: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Hull Shader Syntax

[patchsize(12)][patchconstantfunc(MyPatchConstantFunc)]MyOutPoint main(uint Id : SV_ControlPointID, InputPatch<MyInPoint, 12> InPts){ MyOutPoint result; …

result = TransformControlPoint( InPts[Id] );

return result;}

Page 50: Modern Graphics Using Windows 7 and Direct3D 11 Hardware

Domain Shader Syntax

void main( out MyDSOutput result, float2 myInputUV : SV_DomainPoint, MyDSInput DSInputs, OutputPatch<MyOutPoint, 12> ControlPts, MyTessFactors tessFactors ){ …

result.Position = EvaluateSurfaceUVtoXYZ( ControlPoints, myInputUV );}

Page 51: Modern Graphics Using Windows 7 and Direct3D 11 Hardware