bug 894007 - WebGLContext::getParameter(GL_MAX_TEXTURE_SIZE) should be a power of two - r=jgilbert
authorGuillaume Abadie <gabadie@mozilla.com>
Tue, 30 Jul 2013 11:07:04 -0400
changeset 152839 dda34262d3b8703ca1a6c9885033e686a64a3142
parent 152838 26846fdeeb41028450894ee527db6de58c6bc0d6
child 152840 d1cbd2f59347ae368ccb5488263aaf25d7ecbb93
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs894007
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 894007 - WebGLContext::getParameter(GL_MAX_TEXTURE_SIZE) should be a power of two - r=jgilbert
content/canvas/src/WebGLContextValidate.cpp
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -876,16 +876,28 @@ bool WebGLContext::ValidateStencilParams
   }
   if (mStencilWriteMaskFront != mStencilWriteMaskBack) {
       ErrorInvalidOperation(msg, "stencilMaskSeparate", "write masks");
       return false;
   }
   return true;
 }
 
+static inline int32_t floorPOT(int32_t x)
+{
+    MOZ_ASSERT(x > 0);
+    int32_t pot = 1;
+    while (pot < 0x40000000) {
+        if (x < pot*2)
+            break;
+        pot *= 2;
+    }
+    return pot;
+}
+
 bool
 WebGLContext::InitAndValidateGL()
 {
     if (!gl) return false;
 
     GLenum error = gl->fGetError();
     if (error != LOCAL_GL_NO_ERROR) {
         GenerateWarning("GL error 0x%x occurred during OpenGL context initialization, before WebGL initialization!", error);
@@ -955,16 +967,19 @@ WebGLContext::InitAndValidateGL()
     } else {
         gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &mGLMaxTextureSize);
         gl->fGetIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &mGLMaxCubeMapTextureSize);
         gl->fGetIntegerv(LOCAL_GL_MAX_RENDERBUFFER_SIZE, &mGLMaxRenderbufferSize);
         gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_IMAGE_UNITS, &mGLMaxTextureImageUnits);
         gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &mGLMaxVertexTextureImageUnits);
     }
 
+    mGLMaxTextureSize = floorPOT(mGLMaxTextureSize);
+    mGLMaxRenderbufferSize = floorPOT(mGLMaxRenderbufferSize);
+
     if (MinCapabilityMode()) {
         mGLMaxFragmentUniformVectors = MINVALUE_GL_MAX_FRAGMENT_UNIFORM_VECTORS;
         mGLMaxVertexUniformVectors = MINVALUE_GL_MAX_VERTEX_UNIFORM_VECTORS;
         mGLMaxVaryingVectors = MINVALUE_GL_MAX_VARYING_VECTORS;
     } else {
         if (gl->HasES2Compatibility()) {
             gl->fGetIntegerv(LOCAL_GL_MAX_FRAGMENT_UNIFORM_VECTORS, &mGLMaxFragmentUniformVectors);
             gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_UNIFORM_VECTORS, &mGLMaxVertexUniformVectors);