SlideShare a Scribd company logo
GLX, DRI, andi965
olv@LunarG.com
2014-05-06
1 / 20
ltrace of glxgears
XOpenDisplay(nil) = dpy
glXChooseVisual(dpy, 0, 0x7fff3674ceb0, 0) = visual
XCreateWindow(dpy, 151, 0, 0) = win
glXCreateContext(dpy, visual, 0, 1) = ctx
glXMakeCurrent(dpy, win, ctx, 0xeff5) = 1
glXGetProcAddressARB(0x403d4c, 0x403d36, 0, 0xb11e2a) = 0x7fe222677464
...
glClear(0x4100, 0x7fff3674d020, 0xdde0c, 1) = 0
glCallList(3, 0xdc0490, 0x800001, 0xdc0490) = 0x7fa8b79ea040
...
glXSwapBuffers(dpy, win, 0x800001, 0x93a910) = 2
...
glXMakeCurrent(dpy, 0, 0, 3) = 1
glXDestroyContext(dpy, ctx, 0x7fe2228d6b60, 0) = 0
XDestroyWindow(dpy, win, 0x7fe2228d6b60, 0x8f3be0) = 1
XCloseDisplay(dpy) = <void>
2 / 20
3 / 20
libGL.so::__glXInitialize(Display *dpy)
Associate a struct glx_displaywith dpy,
GLXQueryVersion, mandatory
DRI2QueryVersion, required for direct rendering
DRI3QueryVersion, optional
libxcb-*
X protocol C-language Binding
and associate a struct glx_screenwith each of the display screens
GLXGetVisualConfigsand GLXGetFBConfigs
4 / 20
libGL.so::__glXInitialize(Display *dpy)
For each display screen, when DRI2 is supported,
DRI2Connect
returns device name: /dev/dri/card<N>or /dev/dri/renderD<N>
driver name: use libudevand internal driver maps
loads i965_dri.soand exchange "extensions"
"extensions" are tables of function pointers
DRI drivers are window system agnostic
DRI loaders are window system dependent; to support a new window system,
only a new loader needs to be created
stable ABI
intelInitScreen2()
5 / 20
libGL.so::CreateContext(Display *dpy,...)
Create a struct glx_context
brwCreateContext()
GLXCreateContextor GLXCreateNewContext
only when indirect rendering
visuals v.s. fbconfigs
6 / 20
libGL.so::MakeContextCurrent(Display *dpy,...)
remember the current struct glx_context
GLXMakeCurrentor GLXMakeContextCurrent
only when indirect rendering
intelMakeCurrent()
7 / 20
i965_dri.so::intelMakeCurrent(...)
dri2GetBuffersWithFormat()
returns the backing graphics buffers for the current drawable
The current drawable is some window created by XCreateWindow(). This is
window system dependendent and is thus defined provided by the DRI loader.
_glapi_set_dispatch()
set the dispatch table for glXXX()
_glapi_set_context()
set the implicit current context for glXXX()
8 / 20
libGL.so::glXGetProcAddressARB(const GLubyte*)
_glapi_get_proc_address()
every entry in the dispatch table has a name, such as glBindFramebuffer
returns a function pointer that will use the named entry to jump into the DRI
driver
9 / 20
libGL.so::glXSwapBuffers(...)
intel_dri2_flush_with_flags()
resolve (fast clear value, hiz, MSAA buffer, and etc.)
emit batch buffer
DRI2CopyRegion
ask server to emit another batch buffer to copy the content to the front buffer
DRI2SwapBuffers
ask server to make the presented buffer the front buffer of the window (zero-
copy)
when fullscreen, the server may tell the kernel to emit MI_DISPLAY_FLIPto
make the presented buffer the scan-out buffer
GLXSwapBuffers, only when indirect rendering
10 / 20
Source map
.-- src
|-- egl --enable-egl
|-- gallium --enable-{openvg,opencl,xa,xvmc,vdpau,omx}
|-- gbm --enable-gbm
|-- glsl --enable-{opengl,glesv1,glesv2}
|-- glx --enable-glx
|-- loader
`-- mapi
| |-- es1api --enable-gles1
| |-- es2api --enable-gles2
| |-- glapi --enable-glx
| |-- shared-glapi
| `-- vgapi --enable-openvg
.
.
.
(continued)
11 / 20
Source map
.-- src
`-- mesa --enable-{opengl,glesv1,glesv2}
|-- drivers
| |-- dri --enable-dri
| | |-- i915
| | |-- i965
| | `-- swrast
| |-- osmesa --enable-osmesa
| `-- x11
|-- main
|-- math
|-- program
|-- state_tracker
|-- swrast
|-- swrast_setup
|-- tnl
|-- tnl_dd
`-- vbo
12 / 20
Configuring Mesa
The "golden" options are
APIS="--enable-{opengl,glesv1,glesv2} 
--enable-glx --enable-dri 
--disable-egl"
FEATURES="--enable-shared-glapi 
--enable-glx-tls 
--enable-texture-float"
DRIVERS="--with-dri-drivers=i965 --with-gallum-drivers="
$ ./configure $APIS $FEATURES $DRIVERS 
CC="ccache gcc" CXX="ccache g++"
Or for 32-bit build,
$ ./configure $APIS $FEATURES $DRIVERS --enable-32-bit 
CC="ccache gcc -m32" CXX="ccache g++ -m32"
13 / 20
Dependencies
Install dependencies and latest libdrm
$ sudo apt-get build-dep mesa libdrm
$ sudo apt-get install ccache
$ git clone git://anongit.freedesktop.org/mesa/drm
$ mkdir drm/build-x86_64; cd drm/build-x86_64
$ ../configure --libdir='/usr/local/lib/x86_64-linux-gnu'
$ make -j4
$ sudo make install
Tell the dynamic linker where to find libdrm
$ echo /usr/local/lib/x86_64-linux-gnu > /etc/ld.so.conf.d/local.conf
$ sudo ldconfig
and tell Mesa build system where to find libdrm
$ export PKG_CONFIG_PATH=/usr/local/lib/x86_64-linux-gnu/pkgconfig
14 / 20
Dependencies (32-bit)
Follow https://wiki.debian.org/Multiarch/HOWTO (not needed on Ubuntu?), and build
32-bit libdrm
$ sudo apt-get build-dep -a i386 libdrm
$ mkdir drm/build-i386; cd drm/build-i386
$ ../configure --libdir='/usr/local/lib/i386-linux-gnu' 
--disable-cairo-tests 
CC="gcc -m32"
$ make -j4
$ sudo make install
To install 32-bit dependencies for Mesa, or to get the list of possible dependencies and
install manually when the build-depfails
$ sudo apt-get build-dep -a i386 mesa
or
$ dpkg -l | cut -d' ' -f3 | grep :amd64 | sed 's/:amd64/:i386/'
15 / 20
Options not mentioned yet
--enable-dri3enables support for DRI3protocol in libGL.so
--enable-xlib-glxreplaces libGL.soby one that does not require GLXnor DRI2/DRI3
protocols, and does not support hardware acceleration
--enable-debugenables debug build
16 / 20
Using Mesa without installation
$ cat << EOF > mesa-setup-env
MESA_VARIANT=mesa
MESA_TOP="$HOME/fdo/mesa/$MESA_VARIANT"
export LD_LIBRARY_PATH="$MESA_TOP/lib"
export EGL_DRIVERS_PATH="$MESA_TOP/lib/egl"
export LIBGL_DRIVERS_PATH="$MESA_TOP/lib"
if [ -z "$MESA_PS1" ]; then
MESA_PS1=$PS1
fi
PS1="[$MESA_VARIANT] $MESA_PS1"
EOF
$ . mesa-setup-env
Remember to change $MESA_TOPto point to your Mesa source tree.
17 / 20
i965_dri.so::{_mesa_Clear(),_mesa_CallList()}
brw_clear()
fast depth clear
fast color clear
meta clear
brw_draw_prims()
i965 draw function for GL functions that draw (such as glDrawElements())
brw_upload_state()
brw_predraw_resolve_buffers()
brw_postdraw_set_buffers_need_resolve()
18 / 20
(GL states are converted to this at draw time. Each block is a buffer. Each arrow is a
relocation entry.)
19 / 20
We've got some time left
INTEL_DEBUG=batch, INTEL_DEBUG=auband https://github.com/olvaffe/envytools
INTEL_DEBUG=shader_time
glretrace --pgpu
20 / 20

