GS-4139, RapidFire for Cloud Gaming, by Dmitry Kozlov
1. RAPIDFIRE
API
FOR
CLOUD
GAMING
BRUNO
STEFANIZZI
CHRISTOPHER
MAYER
DMITRY
KOZLOV
2. AMD RapidFire Technology
! Most
cloud
gaming
soluJons
are
CPU
based
! RapidFire
is
dedicated
cloud
hardware
and
soQware
soluJon
with
API
to
simplify
integraJon
– Deliver
more
HD
games
streams
per
GPU
with
low
latency
-‐>
6
x
HD
720p30
fps
– Leverage
AMD
hardware
on
both
server
and
client
Low
Latency
HD
Image
Quality
2
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
Mul?ple
Streams
Virtualiza?on
Enablement
3. AMD RapidFire Technology
!
Design
for
many
use
cases
and
workflows
High
resolu?on
3
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
Collabora?ve
Virtual
Desktop
Adapta?ve
to
Network
environment
4. GCN
Render
Graphics
Frame
Grab
VCE
Notebook
4
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
Low-‐latency
frame
capture
HD
mul?-‐stream
Compression
Handheld
Desktop
5. AMD RapidFire Technology
Server
Client
System
Memory
CPU
H264
Encode
decode
RAPIDFIRE
API
Network
DRIVER
GPU
Keyboard
Mouse
Frame
Buffer
Keyboard
Mouse
events
Keyboard
Mouse
HW
H264
Encode
5
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
6. RAPIDFIRE
TECHNOLOGY
DATA
FLOW
OVERVIEW
Client
Server
GAME
SERVER
NETWORK
NETWORK
Radeon
Sky
GPU
3D
ENGINE
ENCODE
FRAME
BUFFER
6
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
! RF
API
module
! external
module
DECODE
UI
FRAME
BUFFER
7. RAPIDFIRE
TECHNOLOGY
SERVER
SIDE
DATA
FLOW
Radeon
Sky
GPU
3D
ENGINE
EXECUTION
RESOURCES
FRAME
BUFFER
ENCODE
7
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
! Network
component
transfers
UI
events
from
the
client
to
the
server
Server
GAME
INSTANCE
NETWORK
8. RAPIDFIRE
TECHNOLOGY
SERVER
SIDE
DATA
FLOW
Radeon
Sky
GPU
3D
ENGINE
EXECUTION
RESOURCES
FRAME
BUFFER
ENCODE
8
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
! Network
component
transfers
UI
events
from
the
client
to
the
server
Server
GAME
INSTANCE
NETWORK
! Game
server
sends
commands
to
GPU
to
draw
next
frame
9. RAPIDFIRE
TECHNOLOGY
SERVER
SIDE
DATA
FLOW
Radeon
Sky
GPU
3D
ENGINE
EXECUTION
RESOURCES
FRAME
BUFFER
ENCODE
9
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
! Network
component
transfers
UI
events
from
the
client
to
the
server
Server
GAME
INSTANCE
NETWORK
! Game
server
sends
commands
to
GPU
to
draw
next
frame
! GPU
distributes
the
work
among
execuJon
resources
and
produces
resulJng
frame
into
the
frame
buffer
10. RAPIDFIRE
TECHNOLOGY
SERVER
SIDE
DATA
FLOW
Radeon
Sky
GPU
3D
ENGINE
EXECUTION
RESOURCES
FRAME
BUFFER
ENCODE
10
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
! Network
component
transfers
UI
events
from
the
client
to
the
server
Server
GAME
INSTANCE
NETWORK
! Game
server
sends
commands
to
GPU
to
draw
next
frame
! GPU
distributes
the
work
among
execuJon
resources
and
produces
resulJng
frame
into
the
frame
buffer
! VCE
is
performing
asynchronous
frame
sequence
encoding
into
H264
video
stream
and
the
data
is
fetched
to
system
memory
by
the
app
11. RAPIDFIRE
TECHNOLOGY
SERVER
SIDE
DATA
FLOW
Radeon
Sky
GPU
3D
ENGINE
EXECUTION
RESOURCES
FRAME
BUFFER
ENCODE
11
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
! Network
component
transfers
UI
events
from
the
client
to
the
server
Server
GAME
INSTANCE
NETWORK
! Game
server
sends
commands
to
GPU
to
draw
next
frame
! GPU
distributes
the
work
among
execuJon
resources
and
produces
resulJng
frame
into
the
frame
buffer
! VCE
is
performing
asynchronous
frame
sequence
encoding
into
H246
video
stream
and
the
data
is
fetched
to
system
memory
by
the
app
! SW-‐encoded
audio
stream
is
merged
with
the
video
stream
and
sent
to
the
network
12. RAPIDFIRE
TECHNOLOGY
CLIENT
SIDE
DATA
FLOW
! Game
client
receives
H264
stream
from
the
server
using
RTSP
protocol
Client
Radeon
GPU
NETWORK
GAME
CLIENT
DECODE
DECODE
AUDIO
UI
Audio
device
Input
devices
12
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
FRAME
BUFFER
13. RAPIDFIRE
TECHNOLOGY
CLIENT
SIDE
DATA
FLOW
! Game
client
receives
H264
stream
from
the
server
using
RTSP
protocol
Client
Radeon
GPU
NETWORK
GAME
CLIENT
H264
DECODE
DECODE
UI
Audio
device
Input
devices
13
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
FRAME
BUFFER
! The
client
sends
the
stream
to
Radeon
GPU
which
performs
H264
hardware
decoding
to
the
frame
buffer
14. RAPIDFIRE
TECHNOLOGY
CLIENT
SIDE
DATA
FLOW
! Game
client
receives
H264
stream
from
the
server
using
RTSP
protocol
Client
Radeon
GPU
NETWORK
GAME
CLIENT
DECODE
DECODE
AUDIO
Input
devices
! Sound
stream
is
decoded
using
soQware
audio
codec
and
sent
to
audio
hardware
UI
Audio
device
14
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
! The
client
sends
the
stream
to
Radeon
GPU
which
performs
H264
hardware
decoding
to
the
frame
buffer
FRAME
BUFFER
15. RAPIDFIRE
TECHNOLOGY
CLIENT
SIDE
DATA
FLOW
! Game
client
receives
H264
stream
from
the
server
using
RTSP
protocol
Client
Radeon
GPU
NETWORK
GAME
CLIENT
DECODE
DECODE
AUDIO
! The
client
sends
the
stream
to
Radeon
GPU
which
performs
H264
hardware
decoding
to
the
frame
buffer
! Sound
stream
is
decoded
using
soQware
audio
codec
and
sent
to
audio
hardware
UI
! UI
events
are
collected
by
the
client
and
sent
over
the
network
to
the
server
Audio
device
15
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
Input
devices
FRAME
BUFFER
16. THE
RAPIDFIRE
API
COMPONENTS
" Server
component
The
server
component
provides
funcJons
for
the:
‒ Encoding
of
video
and
audio
data
‒ Color
space
conversion
‒ Capturing
of
the
desktop
‒ Handling
of
mulJple
render
targets
‒ Interoperability
with
OpenGL,
D3D9
and
D3D11
" Network
component
The
Network
component
is
a
sample
implementaJon
of
video
and
audio
streaming
based
on
the
LIVE555
Media
Server.
" User
Interface
The
UI
component
provide
funcJons
to:
‒ Capture
user
events
on
the
client
‒ Send
the
events
to
the
server
for
processing
" Client
component
The
client
component
provides
funcJons
for:
‒ Decoding
of
video
and
audio
streams
‒ Color
space
conversion
‒ Interoperability
with
OpenGL,
D3D9
and
D3D11
16
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
17. THE
RAPIDFIRE
API
THE
SERVER
COMPONENT
IniJalizaJon
Render
Loop
Create
RenderTarget
Draw
to
free
RenderTarget
rfCreateEncodeSession
rfRegisterRenderTarget
rfCreateEncoder
rfEncodeFrame
rfGetEncodedFrame
rfRtspServerSendFrame
Done?
17
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
18. THE
RAPIDFIRE
API
THE
SERVER
COMPONENT
IniJalizaJon
Create
RenderTarget
rfCreateEncodeSession
rfRegisterRenderTarget
rfCreateEncoder
" rfCreateEncodeSession
‒ Creates
an
encoding
session
on
the
server.
The
sessions
encapsulates
the
following
components:
‒ Rendering
context/device
‒ Compute
context
that
is
used
for
the
color
space
conversion
‒ Render
targets
‒ Desktop
‒ The
encoder:
SW,
VCE
or
IDENTITY
‒ The
following
session
types
are
supported
‒ OpenGL
‒ DX9
/
DX9Ex
‒ DX11
‒ Desktop
capturing
18
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
19. THE
RAPIDFIRE
API
THE
SERVER
COMPONENT
IniJalizaJon
Create
RenderTarget
rfCreateEncodeSession
rfRegisterRenderTarget
rfCreateEncoder
" rfCreateEncodeSession
‒ CreaJng
an
OpenGL
session
that
uses
the
VCE
HW
encoding
RFProperties
props[]
=
{
RF_GL_GRAPHICS_CTX,
(RFProperties)hGLRC,
RF_GL_DEVICE_CTX,
(RFProperties)hDC,
RF_ENCODER,
(RFProperties)RF_VCE,
0
};
//
Create
RapidFire
encoding
session
RFEncodeSession
session
=
rfCreateEncodeSession(props);
" rfRegisterRenderTargt
for
(unsigned
int
i
=
0;
i
<
NUM_RENDER_TARGETS;
i++)
{
rfRegisterRenderTarget(session,
RF_RT_GL_TEXTURE,
uiTexName[i],
uiWidth,
uiHeight,
&renderTargetIdx[i]));
}
‒ Input:
Name
of
the
OpenGL
Texture,
dimension
of
the
texture
‒ Output:
The
index
used
by
RF
to
idenJfy
this
render
target
19
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
20. THE
RAPIDFIRE
API
THE
SERVER
COMPONENT
IniJalizaJon
" rfCreateEncoder
‒ CreaJng
an
Encoder
using
a
preset
configuraJon
rfCreateEncoder(session,
uiWidth,
uiHeight,
RF_ENCODE_FAST)
Create
RenderTarget
‒ The
following
presets
are
supported:
rfCreateEncodeSession
rfRegisterRenderTarget
‒ RF_ENCODE_FAST
‒ RF_ENCODE_BALANCED
‒ RF_ENCODE_QUALITY
" rfCreateEncoder2
‒ CreaJng
an
encoder
using
properJes
rfCreateEncoder
//
Create
encoder
using
properties
RFProperties
props[]
=
{
RF_ENCODER_PROFILE,
(RFProperties)RF_MAIN,
RF_ENCODER_LEVEL,
(RFProperties)41,
RF_ENCODER_BITRATE,
(RFProperties)6000000,
RF_ENCODER_FPS,
(RFProperties)30,
0
};
rfCreateEncoder2(session,
uiWidth,
uiHeight,
props));
20
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
21. THE
RAPIDFIRE
API
THE
SERVER
COMPONENT
Render
Loop
" rfEncodeFrame
rfEncodeFrame(session,
renderTargetIdx[uiCurrentRT]));
Draw
to
free
RenderTarget
rfEncodeFrame
rfGetEncodedFrame
rfRtspServerSendFrame
Done?
‒ Non-‐blocking
call
to
submit
a
frame
for
encoding
" rfGetEncodedFrame
//
Check
if
encoded
frame
is
ready
if
(rfIsEncodedFrameReady(session))
{
if
(rfGetEncodedFrame(session,
&uiBitStreamSize,
(void**)&pBitStreamdata)
==
RF_STATUS_OK)
{
if
(uiBitStreamSize
>
0)
{
//
Send
encoded
frame
to
Network
rtspStatus
=
rfRtspServerSendFrame(rtsp_sn,
pBitStreamdata,
uiBitStreamSize,
tv.tv_sec,
tv.tv_usec,
1);
}
}
}
‒ Check
first
if
a
frame
is
ready
‒ If
a
frame
is
available
get
the
data
to
system
memory
‒ Send
the
frame
over
the
network
to
the
client
21
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
22. THE
RAPIDFIRE
API
THE
CLIENT
COMPONENT
IniJalizaJon
Render
Loop
Create
Target
Textures
Wait
to
receive
frame
rfCreateDecodeSession
rfDecodeFrame
rfRegisterTargetTexture
Display
frame
using
Target
Texture
rfCreateVideoDecoder
22
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
Done?
23. THE
RAPIDFIRE
API
THE
CLIENT
COMPONENT
IniJalizaJon
" rfCreateDecodeSession
‒ Creates
a
decoding
session
on
the
client.
The
sessions
encapsulates
the
following
components:
Create
Target
Textures
rfCreateDecodeSession
rfRegisterTargetTexture
rfCreateVideoDecoder
‒ Rendering
context/device
‒ Compute
context
that
is
used
for
the
color
space
conversion
‒ Target
Textures
‒ Decoder:
SW
or
UVD
‒ The
following
session
are
supported
‒ OpenGL
‒ DX9
/
DX9Ex
‒ DX11
23
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
24. THE
RAPIDFIRE
API
THE
CLIENT
COMPONENT
IniJalizaJon
Create
Target
Textures
rfCreateDecodeSession
rfRegisterTargetTexture
rfCreateVideoDecoder
" rfCreateDecodeSession
RFProperties
props[]
=
{
RF_GL_GRAPHICS_CTX,
(RFProperties)hGLRC,
RF_GL_DEVICE_CTX,
(RFProperties)hDC,
RF_DECODER,
(RFProperties)RF_UVD,
0
};
//
Create
RapidFire
decoding
session
RFDecSession
session
=
rfCreateDecodeSession(props);
‒ Creates
an
OpenGL
session
that
uses
the
UVD
decoder
" rfRegisterTargetTexture
rfRegisterTargetTexture(session,
uiTextureName);
‒ Registers
an
OpenGL
texture
‒ The
texture
will
be
used
to
store
the
decoded
frame
24
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
25. THE
RAPIDFIRE
API
THE
CLIENT
COMPONENT
IniJalizaJon
" rfCreateVideoDecoder
rfCreateVideoDecoder(session,
uiWidth,
uiHeight);
Create
Target
Textures
‒ Create
the
actual
decoder
rfCreateDecodeSession
rfRegisterTargetTexture
rfCreateVideoDecoder
25
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL
26. THE
RAPIDFIRE
API
THE
CLIENT
COMPONENT
Render
Loop
" rfDecodeFrame
rfDecodeFrame(session);
Wait
to
receive
frame
rfDecodeFrame
‒ Decodes
a
frame
‒ The
decoded
frame
is
stored
in
the
registered
texture
‒ Now
the
applicaJon
can
use
the
texture
to
display
the
frame
Display
frame
using
Target
Texture
Done?
26
|
PRESENTATION
TITLE
|
DECEMBER
4,
2013
|
CONFIDENTIAL