SlideShare a Scribd company logo
1 of 36
Leszek Godlewski
Programmer, Nordic Games
OpenGL (ES) debugging
Nordic Games GmbH
● Started in 2011 as a sister company to Nordic Games
Publishing (We Sing)
● Base IP acquired from JoWooD and DreamCatcher (SpellForce,
The Guild, Aquanox, Painkiller)
● Initially focusing on smaller, niche games
● Acquired THQ IPs in 2013 (Darksiders, Titan Quest, Red
Faction, MX vs. ATV)
● Now shifting towards being a production company with
internal devs
● Since fall 2013: internal studio in Munich, Germany (Grimlore
Games)
Who is this guy?
Leszek Godlewski
Programmer, Nordic Games (early 2014 – now)
– Linux port of Darksiders
Freelance Programmer (Sep 2013 – early 2014)
– Linux port of Painkiller Hell & Damnation
– Linux port of Deadfall Adventures
Generalist Programmer, The Farm 51 (Mar 2010 – Aug
2013)
– Painkiller Hell & Damnation, Deadfall Adventures
Demo code available
is.gd/GDCE14Linux
Agenda
Overview of available IHV tools
Debug callback
– Setup and implementation
– Verbosity control
– Noise filtering
API call tracing and replaying
– Using apitrace
– Annotating the call trace
Resource leak checking
NVIDIA Nsight
NVIDIA Nsight (cont.)
Supports CUDA, OpenGL and Direct3D
Plugin for Visual Studio and Eclipse
Very good feature set
– Including debugging shaders just like CPU code! See [PLASTIC13]
– Operation on one machine is slow, it's suggested to have two (sic!)
Hardware limitations
– Recent NVIDIA GPUs only
Software limitations
– Windows only (Visual Studio edition)
– Windows or Linux (Eclipse edition)
– OpenGL 4.2 or newer
AMD CodeXL
AMD CodeXL (cont.)
Supports OpenCL, OpenGL and advanced AMD CPU
features
Stand-alone applicaiton + plugin for Visual Studio
Reasonable feature set
– Includes functionality of gDEBugger
– No shader debugging (although OpenCL kernels can be debugged)
Hardware limitations
– Some functionality limited to AMD GPUs
AMD GPU PerfStudio
AMD GPU PerfStudio (cont.)
Supports OpenGL and Direct3D
Cross-platform client, Windows stand-alone server/GUI
Reasonable feature set
– Shader debugging only for Direct3D
Hardware limitations
– Some functionality limited to AMD GPUs
Software limitations
– OpenGL 4.2 or newer
Intel Graphics Performance Analyzer
Intel Graphics Performance Analyzer (cont.)
Supports OpenGL ES and Direct3D
Windows/Android client, Windows/Linux stand-alone
server/GUI
Reasonable feature set
– No shader debugging
Hardware limitations
– Only Intel GPUs
Software limitations
– Windows or Android only
– OpenGL ES only (Android)
Agenda
Overview of available IHV tools
Debug callback
– Setup and implementation
– Verbosity control
– Noise filtering
API call tracing and replaying
– Using apitrace
– Annotating the call trace
Resource leak checking
Ye Olde Way
Call glGetError() after each OpenGL call
Get 1 of 8 (sic!) error codes
Look the call up in the manual
See what this particular error means in this particular
context
Check which of the parameters was wrong
– Usually by attaching a regular debugger and replaying the scenario
…
This sucks!
Ye Olde Way
Call glGetError() after each OpenGL call
Get 1 of 8 (sic!) error codes
Look the call up in the manual
See what this particular error means in this particular
context
Check which of the parameters was wrong
– Usually by attaching a regular debugger and replaying the scenario
…
This sucks! used to suck ☺
Debug callback
Never call glGetError() again!
Much more detailed information
– Including Performance tips from the driver
– Good to check what different drivers say
May not work without a debug OpenGL context
– GLX_CONTEXT_DEBUG_BIT_ARB
– WGL_CONTEXT_DEBUG_BIT_ARB
Debug callback (cont.)
Provided by either of (ABI-compatible):
GL_KHR_debug or
GL_ARB_debug_output
Debug callback (cont.)
void callback(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
const GLchar* message,
const void* userParam);
Filter by
source, type,
severity or
individual
messages
Debug callback (cont.)
Verbosity can be controlled
– glDebugMessageControl[ARB]()
– [OPENGL01][OPENGL02]
Turn to 11 for valuable perf information:
– Which memory type a buffer is backed by
– Memory wasted by unused mip levels
– More!
– glDebugMessageControl(GL_DONT_CARE,
GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_TRUE);
Agenda
Overview of available IHV tools
Debug callback
– Setup and implementation
– Verbosity control
– Noise filtering
API call tracing and replaying
– Using apitrace
– Annotating the call trace
Resource leak checking
API call tracing
Record a trace of the run of the application
Replay and review the trace
– Look up OpenGL state at a particular call
– Inspect state variables, resources and objects:
●
Textures
●
Shaders
●
Buffers
●
…
apitrace or VOGL
Well, this is not helpful...
Much better!
Annotating the call stream
Annotating the call stream (cont.)
All aforementioned extensions supported by apitrace
even if not by driver
Recommended: GL_KHR_debug
– Best vendor coverage
●
GL_KHR_debug is slightly less common
●
GL_ARB_debug_output has no debug groups or object labels
– Emulation wrapper for Mac OS X [PIPELINE13]
Annotating the call stream (cont.)
Call grouping
– glPushDebugGroup()/glPopDebugGroup() (KHR_debug)
One-off messages
– glDebugMessageInsert()
(KHR_debug/ARB_debug_output)
– glStringMarkerGREMEDY() (GREMEDY_string_marker)
Object labelling
Buffer, shader, program, vertex array, query, program
pipeline, transform feedback, sampler, texture, render
buffer, frame buffer, display list
– glObjectLabel(), glGetObjectLabel()
Sync objects
– glObjectPtrLabel(), glGetObjectPtrLabel()
Annotation caveats
Multi-threaded/multi-context OpenGL application may
break debug group hierarchy
glDebugMessageInsert() calls the debug callback,
polluting error streams
– Workaround: drop if source ==
GL_DEBUG_SOURCE_APPLICATION
Agenda
Overview of available IHV tools
Debug callback
– Setup and implementation
– Verbosity control
– Noise filtering
API call tracing and replaying
– Using apitrace
– Annotating the call trace
Resource leak checking
Resource leak checking
When created correctly (glGen*()), object names are
integers, consecutive & recycled
– Not necessarily!
– Desktop GL names may be user-supplied
– GLES may be not recycled
Stupid idea: iterate over names [1; ∞)?
Resource leak checking (cont.)
Courtesy of Eric Lengyel & Fabian Giesen
static void check_for_leaks()
{
GLuint max_id = 10000; // better idea would be to keep track of assigned names.
GLuint id;
// if brute force doesn't work, you're not applying it hard enough
for ( id = 1 ; id <= max_id ; id++ )
{
#define CHECK( type ) if ( glIs##type( id ) ) 
fprintf( stderr, "GLX: leaked " #type " handle 0x%xn", (unsigned int) id )
CHECK( Texture );
CHECK( Buffer );
CHECK( Framebuffer );
CHECK( Renderbuffer );
CHECK( VertexArray );
CHECK( Shader );
CHECK( Program );
CHECK( ProgramPipeline );
#undef CHECK
}
}
Takeaway
IHV tools are cool, but complex & have their limits
– Valuable, so pick what works best for your HW+SW combo
Debug callbacks work everywhere
Debug callbacks will show you exactly what the problem
is (most of the time)
API call tracing works everywhere across-the-board
Annotating the trace helps you find your way
Resource leak checks? glIs*()!
@ l g o d l e w s k i @ n o r d i c ga m e s . a t
t @ T h e I n e Q u a t i o n
K w ww . i n e qu a t i o n . o r g
Questions?
F u rt h e r N o rd i c G a m e s i n f o rm a t i o n :
K w w w . n o r d i c g a m e s . a t
D e v e l o p me n t i n f o r ma t i o n :
K ww w . g ri ml o re ga m e s . c o m
Thank you!
References
 PLASTIC13 – Staniszewski, M., Szymczyk, M. ”Nsight” [link]
 OPENGL01 – “ARB_debug_output” [link]
 OPENGL02 – “KHR_debug” [link]
 PIPELINE13 – Menzer, R. ”(Simulating) KHR_debug on MacOS X” [link]

More Related Content

What's hot

A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)Matthias Brugger
 
