Bug 1136428 - Ensure we never create more than the amount supported of color attachments in WebGLFrameBuffer or try to get an attachment point higher than the supported number. r=jgilbert
authorKyle <kfung@mozilla.com>
Wed, 05 Aug 2015 16:45:44 -0400
changeset 288349 2e1b414266f1f89ac43aaa5f8ec3025b96d85985
parent 288348 fea6620f36b8e408aaf22614cb7131ae5c139ef3
child 288350 af87603b35cd762855cb069c283b879ef5847a0f
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1136428
milestone42.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 1136428 - Ensure we never create more than the amount supported of color attachments in WebGLFrameBuffer or try to get an attachment point higher than the supported number. r=jgilbert
dom/canvas/WebGLFramebuffer.cpp
--- a/dom/canvas/WebGLFramebuffer.cpp
+++ b/dom/canvas/WebGLFramebuffer.cpp
@@ -504,17 +504,17 @@ WebGLFramebuffer::GetAttachPoint(FBAttac
         return mStencilAttachment;
 
     default:
         break;
     }
 
     if (attachPoint >= LOCAL_GL_COLOR_ATTACHMENT1) {
         size_t colorAttachmentId = attachPoint.get() - LOCAL_GL_COLOR_ATTACHMENT0;
-        if (colorAttachmentId < WebGLContext::kMaxColorAttachments) {
+        if (colorAttachmentId < (size_t)mContext->mGLMaxColorAttachments) {
             EnsureColorAttachPoints(colorAttachmentId);
             return mMoreColorAttachments[colorAttachmentId - 1];
         }
     }
 
     MOZ_CRASH("bad `attachPoint` validation");
 }
 
@@ -827,27 +827,29 @@ WebGLFramebuffer::CheckAndInitializeAtta
             mMoreColorAttachments[i].SetImageDataStatus(WebGLImageDataStatus::InitializedImageData);
     }
 
     return true;
 }
 
 void WebGLFramebuffer::EnsureColorAttachPoints(size_t colorAttachmentId)
 {
-    MOZ_ASSERT(colorAttachmentId < WebGLContext::kMaxColorAttachments);
+    size_t maxColorAttachments = mContext->mGLMaxColorAttachments;
+
+    MOZ_ASSERT(colorAttachmentId < maxColorAttachments);
 
     if (colorAttachmentId < ColorAttachmentCount())
         return;
 
-    while (ColorAttachmentCount() < WebGLContext::kMaxColorAttachments) {
+    while (ColorAttachmentCount() < maxColorAttachments) {
         GLenum nextAttachPoint = LOCAL_GL_COLOR_ATTACHMENT0 + ColorAttachmentCount();
         mMoreColorAttachments.AppendElement(WebGLFBAttachPoint(this, nextAttachPoint));
     }
 
-    MOZ_ASSERT(ColorAttachmentCount() == WebGLContext::kMaxColorAttachments);
+    MOZ_ASSERT(ColorAttachmentCount() == maxColorAttachments);
 }
 
 static void
 FinalizeDrawAndReadBuffers(gl::GLContext* gl, bool isColorBufferDefined)
 {
     MOZ_ASSERT(gl, "Expected a valid GLContext ptr.");
     // GLES don't support DrawBuffer()/ReadBuffer.
     // According to http://www.opengl.org/wiki/Framebuffer_Object