1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/limits/gl-max-texture-dimensions.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +<!-- 1.5 +Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.6 +Use of this source code is governed by a BSD-style license that can be 1.7 +found in the LICENSE file. 1.8 + --> 1.9 +<!DOCTYPE html> 1.10 +<html> 1.11 +<head> 1.12 +<meta charset="utf-8"> 1.13 +<title>WebGL the max advertized texture size is supported.</title> 1.14 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.15 +<script src="../../resources/js-test-pre.js"></script> 1.16 +<script src="../resources/webgl-test.js"> </script> 1.17 +<script src="../resources/webgl-test-utils.js"> </script> 1.18 +</head> 1.19 +<body> 1.20 +<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas> 1.21 +<div id="description"></div> 1.22 +<div id="console"></div> 1.23 +<script id="vshader" type="x-shader/x-vertex"> 1.24 +attribute vec4 vPosition; 1.25 +attribute vec2 texCoord0; 1.26 +varying vec2 texCoord; 1.27 +void main() 1.28 +{ 1.29 + gl_Position = vPosition; 1.30 + texCoord = texCoord0; 1.31 +} 1.32 +</script> 1.33 + 1.34 +<script id="fshader" type="x-shader/x-fragment"> 1.35 +precision mediump float; 1.36 +uniform samplerCube tex; 1.37 +varying vec2 texCoord; 1.38 +void main() 1.39 +{ 1.40 + gl_FragColor = textureCube(tex, normalize(vec3(texCoord, 1))); 1.41 +} 1.42 +</script> 1.43 +<script> 1.44 +description(document.title); 1.45 +var wtu = WebGLTestUtils; 1.46 +var gl = wtu.create3DContext("example"); 1.47 +var program = wtu.setupTexturedQuad(gl); 1.48 + 1.49 +// Note: It seems like a reasonable assuption that a 1xN texture size should 1.50 +// work. Even 1 by 128k is only 512k 1.51 +var maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); 1.52 +debug("advertised max size: " + maxSize); 1.53 +var testSize = Math.min(maxSize, 128 * 1024); 1.54 +var pixels = new Uint8Array(testSize * 4); 1.55 +for (var ii = 0; ii < testSize; ++ii) { 1.56 + var off = ii * 4; 1.57 + pixels[off + 0] = 0; 1.58 + pixels[off + 1] = 255; 1.59 + pixels[off + 2] = 128; 1.60 + pixels[off + 3] = 255; 1.61 +} 1.62 +var tex = gl.createTexture(); 1.63 +gl.bindTexture(gl.TEXTURE_2D, tex); 1.64 + 1.65 +debug("test " + testSize + "x1"); 1.66 +gl.texImage2D( 1.67 + gl.TEXTURE_2D, 0, gl.RGBA, testSize, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 1.68 + pixels); 1.69 +gl.generateMipmap(gl.TEXTURE_2D); 1.70 + 1.71 +wtu.drawQuad(gl); 1.72 +wtu.checkCanvas(gl, [0, 255, 128, 255], 1.73 + "Should be 0, 255, 128, 255"); 1.74 +debug("test 1x" + testSize); 1.75 +gl.texImage2D( 1.76 + gl.TEXTURE_2D, 0, gl.RGBA, 1, testSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, 1.77 + pixels); 1.78 +gl.generateMipmap(gl.TEXTURE_2D); 1.79 + 1.80 +wtu.drawQuad(gl); 1.81 +wtu.checkCanvas(gl, [0, 255, 128, 255], 1.82 + "Should be 0, 255, 128, 255"); 1.83 + 1.84 +var program = wtu.setupProgram( 1.85 + gl, ['vshader', 'fshader'], ['vPosition', 'texCoord0'], [0, 1]); 1.86 + 1.87 +glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors."); 1.88 + 1.89 +// NOTE: We can't easily test cube maps because they require width == height 1.90 +// and we might not have enough memory for maxSize by maxSize texture. 1.91 + 1.92 +successfullyParsed = true; 1.93 + 1.94 +</script> 1.95 +<script>finishTest();</script> 1.96 + 1.97 +</body> 1.98 +</html> 1.99 + 1.100 +