The Listening: Email Client Backdoor
The Listening: Email Client BackdoorThe Listening: Email Client Backdoor
The Listening: Email Client BackdoorMichael Scovetta
 
Jollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen Chen
 
[COSCUP 2021] A trip about how I contribute to LLVM
[COSCUP 2021] A trip about how I contribute to LLVM[COSCUP 2021] A trip about how I contribute to LLVM
[COSCUP 2021] A trip about how I contribute to LLVMDouglas Chen
 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - ShadersNick Pruehs
 
Alessandro Abbruzzetti - Kernal64
Alessandro Abbruzzetti - Kernal64Alessandro Abbruzzetti - Kernal64
Alessandro Abbruzzetti - Kernal64Scala Italy
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsLinaro
 
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON
 
Doom Technical Review
Doom Technical ReviewDoom Technical Review
Doom Technical ReviewAli Salehi
 
Advanced Evasion Techniques by Win32/Gapz
Advanced Evasion Techniques by Win32/GapzAdvanced Evasion Techniques by Win32/Gapz
Advanced Evasion Techniques by Win32/GapzAlex Matrosov
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UIOpersys inc.
 
Exploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source ToolsExploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source ToolsKoan-Sin Tan
 
Why kernelspace sucks?
Why kernelspace sucks?Why kernelspace sucks?
Why kernelspace sucks?OpenFest team
 