More Related Content

What's hot

20151224-games
20151224-games20151224-games
20151224-games
Noritada Shimizu
 
Make A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkMake A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst Framework
Yodalee
 
プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話
tatsunori ishikawa
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
Noritada Shimizu
 
PyCon KR 2019 sprint - RustPython by example
PyCon KR 2019 sprint  - RustPython by examplePyCon KR 2019 sprint  - RustPython by example
PyCon KR 2019 sprint - RustPython by example
YunWon Jeong
 
我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具
dennis zhuang
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
DaeMyung Kang
 
Cluj Big Data Meetup - Big Data in Practice
Cluj Big Data Meetup - Big Data in PracticeCluj Big Data Meetup - Big Data in Practice
Cluj Big Data Meetup - Big Data in Practice
Steffen Wenz
 
Bash Scripting Workshop
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting Workshop
Ahmed Magdy Ezzeldin, MSc.
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
Ian Barber
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
Node day 2014
Node day 2014Node day 2014
Node day 2014
Trevor Norris
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
Ian Barber
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
Michiel Borkent
 
2013 0928 programming by cuda
2013 0928 programming by cuda2013 0928 programming by cuda
2013 0928 programming by cuda
小明 王
 
Code
CodeCode
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
Michiel Borkent
 
Emscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsEmscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math ops
Luka Zakrajšek
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
Ian Barber
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
Michael Lehmann
 

