SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Power bi proof of concept
Power bi proof of conceptPower bi proof of concept
Power bi proof of conceptharrow812arhed
 
Micro project list dms- 22319
Micro project list dms- 22319Micro project list dms- 22319
Micro project list dms- 22319ARVIND SARDAR
 
ABC Restaurant Food Ordering Management System
ABC Restaurant Food Ordering Management SystemABC Restaurant Food Ordering Management System
ABC Restaurant Food Ordering Management SystemNik Ibrahim
 
Mobile Phone Shop
Mobile Phone ShopMobile Phone Shop
Mobile Phone ShopBashi9675
 
Shop management system
Shop management systemShop management system
Shop management systemBUBT
 
Presentation Inventory Managment System
Presentation Inventory Managment SystemPresentation Inventory Managment System
Presentation Inventory Managment SystemAlinur Seddik
 
Online food ordering system
Online food ordering systemOnline food ordering system
Online food ordering systemIqraKhan158
 
Book Store Management System - Database Design - 2021
Book Store Management System - Database Design - 2021Book Store Management System - Database Design - 2021
Book Store Management System - Database Design - 2021Bharat Chawda
 
Employee management system report
Employee management system reportEmployee management system report
Employee management system reportPrince Singh
 
HCI 2015 (8/10) Data Visualization (an introduction)
HCI 2015 (8/10) Data Visualization (an introduction)HCI 2015 (8/10) Data Visualization (an introduction)
HCI 2015 (8/10) Data Visualization (an introduction)Sabin Buraga
 
Project report On MSM (Mobile Shop Management)
Project report On MSM (Mobile Shop Management)Project report On MSM (Mobile Shop Management)
Project report On MSM (Mobile Shop Management)Dinesh Jogdand
 
Introduction to Microsoft Power BI
Introduction to Microsoft Power BIIntroduction to Microsoft Power BI
Introduction to Microsoft Power BIExilesoft
 
evaluation techniques in HCI
evaluation techniques in HCIevaluation techniques in HCI
evaluation techniques in HCIsawsan slii
 
Software engineering mca
Software engineering mcaSoftware engineering mca
Software engineering mcaAman Adhikari
 
Stock Management System
Stock Management SystemStock Management System
Stock Management SystemShahriar Kabir
 

Tendances (20)

Power bi proof of concept
Power bi proof of conceptPower bi proof of concept
Power bi proof of concept
 
Micro project list dms- 22319
Micro project list dms- 22319Micro project list dms- 22319
Micro project list dms- 22319
 
ABC Restaurant Food Ordering Management System
ABC Restaurant Food Ordering Management SystemABC Restaurant Food Ordering Management System
ABC Restaurant Food Ordering Management System
 
PROJECT REPORT1
PROJECT REPORT1PROJECT REPORT1
PROJECT REPORT1
 
Mobile Phone Shop
Mobile Phone ShopMobile Phone Shop
Mobile Phone Shop
 
Shop management system
Shop management systemShop management system
Shop management system
 
Sap gui
Sap guiSap gui
Sap gui
 
Presentation Inventory Managment System
Presentation Inventory Managment SystemPresentation Inventory Managment System
Presentation Inventory Managment System
 
Online food ordering system
Online food ordering systemOnline food ordering system
Online food ordering system
 
Book Store Management System - Database Design - 2021
Book Store Management System - Database Design - 2021Book Store Management System - Database Design - 2021
Book Store Management System - Database Design - 2021
 
Employee management system report
Employee management system reportEmployee management system report
Employee management system report
 
Library management system using java technology
Library management system using java technologyLibrary management system using java technology
Library management system using java technology
 
Shlaer mellor-method
Shlaer mellor-methodShlaer mellor-method
Shlaer mellor-method
 
HCI 2015 (8/10) Data Visualization (an introduction)
HCI 2015 (8/10) Data Visualization (an introduction)HCI 2015 (8/10) Data Visualization (an introduction)
HCI 2015 (8/10) Data Visualization (an introduction)
 
Project report On MSM (Mobile Shop Management)
Project report On MSM (Mobile Shop Management)Project report On MSM (Mobile Shop Management)
Project report On MSM (Mobile Shop Management)
 
Introduction to Microsoft Power BI
Introduction to Microsoft Power BIIntroduction to Microsoft Power BI
Introduction to Microsoft Power BI
 
evaluation techniques in HCI
evaluation techniques in HCIevaluation techniques in HCI
evaluation techniques in HCI
 
Online music store
Online music storeOnline music store
Online music store
 
Software engineering mca
Software engineering mcaSoftware engineering mca
Software engineering mca
 
Stock Management System
Stock Management SystemStock Management System
Stock Management System
 

En vedette

NVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityNVIDIA's OpenGL Functionality
NVIDIA's OpenGL FunctionalityMark Kilgard
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and MoreMark 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 OverheadTristan Lorach
 
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 GPUsMark 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 SkochinskyCODE BLUE
 

En vedette (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
 

Similaire à 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 specialAnne Nicolas
 
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
 
[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
 
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 Learnedbasisspace
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developersAlison 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 driverAnne Nicolas
 
UniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtimeUniK - a unikernel compiler and runtime
UniK - a unikernel compiler and runtimeLee 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 CloudsTokyo 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 solutionFlavio 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 ToolsAshesh 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 YouLinaro
 
Embedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integrationEmbedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integrationAnne 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 RipardAnne 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
 

Similaire à 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
 
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...
 
[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...
 
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