A Quick Introduction to Programmable Logic
A Quick Introduction to Programmable LogicA Quick Introduction to Programmable Logic
A Quick Introduction to Programmable LogicOmer Kilic
 
Binary art - Byte-ing the PE that fails you (extended offline version)
Binary art - Byte-ing the PE that fails you (extended offline version)Binary art - Byte-ing the PE that fails you (extended offline version)
Binary art - Byte-ing the PE that fails you (extended offline version)Ange Albertini
 
Android Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and ResourcesAndroid Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and ResourcesOpersys inc.
 

What's hot (20)

A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
 
The Listening: Email Client Backdoor
The Listening: Email Client BackdoorThe Listening: Email Client Backdoor
The Listening: Email Client Backdoor
 
Jollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-levelJollen's Presentation: Introducing Android low-level
Jollen's Presentation: Introducing Android low-level
 
[COSCUP 2021] A trip about how I contribute to LLVM
[COSCUP 2021] A trip about how I contribute to LLVM[COSCUP 2021] A trip about how I contribute to LLVM
[COSCUP 2021] A trip about how I contribute to LLVM
 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - Shaders
 
Alessandro Abbruzzetti - Kernal64
Alessandro Abbruzzetti - Kernal64Alessandro Abbruzzetti - Kernal64
Alessandro Abbruzzetti - Kernal64
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
Code Injection in Windows
Code Injection in WindowsCode Injection in Windows
Code Injection in Windows
 
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
 
Doom Technical Review
Doom Technical ReviewDoom Technical Review
Doom Technical Review
 
Advanced Evasion Techniques by Win32/Gapz
Advanced Evasion Techniques by Win32/GapzAdvanced Evasion Techniques by Win32/Gapz
Advanced Evasion Techniques by Win32/Gapz
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Exploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source ToolsExploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source Tools
 
Why kernelspace sucks?
Why kernelspace sucks?Why kernelspace sucks?
Why kernelspace sucks?
 
A Peek into TFRT
A Peek into TFRTA Peek into TFRT
A Peek into TFRT
 
A Quick Introduction to Programmable Logic
A Quick Introduction to Programmable LogicA Quick Introduction to Programmable Logic
A Quick Introduction to Programmable Logic
 
There is more to C
There is more to CThere is more to C
There is more to C
 
Binary art - Byte-ing the PE that fails you (extended offline version)
Binary art - Byte-ing the PE that fails you (extended offline version)Binary art - Byte-ing the PE that fails you (extended offline version)
Binary art - Byte-ing the PE that fails you (extended offline version)
 
Android Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and ResourcesAndroid Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and Resources
 
Android ndk
Android ndkAndroid ndk
Android ndk
 

Viewers also liked

Flying machine Business Profile
Flying machine Business ProfileFlying machine Business Profile
Flying machine Business ProfileSandeep Malkar
 
Crisis Subprime en España
Crisis Subprime en EspañaCrisis Subprime en España
Crisis Subprime en Españaespejodeoesed
 
El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después espejodeoesed
 
CriminalEFS-PowerPoint
CriminalEFS-PowerPointCriminalEFS-PowerPoint
CriminalEFS-PowerPointJenn Amabile
 
Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses Fikriyyah George
 
Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Leszek Godlewski
 
каталог керасис
каталог керасискаталог керасис
каталог керасисNastasik
 
Хипстеры в энтерпрайзе
Хипстеры в энтерпрайзеХипстеры в энтерпрайзе
Хипстеры в энтерпрайзеAleksandr Tarasov
 
