Bug 1309643 - Only enable primitive restart index on OSX for DrawElements. - r=ethlin draft
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 16 Dec 2016 16:17:29 -0800
changeset 450570 cdcabe3bedb4d5c42fffe89cceaf73e9c0f35c68
parent 449758 b1ab720c6d3e412ede797b08dfe63dca170f6ee0
child 539792 de8a57de3573e40b96ae94ee4586259dd7473193
push id38903
push userbmo:jgilbert@mozilla.com
push dateSat, 17 Dec 2016 00:20:30 +0000
reviewersethlin
bugs1309643
milestone53.0a1
Bug 1309643 - Only enable primitive restart index on OSX for DrawElements. - r=ethlin
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,