Direct3D12 and the future of graphics APIs

Download Report

Transcript Direct3D12 and the future of graphics APIs

DIRECT3D12 AND THE FUTURE OF
GRAPHICS APIS
Dave Oldcorn, Direct3D12 Technical Lead, AMD
THE PROBLEM
2 | AMD Direct3D Futures | March 20th, 2014
THE PROBLEM
 Mismatch between existing Direct3D and hardware capabilities
– Lots of CPU cores, but only one stream of data
– State communication in small chunks
– “Hidden” work
 Hard to predict from any one given call what the overhead might be
 Implicit memory management
– Hardware evolving away from classical register programming
3 | AMD Direct3D Futures | March 20th, 2014
 Gap between PC ‘raw’ 3D APIs and the
hardware has opened up
 Very high level APIs now ubiquitous; easy to
access even for casual developers, plenty of
choice
 Where the PC APIs are is a middle ground
4 | AMD Direct3D Futures | March 20th, 2014
Capability, ease of use, distance from 3D engine
API LANDSCAPE
Game Engines
Frostbite
Unity
Unreal
BlitzTech
CryEngine
Application
Flash / Silverlight
D3D11
D3D9
OpenGL
D3D7/8
Opportunity
Metal
Console APIs
(register level access)
WHAT ARE THE CONSEQUENCES?
WHAT ARE THE SOLUTIONS?
5 | AMD Direct3D Futures | March 20th, 2014
SEQUENTIAL API
API input
State contributing
to draw
...
Draw
(more, earlier)
Set PS CB
PS CB
Draw x 5
Set VS CB
VS CB
Draw x 3
Set Blend
Blend state
Set PS
PS
Set RT state
RT state
Draw
Draw
Set VS VB
Draw
...
6 | AMD Direct3D Futures | March 20th, 2014
 Sequential API: state for given draw comes from arbitrary
previous time
 Some states must be reconciled on the CPU (“delayed
validation”)
– All contributing state needs to be visible
 GPU isn’t like this, uses command buffers
– Must save and restore state at start and end
THREADING A SEQUENTIAL API
 Sequential API threading
Application simulation
– Simple producer / consumer model
...
Prebuild
Thread 1
Prebuild
Thread 0
 Extra latency
 Buffering has a cost
 More threading would mean dividing tasks on finer grain
– Bottlenecked on application or driver thread
Application Render Thread
Application
Driver Thread
Queued
Buffer 0
Runtime / Driver
Queued
Buffer 1
Queued
Buffer 2
GPU Execution Queue
7 | AMD Direct3D Futures | March 20th, 2014
 Difficult to extract parallelism (Amdahl’s Law)
COMMAND BUFFER API
Application simulation
 GPUs only listen to command buffers
...
Thread 0
Thread 1
Build Cmd
Buffer
Build
Cmd
Buffer
 Let the app build them
– Command Lists, at the API level
 Solves sequential API CPU issues
Application
Runtime / Driver
Queued
Buffer 0
Queued
Buffer 1
GPU Execution Queue
8 | AMD Direct3D Futures | March 20th, 2014
BETTER SCHEDULING
 App has much more control over scheduling work
– Both CPU side and GPU
D3D11: CB building threads tend to interfere
Create thread
Driver thread
 Threads don’t really share much resource
D3D12: CB building threads more independent
 Many more options for streaming assets
Create thread
Build threads
GPU load still added but only after queuing
Create work
Render work
GPU executes
9 | AMD Direct3D Futures | March 20th, 2014
PIPELINE OBJECTS
 Pipeline objects get rid of JIT and enable LTCG for GPUs
 Decouple interface and implementation
Index
Process
?
Primitive
Generation
 We’re aware that this is a hairpin bend for many graphics
engines to negotiate.
– Many engines don’t think in terms of predicting state up
front
VS
?
Rasteriser
– The benefits are worth it
Simplified dataflow
through pipeline
PS
?
Rendertarget
Output
10 | AMD Direct3D Futures | March 20th, 2014
RENDER OBJECT BINDING MISMATCH
On-chip
root table
(1 per stage)
GPU Memory
SRD table
Pointer to table
(here, textures)
SR
GPU Memory
resource
Pointer to (+ params
of) resource
 Hardware uses tables in video memory
 BUT still programmed like a register solution
– So one bind becomes:
 Allocate a new chunk of video memory
 Create a new copy of the entire table
 Update the one entry
 Write the register with the new table base
address
CB
Pointer to table
(constant buffers)
11 | AMD Direct3D Futures | March 20th, 2014
DESCRIPTOR TABLES
 Several tables of each type of resource
