SlideShare a Scribd company logo
Gallium3D - Mesa’s New Driver Model


                                             Chia-I Wu

                                          olvaffe@gmail.com


                                          Mar 27, 2011




Chia-I Wu (olvaffe@gmail.com)       Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   1 / 24
Agenda


Who Am I?




   main developer of Mesa EGL stack
   Android(-x86) port of Mesa
   experiences in OpenGL stacks




  Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   2 / 24
Agenda


Who Am I?




   main developer of Mesa EGL stack
   Android(-x86) port of Mesa
   experiences in OpenGL stacks

   a member of 0xlab




  Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   2 / 24
Agenda


Agenda




   OpenGL and Linux: DRI
   classic and Gallium3D driver models
   how does it make a developer happy




  Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   3 / 24
OpenGL and Linux


Mesa v.s. Proprietary Drivers




Isn’t this the case?


                                                       Mesa         Proprietary
                                      stability         .               v
                                   performance          .               v
                                    feature set         .               v
                                      it’s free         v                .




   Chia-I Wu (olvaffe@gmail.com)         Gallium3D - Mesa’s New Driver Model      Mar 27, 2011   4 / 24
OpenGL and Linux


Not Always

                            Figure: nouveau v.s. nVidia binary driver (phronix)




  Chia-I Wu (olvaffe@gmail.com)          Gallium3D - Mesa’s New Driver Model      Mar 27, 2011   5 / 24
OpenGL and Linux


People




                         BIG TEAMS / BIG BUDGET




  Chia-I Wu (olvaffe@gmail.com)    Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   6 / 24
OpenGL and Linux


DRI



Direct Rendering Infrastructure, DRI




      direct rendering




   Chia-I Wu (olvaffe@gmail.com)    Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   7 / 24
OpenGL and Linux


DRI



Direct Rendering Infrastructure, DRI




      direct rendering
      core X rendering
      indirect rendering




   Chia-I Wu (olvaffe@gmail.com)    Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   7 / 24
OpenGL and Linux


DRI Components




  Chia-I Wu (olvaffe@gmail.com)    Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   8 / 24
OpenGL and Linux


DRI Components




   <hw> dri.so is the DRI or 3D driver
   <hw> drv.so is the DDX or 2D driver
   <hw>.ko is the DRM kernel module
   libdrm <hw>.so is the user space library for the DRM module
   GLX and DRI2 are X11 protocols


  Chia-I Wu (olvaffe@gmail.com)    Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   8 / 24
OpenGL and Linux


They are all complex




    DRM driver for buffer management, mode setting, ... (radeon has ∼70k LoC)
    DDX driver for 2D operations, video, mode setting, ... (radeon has ∼100k LoC)
    DRI driver for OpenGL (radeon has ∼90k LoC)




   Chia-I Wu (olvaffe@gmail.com)    Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   9 / 24
OpenGL and Linux


OpenGL under Mesa Classic Driver Model




                       libGL.so            <hw>_dri.so                     libdrm_<hw>.so




 DRI driver interface              Mesa common code                           HW code

In the classic model,
    there is common code that checks the arguments of an OpenGL call and updates
    internal states
    it then calls into the HW code using the function table implemented there
There is an almost one-to-one mapping between OpenGL API and the function table that
the HW code implements.




   Chia-I Wu (olvaffe@gmail.com)     Gallium3D - Mesa’s New Driver Model             Mar 27, 2011   10 / 24
OpenGL and Linux


Dissection of the DRI driver




                       libGL.so            <hw>_dri.so                     libdrm_<hw>.so




 DRI driver interface              Mesa common code                           HW code

    OS dependent: the HW code
    display server dependent: none
    OpenGL dependent: the common and HW code




   Chia-I Wu (olvaffe@gmail.com)     Gallium3D - Mesa’s New Driver Model             Mar 27, 2011   11 / 24
OpenGL and Linux


Problems with the Classic Model




The problems with the classic model are
    it is OpenGL(ES) only; even the hardware can support OpenVG, OpenCL, ...
    the driver uses OpenGL data types and objects
    the driver must handle the differences between OpenGL and the hardware
    an implementation issue instead of a design issue in view of the DRI architecture




   Chia-I Wu (olvaffe@gmail.com)    Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   12 / 24
Gallium3D


Ideal Model




  Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   13 / 24
