blob: 0ffd34ca322c5ff5b4e5cd20d3ec2f9ec0462a7d [file] [log] [blame]
<canvas id="canvas" width="10" height="10"></canvas>
<div></div>
<script id='vertex-shader' type='x-shader/x-vertex'>
attribute vec3 position;
void main(void) {
gl_Position = vec4(position, 1.0);
}
</script>
<script id='fragment-shader' type='x-shader/x-fragment'>
precision mediump float;
void main(void) {
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}
</script>
<script>
function output(msg) {
document.querySelector("div").innerHTML += msg + "<br>";
}
if (window.testRunner)
testRunner.dumpAsText();
let canvas = document.getElementById("canvas");
let gl = canvas.getContext("webgl");
gl.getExtension("OES_element_index_uint");
let vShader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vShader, document.getElementById("vertex-shader").text);
gl.compileShader(vShader);
let fShader = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fShader, document.getElementById("fragment-shader").text);
gl.compileShader(fShader);
program = gl.createProgram();
gl.attachShader(program, vShader);
gl.attachShader(program, fShader);
gl.linkProgram(program);
gl.useProgram(program);
let buffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer);
let data;
// Maximum uint.
data = new Uint8Array([255, 255, 255, 255]);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, data, gl.DYNAMIC_DRAW);
gl.drawElements(gl.TRIANGLE_STRIP, 1, gl.UNSIGNED_INT,0);
if (gl.getError() == gl.INVALID_OPERATION)
output("PASS: MAX_UINT index was unable to be simulated");
else
output("FAIL: MAX_UINT index did not fail validation");
// Two large numbers, one of which is smaller than 0.25 * max uint.
data = new Uint32Array([380000000, 4294967295]);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, data, gl.DYNAMIC_DRAW);
gl.drawElements(gl.TRIANGLE_STRIP, 1, gl.UNSIGNED_INT,0);
if (gl.getError() == gl.INVALID_OPERATION)
output("PASS: Huge index was unable to be simulated");
else
output("FAIL: Huge index did not fail validation");
</script>