What's hot (20)

20151224-games
20151224-games20151224-games
20151224-games
 
Make A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkMake A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst Framework
 
プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
 
PyCon KR 2019 sprint - RustPython by example
PyCon KR 2019 sprint  - RustPython by examplePyCon KR 2019 sprint  - RustPython by example
PyCon KR 2019 sprint - RustPython by example
 
我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Cluj Big Data Meetup - Big Data in Practice
Cluj Big Data Meetup - Big Data in PracticeCluj Big Data Meetup - Big Data in Practice
Cluj Big Data Meetup - Big Data in Practice
 
Bash Scripting Workshop
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting Workshop
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
Node day 2014
Node day 2014Node day 2014
Node day 2014
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
2013 0928 programming by cuda
2013 0928 programming by cuda2013 0928 programming by cuda
2013 0928 programming by cuda
 
Code
CodeCode
Code
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 
Emscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsEmscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math ops
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
 

Similar to GLX, DRI, and i965

Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentLecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports Development
Mohammed Farrag
 
Xdp and ebpf_maps
Xdp and ebpf_mapsXdp and ebpf_maps
Xdp and ebpf_maps
lcplcp1
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
Sherif Mousa
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
Andrea Righi
 
Linux Tracing Superpowers by Eugene Pirogov
Linux Tracing Superpowers by Eugene PirogovLinux Tracing Superpowers by Eugene Pirogov
Linux Tracing Superpowers by Eugene Pirogov
Pivorak MeetUp
 
HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3
Linaro
 
HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4
Linaro
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
David Khosid
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
Giovanni Bechis
 
[FOSDEM 2015] How to test OpenGL drivers using Free Software
[FOSDEM 2015] How to test OpenGL drivers using Free Software[FOSDEM 2015] How to test OpenGL drivers using Free Software
[FOSDEM 2015] How to test OpenGL drivers using Free Software
Samuel Iglesias Gonsálvez
 
How to test OpenGL drivers using Free Software (FOSDEM 2015)
How to test OpenGL drivers using Free Software (FOSDEM 2015)How to test OpenGL drivers using Free Software (FOSDEM 2015)
How to test OpenGL drivers using Free Software (FOSDEM 2015)
Igalia
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
JinTaek Seo
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
Azul Systems, Inc.
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdf
maheshkumar12354
 
Debugger Principle Overview & GDB Tricks
Debugger Principle Overview & GDB TricksDebugger Principle Overview & GDB Tricks
Debugger Principle Overview & GDB Tricks
dutor
 
Painless Perl Ports with cpan2port
Painless Perl Ports with cpan2portPainless Perl Ports with cpan2port
Painless Perl Ports with cpan2port
Benny Siegert
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
Vipin Varghese
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
Sergey Platonov
 
XS Boston 2008 Debugging Xen
XS Boston 2008 Debugging XenXS Boston 2008 Debugging Xen
XS Boston 2008 Debugging Xen
The Linux Foundation
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux Awareness
Peter Griffin
 

Similar to GLX, DRI, and i965 (20)

Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentLecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports Development
 
Xdp and ebpf_maps
Xdp and ebpf_mapsXdp and ebpf_maps
Xdp and ebpf_maps
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
 
Linux Tracing Superpowers by Eugene Pirogov
Linux Tracing Superpowers by Eugene PirogovLinux Tracing Superpowers by Eugene Pirogov
Linux Tracing Superpowers by Eugene Pirogov
 
HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3
 
HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
 
[FOSDEM 2015] How to test OpenGL drivers using Free Software
[FOSDEM 2015] How to test OpenGL drivers using Free Software[FOSDEM 2015] How to test OpenGL drivers using Free Software
[FOSDEM 2015] How to test OpenGL drivers using Free Software
 