Service Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud InternalsService Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud InternalsAleksandr Tarasov
 

Viewers also liked (17)

Flying machine Business Profile
Flying machine Business ProfileFlying machine Business Profile
Flying machine Business Profile
 
Crisis Subprime en España
Crisis Subprime en EspañaCrisis Subprime en España
Crisis Subprime en España
 
Ecosistemas
EcosistemasEcosistemas
Ecosistemas
 
El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después
 
El barrroco
El barrrocoEl barrroco
El barrroco
 
CriminalEFS-PowerPoint
CriminalEFS-PowerPointCriminalEFS-PowerPoint
CriminalEFS-PowerPoint
 
Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses
 
Imágenes inmersivas
Imágenes inmersivasImágenes inmersivas
Imágenes inmersivas
 
Suir img
Suir imgSuir img
Suir img
 
Gamedev-grade debugging
Gamedev-grade debuggingGamedev-grade debugging
Gamedev-grade debugging
 
Green Peace y WWF
Green Peace y WWFGreen Peace y WWF
Green Peace y WWF
 
Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0
 
каталог керасис
каталог керасискаталог керасис
каталог керасис
 
Хипстеры в энтерпрайзе
Хипстеры в энтерпрайзеХипстеры в энтерпрайзе
Хипстеры в энтерпрайзе
 
Open gl
Open glOpen gl
Open gl
 
Docker In Bank Unrated
Docker In Bank UnratedDocker In Bank Unrated
Docker In Bank Unrated
 
Service Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud InternalsService Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud Internals
 

Similar to OpenGL (ES) debugging

Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it Prakashchand Suthar
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012DefCamp
 
The Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's PerspectiveThe Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's Perspectivekfrdbs
 
Reverse code engineering
Reverse code engineeringReverse code engineering
Reverse code engineeringKrishs Patil
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipelineGirish Ghate
 
Gdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glGdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glchangehee lee
 
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The Hacking Games - Operation System Vulnerabilities Meetup 29112022The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The Hacking Games - Operation System Vulnerabilities Meetup 29112022lior mazor
 
Game development
Game developmentGame development
Game developmentAsido_
 
Android Things in action
Android Things in actionAndroid Things in action
Android Things in actionStefano Sanna
 
cinema_time_new.pdf
cinema_time_new.pdfcinema_time_new.pdf
cinema_time_new.pdfMaxDmitriev
 
Native client (Евгений Эльцин)
Native client (Евгений Эльцин)Native client (Евгений Эльцин)
Native client (Евгений Эльцин)Ontico
 
Baby Demuxed's First Assembly Language Function
Baby Demuxed's First Assembly Language FunctionBaby Demuxed's First Assembly Language Function
Baby Demuxed's First Assembly Language FunctionKieran Kunhya
 
Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)Igalia
 
TensorFlow - La IA detrás de Google
TensorFlow - La IA detrás de GoogleTensorFlow - La IA detrás de Google
TensorFlow - La IA detrás de GoogleIsrael Blancas
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)JiandSon
 
TSC Summit #3 - Reverse engineering and anti debugging techniques
TSC Summit #3 - Reverse engineering and anti debugging techniquesTSC Summit #3 - Reverse engineering and anti debugging techniques
TSC Summit #3 - Reverse engineering and anti debugging techniquesMikal Villa
 
3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)mistercteam
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...Hafez Kamal
 

Similar to OpenGL (ES) debugging (20)

Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
 
NvFX GTC 2013
NvFX GTC 2013NvFX GTC 2013
NvFX GTC 2013
 
The Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's PerspectiveThe Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's Perspective
 
Reverse code engineering
Reverse code engineeringReverse code engineering
Reverse code engineering
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipeline
 
Gdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glGdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_gl
 
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The Hacking Games - Operation System Vulnerabilities Meetup 29112022The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
 
Game development
Game developmentGame development
Game development
 
Android Things in action
Android Things in actionAndroid Things in action
Android Things in action
 
cinema_time_new.pdf
cinema_time_new.pdfcinema_time_new.pdf
cinema_time_new.pdf
 
Native client (Евгений Эльцин)
Native client (Евгений Эльцин)Native client (Евгений Эльцин)
Native client (Евгений Эльцин)
 
Baby Demuxed's First Assembly Language Function
Baby Demuxed's First Assembly Language FunctionBaby Demuxed's First Assembly Language Function
Baby Demuxed's First Assembly Language Function
 
Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)
 
