Bug 1309643 - Only enable primitive restart index on OSX for DrawElements. - r=ethlin
--- 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,