Gallium3D


Gallium3D




                    libGL.so             <hw>_dri.so                    libdrm_<hw>.so




     DRI state tracker
                                           pipe driver                    pipe winsys
  OpenGL state tracker


   OS dependent: the pipe winsys
   display server dependent: none
   OpenGL dependent: OpenGL state tracker




  Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model             Mar 27, 2011   14 / 24
Gallium3D


Gallium3D




                    libGL.so             <hw>_dri.so                    libdrm_<hw>.so




     DRI state tracker
                                           pipe driver                    pipe winsys
  OpenGL state tracker


   OS dependent: the pipe winsys
   display server dependent: none
   OpenGL dependent: OpenGL state tracker
   The pipe driver is highly protable and has a well-defined interface!




  Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model             Mar 27, 2011   14 / 24
Gallium3D


Classic Model to Gallium3D Model


                         libGL.so          <hw>_dri.so                    libdrm_<hw>.so




         DRI driver interface         Mesa common code                         HW code




    DRI state tracker
                                                              pipe driver         pipe winsys
 OpenGL state tracker

This is a non-trivial process
     DRI and OpenGL state trackers are written once and shared
     the pipe driver and winsys must be written for each HW
     new drivers should adopt the Gallium3D model from beginning


   Chia-I Wu (olvaffe@gmail.com)    Gallium3D - Mesa’s New Driver Model               Mar 27, 2011   15 / 24
Gallium3D


Gallium3D: examples

  libEGL.so         egl_dri2.so           <hw>_dri.so                    libdrm_<hw>.so




      DRI state tracker
                                            pipe driver                    pipe winsys
  OpenVG state tracker



                  libOpenCL.so            <hw>_dri.so                    libdrm_<hw>.so




      DRI state tracker
                                            pipe driver                    pipe winsys
  OpenCL state tracker

(You can also have all OpenGL, OpenVG, and OpenCL state trackers inside a single DRI
driver)

   Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model             Mar 27, 2011   16 / 24
Gallium3D


Gallium3D: even for DDX




                       Xorg          <hw>_drv.so (DDX)                   libdrm_<hw>.so




     DDX state tracker                      pipe driver                    pipe winsys

A modern DDX driver is more than a 2D driver
    EXA/UXA
    Xrender
    video decoding
    mode setting KMS




   Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model             Mar 27, 2011   17 / 24
Gallium3D


Gallium3D: SVGA




VMWare has a virtual GPU named SVGA. The aquisition of Tungsten Graphics gives
    vmwgfx.ko DRM module
    Gallium3D based DRI driver
    Gallium3D based DDX driver
    Gallium3D based D3D9 driver (D3D9 state tracker + Windows winsys)




   Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   18 / 24
Developers


Gallium3D core




Gallium3D core consists of
    two interfaces: struct pipe screen and struct pipe context
    helper functions for format conversions, buffer management, vertex processing, and
    etc.
    wrappers of OS or compiler dependent functions, such as threads, timing, I/O
Pipe drivers implement struct pipe screen and struct pipe context interfaces.
State trackers are users of the interfaces.




   Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   19 / 24
Developers


struct pipe screen




The pipe screen is an abstraction of the adapter. It is used for
    querying adapter capabilities/limitations
    creating resources
    fencing
    and other misc operations




   Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   20 / 24
Developers


struct pipe context

The pipe context is an abstraction of the graphics pipeline (and some misc operations)

   vertex buffers                    vertex fetcher


                                    vertex shader


                                   geometry shader                         stream output buffers

    textures and
  constant buffers                      rasterizer


                                   fragment shader


                                   per-fragment ops                        color and depth buffers


   Chia-I Wu (olvaffe@gmail.com)     Gallium3D - Mesa’s New Driver Model               Mar 27, 2011   21 / 24
Developers


Pseudo Code




/∗ c r e a t e t h e p i p e s c r e e n ∗/
s t r u c t p i p e s c r e e n ∗ s c r e e n = o p e n h w d e v i c e ( dev name ) ;

/∗ c r e a t e a p i p e c o n t e x t ∗/
s t r u c t p i p e s c r e e n ∗ p i p e = s c r e e n −>c o n t e x t c r e a t e ( / ∗ . . . ∗ / ) ;
struct pipe resource ∗ res ;

