content/canvas/test/webgl-conformance/conformance/limits/gl-max-texture-dimensions.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 <!--
     2 Copyright (c) 2011 The Chromium Authors. All rights reserved.
     3 Use of this source code is governed by a BSD-style license that can be
     4 found in the LICENSE file.
     5  -->
     6 <!DOCTYPE html>
     7 <html>
     8 <head>
     9 <meta charset="utf-8">
    10 <title>WebGL the max advertized texture size is supported.</title>
    11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
    12 <script src="../../resources/js-test-pre.js"></script>
    13 <script src="../resources/webgl-test.js"> </script>
    14 <script src="../resources/webgl-test-utils.js"> </script>
    15 </head>
    16 <body>
    17 <canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
    18 <div id="description"></div>
    19 <div id="console"></div>
    20 <script id="vshader" type="x-shader/x-vertex">
    21 attribute vec4 vPosition;
    22 attribute vec2 texCoord0;
    23 varying vec2 texCoord;
    24 void main()
    25 {
    26     gl_Position = vPosition;
    27     texCoord = texCoord0;
    28 }
    29 </script>
    31 <script id="fshader" type="x-shader/x-fragment">
    32 precision mediump float;
    33 uniform samplerCube tex;
    34 varying vec2 texCoord;
    35 void main()
    36 {
    37     gl_FragColor = textureCube(tex, normalize(vec3(texCoord, 1)));
    38 }
    39 </script>
    40 <script>
    41 description(document.title);
    42 var wtu = WebGLTestUtils;
    43 var gl = wtu.create3DContext("example");
    44 var program = wtu.setupTexturedQuad(gl);
    46 // Note: It seems like a reasonable assuption that a 1xN texture size should
    47 // work. Even 1 by 128k is only 512k
    48 var maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
    49 debug("advertised max size: " + maxSize);
    50 var testSize = Math.min(maxSize, 128 * 1024);
    51 var pixels = new Uint8Array(testSize * 4);
    52 for (var ii = 0; ii < testSize; ++ii) {
    53   var off = ii * 4;
    54   pixels[off + 0] = 0;
    55   pixels[off + 1] = 255;
    56   pixels[off + 2] = 128;
    57   pixels[off + 3] = 255;
    58 }
    59 var tex = gl.createTexture();
    60 gl.bindTexture(gl.TEXTURE_2D, tex);
    62 debug("test " + testSize + "x1");
    63 gl.texImage2D(
    64     gl.TEXTURE_2D, 0, gl.RGBA, testSize, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,
    65     pixels);
    66 gl.generateMipmap(gl.TEXTURE_2D);
    68 wtu.drawQuad(gl);
    69 wtu.checkCanvas(gl, [0, 255, 128, 255],
    70                 "Should be 0, 255, 128, 255");
    71 debug("test 1x" + testSize);
    72 gl.texImage2D(
    73     gl.TEXTURE_2D, 0, gl.RGBA, 1, testSize, 0, gl.RGBA, gl.UNSIGNED_BYTE,
    74     pixels);
    75 gl.generateMipmap(gl.TEXTURE_2D);
    77 wtu.drawQuad(gl);
    78 wtu.checkCanvas(gl, [0, 255, 128, 255],
    79                 "Should be 0, 255, 128, 255");
    81 var program = wtu.setupProgram(
    82     gl, ['vshader', 'fshader'], ['vPosition', 'texCoord0'], [0, 1]);
    84 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
    86 // NOTE: We can't easily test cube maps because they require width == height
    87 // and we might not have enough memory for maxSize by maxSize texture.
    89 successfullyParsed = true;
    91 </script>
    92 <script>finishTest();</script>
    94 </body>
    95 </html>

mercurial