Mainline Explicit Fencing A new era for graphics Gustavo Padovan - - PowerPoint PPT Presentation

mainline explicit fencing
SMART_READER_LITE
LIVE PREVIEW

Mainline Explicit Fencing A new era for graphics Gustavo Padovan - - PowerPoint PPT Presentation

Mainline Explicit Fencing A new era for graphics Gustavo Padovan Open First Agenda Intro to Fencing Implicit Fencing Explicit Fencing Android Sync Framework Mainline Explicit Fencing struct fence Sync de-stage


slide-1
SLIDE 1

Open First

Mainline Explicit Fencing

A new era for graphics Gustavo Padovan

slide-2
SLIDE 2

Agenda

  • Intro to Fencing
  • Implicit Fencing
  • Explicit Fencing
  • Android Sync Framework
  • Mainline Explicit Fencing
  • struct fence
  • Sync de-stage
  • fence_array
  • DRM
  • Mesa
  • Current Status

2

slide-3
SLIDE 3

Fencing

  • Ensure ordering between operations
  • Synchronize bufger sharing

– e.g.: Between GPU and Display drivers

  • Implicit fencing: userspace not aware
  • Explicit fencing: userspace aware

3

slide-4
SLIDE 4

Fences

  • Promise from the kernel
  • Work has been queued
  • Signal when fjnished
  • Userspace and drivers wait for the signal

4

slide-5
SLIDE 5

Implicit Fencing

  • No userspace knowledge/interference
  • Simple/Dumb compositors

– No bufger state information

  • But it can freeze the whole desktop!

5

slide-6
SLIDE 6

Implicit Fencing

  • Bufger C will be composed of A and B
  • Bufgers A and B can render in Parallel
  • Compositor notifjed only when both fjnishes

6

A B C

slide-7
SLIDE 7

Implicit Fencing

  • A is fast and B takes too long
  • C is blocked waiting for both to render
  • The entire desktop freezes!

7

A B C

slide-8
SLIDE 8

Explicit Fencing

  • Fences goes to userspace
  • Userspace can control synchronization
  • Smart decisions on compositors
  • Avoid blocking the entire desktop

8

slide-9
SLIDE 9

Explicit Fencing

  • No need to wait/block in userspace
  • Better for traceability/debuggability
  • Vulkan requires it

– Part of the API – Effjcient Sub-bufger processing

9

slide-10
SLIDE 10

Android Sync Framework

  • Android Explicit Fencing implementation
  • Use fd for fence passing
  • Consumer-Producer queue
  • Sync Timeline to control ordering
  • Sync Point to represent a fence
  • Sync Fence for fd passing

10

slide-11
SLIDE 11

Sync Timeline

  • Monotonically increasing counter
  • Usually one timeline per driver context

11

1 2 3 4 5 1 7 6 ...

slide-12
SLIDE 12

Sync Point

  • It is the fence
  • Represents a value on the timeline
  • Three states: active, signaled and error

12

1 2 3 4 5 1 7 6 ... 2 3

slide-13
SLIDE 13

Sync Point

  • Multiple timelines!

13

2 1 1 3 4 5 7 6 ... 2 8 1 3 4 5 7 6 ... 7 6 8 9 10 12 11 ...

slide-14
SLIDE 14

Sync Fence

  • Wrap Sync Point into a fjle
  • Also have active and signaled states
  • Shared via fd-passing to/from userspace

14

2 1 1 3 4 5 7 6 ... 2 8 1 3 4 5 7 6 ... 7 6 8 9 10 12 11 ...

slide-15
SLIDE 15

Sync Fence

  • Sync fence can be merged!
  • It can contain many Sync Points

15

2 1 1 3 4 5 7 6 ... 2 8 1 3 4 5 7 6 ... 7 6 8 9 10 12 11 ...

slide-16
SLIDE 16

Android Sync Framework - ioctls

  • sync_wait(fd)
  • sync_merge(fd1, fd2)
  • sync_fence_info(fd)

16

slide-17
SLIDE 17

Mainline Explicit Fencing

  • Started with the fence synchronization

mechanism by Maarten Lankhorst

  • Bufger synchronization between drivers

17

slide-18
SLIDE 18

struct fence

  • struct fence
  • fence->context
  • fence_signal()
  • fence_wait()
  • fence_add_callback()

18

slide-19
SLIDE 19

Sync Framework de-staging

  • Add Android Sync to staging in 2013
  • Mainly need for fd-passing
  • Removed Sync Timeline
  • Removed Sync Point
  • Reworked Sync Fence

19

slide-20
SLIDE 20

Sync File

  • Renamed Sync Fence to Sync File
  • Changed ioctl API

– Provided patch to Android's libsync

  • Removed internal kernel API
  • Used strictly for fd-passing

– sync_fjle = sync_fjle_create(fence) – fence = sync_fjle_get_fence(fd)

20

slide-21
SLIDE 21

fence_array

  • Subclass of struct fence
  • Store multiple fences
  • Useful for merged Sync File
  • Hide complexity from the drivers

21

slide-22
SLIDE 22

DRM/KMS

  • Only available for Atomic Modesetting
  • Receives fences from userspace
  • Wait for fence signal before scanout
  • Create new fences to return bufger to pipeline
  • Signal created fences at scanout

It means previous bufger can be reused

  • Entirely in DRM Core

22

slide-23
SLIDE 23

DRM/KMS: in-fences

  • in-fences: fences received from userspace
  • FENCE_FD property on each DRM Plane
  • Receives sync_fjle fds carrying fences
  • drm_atomic_helper_wait_for_fences() helper

23

slide-24
SLIDE 24

DRM/KMS: out-fences

  • out-fences: fences sent to userspace
  • One fence per DRM CRTC
  • Extended the DRM Atomic ioctl args
  • Userspace need to ask for out-fence

DRM_MODE_ATOMIC_OUT_FENCE fmag

libdrm: drmModeAtomicAddOutFences()

  • get_unused_fd() + sync_fjle_create() +

fd_install()

24

slide-25
SLIDE 25

DRM/renderer

  • Similar to KMS side
  • Extends execbufger ioctl args on each driver
  • Every driver needs sync_fjle/fences support
  • WIP on freedreno, i915 and virgl

25

slide-26
SLIDE 26

Mesa

  • EGL_ANDROID_native_fence_sync

– Create Android fence fd

  • EGL_ANDROID_wait_sync

– Make the GPU wait for fence to signal

  • WIP by Rob Clark

26

slide-27
SLIDE 27

Current Status Summary

  • Sync File syncronization de-stage: DONE
  • SW_SYNC validation de-stage: DONE
  • fence_array: DONE
  • DRM/KMS: WIP
  • DRM/renderer: WIP
  • MESA: WIP
  • intel-gpu-tests: WIP
  • Wayland: TODO

27

slide-28
SLIDE 28

Thank you to everyone involved

Daniel Vetter, Rob Clark, Greg KH, Daniel Stone, Robert Foss, Sean Paul, Stéphane Marchesin, Maarten Lankhorst, Chris Wilson, Christian König and others.

28

slide-29
SLIDE 29

Thank you!

Gustavo Padovan gustavo@padovan.org www.padovan.org www.collabora.com