How to test OpenGL drivers using Free Software (FOSDEM 2015)
How to test OpenGL drivers using Free Software (FOSDEM 2015)How to test OpenGL drivers using Free Software (FOSDEM 2015)
How to test OpenGL drivers using Free Software (FOSDEM 2015)
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdf
 
Debugger Principle Overview & GDB Tricks
Debugger Principle Overview & GDB TricksDebugger Principle Overview & GDB Tricks
Debugger Principle Overview & GDB Tricks
 
Painless Perl Ports with cpan2port
Painless Perl Ports with cpan2portPainless Perl Ports with cpan2port
Painless Perl Ports with cpan2port
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
 
XS Boston 2008 Debugging Xen
XS Boston 2008 Debugging XenXS Boston 2008 Debugging Xen
XS Boston 2008 Debugging Xen
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux Awareness
 

Recently uploaded

Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
Ayan Halder
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 

Recently uploaded (20)

Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 

GLX, DRI, and i965

  • 2. ltrace of glxgears XOpenDisplay(nil) = dpy glXChooseVisual(dpy, 0, 0x7fff3674ceb0, 0) = visual XCreateWindow(dpy, 151, 0, 0) = win glXCreateContext(dpy, visual, 0, 1) = ctx glXMakeCurrent(dpy, win, ctx, 0xeff5) = 1 glXGetProcAddressARB(0x403d4c, 0x403d36, 0, 0xb11e2a) = 0x7fe222677464 ... glClear(0x4100, 0x7fff3674d020, 0xdde0c, 1) = 0 glCallList(3, 0xdc0490, 0x800001, 0xdc0490) = 0x7fa8b79ea040 ... glXSwapBuffers(dpy, win, 0x800001, 0x93a910) = 2 ... glXMakeCurrent(dpy, 0, 0, 3) = 1 glXDestroyContext(dpy, ctx, 0x7fe2228d6b60, 0) = 0 XDestroyWindow(dpy, win, 0x7fe2228d6b60, 0x8f3be0) = 1 XCloseDisplay(dpy) = <void> 2 / 20
  • 4. libGL.so::__glXInitialize(Display *dpy) Associate a struct glx_displaywith dpy, GLXQueryVersion, mandatory DRI2QueryVersion, required for direct rendering DRI3QueryVersion, optional libxcb-* X protocol C-language Binding and associate a struct glx_screenwith each of the display screens GLXGetVisualConfigsand GLXGetFBConfigs 4 / 20
  • 5. libGL.so::__glXInitialize(Display *dpy) For each display screen, when DRI2 is supported, DRI2Connect returns device name: /dev/dri/card<N>or /dev/dri/renderD<N> driver name: use libudevand internal driver maps loads i965_dri.soand exchange "extensions" "extensions" are tables of function pointers DRI drivers are window system agnostic DRI loaders are window system dependent; to support a new window system, only a new loader needs to be created stable ABI intelInitScreen2() 5 / 20
  • 6. libGL.so::CreateContext(Display *dpy,...) Create a struct glx_context brwCreateContext() GLXCreateContextor GLXCreateNewContext only when indirect rendering visuals v.s. fbconfigs 6 / 20
  • 7. libGL.so::MakeContextCurrent(Display *dpy,...) remember the current struct glx_context GLXMakeCurrentor GLXMakeContextCurrent only when indirect rendering intelMakeCurrent() 7 / 20
  • 8. i965_dri.so::intelMakeCurrent(...) dri2GetBuffersWithFormat() returns the backing graphics buffers for the current drawable The current drawable is some window created by XCreateWindow(). This is window system dependendent and is thus defined provided by the DRI loader. _glapi_set_dispatch() set the dispatch table for glXXX() _glapi_set_context() set the implicit current context for glXXX() 8 / 20
  • 9. libGL.so::glXGetProcAddressARB(const GLubyte*) _glapi_get_proc_address() every entry in the dispatch table has a name, such as glBindFramebuffer returns a function pointer that will use the named entry to jump into the DRI driver 9 / 20
  • 10. libGL.so::glXSwapBuffers(...) intel_dri2_flush_with_flags() resolve (fast clear value, hiz, MSAA buffer, and etc.) emit batch buffer DRI2CopyRegion ask server to emit another batch buffer to copy the content to the front buffer DRI2SwapBuffers ask server to make the presented buffer the front buffer of the window (zero- copy) when fullscreen, the server may tell the kernel to emit MI_DISPLAY_FLIPto make the presented buffer the scan-out buffer GLXSwapBuffers, only when indirect rendering 10 / 20
  • 11. Source map .-- src |-- egl --enable-egl |-- gallium --enable-{openvg,opencl,xa,xvmc,vdpau,omx} |-- gbm --enable-gbm |-- glsl --enable-{opengl,glesv1,glesv2} |-- glx --enable-glx |-- loader `-- mapi | |-- es1api --enable-gles1 | |-- es2api --enable-gles2 | |-- glapi --enable-glx | |-- shared-glapi | `-- vgapi --enable-openvg . . . (continued) 11 / 20
  • 12. Source map .-- src `-- mesa --enable-{opengl,glesv1,glesv2} |-- drivers | |-- dri --enable-dri | | |-- i915 | | |-- i965 | | `-- swrast | |-- osmesa --enable-osmesa | `-- x11 |-- main |-- math |-- program |-- state_tracker |-- swrast |-- swrast_setup |-- tnl |-- tnl_dd `-- vbo 12 / 20
  • 13. Configuring Mesa The "golden" options are APIS="--enable-{opengl,glesv1,glesv2} --enable-glx --enable-dri --disable-egl" FEATURES="--enable-shared-glapi --enable-glx-tls --enable-texture-float" DRIVERS="--with-dri-drivers=i965 --with-gallum-drivers=" $ ./configure $APIS $FEATURES $DRIVERS CC="ccache gcc" CXX="ccache g++" Or for 32-bit build, $ ./configure $APIS $FEATURES $DRIVERS --enable-32-bit CC="ccache gcc -m32" CXX="ccache g++ -m32" 13 / 20
  • 14. Dependencies Install dependencies and latest libdrm $ sudo apt-get build-dep mesa libdrm $ sudo apt-get install ccache $ git clone git://anongit.freedesktop.org/mesa/drm $ mkdir drm/build-x86_64; cd drm/build-x86_64 $ ../configure --libdir='/usr/local/lib/x86_64-linux-gnu' $ make -j4 $ sudo make install Tell the dynamic linker where to find libdrm $ echo /usr/local/lib/x86_64-linux-gnu > /etc/ld.so.conf.d/local.conf $ sudo ldconfig and tell Mesa build system where to find libdrm $ export PKG_CONFIG_PATH=/usr/local/lib/x86_64-linux-gnu/pkgconfig 14 / 20
  • 15. Dependencies (32-bit) Follow https://wiki.debian.org/Multiarch/HOWTO (not needed on Ubuntu?), and build 32-bit libdrm $ sudo apt-get build-dep -a i386 libdrm $ mkdir drm/build-i386; cd drm/build-i386 $ ../configure --libdir='/usr/local/lib/i386-linux-gnu' --disable-cairo-tests CC="gcc -m32" $ make -j4 $ sudo make install To install 32-bit dependencies for Mesa, or to get the list of possible dependencies and install manually when the build-depfails $ sudo apt-get build-dep -a i386 mesa or $ dpkg -l | cut -d' ' -f3 | grep :amd64 | sed 's/:amd64/:i386/' 15 / 20
  • 16. Options not mentioned yet --enable-dri3enables support for DRI3protocol in libGL.so --enable-xlib-glxreplaces libGL.soby one that does not require GLXnor DRI2/DRI3 protocols, and does not support hardware acceleration --enable-debugenables debug build 16 / 20
  • 17. Using Mesa without installation $ cat << EOF > mesa-setup-env MESA_VARIANT=mesa MESA_TOP="$HOME/fdo/mesa/$MESA_VARIANT" export LD_LIBRARY_PATH="$MESA_TOP/lib" export EGL_DRIVERS_PATH="$MESA_TOP/lib/egl" export LIBGL_DRIVERS_PATH="$MESA_TOP/lib" if [ -z "$MESA_PS1" ]; then MESA_PS1=$PS1 fi PS1="[$MESA_VARIANT] $MESA_PS1" EOF $ . mesa-setup-env Remember to change $MESA_TOPto point to your Mesa source tree. 17 / 20
  • 18. i965_dri.so::{_mesa_Clear(),_mesa_CallList()} brw_clear() fast depth clear fast color clear meta clear brw_draw_prims() i965 draw function for GL functions that draw (such as glDrawElements()) brw_upload_state() brw_predraw_resolve_buffers() brw_postdraw_set_buffers_need_resolve() 18 / 20
  • 19. (GL states are converted to this at draw time. Each block is a buffer. Each arrow is a relocation entry.) 19 / 20
  • 20. We've got some time left INTEL_DEBUG=batch, INTEL_DEBUG=auband https://github.com/olvaffe/envytools INTEL_DEBUG=shader_time glretrace --pgpu 20 / 20