Bug 1309643 - Only enable primitive restart index on OSX for DrawElements. - r=ethlin. a=gchang
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 16 Dec 2016 16:17:29 -0800
changeset 353130 617286d6483d74081fdb9fc001bed23b002a1ffe
parent 353129 882a3059bd47062f8272eaf6f7699e4cf97b1b36
child 353131 62eb5ff8893e7803da94b2e52bd108285aa1f5fe
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersethlin, gchang
bugs1309643
milestone52.0a2
Bug 1309643 - Only enable primitive restart index on OSX for DrawElements. - r=ethlin. a=gchang
dom/canvas/WebGL2Context.cpp
dom/canvas/WebGLContextDraw.cpp
gfx/gl/GLContextFeatures.cpp
--- a/dom/canvas/WebGL2Context.cpp
+++ b/dom/canvas/WebGL2Context.cpp
@@ -170,17 +170,16 @@ WebGLContext::InitWebGL2(FailureReason* 
         // support sRGB operations on framebuffers.
         gl->fEnable(LOCAL_GL_FRAMEBUFFER_SRGB_EXT);
     }
 
     if (gl->IsSupported(gl::GLFeature::prim_restart_fixed)) {
         gl->fEnable(LOCAL_GL_PRIMITIVE_RESTART_FIXED_INDEX);
     } else {
         MOZ_ASSERT(gl->IsSupported(gl::GLFeature::prim_restart));
-        gl->fEnable(LOCAL_GL_PRIMITIVE_RESTART);
     }
 
     //////
 
     return true;
 }
 
 } // namespace mozilla
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -265,21 +265,21 @@ WebGLContext::DrawArrays_check(const cha
         return false;
     }
 
     if (!ValidateStencilParamsForDrawCall())
         return false;
 
     if (IsWebGL2() && !gl->IsSupported(gl::GLFeature::prim_restart_fixed)) {
         MOZ_ASSERT(gl->IsSupported(gl::GLFeature::prim_restart));
-        if (mPrimRestartTypeBytes != 4) {
-            mPrimRestartTypeBytes = 4;
+        if (mPrimRestartTypeBytes != 0) {
+            mPrimRestartTypeBytes = 0;
 
-            // OSX has issues leaving this as 0.
-            gl->fPrimitiveRestartIndex(UINT32_MAX);
+            // OSX appears to have severe perf issues with leaving this enabled.
+            gl->fDisable(LOCAL_GL_PRIMITIVE_RESTART);
         }
     }
 
     if (!vertCount || !instanceCount)
         return false; // No error, just early out.
 
     if (!ValidateBufferFetching(funcName))
         return false;
@@ -625,16 +625,17 @@ WebGLContext::DrawElements_check(const c
     ////
 
     if (IsWebGL2() && !gl->IsSupported(gl::GLFeature::prim_restart_fixed)) {
         MOZ_ASSERT(gl->IsSupported(gl::GLFeature::prim_restart));
         if (mPrimRestartTypeBytes != bytesPerElem) {
             mPrimRestartTypeBytes = bytesPerElem;
 
             const uint32_t ones = UINT32_MAX >> (4 - mPrimRestartTypeBytes);
+            gl->fEnable(LOCAL_GL_PRIMITIVE_RESTART);
             gl->fPrimitiveRestartIndex(ones);
         }
     }
 
     ////
 
     const GLsizei first = byteOffset / bytesPerElem;
     const CheckedUint32 checked_byteCount = bytesPerElem * CheckedUint32(vertCount);
--- a/gfx/gl/GLContextFeatures.cpp
+++ b/gfx/gl/GLContextFeatures.cpp
@@ -440,17 +440,17 @@ static const FeatureInfo sFeatureInfoArr
         }
     },
     {
         "prim_restart",
         GLVersion::GL3_1,
         GLESVersion::NONE,
         GLContext::Extension_None,
         {
-            GLContext::NV_primitive_restart,
+            //GLContext::NV_primitive_restart, // Has different enum values.
             GLContext::Extensions_End
         }
     },
     {
         "prim_restart_fixed",
         kGLCoreVersionForES3Compat,
         GLESVersion::ES3,
         GLContext::ARB_ES3_compatibility,