On-chip
root table
SR.T[0]
Pointer to table
(textures table 0)
GPU Memory
SRD table
– Easy to divide up by frequency
SR.T[0][0]
SR.T[1]
SR.T[0][1]
SR.T[2]
SR.T[0][2]
 Tables can be of arbitrary size; dynamically indexed to
provide bindless textures
SR.T[3]
UAV
 Changing a pointer in the root table is cheap
Samp
CB.T[0]
CB.T[1]
CB.T[1][0]
Pointer to table
(constbuf table 1)
CB.T[1][1]
12 | AMD Direct3D Futures | March 20th, 2014
 Updating a descriptor in a table is not so cheap
– Some dynamic descriptors are a requirement but avoid
in general.
KEY INNOVATIONS
Innovation
CPU-side win
GPU-side win
Command buffers
Build on many threads
Control of scheduling
Lower latency
Simplified state tracking
Pipeline state objects
Link at create time
No JIT shader compiles
Efficient batched updates
Cheaper state updates
Enables LTCG
Bind objects in groups
Cheap to change group
Cheap to change group
Fits hardware paradigm
Move work to Create
Predictability
Enables optimisations
13 | AMD Direct3D Futures | March 20th, 2014
KEY INNOVATIONS
Innovation
CPU-side win
GPU-side win
Explicit Synchronisation
Efficiency
Required for bindless textures
Less overhead
Explicit Memory
Management
Efficiency
Predictability
Application flexibility
Zero copy
Control over placement
Do less
14 | AMD Direct3D Futures | March 20th, 2014
Predictability, Efficiency
Enables aggressive schedule
FEWER BUGS
NEW PROBLEMS
(AND TIPS TO SOLVE THEM)
15 | AMD Direct3D Futures | March 20th, 2014
NEW VISIBLE LIMITS
 More draws in does not automatically mean more
triangles out
– You will not see full rendering rates with triangles
averaging 1 pixel each.
– Wireframe mode should look different to filled
rendering
16 | AMD Direct3D Futures | March 20th, 2014
NEW VISIBLE LIMITS
 Feeding the GPU much more efficiently means exploring interesting new limits that weren’t visible before
 10k/frame of anything is ~1µs per thing.
 GPU pipeline depth is likely to be 1-10µs (1k-10k cycles).
 Specific limit: context registers
– Root shader table is NOT in the context
– Compute doesn’t bottleneck on context
17 | AMD Direct3D Futures | March 20th, 2014
APPLICATION IN CHARGE
 Application is arbiter of correct rendering
– This is a serious responsibility
– The benefits of D3D12 aren’t readily available without this condition
Applications must be warning-free on the debug layer
 Different opportunities for driver intervention
 Consider controlling risk by avoiding riskier techniques
18 | AMD Direct3D Futures | March 20th, 2014
APPLICATION IN CHARGE
 No driver thread in play
– App can target much lower latency
– BUT implies app has to be ready with new
GPU work
D3D11: No dead GPU time after 1st frame (but extra latency)
App Render
Frame 1
Frame 2
First work sent to driver
Driver
GPU
Dead
Time
Frame 3
Driver buffers Present; no future dead time
F2
F1
F1
F3
F2
F3
No buffered present reveals dead time on GPU
19 | AMD Direct3D Futures | March 20th, 2014
USE COMMAND BUFFERS SPARINGLY
Multiple applications running on system
 Each API command list maps to a single hardware
command buffer
Application 0 queue
CB0
CB1
CB2
 Starting / ending a command list has an overhead
– Writes full 3D state, may flush caches or idle GPU
Application 1 queue
CB0
 We think a good rule of thumb will be to target around 100
command buffers/frame
GPU executes
CB0
CB1
– Use the multiple submission API where possible
CB0
20 | AMD Direct3D Futures | March 20th, 2014
CB2
ROUND-UP
21 | AMD Direct3D Futures | March 20th, 2014
ALL-NEW
 There’s a learning curve here for all of us
 In the main it’s a shallow one
– Compared at least to the general problem of multithreaded rendering
 Multithread is always hard.
– Simpler design means fewer bugs and more predictable performance
22 | AMD Direct3D Futures | March 20th, 2014
WHAT AMD PLAN TO DELIVER
 Release driver for Direct3D12 launch
 Continuous engagement
– With Microsoft
– With ISVs
 Bring your opinions to us and to Microsoft.
23 | AMD Direct3D Futures | March 20th, 2014
QUESTIONS
24 | AMD Direct3D Futures | March 20th, 2014