/∗ c r e a t e a r e s o u r c e from t h e s c r e e n ∗/
r e s = s c r e e n −>r e s o u r c e c r e a t e ( / ∗ . . . ∗ / ) ;

/∗ s e t t h e r e s o u r c e a s t h e f r a m e b u f f e r ∗/
p i p e −>s e t f r a m e b u f f e r s t a t e ( / ∗ . . . ∗ / ) ;




    Chia-I Wu (olvaffe@gmail.com)        Gallium3D - Mesa’s New Driver Model                Mar 27, 2011   22 / 24
Developers


It is easier




Gallium3D driver model
    has well-defined interfaces and types
    is close to the hardware
    has reusable state trackers
    has lots of helper functions
    supports pipe screen/context wrapping: trace, rbug, galahad




   Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   23 / 24
Q&A


Q&A




Questions?




   Chia-I Wu (olvaffe@gmail.com)   Gallium3D - Mesa’s New Driver Model   Mar 27, 2011   24 / 24

More Related Content

What's hot

Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)
Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)
Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)
Shinya Takamaeda-Y
 
FC SAN Fabric環境におけるパフォーマンストラブルの対処法
FC SAN Fabric環境におけるパフォーマンストラブルの対処法FC SAN Fabric環境におけるパフォーマンストラブルの対処法
FC SAN Fabric環境におけるパフォーマンストラブルの対処法
Brocade
 
SEGMENT Routing
SEGMENT RoutingSEGMENT Routing
Barman (PostgreSql) manual
Barman (PostgreSql) manualBarman (PostgreSql) manual
Barman (PostgreSql) manual
Marcelo Pesallaccia
 
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
The Top 5 Reasons to Deploy Your Applications on Oracle RACThe Top 5 Reasons to Deploy Your Applications on Oracle RAC
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
Markus Michalewicz
 
ブロケード FC ファブリックスイッチオペレーション講座(前編)
ブロケード FC ファブリックスイッチオペレーション講座(前編)ブロケード FC ファブリックスイッチオペレーション講座(前編)
ブロケード FC ファブリックスイッチオペレーション講座(前編)
Brocade
 
ONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
ONIE: Open Network Install Environment @ OSDC 2014 Netways, BerlinONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
ONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
Nat Morris
 
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Sandesh Rao
 
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Markus Michalewicz
 
Juniper mpls best practice part 2
Juniper mpls best practice   part 2Juniper mpls best practice   part 2
Juniper mpls best practice part 2
Febrian ‎
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
dibyajyotig
 
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong TangAccelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Ceph Community
 
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
OpenStack Korea Community
 
Data guard architecture
Data guard architectureData guard architecture
Data guard architectureVimlendu Kumar
 
ACI Multicast 구성 가이드
ACI Multicast 구성 가이드ACI Multicast 구성 가이드
ACI Multicast 구성 가이드
Woo Hyung Choi
 
M4 san features-4.3.1
M4 san features-4.3.1M4 san features-4.3.1
M4 san features-4.3.1
MrudulaJoshi10
 
“見てわかる” ファイバーチャネルSAN基礎講座(第5弾)~さあ、いよいよ、運用です!~
“見てわかる” ファイバーチャネルSAN基礎講座(第5弾)~さあ、いよいよ、運用です!~“見てわかる” ファイバーチャネルSAN基礎講座(第5弾)~さあ、いよいよ、運用です!~
“見てわかる” ファイバーチャネルSAN基礎講座(第5弾)~さあ、いよいよ、運用です!~
Brocade
 
OVN - Basics and deep dive
OVN - Basics and deep diveOVN - Basics and deep dive
OVN - Basics and deep dive
Trinath Somanchi
 
Segment Routing Technology Deep Dive and Advanced Use Cases
Segment Routing Technology Deep Dive and Advanced Use CasesSegment Routing Technology Deep Dive and Advanced Use Cases
Segment Routing Technology Deep Dive and Advanced Use Cases
Cisco Canada
 

What's hot (19)

Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)
Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)
Debian Linux on Zynq (Xilinx ARM-SoC FPGA) Setup Flow (Vivado 2015.4)
 
FC SAN Fabric環境におけるパフォーマンストラブルの対処法
FC SAN Fabric環境におけるパフォーマンストラブルの対処法FC SAN Fabric環境におけるパフォーマンストラブルの対処法
FC SAN Fabric環境におけるパフォーマンストラブルの対処法
 
