Closed
Bug 1378571
Opened 7 years ago
Closed 7 years ago
Avoid unnecessary MakeCurrentImpl calls when GL context is already current
Categories
(Core :: Graphics: CanvasWebGL, enhancement)
Core
Graphics: CanvasWebGL
Tracking
()
RESOLVED
FIXED
mozilla56
Tracking | Status | |
---|---|---|
firefox56 | --- | fixed |
People
(Reporter: svargas, Assigned: svargas)
Details
Attachments
(1 file, 5 obsolete files)
7.21 KB,
patch
|
jgilbert
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•7 years ago
|
||
Assignee: nobody → svargas
Attachment #8883763 -
Flags: review?(jgilbert)
Comment 2•7 years ago
|
||
Comment on attachment 8883763 [details] [diff] [review] 0001-Bug-1378571-Avoid-unnecessary-MakeCurrentImpl-calls-.patch Review of attachment 8883763 [details] [diff] [review]: ----------------------------------------------------------------- Good start! There should also be a flag on the context that mediates whether the context can take advantage of this optimization. This should be a const bool member. ::: gfx/gl/GLContext.cpp @@ +285,4 @@ > mMaxViewportDims[0] = 0; > mMaxViewportDims[1] = 0; > mOwningThreadId = PlatformThread::CurrentId(); > + MOZ_ALWAYS_TRUE(GLContext::currentContext.init()); With code inside a MOZ_ALWAYS_TRUE, prefer to put spaces around it, like: MOZ_ALWAYS_TRUE( sCurrentContext.init() ); It's probably worth following this with a `sCurrentContext.set(nullptr)`. @@ +3003,5 @@ > > +bool GLContext::MakeCurrent(bool aForce) { > + if (IsDestroyed()) { > + return false; > + } The style should be: bool GLContext::MakeCurrent(bool aForce) { if (IsDestroyed()) return false; #ifdef MOZ_GL_DEBUG PR_SetThreadPrivate... @@ +3020,5 @@ > + #endif > + #endif > + if (GLContext::currentContext.get() == this) { > + return true; > + } if (sCurrentContext.get() == this) return true; @@ +3024,5 @@ > + } > + > + bool success = MakeCurrentImpl(aForce); > + if (success) { > + GLContext::currentContext.set(this); GLContext:: is implicit ::: gfx/gl/GLContext.h @@ +197,4 @@ > { > public: > MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GLContext) > + static MOZ_THREAD_LOCAL(GLContext*) currentContext; sCurrentContext
Attachment #8883763 -
Flags: review?(jgilbert) → review-
Assignee | ||
Comment 3•7 years ago
|
||
Implemented fixes, added bool canUseTLSIsCurrent = false to GLContext constructor. Need to attach another patch for toggling it on / off depending on the context provider still.
Attachment #8883763 -
Attachment is obsolete: true
Attachment #8884094 -
Flags: review?(jgilbert)
Comment 4•7 years ago
|
||
Comment on attachment 8884094 [details] [diff] [review] 0001-Bug-1378571-Avoid-unnecessary-MakeCurrentImpl-calls-.patch Review of attachment 8884094 [details] [diff] [review]: ----------------------------------------------------------------- ::: gfx/gl/GLContext.cpp @@ +3007,5 @@ > +{ > + if (IsDestroyed()) > + return false; > + > + #ifdef MOZ_GL_DEBUG This #ifdef here should not be indented with the scope, or its contents must be indented with a new scope level. @@ +3022,5 @@ > + "MakeCurrent() called on different thread than this context was created on!"); > + #endif > + #endif > + if (mCanUseTLSIsCurrent && sCurrentContext.get() == this) > + return true; Add `MOZ_ASSERT(IsCurrent())` before the `return true` here. @@ +3028,5 @@ > + bool success = MakeCurrentImpl(aForce); > + if (mCanUseTLSIsCurrent && success) { > + sCurrentContext.set(this); > + } > + return success; I would write this as: if (!MakeCurrentImpl(aForce)) return false; if (mCanUseTLSIsCurrent) { sCurrentContext.set(this); } return true;
Attachment #8884094 -
Flags: review?(jgilbert) → review-
Assignee | ||
Comment 5•7 years ago
|
||
Attachment #8884094 -
Attachment is obsolete: true
Attachment #8884111 -
Flags: review?(jgilbert)
Assignee | ||
Comment 6•7 years ago
|
||
Modified the patch to use a 'gl.use-tls-is-current' key that either force enables, force disables, or uses the default useTLSISCurrent value passed into the GLContext constructor by ContextProviders.
Attachment #8884111 -
Attachment is obsolete: true
Attachment #8884111 -
Flags: review?(jgilbert)
Attachment #8884124 -
Flags: review?(jgilbert)
Assignee | ||
Comment 7•7 years ago
|
||
Modify ContextProviderEGL to use 'UseTLSIsCurrent' if 'sEGLLibrary.IsANGLE()' is true. Also pushed to TryServer: https://treeherder.mozilla.org/#/jobs?repo=try&revision=7693f2800644f068d11d3bd5aeac6382ca4ddc64
Attachment #8884124 -
Attachment is obsolete: true
Attachment #8884124 -
Flags: review?(jgilbert)
Attachment #8884127 -
Flags: review?(jgilbert)
Assignee | ||
Comment 8•7 years ago
|
||
Two new changes: 1) Switch from 'Once' to 'Live' in gfxPrefs.h for faster future debugging with the gl.use-tls-is-current preference. 2) Add '&& !aForce' to GLContext::MakeCurrent to allow users to explicitly bypass the mUseTLSIsCurrent behavior (was causing failures on misc WebGL conformance tests without this). Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=d1d61d1fc3bf57e79c222833b2da4e1f64f526f4
Attachment #8884127 -
Attachment is obsolete: true
Attachment #8884127 -
Flags: review?(jgilbert)
Attachment #8884460 -
Flags: review?(jgilbert)
Updated•7 years ago
|
Attachment #8884460 -
Flags: review?(jgilbert) → review+
Assignee | ||
Updated•7 years ago
|
Keywords: checkin-needed
Pushed by cbook@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/122e0e90b9a1 Avoid unnecessary MakeCurrentImpl calls when GL context is already current - r=jgilbert
Keywords: checkin-needed
Comment 10•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/122e0e90b9a1
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox56:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in
before you can comment on or make changes to this bug.
Description
•