Bug 1228711 - Cubemap images must be square. - r=benwa
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 03 Dec 2015 15:38:06 -0800
changeset 275511 5cd26800514465d5a346d35b7b64847bc9d46c34
parent 275510 00a1550117478befe5df1ef2ce1bc0e146b28bfd
child 275512 c6341b8dd280ea968768f76857624ed897a02558
push id68870
push userjgilbert@mozilla.com
push dateThu, 03 Dec 2015 23:39:01 +0000
treeherdermozilla-inbound@5cd268005144 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenwa
bugs1228711
milestone45.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 1228711 - Cubemap images must be square. - r=benwa
dom/canvas/WebGLTextureUpload.cpp
dom/canvas/test/webgl-mochitest.ini
dom/canvas/test/webgl-mochitest/test_cubemap_must_be_square.html
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -360,16 +360,23 @@ WebGLTexture::ValidateTexImageSpecificat
          *   and if either wt or ht are less than zero, then the error
          *   INVALID_VALUE is generated."
          */
         mContext->ErrorInvalidValue("%s: `width`/`height`/`depth` must be >= 0.",
                                     funcName);
         return false;
     }
 
+    if (mTarget == LOCAL_GL_TEXTURE_CUBE_MAP &&
+        width != height)
+    {
+        mContext->ErrorInvalidValue("%s: Cube map images must be square.", funcName);
+        return false;
+    }
+
     /* GLES 3.0.4, p133-134:
      * GL_MAX_TEXTURE_SIZE is *not* the max allowed texture size. Rather, it is the
      * max (width/height) size guaranteed not to generate an INVALID_VALUE for too-large
      * dimensions. Sizes larger than GL_MAX_TEXTURE_SIZE *may or may not* result in an
      * INVALID_VALUE, or possibly GL_OOM.
      *
      * However, we have needed to set our maximums lower in the past to prevent resource
      * corruption. Therefore we have mImplMaxTextureSize, which is neither necessarily
--- a/dom/canvas/test/webgl-mochitest.ini
+++ b/dom/canvas/test/webgl-mochitest.ini
@@ -6,16 +6,17 @@ support-files =
   webgl-mochitest/driver-info.js
   webgl-mochitest/webgl-util.js
 
 [webgl-mochitest/test_backbuffer_channels.html]
 fail-if = (os == 'b2g')
 [webgl-mochitest/test_depth_readpixels.html]
 [webgl-mochitest/test_capture.html]
 support-files = captureStream_common.js
+[webgl-mochitest/test_cubemap_must_be_square.html]
 [webgl-mochitest/test_draw.html]
 [webgl-mochitest/test_fb_param.html]
 [webgl-mochitest/test_fb_param_crash.html]
 [webgl-mochitest/test_hidden_alpha.html]
 skip-if = (os == 'b2g') || buildapp == 'mulet' # Mulet - bug 1093639 (crashes in libLLVM-3.0.so)
 [webgl-mochitest/test_implicit_color_buffer_float.html]
 [webgl-mochitest/test_highp_fs.html]
 [webgl-mochitest/test_no_arr_points.html]
new file mode 100644
--- /dev/null
+++ b/dom/canvas/test/webgl-mochitest/test_cubemap_must_be_square.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta http-equiv='content-type' content='text/html; charset=utf-8'/>
+
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
+  <script src='webgl-util.js'></script>
+</head>
+
+<body>
+<script>
+'use strict';
+
+(function() {
+  var c = document.createElement('canvas');
+  var gl = c.getContext('webgl');
+
+  ok(!gl.getError(), 'No error before.');
+
+  var tex = gl.createTexture();
+  gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex);
+  gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGBA, 4, 3, 0, gl.RGBA,
+                gl.UNSIGNED_BYTE, null);
+
+  var err = gl.getError();
+  ok(err == gl.INVALID_VALUE,
+     'Should be INVALID_VALUE (0x501) after, was 0x' + err.toString(16) + '.');
+})();
+
+ok(true, 'Test complete.');
+
+</script>
+</body>
+</html>