Bug 1404196 - Add profiling labels for WebGL draw commands. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 20 Oct 2017 16:56:28 -0700
changeset 689132 253c9db6c2a4c75c228c6a7590c6f56c698f2af4
parent 684181 a9131757dfdd4f2820c397523b54386f9675d607
child 689133 1f83d85da3a86f5acef633c1f48d3e1686fcca9a
push id86923
push userbmo:jgilbert@mozilla.com
push dateTue, 31 Oct 2017 03:29:56 +0000
reviewersdaoshengmu
bugs1404196
milestone58.0a1
Bug 1404196 - Add profiling labels for WebGL draw commands. - r=daoshengmu MozReview-Commit-ID: 5TUvfVxsfXg
dom/canvas/WebGLContextDraw.cpp
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -546,16 +546,17 @@ public:
     }
 };
 
 ////////////////////////////////////////
 
 void
 WebGLContext::DrawArrays(GLenum mode, GLint first, GLsizei vertCount)
 {
+    AUTO_PROFILER_LABEL("WebGLContext::DrawArrays", GRAPHICS);
     const char funcName[] = "drawArrays";
     if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     bool error = false;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
@@ -572,27 +573,29 @@ WebGLContext::DrawArrays(GLenum mode, GL
 
     const ScopedDrawWithTransformFeedback scopedTF(this, funcName, mode, vertCount,
                                                    instanceCount, &error);
     if (error)
         return;
 
     {
         ScopedDrawCallWrapper wrapper(*this);
+        AUTO_PROFILER_LABEL("glDrawArrays", GRAPHICS);
         gl->fDrawArrays(mode, first, vertCount);
     }
 
     Draw_cleanup(funcName);
     scopedTF.Advance();
 }
 
 void
 WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount,
                                   GLsizei instanceCount)
 {
+    AUTO_PROFILER_LABEL("WebGLContext::DrawArraysInstanced", GRAPHICS);
     const char funcName[] = "drawArraysInstanced";
     if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     bool error = false;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
@@ -611,16 +614,17 @@ WebGLContext::DrawArraysInstanced(GLenum
 
     const ScopedDrawWithTransformFeedback scopedTF(this, funcName, mode, vertCount,
                                                    instanceCount, &error);
     if (error)
         return;
 
     {
         ScopedDrawCallWrapper wrapper(*this);
+        AUTO_PROFILER_LABEL("glDrawArraysInstanced", GRAPHICS);
         gl->fDrawArraysInstanced(mode, first, vertCount, instanceCount);
     }
 
     Draw_cleanup(funcName);
     scopedTF.Advance();
 }
 
 ////////////////////////////////////////
@@ -768,16 +772,17 @@ HandleDrawElementsErrors(WebGLContext* w
         return;
     }
 }
 
 void
 WebGLContext::DrawElements(GLenum mode, GLsizei vertCount, GLenum type,
                            WebGLintptr byteOffset, const char* funcName)
 {
+    AUTO_PROFILER_LABEL("WebGLContext::DrawElements", GRAPHICS);
     if (!funcName) {
         funcName = "drawElements";
     }
 
     if (IsContextLost())
         return;
 
     MakeContextCurrent();
@@ -800,32 +805,34 @@ WebGLContext::DrawElements(GLenum mode, 
         ScopedDrawCallWrapper wrapper(*this);
         {
             UniquePtr<gl::GLContext::LocalErrorScope> errorScope;
 
             if (gl->IsANGLE()) {
                 errorScope.reset(new gl::GLContext::LocalErrorScope(*gl));
             }
 
+            AUTO_PROFILER_LABEL("glDrawElements", GRAPHICS);
             gl->fDrawElements(mode, vertCount, type,
                               reinterpret_cast<GLvoid*>(byteOffset));
 
             if (errorScope) {
                 HandleDrawElementsErrors(this, funcName, *errorScope);
             }
         }
     }
 
     Draw_cleanup(funcName);
 }
 
 void
 WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei vertCount, GLenum type,
                                     WebGLintptr byteOffset, GLsizei instanceCount)
 {
+    AUTO_PROFILER_LABEL("WebGLContext::DrawElementsInstanced", GRAPHICS);
     const char funcName[] = "drawElementsInstanced";
     if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     bool error = false;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
@@ -847,19 +854,21 @@ WebGLContext::DrawElementsInstanced(GLen
         ScopedDrawCallWrapper wrapper(*this);
         {
             UniquePtr<gl::GLContext::LocalErrorScope> errorScope;
 
             if (gl->IsANGLE()) {
                 errorScope.reset(new gl::GLContext::LocalErrorScope(*gl));
             }
 
+            AUTO_PROFILER_LABEL("glDrawElementsInstanced", GRAPHICS);
             gl->fDrawElementsInstanced(mode, vertCount, type,
                                        reinterpret_cast<GLvoid*>(byteOffset),
                                        instanceCount);
+
             if (errorScope) {
                 HandleDrawElementsErrors(this, funcName, *errorScope);
             }
         }
     }
 
     Draw_cleanup(funcName);
 }