310 likes | 529 Views
Advanced Debugging and Profiling with gDEBugger ES. Yaki Tebeka Avi Shapira. OpenGL ES debugging model. Application is sending API calls. Something happens here!. Why is OpenGL ES debugging difficult?. A general purpose debugger views the graphic system as a “ black box ”
E N D
Advanced Debugging and Profiling with gDEBugger ES Yaki Tebeka Avi Shapira
OpenGL ES debugging model Application is sending API calls Something happens here!
Why is OpenGL ES debugging difficult? A general purpose debugger views the graphic system as a “black box” • A render context is a huge “global” state machine • Commonly used features use a lot of state variables • You cannot watch OpenGL ES state variable values • You cannot break on state variables access functions • You cannot view allocated graphic objects (textures, buffers, etc) • OpenGL ES is a low level API: few thousand calls per frame • OpenGL ES error model: It takes time to locate the place that generated the error
Use an OpenGL ES debugger! An OpenGL ES debugger transforms your debugging task into a “white box” model • Lets you watch OpenGL ES state variable values • Lets you put a breakpoint on an OpenGL ES function • Lets you view allocated graphic objects (textures, etc) • Breaks automatically when an OpenGL error occurs • View the application call stack and source code when the application breaks • Displays the OpenGL ES calls log • Saves debugging time • Improves product quality
Problem #1 • The rendered object does not appear on the screen.
Remedy #1 • Use the State Variables view: • Break the application run when the relevant object is being rendered • Watch the values of the state variable associated with the described problem
Problem #2 • A rendered objects material is incorrect. • This happens in a certain mode / scenario.
Remedy #2 • Use the State Variables Comparison Viewer: • Break the application run when things are ok • Take a snapshot of the entire state machine • Break the application run when things go wrong • Compare the current state machine values to the saved snapshot
But how do I… • Break the application run when the relevant object is being rendered? • Breakpoints Dialog • Interactive Mode Toolbar • “Draw Step” Command • Find the place that changed the state variable value? • Call Stack View • Source code Viewer • Locate geometry related problems • Raster mode toolbar: force OpenGL ES raster mode to points, lines or fill • View the rendered geometry to locate Skinning / Level of details / Culling problems
If the problem is related to textures? • Use the Textures viewer • Lets you view textures allocated by the debugged application • Displays textures properties • Displays the bound textures for each bind target in each texture unit • Supports 1D, 2D, 3D, Cube map and rectangle textures • Textures data can be saved to disk as an image • Updates in real time
If the problem is related to Shaders? • Use the Shaders Source Code Editor • Lets you view shaders and programs allocated by the debugged application • Displays shaders and programs properties • Displays programs active uniforms values • Displays the active program • Programs and Shaders can be edited, compiled, linked and validated “on the fly” • Updates in real time
OpenGL ES profiling model Application is sending API calls Something happens here!
A profiling nightmare… • A general purpose profiler views the GPU as a “black box” • A pipelined system • Pipeline stages are highly parallel • Pipeline stages are highly programmable (usually SIMD or MIMD arrays) • Few actions per processor cycle • Caching is used in different stages • Hardware uses a lot of algorithms • IHVs keep implementation details secret…
Before you start the profiling effort • Clean your OpenGL ES usage! • Remove OpenGL ES errors • Remove redundant OpenGL ES calls • Redundant state changes • Repeatedly turning on and off the same mechanisms • Redundant API calls • etc.
Remove OpenGL errors • OpenGL usually ignores commands that cause errors • These commands may have significant impact on render performance! • It’s easy to test for errors, but much harder to locate them: // End of frame test: GLenumopenGLError = glGetError(); if (openGLError != GL_NO_ERROR) { assert(0); // But, who generated this error? }
Remove OpenGL errors - cont • gDEBugger ES enables you to “break on” • OpenGL errors • gDEBugger detected errors • NVIDIA GLExpert driver reports • When the debugged application breaks, view its call stack
Remove redundant OpenGL calls • Calls Statistics view • Displays the number of times each OpenGL, WGL and extensions function call was called • Calls History view • Displays a log of OpenGL, WGL and extensions function calls • Call Stack and Source Code views • Enables you to trace the source code location that caused each redundant call
Steps for optimizing render performance • Identify a performance bottleneck • Optimize the pipeline stage that causes the bottleneck • Repeat 1 and 2 until reaching the desired performance level or performance cannot be improved anymore • If you cannot improve performance anymore, you can add workload to pipeline stages that are not fully utilized (improve visual effects / visual fidelity)
Performance graph and dashboard views Displays performance counters graphs of: • gDEBugger • Win32 • ATI • NVIDIA
Performance Analysis Toolbar • Turn off the graphic pipeline stages one after the other • If performance improves when turning off a certain stage, you have found a graphic pipeline bottleneck
Commands include • Enter profiling mode • Eliminate draw commands • Eliminate raster operations • Eliminate fixed pipeline lights • Eliminate texture data fetch operations • Eliminate fragment shader operations
Other gDEBugger features • Launch any OpenGL or OpenGL ES application for debug or profile session. Instrumentation or recompilation are not needed! • Adds breakpoints for any OpenGL, OpenGL ES or extensions entry point • Views a list of active and deleted OpenGL render contexts • Display debugged process events such as: thread created, dll loaded and unloaded, breakpoint hit, etc. • Forces OpenGL to render directly into the front buffer and controls the rendering speed • Forces the OpenGL Polygon Raster mode to see the rendered geometry • Supports debugging and profiling of OpenGL ES applications • gDEBugger ES is being used as an “out of the box” OpenGL ES emulator for the embedded systems on a Windows PC machine • Displays implementation-specific OpenGL run-time information such as pixel formats and available extensions • Saves textures as image files to disk • Views OpenGL state variables values in the watch view • Supports applications that render using multiple threads and multiple render contexts. • Saves performance counters data into a file (.csv). This enables you to do performance and regression tests for your application using different hardware and driver configurations. • Output an OpenGL calls log into a formatted HTML file, containing texture imaged, vertex and fragment shaders source code. • Supports GL_GREMEDY_string_marker extension that allows adding string markers into the reported and recorded calls log, making the calls log much clearer. • Support OpenGL 2.0 standard and additional extensions • And more…
gDEBugger version 2.5 • The first public gDEBugger ES beta • Official version is planned to be shipped in September • OpenGL ES implementation on Desktop windows • Supports OpenGL ES 1.1 and EGL 1.1
In the pipeline… • Linux port • On device debugging and profiling • EGL 1.2 support • OpenGL ES 2.0 support • Buffer Viewer • Dev Studio Integration
Free gDEBugger License for Academic users! OpenGL ARB and Graphic Remedy Academic Program: • Annual program for all OpenGL Academic users • License of the full feature version for one year • Includes all software updates • A limited number of free licenses available fornon-commercial developers who are not in academia • More details: http://academic.gremedy.com
Questions / comments www.gremedy.com info (at) gremedy.com NVIDIA booth Tue-Thu