TensorFlow - La IA detrás de Google
TensorFlow - La IA detrás de GoogleTensorFlow - La IA detrás de Google
TensorFlow - La IA detrás de Google
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
TSC Summit #3 - Reverse engineering and anti debugging techniques
TSC Summit #3 - Reverse engineering and anti debugging techniquesTSC Summit #3 - Reverse engineering and anti debugging techniques
TSC Summit #3 - Reverse engineering and anti debugging techniques
 
3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
 
Vxcon 2016
Vxcon 2016Vxcon 2016
Vxcon 2016
 

Recently uploaded

The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 

Recently uploaded (20)

The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 

OpenGL (ES) debugging

  • 1. Leszek Godlewski Programmer, Nordic Games OpenGL (ES) debugging
  • 2. Nordic Games GmbH ● Started in 2011 as a sister company to Nordic Games Publishing (We Sing) ● Base IP acquired from JoWooD and DreamCatcher (SpellForce, The Guild, Aquanox, Painkiller) ● Initially focusing on smaller, niche games ● Acquired THQ IPs in 2013 (Darksiders, Titan Quest, Red Faction, MX vs. ATV) ● Now shifting towards being a production company with internal devs ● Since fall 2013: internal studio in Munich, Germany (Grimlore Games)
  • 3. Who is this guy? Leszek Godlewski Programmer, Nordic Games (early 2014 – now) – Linux port of Darksiders Freelance Programmer (Sep 2013 – early 2014) – Linux port of Painkiller Hell & Damnation – Linux port of Deadfall Adventures Generalist Programmer, The Farm 51 (Mar 2010 – Aug 2013) – Painkiller Hell & Damnation, Deadfall Adventures
  • 5. Agenda Overview of available IHV tools Debug callback – Setup and implementation – Verbosity control – Noise filtering API call tracing and replaying – Using apitrace – Annotating the call trace Resource leak checking
  • 7. NVIDIA Nsight (cont.) Supports CUDA, OpenGL and Direct3D Plugin for Visual Studio and Eclipse Very good feature set – Including debugging shaders just like CPU code! See [PLASTIC13] – Operation on one machine is slow, it's suggested to have two (sic!) Hardware limitations – Recent NVIDIA GPUs only Software limitations – Windows only (Visual Studio edition) – Windows or Linux (Eclipse edition) – OpenGL 4.2 or newer
  • 9. AMD CodeXL (cont.) Supports OpenCL, OpenGL and advanced AMD CPU features Stand-alone applicaiton + plugin for Visual Studio Reasonable feature set – Includes functionality of gDEBugger – No shader debugging (although OpenCL kernels can be debugged) Hardware limitations – Some functionality limited to AMD GPUs
  • 11. AMD GPU PerfStudio (cont.) Supports OpenGL and Direct3D Cross-platform client, Windows stand-alone server/GUI Reasonable feature set – Shader debugging only for Direct3D Hardware limitations – Some functionality limited to AMD GPUs Software limitations – OpenGL 4.2 or newer
  • 13. Intel Graphics Performance Analyzer (cont.) Supports OpenGL ES and Direct3D Windows/Android client, Windows/Linux stand-alone server/GUI Reasonable feature set – No shader debugging Hardware limitations – Only Intel GPUs Software limitations – Windows or Android only – OpenGL ES only (Android)
  • 14. Agenda Overview of available IHV tools Debug callback – Setup and implementation – Verbosity control – Noise filtering API call tracing and replaying – Using apitrace – Annotating the call trace Resource leak checking
  • 15. Ye Olde Way Call glGetError() after each OpenGL call Get 1 of 8 (sic!) error codes Look the call up in the manual See what this particular error means in this particular context Check which of the parameters was wrong – Usually by attaching a regular debugger and replaying the scenario … This sucks!
  • 16. Ye Olde Way Call glGetError() after each OpenGL call Get 1 of 8 (sic!) error codes Look the call up in the manual See what this particular error means in this particular context Check which of the parameters was wrong – Usually by attaching a regular debugger and replaying the scenario … This sucks! used to suck ☺
  • 17. Debug callback Never call glGetError() again! Much more detailed information – Including Performance tips from the driver – Good to check what different drivers say May not work without a debug OpenGL context – GLX_CONTEXT_DEBUG_BIT_ARB – WGL_CONTEXT_DEBUG_BIT_ARB
  • 18. Debug callback (cont.) Provided by either of (ABI-compatible): GL_KHR_debug or GL_ARB_debug_output
  • 19. Debug callback (cont.) void callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); Filter by source, type, severity or individual messages
  • 20. Debug callback (cont.) Verbosity can be controlled – glDebugMessageControl[ARB]() – [OPENGL01][OPENGL02] Turn to 11 for valuable perf information: – Which memory type a buffer is backed by – Memory wasted by unused mip levels – More! – glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_TRUE);
  • 21. Agenda Overview of available IHV tools Debug callback – Setup and implementation – Verbosity control – Noise filtering API call tracing and replaying – Using apitrace – Annotating the call trace Resource leak checking
  • 22. API call tracing Record a trace of the run of the application Replay and review the trace – Look up OpenGL state at a particular call – Inspect state variables, resources and objects: ● Textures ● Shaders ● Buffers ● … apitrace or VOGL
  • 23. Well, this is not helpful...
  • 26. Annotating the call stream (cont.) All aforementioned extensions supported by apitrace even if not by driver Recommended: GL_KHR_debug – Best vendor coverage ● GL_KHR_debug is slightly less common ● GL_ARB_debug_output has no debug groups or object labels – Emulation wrapper for Mac OS X [PIPELINE13]
  • 27. Annotating the call stream (cont.) Call grouping – glPushDebugGroup()/glPopDebugGroup() (KHR_debug) One-off messages – glDebugMessageInsert() (KHR_debug/ARB_debug_output) – glStringMarkerGREMEDY() (GREMEDY_string_marker)
  • 28. Object labelling Buffer, shader, program, vertex array, query, program pipeline, transform feedback, sampler, texture, render buffer, frame buffer, display list – glObjectLabel(), glGetObjectLabel() Sync objects – glObjectPtrLabel(), glGetObjectPtrLabel()
  • 29. Annotation caveats Multi-threaded/multi-context OpenGL application may break debug group hierarchy glDebugMessageInsert() calls the debug callback, polluting error streams – Workaround: drop if source == GL_DEBUG_SOURCE_APPLICATION
  • 30. Agenda Overview of available IHV tools Debug callback – Setup and implementation – Verbosity control – Noise filtering API call tracing and replaying – Using apitrace – Annotating the call trace Resource leak checking
  • 31. Resource leak checking When created correctly (glGen*()), object names are integers, consecutive & recycled – Not necessarily! – Desktop GL names may be user-supplied – GLES may be not recycled Stupid idea: iterate over names [1; ∞)?
  • 32. Resource leak checking (cont.) Courtesy of Eric Lengyel & Fabian Giesen static void check_for_leaks() { GLuint max_id = 10000; // better idea would be to keep track of assigned names. GLuint id; // if brute force doesn't work, you're not applying it hard enough for ( id = 1 ; id <= max_id ; id++ ) { #define CHECK( type ) if ( glIs##type( id ) ) fprintf( stderr, "GLX: leaked " #type " handle 0x%xn", (unsigned int) id ) CHECK( Texture ); CHECK( Buffer ); CHECK( Framebuffer ); CHECK( Renderbuffer ); CHECK( VertexArray ); CHECK( Shader ); CHECK( Program ); CHECK( ProgramPipeline ); #undef CHECK } }
  • 33. Takeaway IHV tools are cool, but complex & have their limits – Valuable, so pick what works best for your HW+SW combo Debug callbacks work everywhere Debug callbacks will show you exactly what the problem is (most of the time) API call tracing works everywhere across-the-board Annotating the trace helps you find your way Resource leak checks? glIs*()!
  • 34. @ l g o d l e w s k i @ n o r d i c ga m e s . a t t @ T h e I n e Q u a t i o n K w ww . i n e qu a t i o n . o r g Questions?
  • 35. F u rt h e r N o rd i c G a m e s i n f o rm a t i o n : K w w w . n o r d i c g a m e s . a t D e v e l o p me n t i n f o r ma t i o n : K ww w . g ri ml o re ga m e s . c o m Thank you!
  • 36. References  PLASTIC13 – Staniszewski, M., Szymczyk, M. ”Nsight” [link]  OPENGL01 – “ARB_debug_output” [link]  OPENGL02 – “KHR_debug” [link]  PIPELINE13 – Menzer, R. ”(Simulating) KHR_debug on MacOS X” [link]

Editor's Notes

  1. &amp;lt;number&amp;gt;
  2. &amp;lt;number&amp;gt;
  3. &amp;lt;number&amp;gt;
  4. &amp;lt;number&amp;gt;