SEGMENT Routing
SEGMENT RoutingSEGMENT Routing
SEGMENT Routing
 
Barman (PostgreSql) manual
Barman (PostgreSql) manualBarman (PostgreSql) manual
Barman (PostgreSql) manual
 
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
The Top 5 Reasons to Deploy Your Applications on Oracle RACThe Top 5 Reasons to Deploy Your Applications on Oracle RAC
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
 
ブロケード FC ファブリックスイッチオペレーション講座(前編)
ブロケード FC ファブリックスイッチオペレーション講座(前編)ブロケード FC ファブリックスイッチオペレーション講座(前編)
ブロケード FC ファブリックスイッチオペレーション講座(前編)
 
ONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
ONIE: Open Network Install Environment @ OSDC 2014 Netways, BerlinONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
ONIE: Open Network Install Environment @ OSDC 2014 Netways, Berlin
 
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
 
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
Oracle RAC 12c Practical Performance Management and Tuning OOW13 [CON8825]
 
Juniper mpls best practice part 2
Juniper mpls best practice   part 2Juniper mpls best practice   part 2
Juniper mpls best practice part 2
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong TangAccelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
Accelerating Ceph with iWARP RDMA over Ethernet - Brien Porter, Haodong Tang
 
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
[OpenInfra Days Korea 2018] Day 2 - CEPH 운영자를 위한 Object Storage Performance T...
 
Data guard architecture
Data guard architectureData guard architecture
Data guard architecture
 
ACI Multicast 구성 가이드
ACI Multicast 구성 가이드ACI Multicast 구성 가이드
ACI Multicast 구성 가이드
 
M4 san features-4.3.1
M4 san features-4.3.1M4 san features-4.3.1
M4 san features-4.3.1
 
“見てわかる” ファイバーチャネルSAN基礎講座(第5弾)~さあ、いよいよ、運用です!~
“見てわかる” ファイバーチャネルSAN基礎講座(第5弾)~さあ、いよいよ、運用です!~“見てわかる” ファイバーチャネルSAN基礎講座(第5弾)~さあ、いよいよ、運用です!~
“見てわかる” ファイバーチャネルSAN基礎講座(第5弾)~さあ、いよいよ、運用です!~
 
OVN - Basics and deep dive
OVN - Basics and deep diveOVN - Basics and deep dive
OVN - Basics and deep dive
 
Segment Routing Technology Deep Dive and Advanced Use Cases
Segment Routing Technology Deep Dive and Advanced Use CasesSegment Routing Technology Deep Dive and Advanced Use Cases
Segment Routing Technology Deep Dive and Advanced Use Cases
 

Viewers also liked

NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
Mark Kilgard
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
Mark Kilgard
 
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadOpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
Tristan Lorach
 
OpenGL 4 for 2010
OpenGL 4 for 2010OpenGL 4 for 2010
OpenGL 4 for 2010
Mark Kilgard
 
OpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsOpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUs
Mark Kilgard
 
Secret of Intel Management Engine by Igor Skochinsky
Secret of Intel Management Engine  by Igor SkochinskySecret of Intel Management Engine  by Igor Skochinsky
Secret of Intel Management Engine by Igor Skochinsky
CODE BLUE
 
Beyond porting
Beyond portingBeyond porting
Beyond porting
Cass Everitt
 

Viewers also liked (7)

NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL Functionality
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadOpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
 
OpenGL 4 for 2010
OpenGL 4 for 2010OpenGL 4 for 2010
OpenGL 4 for 2010
 
OpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsOpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUs
 
Secret of Intel Management Engine by Igor Skochinsky
Secret of Intel Management Engine  by Igor SkochinskySecret of Intel Management Engine  by Igor Skochinsky
Secret of Intel Management Engine by Igor Skochinsky
 
Beyond porting
Beyond portingBeyond porting
Beyond porting
 

Similar to Gallium3D - Mesa's New Driver Model

Embedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less specialEmbedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less special
Anne Nicolas
 
Build Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVMBuild Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVM
National Cheng Kung University
 
Android Optimization: Myth and Reality
Android Optimization: Myth and RealityAndroid Optimization: Myth and Reality
Android Optimization: Myth and Reality
National Cheng Kung University
 
