Last Comment Bug 597881 - OpenGL debug mode
: OpenGL debug mode
Status: RESOLVED FIXED
: dev-doc-complete
Product: Core
Classification: Components
Component: Graphics (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: Benoit Jacob [:bjacob] (mostly away)
:
:
Mentors:
: 595151 (view as bug list)
Depends on: 603821
Blocks: 594357 601601
  Show dependency treegraph
 
Reported: 2010-09-19 12:46 PDT by Benoit Jacob [:bjacob] (mostly away)
Modified: 2011-09-06 09:12 PDT (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
OpenGL debug mode (88.72 KB, patch)
2010-09-19 12:46 PDT, Benoit Jacob [:bjacob] (mostly away)
no flags Details | Diff | Splinter Review
updated patch (111.84 KB, patch)
2010-09-24 13:02 PDT, Benoit Jacob [:bjacob] (mostly away)
no flags Details | Diff | Splinter Review
patch v3 (112.98 KB, patch)
2010-10-01 14:45 PDT, Benoit Jacob [:bjacob] (mostly away)
no flags Details | Diff | Splinter Review
some small tweaks (108.83 KB, patch)
2010-10-05 11:41 PDT, Vladimir Vukicevic [:vlad] [:vladv]
no flags Details | Diff | Splinter Review
updated and compiling now! (108.75 KB, patch)
2010-10-05 14:41 PDT, Vladimir Vukicevic [:vlad] [:vladv]
jacob.benoit.1: review+
Details | Diff | Splinter Review
updated to apply again (114.80 KB, patch)
2010-10-08 11:11 PDT, Benoit Jacob [:bjacob] (mostly away)
jacob.benoit.1: review+
vladimir: approval2.0+
Details | Diff | Splinter Review

Description Benoit Jacob [:bjacob] (mostly away) 2010-09-19 12:46:05 PDT
This patch adds a OpenGL debug mode.

* This only has an effect on DEBUG builds. Non-DEBUG builds should be essentially unaffected (just a couple more unused PRPackedBool's in GLContext)

* When using a DEBUG build, you can enable the OpenGL debug mode by defining the environment variable MOZ_GL_DEBUG. This has the following effects on every GL call:
   1. Checks that the GL context is current. This uses a thread-local static variable. Aborts otherwise.
   2. Calls glFinish() after every GL call. This turns OpenGL into a synchronous API. Thanks to that, in case of a crash in the Firefox process caused by a GL call, the stack trace that we get becomes useful.
   3. Checks that no GL error was generated. Prints an error message otherwise.

* An extra verbose mode can be enabled by defining the env var MOZ_GL_DEBUG_VERBOSE. It causes messages to be printed before and after every GL call. This is useful to debug graphics system crashes/lockups that make the computer unusable.

* An extra pedantic mode can be enabled by defining the env var MOZ_GL_DEBUG_ABORT_ON_ERROR. It causes us to abort as soon as a GL error is generated. This is useful in the common case where we know that no error should be generated. It must be noted though that some valid WebGL code may generate OpenGL errors (although most WebGL errors are handled by us before calling OpenGL).

The extra verbose/pedantic modes imply the regular debug mode.

Not adding a pref for this, as it's only a debugging tool and mostly a one-shot tool.

Notice that this patch reimplements GL functions as inline methods in GLContext. Notice that being implemented inline in the class body, the 'inline' keyword should be implicit for them.

Notice that the GL error handling means that we reimplement glGetError.

This patch replaces the patch from bug 595151. No multiple inheritance anymode, instead we have a member struct mSymbols.
Comment 1 Benoit Jacob [:bjacob] (mostly away) 2010-09-19 12:46:43 PDT
Created attachment 476665 [details] [diff] [review]
OpenGL debug mode
Comment 2 Benoit Jacob [:bjacob] (mostly away) 2010-09-19 12:49:26 PDT
*** Bug 595151 has been marked as a duplicate of this bug. ***
Comment 3 Benoit Jacob [:bjacob] (mostly away) 2010-09-24 13:02:09 PDT
Created attachment 478371 [details] [diff] [review]
updated patch

Updated patch:
 - support Windows
 - adapt to recent changes, especially the Scissor / Viewport stuff

Will do the generate-stuff-with-a-script changes and then will ask for review.
Comment 4 Benoit Jacob [:bjacob] (mostly away) 2010-10-01 14:45:58 PDT
Created attachment 480252 [details] [diff] [review]
patch v3

Here's a new version. Still no automatic python generation, but made it compile on all platforms by removing the thread-local stuff, adding an assertion instead that all GL calls are made from the main thread. Of course this is inessential so if we eventually need to do GL calls from other threads, we'd need to fix this. Comments added.
Comment 5 Vladimir Vukicevic [:vlad] [:vladv] 2010-10-05 11:41:34 PDT
Created attachment 480989 [details] [diff] [review]
some small tweaks

some small tweaks to this -- mainly moving things to a .h file, and changing some variables and stuff around
Comment 6 Benoit Jacob [:bjacob] (mostly away) 2010-10-05 12:30:22 PDT
What happened to ZeroBase? It disappeared, but you are still calling Zero() though (compilation error).

ZeroBase probably didn't have a good name, but it was already useful not only for the symbols, also for the ContextFormat class.
Comment 7 Vladimir Vukicevic [:vlad] [:vladv] 2010-10-05 14:41:09 PDT
Created attachment 481054 [details] [diff] [review]
updated and compiling now!

Updated and fixed.. yeah, I nuked ZeroBase -- it had some utility, but it's clearer/easier to just call memset in the two places where it's relevant rather than introduce another base class that people have to figure out when reading the code.  :-)
Comment 8 Benoit Jacob [:bjacob] (mostly away) 2010-10-08 11:11:59 PDT
Created attachment 481878 [details] [diff] [review]
updated to apply again

trivial update.
Comment 9 Benoit Jacob [:bjacob] (mostly away) 2010-10-12 14:53:07 PDT
Pushed at last!

http://hg.mozilla.org/mozilla-central/rev/d3f448b20f20
Comment 10 Daniel Holbert [:dholbert] 2010-10-12 16:20:48 PDT
This busted non-libxul debug builds -- filed as Bug 603821.
Comment 11 Eric Shepherd [:sheppy] 2010-11-09 13:04:01 PST
Now documented:

https://developer.mozilla.org/En/Debugging/Debugging_OpenGL

Linked from the main Debugging page at:

https://developer.mozilla.org/En/Debugging

Note You need to log in before you can comment on or make changes to this bug.