[Ubucon Europe 2018] Introduction to mesa, the open-source graphics API imple...
[Ubucon Europe 2018] Introduction to mesa, the open-source graphics API imple...[Ubucon Europe 2018] Introduction to mesa, the open-source graphics API imple...
[Ubucon Europe 2018] Introduction to mesa, the open-source graphics API imple...
Samuel Iglesias Gonsálvez
 
Introduction to Mesa. The Open-Source Graphics API Implementation Library (Ub...
Introduction to Mesa. The Open-Source Graphics API Implementation Library (Ub...Introduction to Mesa. The Open-Source Graphics API Implementation Library (Ub...
Introduction to Mesa. The Open-Source Graphics API Implementation Library (Ub...
Igalia
 
Porting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons LearnedPorting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons Learned
basisspace
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
Alison Chaiken
 
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driverKernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Anne Nicolas
 
UniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtimeUniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtime
Lee Calcote
 
3-Way Scripts as a Practical Platform for Secure Distributed Code in Clouds
3-Way Scripts as a Practical Platform for Secure Distributed Code in Clouds3-Way Scripts as a Practical Platform for Secure Distributed Code in Clouds
3-Way Scripts as a Practical Platform for Secure Distributed Code in Clouds
Tokyo University of Science
 
Virtual Distro Dispatcher - A light-weight Desktop-as-a-Service solution
Virtual Distro Dispatcher - A light-weight Desktop-as-a-Service solutionVirtual Distro Dispatcher - A light-weight Desktop-as-a-Service solution
Virtual Distro Dispatcher - A light-weight Desktop-as-a-Service solution
Flavio Bertini
 
Csc533 ch3a mm_framework
Csc533 ch3a mm_frameworkCsc533 ch3a mm_framework
Csc533 ch3a mm_frameworkErkks Hohoho
 
UML Case Tools
UML Case ToolsUML Case Tools
UML Case Tools
Ashesh R
 
Embedded Linux Multimedia
Embedded Linux MultimediaEmbedded Linux Multimedia
Embedded Linux MultimediaCaglar Dursun
 
LCA13: OpenGL ES3 and You
LCA13: OpenGL ES3 and YouLCA13: OpenGL ES3 and You
LCA13: OpenGL ES3 and You
Linaro
 
Embedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integrationEmbedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integration
Anne Nicolas
 
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime RipardKernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Anne Nicolas
 
A Project Report on Insurance System with Tracking Manager
 A Project Report on Insurance System with Tracking Manager  A Project Report on Insurance System with Tracking Manager
A Project Report on Insurance System with Tracking Manager
Sachin Kariyattin
 

Similar to Gallium3D - Mesa's New Driver Model (20)

Embedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less specialEmbedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less special
 
Build Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVMBuild Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVM
 
Android Optimization: Myth and Reality
Android Optimization: Myth and RealityAndroid Optimization: Myth and Reality
Android Optimization: Myth and Reality
 
[Ubucon Europe 2018] Introduction to mesa, the open-source graphics API imple...
[Ubucon Europe 2018] Introduction to mesa, the open-source graphics API imple...[Ubucon Europe 2018] Introduction to mesa, the open-source graphics API imple...
[Ubucon Europe 2018] Introduction to mesa, the open-source graphics API imple...
 
Introduction to Mesa. The Open-Source Graphics API Implementation Library (Ub...
Introduction to Mesa. The Open-Source Graphics API Implementation Library (Ub...Introduction to Mesa. The Open-Source Graphics API Implementation Library (Ub...
Introduction to Mesa. The Open-Source Graphics API Implementation Library (Ub...
 
Porting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons LearnedPorting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons Learned
 
KIRANKUMAR_MV
KIRANKUMAR_MVKIRANKUMAR_MV
KIRANKUMAR_MV
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
 
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driverKernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driver
 
UniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtimeUniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtime
 
3-Way Scripts as a Practical Platform for Secure Distributed Code in Clouds
3-Way Scripts as a Practical Platform for Secure Distributed Code in Clouds3-Way Scripts as a Practical Platform for Secure Distributed Code in Clouds
3-Way Scripts as a Practical Platform for Secure Distributed Code in Clouds
 
Virtual Distro Dispatcher - A light-weight Desktop-as-a-Service solution
Virtual Distro Dispatcher - A light-weight Desktop-as-a-Service solutionVirtual Distro Dispatcher - A light-weight Desktop-as-a-Service solution
Virtual Distro Dispatcher - A light-weight Desktop-as-a-Service solution
 
J interop
J interopJ interop
J interop
 
Csc533 ch3a mm_framework
Csc533 ch3a mm_frameworkCsc533 ch3a mm_framework
Csc533 ch3a mm_framework
 
UML Case Tools
UML Case ToolsUML Case Tools
UML Case Tools
 
Embedded Linux Multimedia
Embedded Linux MultimediaEmbedded Linux Multimedia
Embedded Linux Multimedia
 
LCA13: OpenGL ES3 and You
LCA13: OpenGL ES3 and YouLCA13: OpenGL ES3 and You
LCA13: OpenGL ES3 and You
 
Embedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integrationEmbedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integration
 
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime RipardKernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
 
A Project Report on Insurance System with Tracking Manager
 A Project Report on Insurance System with Tracking Manager  A Project Report on Insurance System with Tracking Manager
A Project Report on Insurance System with Tracking Manager
 

Gallium3D - Mesa's New Driver Model

  • 1. Gallium3D - Mesa’s New Driver Model Chia-I Wu olvaffe@gmail.com Mar 27, 2011 Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 1 / 24
  • 2. Agenda Who Am I? main developer of Mesa EGL stack Android(-x86) port of Mesa experiences in OpenGL stacks Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 2 / 24
  • 3. Agenda Who Am I? main developer of Mesa EGL stack Android(-x86) port of Mesa experiences in OpenGL stacks a member of 0xlab Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 2 / 24
  • 4. Agenda Agenda OpenGL and Linux: DRI classic and Gallium3D driver models how does it make a developer happy Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 3 / 24
  • 5. OpenGL and Linux Mesa v.s. Proprietary Drivers Isn’t this the case? Mesa Proprietary stability . v performance . v feature set . v it’s free v . Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 4 / 24
  • 6. OpenGL and Linux Not Always Figure: nouveau v.s. nVidia binary driver (phronix) Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 5 / 24
  • 7. OpenGL and Linux People BIG TEAMS / BIG BUDGET Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 6 / 24
  • 8. OpenGL and Linux DRI Direct Rendering Infrastructure, DRI direct rendering Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 7 / 24
  • 9. OpenGL and Linux DRI Direct Rendering Infrastructure, DRI direct rendering core X rendering indirect rendering Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 7 / 24
  • 10. OpenGL and Linux DRI Components Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 8 / 24
  • 11. OpenGL and Linux DRI Components <hw> dri.so is the DRI or 3D driver <hw> drv.so is the DDX or 2D driver <hw>.ko is the DRM kernel module libdrm <hw>.so is the user space library for the DRM module GLX and DRI2 are X11 protocols Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 8 / 24
  • 12. OpenGL and Linux They are all complex DRM driver for buffer management, mode setting, ... (radeon has ∼70k LoC) DDX driver for 2D operations, video, mode setting, ... (radeon has ∼100k LoC) DRI driver for OpenGL (radeon has ∼90k LoC) Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 9 / 24
  • 13. OpenGL and Linux OpenGL under Mesa Classic Driver Model libGL.so <hw>_dri.so libdrm_<hw>.so DRI driver interface Mesa common code HW code In the classic model, there is common code that checks the arguments of an OpenGL call and updates internal states it then calls into the HW code using the function table implemented there There is an almost one-to-one mapping between OpenGL API and the function table that the HW code implements. Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 10 / 24
  • 14. OpenGL and Linux Dissection of the DRI driver libGL.so <hw>_dri.so libdrm_<hw>.so DRI driver interface Mesa common code HW code OS dependent: the HW code display server dependent: none OpenGL dependent: the common and HW code Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 11 / 24
  • 15. OpenGL and Linux Problems with the Classic Model The problems with the classic model are it is OpenGL(ES) only; even the hardware can support OpenVG, OpenCL, ... the driver uses OpenGL data types and objects the driver must handle the differences between OpenGL and the hardware an implementation issue instead of a design issue in view of the DRI architecture Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 12 / 24
  • 16. Gallium3D Ideal Model Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 13 / 24
  • 17. Gallium3D Gallium3D libGL.so <hw>_dri.so libdrm_<hw>.so DRI state tracker pipe driver pipe winsys OpenGL state tracker OS dependent: the pipe winsys display server dependent: none OpenGL dependent: OpenGL state tracker Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 14 / 24
  • 18. Gallium3D Gallium3D libGL.so <hw>_dri.so libdrm_<hw>.so DRI state tracker pipe driver pipe winsys OpenGL state tracker OS dependent: the pipe winsys display server dependent: none OpenGL dependent: OpenGL state tracker The pipe driver is highly protable and has a well-defined interface! Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 14 / 24
  • 19. Gallium3D Classic Model to Gallium3D Model libGL.so <hw>_dri.so libdrm_<hw>.so DRI driver interface Mesa common code HW code DRI state tracker pipe driver pipe winsys OpenGL state tracker This is a non-trivial process DRI and OpenGL state trackers are written once and shared the pipe driver and winsys must be written for each HW new drivers should adopt the Gallium3D model from beginning Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 15 / 24
  • 20. Gallium3D Gallium3D: examples libEGL.so egl_dri2.so <hw>_dri.so libdrm_<hw>.so DRI state tracker pipe driver pipe winsys OpenVG state tracker libOpenCL.so <hw>_dri.so libdrm_<hw>.so DRI state tracker pipe driver pipe winsys OpenCL state tracker (You can also have all OpenGL, OpenVG, and OpenCL state trackers inside a single DRI driver) Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 16 / 24
  • 21. Gallium3D Gallium3D: even for DDX Xorg <hw>_drv.so (DDX) libdrm_<hw>.so DDX state tracker pipe driver pipe winsys A modern DDX driver is more than a 2D driver EXA/UXA Xrender video decoding mode setting KMS Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 17 / 24
  • 22. Gallium3D Gallium3D: SVGA VMWare has a virtual GPU named SVGA. The aquisition of Tungsten Graphics gives vmwgfx.ko DRM module Gallium3D based DRI driver Gallium3D based DDX driver Gallium3D based D3D9 driver (D3D9 state tracker + Windows winsys) Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 18 / 24
  • 23. Developers Gallium3D core Gallium3D core consists of two interfaces: struct pipe screen and struct pipe context helper functions for format conversions, buffer management, vertex processing, and etc. wrappers of OS or compiler dependent functions, such as threads, timing, I/O Pipe drivers implement struct pipe screen and struct pipe context interfaces. State trackers are users of the interfaces. Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 19 / 24
  • 24. Developers struct pipe screen The pipe screen is an abstraction of the adapter. It is used for querying adapter capabilities/limitations creating resources fencing and other misc operations Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 20 / 24
  • 25. Developers struct pipe context The pipe context is an abstraction of the graphics pipeline (and some misc operations) vertex buffers vertex fetcher vertex shader geometry shader stream output buffers textures and constant buffers rasterizer fragment shader per-fragment ops color and depth buffers Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 21 / 24
  • 26. Developers Pseudo Code /∗ c r e a t e t h e p i p e s c r e e n ∗/ s t r u c t p i p e s c r e e n ∗ s c r e e n = o p e n h w d e v i c e ( dev name ) ; /∗ c r e a t e a p i p e c o n t e x t ∗/ s t r u c t p i p e s c r e e n ∗ p i p e = s c r e e n −>c o n t e x t c r e a t e ( / ∗ . . . ∗ / ) ; struct pipe resource ∗ res ; /∗ c r e a t e a r e s o u r c e from t h e s c r e e n ∗/ r e s = s c r e e n −>r e s o u r c e c r e a t e ( / ∗ . . . ∗ / ) ; /∗ s e t t h e r e s o u r c e a s t h e f r a m e b u f f e r ∗/ p i p e −>s e t f r a m e b u f f e r s t a t e ( / ∗ . . . ∗ / ) ; Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 22 / 24
  • 27. Developers It is easier Gallium3D driver model has well-defined interfaces and types is close to the hardware has reusable state trackers has lots of helper functions supports pipe screen/context wrapping: trace, rbug, galahad Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 23 / 24
  • 28. Q&A Q&A Questions? Chia-I Wu (olvaffe@gmail.com) Gallium3D - Mesa’s New Driver Model Mar 27, 2011 24 / 24