Update WebGL conformance suite 1.0.3 from upstream

This commit is contained in:
Imanol Fernandez 2017-10-30 19:07:01 +01:00
parent c4bb30413c
commit 4989f00916
1568 changed files with 27218 additions and 27288 deletions

View file

@ -53,7 +53,7 @@ FILE_PATTERNS_TO_CHECK = ["*.rs", "*.rc", "*.cpp", "*.c",
"*.yml"]
# File patterns that are ignored for all tidy and lint checks.
FILE_PATTERNS_TO_IGNORE = ["*.#*", "*.pyc", "fake-ld.sh"]
FILE_PATTERNS_TO_IGNORE = ["*.#*", "*.pyc", "fake-ld.sh", "*.ogv", "*.webm"]
SPEC_BASE_PATH = "components/script/dom/"

View file

@ -1,92 +1,92 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<title>bindAttribLocation with aliasing</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="8" height="8" style="width: 8px; height: 8px;"></canvas>
<script id="vertexShader" type="text/something-not-javascript">
precision mediump float;
attribute $(type_1) a_1;
attribute $(type_2) a_2;
void main() {
gl_Position = $(gl_Position_1) + $(gl_Position_2);
}
</script>
<script>
"use strict";
description("This test verifies combinations of valid, active attribute types cannot be bound to the same location with bindAttribLocation.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas, {antialias: false});
var glFragmentShader = wtu.setupSimpleColorFragmentShader(gl);
var typeInfo = [
{ type: 'float', asVec4: 'vec4(0.0, $(var), 0.0, 1.0)' },
{ type: 'vec2', asVec4: 'vec4($(var), 0.0, 1.0)' },
{ type: 'vec3', asVec4: 'vec4($(var), 1.0)' },
{ type: 'vec4', asVec4: '$(var)' },
];
var maxAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
// Test all type combinations of a_1 and a_2.
typeInfo.forEach(function(typeInfo1) {
typeInfo.forEach(function(typeInfo2) {
debug('attribute_1: ' + typeInfo1.type + ' attribute_2: ' + typeInfo2.type);
var replaceParams = {
type_1: typeInfo1.type,
type_2: typeInfo2.type,
gl_Position_1: wtu.replaceParams(typeInfo1.asVec4, {var: 'a_1'}),
gl_Position_2: wtu.replaceParams(typeInfo2.asVec4, {var: 'a_2'})
};
var strVertexShader = wtu.replaceParams(wtu.getScript('vertexShader'), replaceParams);
var glVertexShader = wtu.loadShader(gl, strVertexShader, gl.VERTEX_SHADER);
assertMsg(glVertexShader != null, "Vertex shader compiled successfully.");
// Bind both a_1 and a_2 to the same position and verify the link fails.
// Do so for all valid positions available.
for (var l = 0; l < maxAttributes; l++) {
var glProgram = gl.createProgram();
gl.bindAttribLocation(glProgram, l, 'a_1');
gl.bindAttribLocation(glProgram, l, 'a_2');
gl.attachShader(glProgram, glVertexShader);
gl.attachShader(glProgram, glFragmentShader);
gl.linkProgram(glProgram);
assertMsg(!gl.getProgramParameter(glProgram, gl.LINK_STATUS), "Link should fail when both types are aliased to location " + l);
}
});
});
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<title>bindAttribLocation with aliasing</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="8" height="8" style="width: 8px; height: 8px;"></canvas>
<script id="vertexShader" type="text/something-not-javascript">
precision mediump float;
attribute $(type_1) a_1;
attribute $(type_2) a_2;
void main() {
gl_Position = $(gl_Position_1) + $(gl_Position_2);
}
</script>
<script>
"use strict";
description("This test verifies combinations of valid, active attribute types cannot be bound to the same location with bindAttribLocation.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas, {antialias: false});
var glFragmentShader = wtu.setupSimpleColorFragmentShader(gl);
var typeInfo = [
{ type: 'float', asVec4: 'vec4(0.0, $(var), 0.0, 1.0)' },
{ type: 'vec2', asVec4: 'vec4($(var), 0.0, 1.0)' },
{ type: 'vec3', asVec4: 'vec4($(var), 1.0)' },
{ type: 'vec4', asVec4: '$(var)' },
];
var maxAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
// Test all type combinations of a_1 and a_2.
typeInfo.forEach(function(typeInfo1) {
typeInfo.forEach(function(typeInfo2) {
debug('attribute_1: ' + typeInfo1.type + ' attribute_2: ' + typeInfo2.type);
var replaceParams = {
type_1: typeInfo1.type,
type_2: typeInfo2.type,
gl_Position_1: wtu.replaceParams(typeInfo1.asVec4, {var: 'a_1'}),
gl_Position_2: wtu.replaceParams(typeInfo2.asVec4, {var: 'a_2'})
};
var strVertexShader = wtu.replaceParams(wtu.getScript('vertexShader'), replaceParams);
var glVertexShader = wtu.loadShader(gl, strVertexShader, gl.VERTEX_SHADER);
assertMsg(glVertexShader != null, "Vertex shader compiled successfully.");
// Bind both a_1 and a_2 to the same position and verify the link fails.
// Do so for all valid positions available.
for (var l = 0; l < maxAttributes; l++) {
var glProgram = gl.createProgram();
gl.bindAttribLocation(glProgram, l, 'a_1');
gl.bindAttribLocation(glProgram, l, 'a_2');
gl.attachShader(glProgram, glVertexShader);
gl.attachShader(glProgram, glFragmentShader);
gl.linkProgram(glProgram);
assertMsg(!gl.getProgramParameter(glProgram, gl.LINK_STATUS), "Link should fail when both types are aliased to location " + l);
}
});
});
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

View file

@ -85,8 +85,7 @@ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, array);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, null);
wtu.glErrorShouldBe(gl, [gl.NO_ERROR, gl.INVALID_VALUE]);
wtu.shouldThrowOrGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_VALUE], "gl.bufferSubData(gl.ARRAY_BUFFER, 10, null)");
var successfullyParsed = true;
</script>

View file

@ -58,13 +58,15 @@ context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
var indices = new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, indices, context.STATIC_DRAW);
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
var indexValidationError = wtu.shouldGenerateGLError(context,
[context.INVALID_OPERATION, context.NO_ERROR],
"context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;

View file

@ -60,9 +60,9 @@ var indexObject = context.createBuffer();
debug("Test out of range indices")
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]), context.STATIC_DRAW);
var indexValidationError = wtu.shouldGenerateGLError(context, [context.INVALID_OPERATION, context.NO_ERROR], "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;

View file

@ -112,7 +112,7 @@ gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT),
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
wtu.glErrorShouldBe(gl, [gl.INVALID_OPERATION, gl.NO_ERROR]);
debug("Test with enabled attribute that does not belong to current program");

View file

@ -48,7 +48,7 @@ var constants = {
DEPTH_BUFFER_BIT : 0x00000100,
STENCIL_BUFFER_BIT : 0x00000400,
COLOR_BUFFER_BIT : 0x00004000,
/* BeginMode */
POINTS : 0x0000,
LINES : 0x0001,
@ -57,7 +57,7 @@ LINE_STRIP : 0x0003,
TRIANGLES : 0x0004,
TRIANGLE_STRIP : 0x0005,
TRIANGLE_FAN : 0x0006,
/* AlphaFunction (not supported in ES20) */
/* NEVER */
/* LESS */
@ -67,7 +67,7 @@ TRIANGLE_FAN : 0x0006,
/* NOTEQUAL */
/* GEQUAL */
/* ALWAYS */
/* BlendingFactorDest */
ZERO : 0,
ONE : 1,
@ -77,7 +77,7 @@ SRC_ALPHA : 0x0302,
ONE_MINUS_SRC_ALPHA : 0x0303,
DST_ALPHA : 0x0304,
ONE_MINUS_DST_ALPHA : 0x0305,
/* BlendingFactorSrc */
/* ZERO */
/* ONE */
@ -88,17 +88,17 @@ SRC_ALPHA_SATURATE : 0x0308,
/* ONE_MINUS_SRC_ALPHA */
/* DST_ALPHA */
/* ONE_MINUS_DST_ALPHA */
/* BlendEquationSeparate */
FUNC_ADD : 0x8006,
BLEND_EQUATION : 0x8009,
BLEND_EQUATION_RGB : 0x8009, /* same as BLEND_EQUATION */
BLEND_EQUATION_ALPHA : 0x883D,
/* BlendSubtract */
FUNC_SUBTRACT : 0x800A,
FUNC_REVERSE_SUBTRACT : 0x800B,
/* Separate Blend Functions */
BLEND_DST_RGB : 0x80C8,
BLEND_SRC_RGB : 0x80C9,
@ -109,27 +109,27 @@ ONE_MINUS_CONSTANT_COLOR : 0x8002,
CONSTANT_ALPHA : 0x8003,
ONE_MINUS_CONSTANT_ALPHA : 0x8004,
BLEND_COLOR : 0x8005,
/* Buffer Objects */
ARRAY_BUFFER : 0x8892,
ELEMENT_ARRAY_BUFFER : 0x8893,
ARRAY_BUFFER_BINDING : 0x8894,
ELEMENT_ARRAY_BUFFER_BINDING : 0x8895,
STREAM_DRAW : 0x88E0,
STATIC_DRAW : 0x88E4,
DYNAMIC_DRAW : 0x88E8,
BUFFER_SIZE : 0x8764,
BUFFER_USAGE : 0x8765,
CURRENT_VERTEX_ATTRIB : 0x8626,
/* CullFaceMode */
FRONT : 0x0404,
BACK : 0x0405,
FRONT_AND_BACK : 0x0408,
/* DepthFunction */
/* NEVER */
/* LESS */
@ -139,7 +139,7 @@ FRONT_AND_BACK : 0x0408,
/* NOTEQUAL */
/* GEQUAL */
/* ALWAYS */
/* EnableCap */
/* TEXTURE_2D */
CULL_FACE : 0x0B44,
@ -151,18 +151,18 @@ SCISSOR_TEST : 0x0C11,
POLYGON_OFFSET_FILL : 0x8037,
SAMPLE_ALPHA_TO_COVERAGE : 0x809E,
SAMPLE_COVERAGE : 0x80A0,
/* ErrorCode */
NO_ERROR : 0,
INVALID_ENUM : 0x0500,
INVALID_VALUE : 0x0501,
INVALID_OPERATION : 0x0502,
OUT_OF_MEMORY : 0x0505,
/* FrontFaceDirection */
CW : 0x0900,
CCW : 0x0901,
/* GetPName */
LINE_WIDTH : 0x0B21,
ALIASED_POINT_SIZE_RANGE : 0x846D,
@ -212,23 +212,23 @@ SAMPLE_BUFFERS : 0x80A8,
SAMPLES : 0x80A9,
SAMPLE_COVERAGE_VALUE : 0x80AA,
SAMPLE_COVERAGE_INVERT : 0x80AB,
/* GetTextureParameter */
/* TEXTURE_MAG_FILTER */
/* TEXTURE_MIN_FILTER */
/* TEXTURE_WRAP_S */
/* TEXTURE_WRAP_T */
COMPRESSED_TEXTURE_FORMATS : 0x86A3,
/* HintMode */
DONT_CARE : 0x1100,
FASTEST : 0x1101,
NICEST : 0x1102,
/* HintTarget */
GENERATE_MIPMAP_HINT : 0x8192,
/* DataType */
BYTE : 0x1400,
UNSIGNED_BYTE : 0x1401,
@ -237,7 +237,7 @@ UNSIGNED_SHORT : 0x1403,
INT : 0x1404,
UNSIGNED_INT : 0x1405,
FLOAT : 0x1406,
/* PixelFormat */
DEPTH_COMPONENT : 0x1902,
ALPHA : 0x1906,
@ -245,13 +245,13 @@ RGB : 0x1907,
RGBA : 0x1908,
LUMINANCE : 0x1909,
LUMINANCE_ALPHA : 0x190A,
/* PixelType */
/* UNSIGNED_BYTE */
UNSIGNED_SHORT_4_4_4_4 : 0x8033,
UNSIGNED_SHORT_5_5_5_1 : 0x8034,
UNSIGNED_SHORT_5_6_5 : 0x8363,
/* Shaders */
FRAGMENT_SHADER : 0x8B30,
VERTEX_SHADER : 0x8B31,
@ -271,7 +271,7 @@ ACTIVE_UNIFORMS : 0x8B86,
ACTIVE_ATTRIBUTES : 0x8B89,
SHADING_LANGUAGE_VERSION : 0x8B8C,
CURRENT_PROGRAM : 0x8B8D,
/* StencilFunction */
NEVER : 0x0200,
LESS : 0x0201,
@ -281,7 +281,7 @@ GREATER : 0x0204,
NOTEQUAL : 0x0205,
GEQUAL : 0x0206,
ALWAYS : 0x0207,
/* StencilOp */
/* ZERO */
KEEP : 0x1E00,
@ -291,16 +291,16 @@ DECR : 0x1E03,
INVERT : 0x150A,
INCR_WRAP : 0x8507,
DECR_WRAP : 0x8508,
/* StringName */
VENDOR : 0x1F00,
RENDERER : 0x1F01,
VERSION : 0x1F02,
/* TextureMagFilter */
NEAREST : 0x2600,
LINEAR : 0x2601,
/* TextureMinFilter */
/* NEAREST */
/* LINEAR */
@ -308,17 +308,17 @@ NEAREST_MIPMAP_NEAREST : 0x2700,
LINEAR_MIPMAP_NEAREST : 0x2701,
NEAREST_MIPMAP_LINEAR : 0x2702,
LINEAR_MIPMAP_LINEAR : 0x2703,
/* TextureParameterName */
TEXTURE_MAG_FILTER : 0x2800,
TEXTURE_MIN_FILTER : 0x2801,
TEXTURE_WRAP_S : 0x2802,
TEXTURE_WRAP_T : 0x2803,
/* TextureTarget */
TEXTURE_2D : 0x0DE1,
TEXTURE : 0x1702,
TEXTURE_CUBE_MAP : 0x8513,
TEXTURE_BINDING_CUBE_MAP : 0x8514,
TEXTURE_CUBE_MAP_POSITIVE_X : 0x8515,
@ -328,7 +328,7 @@ TEXTURE_CUBE_MAP_NEGATIVE_Y : 0x8518,
TEXTURE_CUBE_MAP_POSITIVE_Z : 0x8519,
TEXTURE_CUBE_MAP_NEGATIVE_Z : 0x851A,
MAX_CUBE_MAP_TEXTURE_SIZE : 0x851C,
/* TextureUnit */
TEXTURE0 : 0x84C0,
TEXTURE1 : 0x84C1,
@ -363,12 +363,12 @@ TEXTURE29 : 0x84DD,
TEXTURE30 : 0x84DE,
TEXTURE31 : 0x84DF,
ACTIVE_TEXTURE : 0x84E0,
/* TextureWrapMode */
REPEAT : 0x2901,
CLAMP_TO_EDGE : 0x812F,
MIRRORED_REPEAT : 0x8370,
/* Uniform Types */
FLOAT_VEC2 : 0x8B50,
FLOAT_VEC3 : 0x8B51,
@ -385,7 +385,7 @@ FLOAT_MAT3 : 0x8B5B,
FLOAT_MAT4 : 0x8B5C,
SAMPLER_2D : 0x8B5E,
SAMPLER_CUBE : 0x8B60,
/* Vertex Arrays */
VERTEX_ATTRIB_ARRAY_ENABLED : 0x8622,
VERTEX_ATTRIB_ARRAY_SIZE : 0x8623,
@ -394,14 +394,14 @@ VERTEX_ATTRIB_ARRAY_TYPE : 0x8625,
VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A,
VERTEX_ATTRIB_ARRAY_POINTER : 0x8645,
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F,
/* Read Format */
IMPLEMENTATION_COLOR_READ_TYPE : 0x8B9A,
IMPLEMENTATION_COLOR_READ_FORMAT : 0x8B9B,
/* Shader Source */
COMPILE_STATUS : 0x8B81,
/* Shader Precision-Specified Types */
LOW_FLOAT : 0x8DF0,
MEDIUM_FLOAT : 0x8DF1,
@ -409,19 +409,18 @@ HIGH_FLOAT : 0x8DF2,
LOW_INT : 0x8DF3,
MEDIUM_INT : 0x8DF4,
HIGH_INT : 0x8DF5,
/* Framebuffer Object. */
FRAMEBUFFER : 0x8D40,
RENDERBUFFER : 0x8D41,
RGBA4 : 0x8056,
RGB5_A1 : 0x8057,
RGB565 : 0x8D62,
DEPTH_COMPONENT16 : 0x81A5,
STENCIL_INDEX : 0x1901,
STENCIL_INDEX8 : 0x8D48,
DEPTH_STENCIL : 0x84F9,
RENDERBUFFER_WIDTH : 0x8D42,
RENDERBUFFER_HEIGHT : 0x8D43,
RENDERBUFFER_INTERNAL_FORMAT : 0x8D44,
@ -431,29 +430,29 @@ RENDERBUFFER_BLUE_SIZE : 0x8D52,
RENDERBUFFER_ALPHA_SIZE : 0x8D53,
RENDERBUFFER_DEPTH_SIZE : 0x8D54,
RENDERBUFFER_STENCIL_SIZE : 0x8D55,
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : 0x8CD0,
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : 0x8CD1,
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : 0x8CD2,
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : 0x8CD3,
COLOR_ATTACHMENT0 : 0x8CE0,
DEPTH_ATTACHMENT : 0x8D00,
STENCIL_ATTACHMENT : 0x8D20,
DEPTH_STENCIL_ATTACHMENT : 0x821A,
NONE : 0,
FRAMEBUFFER_COMPLETE : 0x8CD5,
FRAMEBUFFER_INCOMPLETE_ATTACHMENT : 0x8CD6,
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7,
FRAMEBUFFER_INCOMPLETE_DIMENSIONS : 0x8CD9,
FRAMEBUFFER_UNSUPPORTED : 0x8CDD,
FRAMEBUFFER_BINDING : 0x8CA6,
RENDERBUFFER_BINDING : 0x8CA7,
MAX_RENDERBUFFER_SIZE : 0x84E8,
INVALID_FRAMEBUFFER_OPERATION : 0x0506,
/* WebGL-specific enums */
@ -475,6 +474,7 @@ canvas : "implementation-dependent"
// added in versions of the spec that are backward-compatible with
// this version
var ignoredProperties = [
'STENCIL_INDEX',
];
// Constants removed from the WebGL spec compared to ES 2.0

View file

@ -64,8 +64,7 @@ void main()
var wtu = WebGLTestUtils;
var gl;
var contextAttribs = null;
var pixel_1 = [0, 0, 0, 1];
var pixel_2 = [0, 0, 0, 1];
var redChannels = [0, 0, 0];
var correctColor = null;
var framebuffer;
var fbHasColor;
@ -304,10 +303,13 @@ function testStencilAndDepth(stencil, depth)
function testAntialias(antialias)
{
debug("Testing antialias = " + antialias);
// Both the width and height of canvas are N.
// Note that "N = 2" doesn't work for some post processing AA per the discussion at https://github.com/KhronosGroup/WebGL/pull/1977.
var N = 3;
if (antialias)
shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("gl = getWebGL(" + N + ", " + N + ", { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");
else
shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("gl = getWebGL(" + N + ", " + N + ", { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
var vertices = new Float32Array([
@ -319,17 +321,13 @@ function testAntialias(antialias)
255, 0, 0, 255,
255, 0, 0, 255]);
drawAndReadPixel(gl, vertices, colors, 0, 0);
var buf_1 = new Uint8Array(1 * 1 * 4);
var buf_2 = new Uint8Array(1 * 1 * 4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf_1);
gl.readPixels(0, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf_2);
pixel_1[0] = buf_1[0];
pixel_2[0] = buf_2[0];
// For some anti-alias algorithms, effects may be not on diagonal line pixels, so that either:
// - The red channel of the pixel at (0, 0) is not 0 and not 255, or,
// - If it is 0, expect that the red channel of the pixel at (0, 1) is not 0 and not 255.
shouldBe("pixel_1[0] != 255 && pixel_1[0] != 0 || pixel_1[0] == 0 && pixel_2[0] != 255 && pixel_2[0] != 0",
"contextAttribs.antialias");
var buf = new Uint8Array(N * N * 4);
gl.readPixels(0, 0, N, N, gl.RGBA, gl.UNSIGNED_BYTE, buf);
redChannels[0] = buf[4 * (N + 1)]; // (1, 1)
redChannels[1] = buf[4 * N * (N - 1)]; // left top
redChannels[2] = buf[4 * (N - 1)]; // right bottom
shouldBeTrue("redChannels[1] == 255 && redChannels[2] == 0");
shouldBe("redChannels[0] != 255 && redChannels[0] != 0", "contextAttribs.antialias");
}
function runTest()

View file

@ -159,7 +159,7 @@ function testLosingAndRestoringContext()
// restore the context after this event has exited.
setTimeout(function() {
shouldGenerateGLError(gl, gl.NO_ERROR, "WEBGL_lose_context.restoreContext()");
// The context should still be lost. It will not get restored until the
// The context should still be lost. It will not get restored until the
// webglrestorecontext event is fired.
shouldBeTrue("gl.isContextLost()");
shouldBe("gl.getError()", "gl.NO_ERROR");

View file

@ -87,6 +87,9 @@ function init()
canvas.addEventListener("webglcontextlost", testLostContext, false);
// We need to initialize |uniformLocation| before losing context.
// Otherwise gl.getUniform() when context is lost will throw.
uniformLocation = gl.getUniformLocation(program, "tex");
loseContext();
}

View file

@ -125,7 +125,7 @@ function runSupportedTest(extensionEnabled) {
function runDivisorTestDisabled() {
debug("Testing VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE with extension disabled");
var VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE;
gl.getVertexAttrib(0, VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
@ -385,7 +385,7 @@ function runANGLECorruptionTest()
ext.drawArraysInstancedANGLE(gl.TRIANGLES, 0, 6, instanceCount);
// Make sure each color was drawn correctly
// Make sure each color was drawn correctly
var i;
var passed = true;
for (i = 0; i < instanceCount; ++i) {

View file

@ -202,7 +202,7 @@ function runOutputTests() {
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
// Enable depth testing with a clearDepth of 0.5
// This makes it so that fragments are only rendered when
// gl_fragDepthEXT is < 0.5

View file

@ -326,7 +326,7 @@ function runFramebufferTextureConversionTest(format) {
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)', 'ext.SRGB_EXT');
if (validFormat) {
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");

View file

@ -93,22 +93,22 @@ function runSupportedTest(extensionEnabled) {
function runHintTestDisabled() {
debug("Testing MAX_TEXTURE_MAX_ANISOTROPY_EXT with extension disabled");
var MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
gl.getParameter(MAX_TEXTURE_MAX_ANISOTROPY_EXT);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "MAX_TEXTURE_MAX_ANISOTROPY_EXT should not be queryable if extension is disabled");
debug("Testing TEXTURE_MAX_ANISOTROPY_EXT with extension disabled");
var TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.getTexParameter(gl.TEXTURE_2D, TEXTURE_MAX_ANISOTROPY_EXT);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "TEXTURE_MAX_ANISOTROPY_EXT should not be queryable if extension is disabled");
gl.texParameterf(gl.TEXTURE_2D, TEXTURE_MAX_ANISOTROPY_EXT, 1);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "TEXTURE_MAX_ANISOTROPY_EXT should not be settable if extension is disabled");
gl.texParameteri(gl.TEXTURE_2D, TEXTURE_MAX_ANISOTROPY_EXT, 1);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "TEXTURE_MAX_ANISOTROPY_EXT should not be settable if extension is disabled");
@ -129,7 +129,7 @@ function runHintTestEnabled() {
else{
testFailed("Minimum value of MAX_TEXTURE_MAX_ANISOTROPY_EXT is 2.0, returned values was: " + max_anisotropy);
}
// TODO make a texture and verify initial value == 1 and setting to less than 1 is invalid value
debug("Testing TEXTURE_MAX_ANISOTROPY_EXT with extension disabled");
@ -137,7 +137,7 @@ function runHintTestEnabled() {
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
var queried_value = gl.getTexParameter(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "TEXTURE_MAX_ANISOTROPY_EXT query should succeed if extension is enabled");
@ -150,13 +150,13 @@ function runHintTestEnabled() {
gl.texParameterf(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "texParameterf TEXTURE_MAX_ANISOTROPY_EXT set to < 1 should be an invalid value");
gl.texParameteri(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "texParameteri TEXTURE_MAX_ANISOTROPY_EXT set to < 1 should be an invalid value");
gl.texParameterf(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameterf TEXTURE_MAX_ANISOTROPY_EXT set to >= 2 should succeed");
gl.texParameteri(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameteri TEXTURE_MAX_ANISOTROPY_EXT set to >= 2 should succeed");

View file

@ -81,7 +81,7 @@ for (var ii = 0; ii < 2; ++ii) {
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
var drawType = (ii == 0) ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW;
debug("Testing " + ((ii == 0) ? "STATIC_DRAW" : "DYNAMIC_DRAW"));
@ -131,17 +131,17 @@ function runSupportedTest(extensionEnabled) {
function runDrawTests(drawType) {
debug("Test that draws with unsigned integer indices produce the expected results");
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
var program = wtu.setupNoTexCoordTextureProgram(gl);
function setupDraw(s) {
// Create a vertex buffer that cannot be fully indexed via shorts
var quadArrayLen = 65537 * 3;
var quadArray = new Float32Array(quadArrayLen);
// Leave all but the last 4 values zero-ed out
var idx = quadArrayLen - 12;
@ -290,8 +290,8 @@ function runIndexValidationTests(drawType) {
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
'gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
debug("Test with enabled attribute that does not belong to current program");
@ -331,13 +331,14 @@ function runCopiesIndicesTests(drawType) {
var indices = new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runResizedBufferTests(drawType) {
@ -423,8 +424,9 @@ function runVerifiesTooManyIndicesTests(drawType) {
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]), drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
var indexValidationError = wtu.shouldGenerateGLError(gl, [gl.INVALID_OPERATION, gl.NO_ERROR],
"gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, indexValidationError, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runCrashWithBufferSubDataTests(drawType) {

View file

@ -183,10 +183,10 @@ function arrayToString(arr, size) {
mySize = size;
var out = "[";
for (var ii = 0; ii < mySize; ++ii) {
if (ii > 0) {
out += ", ";
}
out += arr[ii];
if (ii > 0) {
out += ", ";
}
out += arr[ii];
}
return out + "]";
}
@ -252,25 +252,25 @@ function runRenderTargetAndReadbackTest(testProgram, format, numberOfChannels, s
var implType = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "getParameter of IMPLEMENTATION_COLOR_READ_{FORMAT|TYPE} should succeed");
if ((implFormat == gl.RGBA || implFormat == gl.RGB) && implType == gl.FLOAT) {
debug("Checking readback of floating-point values");
var arraySize = (implFormat == gl.RGBA) ? 4 : 3
var buf = new Float32Array(arraySize);
gl.readPixels(0, 0, 1, 1, implFormat, implType , buf);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "readPixels from floating-point renderbuffer should succeed");
var ok = true;
var tolerance = 8.0; // TODO: factor this out from both this test and the subtractor shader above.
for (var ii = 0; ii < buf.length; ++ii) {
if (Math.abs(buf[ii] - subtractor[ii]) > tolerance) {
ok = false;
break;
}
}
if (ok) {
testPassed("readPixels of float-type data from floating-point renderbuffer succeeded");
} else {
testFailed("readPixels of float-type data from floating-point renderbuffer failed: expected "
+ arrayToString(subtractor, arraySize) + ", got " + arrayToString(buf));
}
debug("Checking readback of floating-point values");
var arraySize = (implFormat == gl.RGBA) ? 4 : 3
var buf = new Float32Array(arraySize);
gl.readPixels(0, 0, 1, 1, implFormat, implType , buf);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "readPixels from floating-point renderbuffer should succeed");
var ok = true;
var tolerance = 8.0; // TODO: factor this out from both this test and the subtractor shader above.
for (var ii = 0; ii < buf.length; ++ii) {
if (Math.abs(buf[ii] - subtractor[ii]) > tolerance) {
ok = false;
break;
}
}
if (ok) {
testPassed("readPixels of float-type data from floating-point renderbuffer succeeded");
} else {
testFailed("readPixels of float-type data from floating-point renderbuffer failed: expected "
+ arrayToString(subtractor, arraySize) + ", got " + arrayToString(buf));
}
}
}

View file

@ -117,13 +117,13 @@ if (!gl) {
formats.forEach(function(f) {
runTextureCreationTest(true, f.format, null, f.expected);
});
// Texture creation should fail when passed with non-null, non-Uint16 ArrayBufferView
formats.forEach(function(f) {
var width = 2;
var height = 2;
var format = f.format;
// Float32Array
var float32Data = new Float32Array(width * height * getNumberOfChannels(format));
for (var ii = 0; ii < float32Data.length; ii++) {
@ -140,7 +140,7 @@ if (!gl) {
});
// Test that Uint16 encoded half float values can be used as texture data.
// First test that values in the 0-1 range can be written and read.
var halfFloatOneThird = 0x3555; // Half float 1/3
var uint16Formats = [
@ -234,12 +234,12 @@ function runTextureCreationTest(extensionEnabled, opt_format, opt_data, opt_expe
var format = opt_format || gl.RGBA;
var data = opt_data || null;
var expectSuccess = true;
if (!extensionEnabled || !opt_expected)
expectSuccess = false;
debug("Testing texture creation with extension " + (extensionEnabled ? "enabled" : "disabled") +
", format " + getFormatName(format) + ", and data " + (data ? "non-null" : "null") +
". Expect " + (expectSuccess ? "Success" : "Failure"));
". Expect " + (expectSuccess ? "Success" : "Failure"));
var texture = allocateTexture();
var width = 2;

View file

@ -101,7 +101,7 @@ if (!gl) {
* namely the Nexus 5, and Nexus 7 (in 2014/01) when using bufferData before binding the VAO.
* The tested OS was Android KitKat 4.4.2, the effects were the same in all tested browsers
* (Chrome, Chrome Beta, Firefox, Firefox Beta), so it is likely a driver bug.
* These devices have the similar Adreno 320 and Adreno 330 GPUs respectively.
* These devices have the similar Adreno 320 and Adreno 330 GPUs respectively.
*
* The issuse resulted from this sequence of actions in a requestAnimationFrame loop:
* 1. upload some vertex buffers with gl.bufferData (eg. colors)
@ -109,12 +109,12 @@ if (!gl) {
* 3. clear the canvas
* 4. draw (some triangles) to the canvas
* 5. unbind the VAO
*
*
* This caused the drawn triangles to be drawn with black (0) for most of the frames, with some
* rare frames presenting the correct render results. Interestingly on both devices exactly every
* 64th frame passed (starting with the very first one), the others failed.
* 64th frame passed (starting with the very first one), the others failed.
* (Because of this, we test multiple frames.)
* When positions were uploaded, seemingly nothing was drawn, that's likely because the
* When positions were uploaded, seemingly nothing was drawn, that's likely because the
* position buffer was also all 0s.
*
* The issue did not occur:
@ -123,61 +123,61 @@ if (!gl) {
*/
function runBufferDataTest() {
debug("Testing draws with bufferData");
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
var testColor = [0, 255, 0, 255];
var clearColor = [255, 0, 0, 255];
// Where the issue occures, this is the sequence of success/failure every time:
// result: success fail fail fail fail ... success fail fail ...
// currentTestCount: 0 1 2 3 4 ... 64 65 66 ...
// So with just 1 test it passes, but 2 tests are enough. Here we use 3.
var numberOfTests = 3;
var numberOfTests = 3;
var currentTestCount = 0;
var positionLoc = 0;
var colorLoc = 1;
var gridRes = 1;
var program = wtu.setupSimpleVertexColorProgram(gl, positionLoc, colorLoc);
var vao0 = ext.createVertexArrayOES();
ext.bindVertexArrayOES(vao0);
var buffers = wtu.setupIndexedQuadWithOptions(gl,
{ gridRes: gridRes,
positionLocation: positionLoc
});
var colorTypedArray = createColorTypedArray();
var colorBuffer = gl.createBuffer(gl.ARRAY_BUFFER);
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.enableVertexAttribArray(colorLoc);
gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 0);
gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 0);
ext.bindVertexArrayOES(null);
testDrawing();
function testDrawing() {
// this order works fine:
// ext.bindVertexArrayOES(vao0);
// uploadColor();
// this order doesn't:
uploadColor();
ext.bindVertexArrayOES(vao0);
wtu.clearAndDrawIndexedQuad(gl, 1, clearColor);
ext.bindVertexArrayOES(null);
//debug("<span>"+currentTestCount+"</span");
wtu.checkCanvas(gl, testColor, "should be green")
if (++currentTestCount < numberOfTests) {
testDrawing();
// wtu.requestAnimFrame(testDrawing);
@ -186,12 +186,12 @@ function runBufferDataTest() {
ext.deleteVertexArrayOES(vao0);
}
}
function uploadColor() {
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.bufferData(gl.ARRAY_BUFFER, colorTypedArray, gl.STREAM_DRAW);
}
function createColorTypedArray() {
var colors = [];
var pOffset = 0;

View file

@ -127,10 +127,10 @@ function runSupportedTest(extensionEnabled) {
function runBindingTestDisabled() {
debug("");
debug("Testing binding enum with extension disabled");
// Use the constant directly as we don't have the extension
var VERTEX_ARRAY_BINDING_OES = 0x85B5;
gl.getParameter(VERTEX_ARRAY_BINDING_OES);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "VERTEX_ARRAY_BINDING_OES should not be queryable if extension is disabled");
}
@ -138,12 +138,12 @@ function runBindingTestDisabled() {
function runBindingTestEnabled() {
debug("");
debug("Testing binding enum with extension enabled");
shouldBe("ext.VERTEX_ARRAY_BINDING_OES", "0x85B5");
gl.getParameter(ext.VERTEX_ARRAY_BINDING_OES);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "VERTEX_ARRAY_BINDING_OES query should succeed if extension is enabled");
// Default value is null
if (gl.getParameter(ext.VERTEX_ARRAY_BINDING_OES) === null) {
testPassed("Default value of VERTEX_ARRAY_BINDING_OES is null");
@ -180,20 +180,20 @@ function runBindingTestEnabled() {
function runObjectTest() {
debug("");
debug("Testing object creation");
vao = ext.createVertexArrayOES();
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "createVertexArrayOES should not set an error");
shouldBeNonNull("vao");
// Expect false if never bound
shouldBeFalse("ext.isVertexArrayOES(vao)");
ext.bindVertexArrayOES(vao);
shouldBeTrue("ext.isVertexArrayOES(vao)");
ext.bindVertexArrayOES(null);
shouldBeTrue("ext.isVertexArrayOES(vao)");
shouldBeFalse("ext.isVertexArrayOES(null)");
ext.deleteVertexArrayOES(vao);
vao = null;
}
@ -201,57 +201,57 @@ function runObjectTest() {
function runAttributeTests() {
debug("");
debug("Testing attributes work across bindings");
var states = [];
var attrCount = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
for (var n = 0; n < attrCount; n++) {
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
var state = {};
states.push(state);
var vao = state.vao = ext.createVertexArrayOES();
ext.bindVertexArrayOES(vao);
var enableArray = (n % 2 == 0);
if (enableArray) {
gl.enableVertexAttribArray(n);
} else {
gl.disableVertexAttribArray(n);
}
if (enableArray) {
var buffer = state.buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
gl.vertexAttribPointer(n, 1 + n % 4, gl.FLOAT, true, n * 4, n * 4);
}
if (enableArray) {
var elbuffer = state.elbuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elbuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
}
ext.bindVertexArrayOES(null);
}
var anyMismatch = false;
for (var n = 0; n < attrCount; n++) {
var state = states[n];
ext.bindVertexArrayOES(state.vao);
var shouldBeEnabled = (n % 2 == 0);
var isEnabled = gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_ENABLED);
if (shouldBeEnabled != isEnabled) {
testFailed("VERTEX_ATTRIB_ARRAY_ENABLED not preserved");
anyMismatch = true;
}
var buffer = gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
if (shouldBeEnabled) {
if (buffer == state.buffer) {
@ -277,7 +277,7 @@ function runAttributeTests() {
anyMismatch = true;
}
}
var elbuffer = gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING);
if (shouldBeEnabled) {
if (elbuffer == state.elbuffer) {
@ -299,7 +299,7 @@ function runAttributeTests() {
if (!anyMismatch) {
testPassed("All attributes preserved across bindings");
}
for (var n = 0; n < attrCount; n++) {
var state = states[n];
ext.deleteVertexArrayOES(state.vao);
@ -309,41 +309,41 @@ function runAttributeTests() {
function runAttributeValueTests() {
debug("");
debug("Testing that attribute values are not attached to bindings");
var v;
var vao0 = ext.createVertexArrayOES();
var anyFailed = false;
ext.bindVertexArrayOES(null);
gl.vertexAttrib4f(0, 0, 1, 2, 3);
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 0 && v[1] == 1 && v[2] == 2 && v[3] == 3)) {
testFailed("Vertex attrib value not round-tripped?");
anyFailed = true;
}
ext.bindVertexArrayOES(vao0);
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 0 && v[1] == 1 && v[2] == 2 && v[3] == 3)) {
testFailed("Vertex attrib value reset across bindings");
anyFailed = true;
}
gl.vertexAttrib4f(0, 4, 5, 6, 7);
ext.bindVertexArrayOES(null);
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 4 && v[1] == 5 && v[2] == 6 && v[3] == 7)) {
testFailed("Vertex attrib value bound to buffer");
anyFailed = true;
}
if (!anyFailed) {
testPassed("Vertex attribute values are not attached to bindings")
}
ext.bindVertexArrayOES(null);
ext.deleteVertexArrayOES(vao0);
}
@ -351,19 +351,19 @@ function runAttributeValueTests() {
function runDrawTests() {
debug("");
debug("Testing draws with various VAO bindings");
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
var vao0 = ext.createVertexArrayOES();
var vao1 = ext.createVertexArrayOES();
var vao2 = ext.createVertexArrayOES();
var positionLocation = 0;
var colorLocation = 1;
var program = wtu.setupSimpleVertexColorProgram(gl, positionLocation, colorLocation);
function setupQuad(s, colorsInArray) {
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
@ -394,7 +394,7 @@ function runDrawTests() {
gl.disableVertexAttribArray(colorLocation);
}
};
function verifyDiagonalPixels(s, expectedInside, drawDescription) {
// Tests pixels along a diagonal running from the center of the canvas to the (0, 0) corner.
// Values on the points list indicate relative position along this diagonal.
@ -412,7 +412,7 @@ function runDrawTests() {
var expectedInside = colorsInArray ? 0 : 128;
verifyDiagonalPixels(s, expectedInside, drawDescription);
};
// Setup all bindings
setupQuad(1, true);
ext.bindVertexArrayOES(vao0);
@ -423,7 +423,7 @@ function runDrawTests() {
setupQuad(0.75, false);
gl.vertexAttrib4f(colorLocation, 0.5, 0.5, 0.5, 1);
// Verify drawing
ext.bindVertexArrayOES(null);
verifyDraw("with the default VAO", 1, true);

View file

@ -127,8 +127,9 @@ function getSharedArrayBufferSize() {
sharedArrayBufferSize = bufferSizeNeeded;
}
bufferSizeNeeded = test.func(t.maxSize + test.sizeStep, t.maxSize + test.sizeStep);
// ArrayBuffers can be at most 4GB (minus 1 byte)
if (bufferSizeNeeded > sharedArrayBufferSize && bufferSizeNeeded <= 4294967295) {
// ArrayBuffers can be at most 4GB (minus 1 byte), but any allocations larger than 1 GB are unreliable in practice. So limit allocations to 1 GB.
// Textures that are wide in just one dimension can still be used to test max TEXTURE_2D size limit even if we don't allocate space for huge square textures.
if (bufferSizeNeeded > sharedArrayBufferSize && bufferSizeNeeded <= Math.pow(2, 30)) {
sharedArrayBufferSize = bufferSizeNeeded;
}
}
@ -195,7 +196,7 @@ function testFormatType(t, test) {
for (var j = 0; j < t.targets.length; ++j) {
var target = t.targets[j];
debug("");
debug(wtu.glEnumToString(gl, target));
debug(wtu.glEnumToString(gl, target) + " " + wtu.glEnumToString(ext, test.format));
// positive test
var size = positiveTestSize;
@ -219,11 +220,25 @@ function testFormatType(t, test) {
var dataSize = test.func(t.maxSize + test.sizeStep, t.maxSize + test.sizeStep);
// this check assumes that each element is 1 byte
if (dataSize > sharedArrayBuffer.byteLength) {
testPassed("Unable to test texture larger than maximum size due to ArrayBuffer size limitations -- this is legal");
if (t.target == gl.TEXTURE_CUBE_MAP) {
testPassed("Unable to test texture larger than maximum size due to ArrayBuffer size limitations -- this is legal");
} else {
var wideAndShortDataSize = test.func(t.maxSize + test.sizeStep, test.sizeStep);
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, wideAndShortDataSize);
gl.compressedTexImage2D(target, 0, test.format, t.maxSize + test.sizeStep, test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (t.maxSize + test.sizeStep) + "x" + (test.sizeStep));
var narrowAndTallDataSize = test.func(test.sizeStep, t.maxSize + test.sizeStep);
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, narrowAndTallDataSize);
gl.compressedTexImage2D(target, 0, test.format, test.sizeStep, t.maxSize + test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "height out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (test.sizeStep) + "x" + (t.maxSize + test.sizeStep));
}
} else {
var pixelsNegativeTest1 = new test.dataType(sharedArrayBuffer, 0, dataSize);
gl.compressedTexImage2D(target, 0, test.format, t.maxSize + test.sizeStep, t.maxSize + test.sizeStep, 0, pixelsNegativeTest1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width or height out of bounds: should generate INVALID_VALUE."
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "width and height out of bounds: should generate INVALID_VALUE."
+ " level is 0, size is " + (t.maxSize + test.sizeStep) + "x" + (t.maxSize + test.sizeStep));
}
// level out of bounds

View file

@ -62,6 +62,13 @@ void main() {
gl_FragColor = vec4(1,0,0,1);
}
</script>
<script id="fshaderRedWithExtension" type="x-shader/x-fragment">
#extension GL_EXT_draw_buffers : require
precision mediump float;
void main() {
gl_FragColor = vec4(1,0,0,1);
}
</script>
<script id="fshaderMacroDisabled" type="x-shader/x-fragment">
#ifdef GL_EXT_draw_buffers
bad code here
@ -104,7 +111,7 @@ var canvas = document.getElementById("canvas");
var output = document.getElementById("console");
var gl = wtu.create3DContext(canvas);
var ext = null;
var vao = null;
var programWithMaxDrawBuffersEqualOne = null;
var extensionConstants = [
{ name: "MAX_COLOR_ATTACHMENTS_WEBGL", enum: 0x8CDF, expectedFn: function(v) { return v >= 4; }, passMsg: " should be >= 4"},
@ -179,8 +186,7 @@ if (!gl) {
function createExtDrawBuffersProgram(scriptId, sub) {
var fsource = wtu.getScript(scriptId);
fsource = wtu.replaceParams(fsource, sub);
wtu.addShaderSource(output, "fragment shader", fsource);
return wtu.setupProgram(gl, ["vshader", fsource], ["a_position"]);
return wtu.setupProgram(gl, ["vshader", fsource], ["a_position"], undefined, true);
}
function runSupportedTest(extensionEnabled) {
@ -246,9 +252,7 @@ function runEnumTestEnabled() {
function testShaders(tests, sub) {
tests.forEach(function(test) {
var shaders = [wtu.getScript(test.shaders[0]), wtu.replaceParams(wtu.getScript(test.shaders[1]), sub)];
wtu.addShaderSource(output, "vertex shader", shaders[0]);
wtu.addShaderSource(output, "fragment shader", shaders[1]);
var program = wtu.setupProgram(gl, shaders, ["a_position"]);
var program = wtu.setupProgram(gl, shaders, ["a_position"], undefined, true);
var programLinkedSuccessfully = (program != null);
var expectedProgramToLinkSuccessfully = (test.expectFailure == true);
expectTrue(programLinkedSuccessfully != expectedProgramToLinkSuccessfully, test.msg);
@ -260,6 +264,7 @@ function runShadersTestDisabled() {
debug("");
debug("test shaders disabled");
var sub = {numDrawingBuffers: 1};
testShaders([
{ shaders: ["vshader", "fshaderMacroDisabled"],
msg: "GL_EXT_draw_buffers should not be defined in GLSL",
@ -268,7 +273,12 @@ function runShadersTestDisabled() {
msg: "#extension GL_EXT_draw_buffers should not be allowed in GLSL",
expectFailure: true,
},
], {numDrawingBuffers: 1});
], sub);
programWithMaxDrawBuffersEqualOne = createExtDrawBuffersProgram("fshaderBuiltInConstEnabled", sub);
wtu.setupUnitQuad(gl);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}
@ -410,6 +420,7 @@ function runDrawTests() {
var checkProgram = wtu.setupTexturedQuad(gl);
var redProgram = wtu.setupProgram(gl, ["vshader", "fshaderRed"], ["a_position"]);
var redProgramWithExtension = wtu.setupProgram(gl, ["vshader", "fshaderRedWithExtension"], ["a_position"]);
var drawProgram = createExtDrawBuffersProgram("fshader", {numDrawingBuffers: maxDrawingBuffers});
var width = 64;
var height = 64;
@ -548,28 +559,56 @@ function runDrawTests() {
checkAttachmentsForColor(attachments, [0, 255, 0, 255]);
debug("test that gl_FragColor broadcasts");
debug("test that gl_FragColor does not broadcast unless extension is enabled in fragment shader");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
ext.drawBuffersWEBGL(bufs);
gl.useProgram(redProgram);
wtu.drawUnitQuad(gl);
checkAttachmentsForColorFn(attachments, function(attachment, index) {
return (index == 0) ? [255, 0, 0, 255] : [0, 255, 0, 255];
});
debug("test that gl_FragColor broadcasts if extension is enabled in fragment shader");
gl.clear(gl.COLOR_BUFFER_BIT);
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
ext.drawBuffersWEBGL(bufs);
gl.useProgram(redProgramWithExtension);
wtu.drawUnitQuad(gl);
checkAttachmentsForColor(attachments, [255, 0, 0, 255]);
if (maxUsable > 1) {
// First half of color buffers disable.
var bufs1 = makeColorAttachmentArray(maxUsable);
// Second half of color buffers disable.
var bufs2 = makeColorAttachmentArray(maxUsable);
// Color buffers with even indices disabled.
var bufs3 = makeColorAttachmentArray(maxUsable);
// Color buffers with odd indices disabled.
var bufs4 = makeColorAttachmentArray(maxUsable);
for (var ii = 0; ii < maxUsable; ++ii) {
if (ii < half) {
bufs1[ii] = gl.NONE;
} else {
bufs2[ii] = gl.NONE;
}
if (ii % 2) {
bufs3[ii] = gl.NONE;
} else {
bufs4[ii] = gl.NONE;
}
}
debug("test setting first half to NONE and clearing");
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
// We should clear all buffers rather than depending on the previous
// gl_FragColor broadcasts test to succeed and setting the colors.
ext.drawBuffersWEBGL(bufs);
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
ext.drawBuffersWEBGL(bufs1);
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
@ -594,6 +633,7 @@ function runDrawTests() {
ext.drawBuffersWEBGL(bufs);
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
ext.drawBuffersWEBGL(bufs2);
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
@ -698,6 +738,7 @@ function runDrawTests() {
});
gl.deleteProgram(checkProgram);
gl.deleteProgram(redProgram);
gl.deleteProgram(redProgramWithExtension);
gl.deleteProgram(drawProgram);
}
@ -729,6 +770,7 @@ function runPreserveTests() {
finishTest();
});
}
</script>
</body>
</html>

View file

@ -43,49 +43,49 @@
<script id="shader-vs" type="x-shader/x-vertex">
// Inputs
attribute vec4 a_position;
attribute vec2 a_tex_coords;
attribute vec4 a_position;
attribute vec2 a_tex_coords;
// Output
varying vec2 v_tex_coords;
void main(void) {
v_tex_coords = a_tex_coords;
varying vec2 v_tex_coords;
void main(void) {
v_tex_coords = a_tex_coords;
gl_Position = a_position;
}
}
</script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
precision mediump float;
// Constants
const float TEXEL_COUNT_V = 256.0;
const float TEXEL_HEIGHT = 1.0 / TEXEL_COUNT_V;
const float TEXEL_COUNT_V = 256.0;
const float TEXEL_HEIGHT = 1.0 / TEXEL_COUNT_V;
const float SEP_IX = TEXEL_COUNT_V / 2.0;
const vec4 GREEN = vec4(0.0, 1.0, 0.0, 1.0);
const vec4 BLUE = vec4(0.0, 0.0, 1.0, 1.0);
const vec4 GREEN = vec4(0.0, 1.0, 0.0, 1.0);
const vec4 BLUE = vec4(0.0, 0.0, 1.0, 1.0);
// Input
varying vec2 v_tex_coords;
varying vec2 v_tex_coords;
uniform sampler2D u_data;
uniform sampler2D u_data;
// Without this function or directly returning the data, the issue does not occur
mediump vec4 UnpackData(in vec4 inData) {
float s = inData.x;
// Note s is always 0
// mod(0, 1) = 0
// So return value = (0, 0, -1, 0)
// Note s is always 0
// mod(0, 1) = 0
// So return value = (0, 0, -1, 0)
return vec4(0.0, 0.0, mod(s, 1.0) - 1.0, 0.0);
// Comment out the line above and uncomment the line below and the test succeeds on angle-dx11
// return vec4(0.0, 0.0, -1.0, 0.0);
}
}
void main(void) {
// Set initial color
gl_FragColor = BLUE;
// Set initial color
gl_FragColor = BLUE;
if (gl_FragCoord.y <= SEP_IX) {
mediump vec2 addr = vec2(v_tex_coords.x, TEXEL_HEIGHT);
@ -94,8 +94,8 @@ void main(void) {
vec4 entry = texture2D(u_data, addr);
mediump vec4 unpack = UnpackData(entry);
// Buffer is filled with 0, unpack is always (0, 0, -1, 0)
// So discard is always triggered
// Buffer is filled with 0, unpack is always (0, 0, -1, 0)
// So discard is always triggered
if (unpack.z == -1.0) {
discard;
}
@ -126,7 +126,7 @@ if (!gl) {
testFailed("context does not exist");
} else {
// Create texture filled with zero's
// Create texture filled with zero's
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
@ -135,14 +135,14 @@ if (!gl) {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
wtu.fillTexture(gl, tex, 256, 256, [0, 0, 0, 0]);
// Clear complete viewport to red
// Clear complete viewport to red
gl.clearColor(1.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
var attribBuffers = wtu.setupUnitQuad(gl, 0, 1);
var program = wtu.setupProgram(gl, ["shader-vs", "shader-fs"], ["a_position", "a_tex_coords"], [0, 1]);
// Bind texture
// Bind texture
var uniformMap = wtu.getUniformMap(gl, program);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, tex);
@ -150,7 +150,7 @@ if (!gl) {
// Draw
wtu.drawUnitQuad(gl);
// Verify output
wtu.checkCanvasRect(gl, 0, 0, 256, 128, [ 255, 0, 0, 255 ], "should be red", 1);
wtu.checkCanvasRect(gl, 0, 128, 256, 128, [ 0, 255, 0, 255 ], "should be green", 1);

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "bvec2";
var targetType = "bvec2";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "bvec3";
var targetType = "bvec3";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "bvec4";
var targetType = "bvec4";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "ivec2";
var targetType = "ivec2";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "ivec3";
var targetType = "ivec3";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "ivec4";
var targetType = "ivec4";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "mat2";
var targetType = "mat2";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "mat3";
var targetType = "mat3";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "mat4";
var targetType = "mat4";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "vec2";
var targetType = "vec2";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "vec3";
var targetType = "vec3";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -44,15 +44,15 @@
<div id="console"></div>
<script>
"use strict";
var targetType = "vec4";
var targetType = "vec4";
description("Test " + targetType + " constructor expressions.");
var testSet = GLSLConstructorTestsGenerator.getDefaultTestSet(targetType);
// Generate tests
var testCases = GLSLConstructorTestsGenerator.getConstructorTests(targetType, testSet);
// Run the tests
// Run the tests
GLSLConformanceTester.runTests(testCases);
debug("");

View file

@ -79,7 +79,7 @@ GLSLGenerator.runFeatureTest({
tests: [
["$(output) = vec4(",
" $(func)(",
" $(input).x * 8.0 - 4.0,",
" $(input).x * 8.0 - 4.0,",
" $(input).y * 8.0 - 4.0) / 8.0,",
" 0,",
" 0,",
@ -88,7 +88,7 @@ GLSLGenerator.runFeatureTest({
" 0,",
" $(func)(",
" $(input).xy * 8.0 - 4.0,",
" $(input).wz * 8.0 - 4.0) / 8.0,",
" $(input).wz * 8.0 - 4.0) / 8.0,",
" 0, 1);"].join("\n"),
["$(output) = vec4(",
" 0, 0,",

View file

@ -80,7 +80,7 @@ GLSLGenerator.runFeatureTest({
tests: [
["$(output) = vec4(",
" $(func)(",
" $(input).x * 8.0 - 4.0,",
" $(input).x * 8.0 - 4.0,",
" $(input).y * 8.0 - 4.0) / 8.0,",
" 0,",
" 0,",
@ -89,7 +89,7 @@ GLSLGenerator.runFeatureTest({
" 0,",
" $(func)(",
" $(input).xy * 8.0 - 4.0,",
" $(input).wz * 8.0 - 4.0) / 8.0,",
" $(input).wz * 8.0 - 4.0) / 8.0,",
" 0, 1);"].join("\n"),
["$(output) = vec4(",
" 0, 0,",

View file

@ -1,89 +1,89 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
void main() {
$(type) a, b;
$(type) c = (b = $(initializer), a = b);
gl_FragColor = $(asVec4);
}
</script>
<script>
"use strict";
description("Verifies expression lists in declarator initializers work correctly.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfos = [
{ type: 'float', initializer: '1.0', asVec4: 'vec4(0.0,$(var),0.0,1.0)' },
{ type: 'vec2', initializer: 'vec2(0.0, 1.0)', asVec4: 'vec4($(var),0.0,1.0)' },
{ type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', asVec4: 'vec4($(var),1.0)' },
{ type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', asVec4: '$(var)' },
{ type: 'int', initializer: '1', asVec4: 'vec4(0.0,$(var),0.0,1.0)' },
{ type: 'ivec2', initializer: 'ivec2(0, 1)', asVec4: 'vec4($(var),0.0,1.0)' },
{ type: 'ivec3', initializer: 'ivec3(0, 1, 0)', asVec4: 'vec4($(var),1.0)' },
{ type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', asVec4: 'vec4($(var))' },
{ type: 'bool', initializer: 'true', asVec4: 'vec4(0.0,$(var),0.0,1.0)' },
{ type: 'bvec2', initializer: 'bvec2(false, true)', asVec4: 'vec4($(var),0.0,1.0)' },
{ type: 'bvec3', initializer: 'bvec3(false, true, false)', asVec4: 'vec4($(var),1.0)' },
{ type: 'bvec4', initializer: 'bvec4(false,true,false,true)',asVec4: 'vec4($(var))' },
];
// Ensure that each variable is properly initialized to green, not just c.
['a', 'b', 'c'].forEach(function(varName) {
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
type: typeInfo.type,
initializer: typeInfo.initializer,
asVec4: wtu.replaceParams(typeInfo.asVec4, {var: varName}),
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: typeInfo.type + ' with contents of ' + varName + ' rendered',
fShaderSuccess: true,
linkSuccess: true,
render:true
});
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
void main() {
$(type) a, b;
$(type) c = (b = $(initializer), a = b);
gl_FragColor = $(asVec4);
}
</script>
<script>
"use strict";
description("Verifies expression lists in declarator initializers work correctly.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfos = [
{ type: 'float', initializer: '1.0', asVec4: 'vec4(0.0,$(var),0.0,1.0)' },
{ type: 'vec2', initializer: 'vec2(0.0, 1.0)', asVec4: 'vec4($(var),0.0,1.0)' },
{ type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', asVec4: 'vec4($(var),1.0)' },
{ type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', asVec4: '$(var)' },
{ type: 'int', initializer: '1', asVec4: 'vec4(0.0,$(var),0.0,1.0)' },
{ type: 'ivec2', initializer: 'ivec2(0, 1)', asVec4: 'vec4($(var),0.0,1.0)' },
{ type: 'ivec3', initializer: 'ivec3(0, 1, 0)', asVec4: 'vec4($(var),1.0)' },
{ type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', asVec4: 'vec4($(var))' },
{ type: 'bool', initializer: 'true', asVec4: 'vec4(0.0,$(var),0.0,1.0)' },
{ type: 'bvec2', initializer: 'bvec2(false, true)', asVec4: 'vec4($(var),0.0,1.0)' },
{ type: 'bvec3', initializer: 'bvec3(false, true, false)', asVec4: 'vec4($(var),1.0)' },
{ type: 'bvec4', initializer: 'bvec4(false,true,false,true)',asVec4: 'vec4($(var))' },
];
// Ensure that each variable is properly initialized to green, not just c.
['a', 'b', 'c'].forEach(function(varName) {
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
type: typeInfo.type,
initializer: typeInfo.initializer,
asVec4: wtu.replaceParams(typeInfo.asVec4, {var: varName}),
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: typeInfo.type + ' with contents of ' + varName + ' rendered',
fShaderSuccess: true,
linkSuccess: true,
render:true
});
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -1,4 +1,4 @@
// Do not delete!
// Needed to help glsl-conformance tests.
// Do not delete!
// Needed to help glsl-conformance tests.

View file

@ -1,254 +1,254 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!-- author: Jamie Madill (jmadill at chromium) -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Struct Scope Test</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!-- author: Jamie Madill (jmadill at chromium) -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Struct Scope Test</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="shader-vs-1" type="x-shader/x-vertex">
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
{
struct T {
int v1;
};
T x;
gl_Position.x += float(x.v1);
}
{
struct T {
float v2;
};
T x;
gl_Position.x += x.v2;
}
}
</script>
<script id="shader-vs-2" type="x-shader/x-vertex">
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
struct T {
int v1;
};
T x;
gl_Position.x += float(x.v1);
{
struct T {
float v2;
};
T x;
gl_Position.x += x.v2;
}
}
</script>
<script id="shader-vs-3" type="x-shader/x-vertex">
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
{
struct T {
int v1;
};
T x;
gl_Position.x += float(x.v1);
}
struct T {
float v2;
};
T x;
gl_Position.x += x.v2;
}
</script>
<script id="shader-vs-bad" type="x-shader/x-vertex">
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
struct T {
int v1;
};
T x;
gl_Position.x += float(x.v1);
struct T {
float v2;
};
T y;
gl_Position.x += y.v2;
}
</script>
<script id="shader-vs-anglebug" type="x-shader/x-vertex">
struct T_0 {
int v1;
};
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
struct T {
float v2;
};
T_0 x;
gl_Position.x += float(x.v1);
T y;
gl_Position.x += y.v2;
}
</script>
<script id="shader-vs-masked-struct-variable" type="x-shader/x-vertex">
struct T {
float f;
};
void main(void) {
T a;
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
struct T {
float q;
};
gl_Position.x += a.f;
T b;
gl_Position.x += b.q;
}
</script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
void main(void) {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
description("Testing struct definition scope");
var wtu = WebGLTestUtils;
GLSLConformanceTester.runTests([
{
vShaderId: "shader-vs-1",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Two structs defined within non-overlapping scopes should be able to use the same name",
},
{
vShaderId: "shader-vs-2",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "A struct defined inside a scope overrides a struct defined in a outer scope with the same name",
},
{
vShaderId: "shader-vs-3",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "A struct can use the same name of another out-of-scope struct",
},
{
vShaderId: "shader-vs-bad",
vShaderSuccess: false,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: false,
passMsg: "A struct can't be defined with the same name as another struct defined in the same scope",
},
{
vShaderId: "shader-vs-anglebug",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Structs with appended underscored numbers don't cause link errors (ANGLE bug)",
},
{
vShaderId: "shader-vs-masked-struct-variable",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Variables of masked outer scope struct work with inner scope struct",
},
]);
debug("");
var successfullyParsed = true;
</script>
</body>
</html>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="shader-vs-1" type="x-shader/x-vertex">
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
{
struct T {
int v1;
};
T x;
gl_Position.x += float(x.v1);
}
{
struct T {
float v2;
};
T x;
gl_Position.x += x.v2;
}
}
</script>
<script id="shader-vs-2" type="x-shader/x-vertex">
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
struct T {
int v1;
};
T x;
gl_Position.x += float(x.v1);
{
struct T {
float v2;
};
T x;
gl_Position.x += x.v2;
}
}
</script>
<script id="shader-vs-3" type="x-shader/x-vertex">
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
{
struct T {
int v1;
};
T x;
gl_Position.x += float(x.v1);
}
struct T {
float v2;
};
T x;
gl_Position.x += x.v2;
}
</script>
<script id="shader-vs-bad" type="x-shader/x-vertex">
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
struct T {
int v1;
};
T x;
gl_Position.x += float(x.v1);
struct T {
float v2;
};
T y;
gl_Position.x += y.v2;
}
</script>
<script id="shader-vs-anglebug" type="x-shader/x-vertex">
struct T_0 {
int v1;
};
void main(void) {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
struct T {
float v2;
};
T_0 x;
gl_Position.x += float(x.v1);
T y;
gl_Position.x += y.v2;
}
</script>
<script id="shader-vs-masked-struct-variable" type="x-shader/x-vertex">
struct T {
float f;
};
void main(void) {
T a;
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
struct T {
float q;
};
gl_Position.x += a.f;
T b;
gl_Position.x += b.q;
}
</script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
void main(void) {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
description("Testing struct definition scope");
var wtu = WebGLTestUtils;
GLSLConformanceTester.runTests([
{
vShaderId: "shader-vs-1",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Two structs defined within non-overlapping scopes should be able to use the same name",
},
{
vShaderId: "shader-vs-2",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "A struct defined inside a scope overrides a struct defined in a outer scope with the same name",
},
{
vShaderId: "shader-vs-3",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "A struct can use the same name of another out-of-scope struct",
},
{
vShaderId: "shader-vs-bad",
vShaderSuccess: false,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: false,
passMsg: "A struct can't be defined with the same name as another struct defined in the same scope",
},
{
vShaderId: "shader-vs-anglebug",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Structs with appended underscored numbers don't cause link errors (ANGLE bug)",
},
{
vShaderId: "shader-vs-masked-struct-variable",
vShaderSuccess: true,
fShaderId: "shader-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Variables of masked outer scope struct work with inner scope struct",
},
]);
debug("");
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -75,7 +75,7 @@
{
int x = 1;
$(variables)
if ($(condition))
{ /*do nothing*/ }
@ -92,7 +92,7 @@
{
int x = 1;
$(variables)
if ($(condition))
{ /*do nothing*/ }

View file

@ -1,146 +1,146 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL GLSL Conformance Tests</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL GLSL Conformance Tests</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="vertexShaderLiteralLoopCondition" type="text/something-not-javascript">
attribute vec4 a_position;
void main()
{
for (int i = 0; i < 5 + 5; i++) { }
gl_Position = a_position;
}
</script>
<script id="fragmentShaderLiteralLoopCondition" type="text/something-not-javascript">
void main()
{
for (int i = 0; i < 5 + 5; i++) { }
gl_FragColor = vec4(1.0);
}
</script>
<script id="vertexShaderConstVarLoopCondition" type="text/something-not-javascript">
attribute vec4 a_position;
void main()
{
// Explicitly constant variables can be part of a constant expression
const int constVar = 5;
for (int i = 0; i < 5 + constVar; i++) { }
gl_Position = a_position;
}
</script>
<script id="fragmentShaderConstVarLoopCondition" type="text/something-not-javascript">
void main()
{
// Explicitly constant variables can be part of a constant expression
const int constVar = 5;
for (int i = 0; i < constVar + 5; i++) { }
gl_FragColor = vec4(1.0);
}
</script>
<script id="vertexShaderNonConstVarLoopCondition" type="text/something-not-javascript">
attribute vec4 a_position;
void main()
{
// Despite assigning a constant and not modifying it, nonConstVar is not semantically a constant expression
int nonConstVar = 10;
for (int i = 0; i < nonConstVar; i++) { }
gl_Position = a_position;
}
</script>
<script id="fragmentShaderNonConstVarLoopCondition" type="text/something-not-javascript">
void main()
{
// Despite assigning a constant and not modifying it, nonConstVar is not semantically a constant expression
int nonConstVar = 10;
for (int i = 0; i < nonConstVar; i++) { }
gl_FragColor = vec4(1.0);
}
</script>
<script>
"use strict";
var wtu = WebGLTestUtils;
var tests = [];
tests.push({
vShaderSource: wtu.getScript("vertexShaderLiteralLoopCondition"),
vShaderSuccess: true,
fShaderSource: wtu.getScript("fragmentShaderLiteralLoopCondition"),
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Shaders with literals in the loop condition should compile and link.",
});
tests.push({
vShaderSource: wtu.getScript("vertexShaderConstVarLoopCondition"),
vShaderSuccess: true,
fShaderSource: wtu.getScript("fragmentShaderConstVarLoopCondition"),
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Shaders with constant variables in the loop condition should compile and link.",
});
tests.push({
vShaderSource: wtu.getScript("vertexShaderConstVarLoopCondition"),
vShaderSuccess: true,
fShaderSource: wtu.getScript("fragmentShaderConstVarLoopCondition"),
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Shaders with constant variables in the loop condition should compile and link.",
});
tests.push({
vShaderSource: wtu.getScript("vertexShaderNonConstVarLoopCondition"),
vShaderSuccess: false,
fShaderSource: wtu.getScript("fragmentShaderLiteralLoopCondition"),
fShaderSuccess: true,
linkSuccess: false,
passMsg: "Vertex shader with non-const variable in the loop condition should fail.",
});
tests.push({
vShaderSource: wtu.getScript("vertexShaderLiteralLoopCondition"),
vShaderSuccess: true,
fShaderSource: wtu.getScript("fragmentShaderNonConstVarLoopCondition"),
fShaderSuccess: false,
linkSuccess: false,
passMsg: "Fragment shader with non-const variable in the loop condition should fail.",
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="vertexShaderLiteralLoopCondition" type="text/something-not-javascript">
attribute vec4 a_position;
void main()
{
for (int i = 0; i < 5 + 5; i++) { }
gl_Position = a_position;
}
</script>
<script id="fragmentShaderLiteralLoopCondition" type="text/something-not-javascript">
void main()
{
for (int i = 0; i < 5 + 5; i++) { }
gl_FragColor = vec4(1.0);
}
</script>
<script id="vertexShaderConstVarLoopCondition" type="text/something-not-javascript">
attribute vec4 a_position;
void main()
{
// Explicitly constant variables can be part of a constant expression
const int constVar = 5;
for (int i = 0; i < 5 + constVar; i++) { }
gl_Position = a_position;
}
</script>
<script id="fragmentShaderConstVarLoopCondition" type="text/something-not-javascript">
void main()
{
// Explicitly constant variables can be part of a constant expression
const int constVar = 5;
for (int i = 0; i < constVar + 5; i++) { }
gl_FragColor = vec4(1.0);
}
</script>
<script id="vertexShaderNonConstVarLoopCondition" type="text/something-not-javascript">
attribute vec4 a_position;
void main()
{
// Despite assigning a constant and not modifying it, nonConstVar is not semantically a constant expression
int nonConstVar = 10;
for (int i = 0; i < nonConstVar; i++) { }
gl_Position = a_position;
}
</script>
<script id="fragmentShaderNonConstVarLoopCondition" type="text/something-not-javascript">
void main()
{
// Despite assigning a constant and not modifying it, nonConstVar is not semantically a constant expression
int nonConstVar = 10;
for (int i = 0; i < nonConstVar; i++) { }
gl_FragColor = vec4(1.0);
}
</script>
<script>
"use strict";
var wtu = WebGLTestUtils;
var tests = [];
tests.push({
vShaderSource: wtu.getScript("vertexShaderLiteralLoopCondition"),
vShaderSuccess: true,
fShaderSource: wtu.getScript("fragmentShaderLiteralLoopCondition"),
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Shaders with literals in the loop condition should compile and link.",
});
tests.push({
vShaderSource: wtu.getScript("vertexShaderConstVarLoopCondition"),
vShaderSuccess: true,
fShaderSource: wtu.getScript("fragmentShaderConstVarLoopCondition"),
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Shaders with constant variables in the loop condition should compile and link.",
});
tests.push({
vShaderSource: wtu.getScript("vertexShaderConstVarLoopCondition"),
vShaderSuccess: true,
fShaderSource: wtu.getScript("fragmentShaderConstVarLoopCondition"),
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Shaders with constant variables in the loop condition should compile and link.",
});
tests.push({
vShaderSource: wtu.getScript("vertexShaderNonConstVarLoopCondition"),
vShaderSuccess: false,
fShaderSource: wtu.getScript("fragmentShaderLiteralLoopCondition"),
fShaderSuccess: true,
linkSuccess: false,
passMsg: "Vertex shader with non-const variable in the loop condition should fail.",
});
tests.push({
vShaderSource: wtu.getScript("vertexShaderLiteralLoopCondition"),
vShaderSuccess: true,
fShaderSource: wtu.getScript("fragmentShaderNonConstVarLoopCondition"),
fShaderSuccess: false,
linkSuccess: false,
passMsg: "Fragment shader with non-const variable in the loop condition should fail.",
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -42,7 +42,7 @@
<div id="description"></div>
<div id="console"></div>
<script id="vertexShaderStructSequence" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -58,7 +58,7 @@ void main()
}
</script>
<script id="fragmentShaderStructSequence" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -74,7 +74,7 @@ void main()
}
</script>
<script id="vertexShaderStructName" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -90,7 +90,7 @@ void main()
}
</script>
<script id="fragmentShaderStructNameFailure" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -106,7 +106,7 @@ void main()
}
</script>
<script id="fragmentShaderStructNameSuccess" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -131,7 +131,7 @@ void main()
}
</script>
<script id="vertexShaderStructFieldName" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -147,7 +147,7 @@ void main()
}
</script>
<script id="fragmentShaderStructFieldName" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -163,7 +163,7 @@ void main()
}
</script>
<script id="vertexShaderStructFieldType" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -179,7 +179,7 @@ void main()
}
</script>
<script id="fragmentShaderStructFieldType" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;
@ -195,7 +195,7 @@ void main()
}
</script>
<script id="vertexShaderStructFieldPrecision" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
struct info {
@ -210,7 +210,7 @@ void main()
}
</script>
<script id="fragmentShaderStructFieldPrecision" type="text/something-not-javascript">
// Structures must have the same name, sequence of type names, and
// Structures must have the same name, sequence of type names, and
// type definitions, and field names to be considered the same type.
// GLSL 1.017 4.2.4
precision mediump float;

View file

@ -1,180 +1,180 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GLSL Structure Equals Test</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GLSL Structure Equals Test</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"> </script>
<script src="../../resources/glsl-conformance-test.js"></script>
<script id="simple-vs" type="x-shader/x-vertex">
attribute vec4 a_position;
void main(void) {
gl_Position = a_position;
}
</script>
<script id="simple-struct-fs" type="x-shader/x-fragment">
precision mediump float;
struct my_struct {
float f;
};
my_struct a = my_struct(1.0);
my_struct b = my_struct(1.0);
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
if (a == b) {
gl_FragColor.y = 1.0;
}
}
</script>
<script id="vec-struct-fs" type="x-shader/x-fragment">
precision mediump float;
struct my_struct {
vec3 v;
};
my_struct a = my_struct(vec3(1.0, 2.0, 3.0));
my_struct b = my_struct(vec3(1.0, 2.0, 3.0));
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
if (a == b) {
gl_FragColor.y = 1.0;
}
}
</script>
<script id="nested-struct-fs" type="x-shader/x-fragment">
precision mediump float;
struct s1
{
float f;
};
struct s2
{
s1 s;
};
s2 a = s2(s1(1.0));
s2 b = s2(s1(1.0));
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
if (a == b) {
gl_FragColor.y = 1.0;
}
}
</script>
<script id="nested-vec-struct-fs" type="x-shader/x-fragment">
precision mediump float;
struct s1
{
vec3 v;
};
struct s2
{
s1 s;
};
s2 a = s2(s1(vec3(1.0, 2.0, 3.0)));
s2 b = s2(s1(vec3(1.0, 2.0, 3.0)));
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
if (a == b) {
gl_FragColor.y = 1.0;
}
}
</script>
</head>
<body>
<canvas id="canvas" width="50" height="50"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Testing struct equals");
var wtu = WebGLTestUtils;
GLSLConformanceTester.runRenderTests([
{
vShaderId: "simple-vs",
vShaderSuccess: true,
fShaderId: "simple-struct-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Simple struct with one float",
},
{
vShaderId: "simple-vs",
vShaderSuccess: true,
fShaderId: "vec-struct-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Simple struct with a vector",
},
{
vShaderId: "simple-vs",
vShaderSuccess: true,
fShaderId: "nested-struct-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Nested struct with a float",
},
{
vShaderId: "simple-vs",
vShaderSuccess: true,
fShaderId: "nested-vec-struct-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Nested struct with a vector",
},
]);
debug("");
var successfullyParsed = true;
</script>
</body>
</html>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"> </script>
<script src="../../resources/glsl-conformance-test.js"></script>
<script id="simple-vs" type="x-shader/x-vertex">
attribute vec4 a_position;
void main(void) {
gl_Position = a_position;
}
</script>
<script id="simple-struct-fs" type="x-shader/x-fragment">
precision mediump float;
struct my_struct {
float f;
};
my_struct a = my_struct(1.0);
my_struct b = my_struct(1.0);
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
if (a == b) {
gl_FragColor.y = 1.0;
}
}
</script>
<script id="vec-struct-fs" type="x-shader/x-fragment">
precision mediump float;
struct my_struct {
vec3 v;
};
my_struct a = my_struct(vec3(1.0, 2.0, 3.0));
my_struct b = my_struct(vec3(1.0, 2.0, 3.0));
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
if (a == b) {
gl_FragColor.y = 1.0;
}
}
</script>
<script id="nested-struct-fs" type="x-shader/x-fragment">
precision mediump float;
struct s1
{
float f;
};
struct s2
{
s1 s;
};
s2 a = s2(s1(1.0));
s2 b = s2(s1(1.0));
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
if (a == b) {
gl_FragColor.y = 1.0;
}
}
</script>
<script id="nested-vec-struct-fs" type="x-shader/x-fragment">
precision mediump float;
struct s1
{
vec3 v;
};
struct s2
{
s1 s;
};
s2 a = s2(s1(vec3(1.0, 2.0, 3.0)));
s2 b = s2(s1(vec3(1.0, 2.0, 3.0)));
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
if (a == b) {
gl_FragColor.y = 1.0;
}
}
</script>
</head>
<body>
<canvas id="canvas" width="50" height="50"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Testing struct equals");
var wtu = WebGLTestUtils;
GLSLConformanceTester.runRenderTests([
{
vShaderId: "simple-vs",
vShaderSuccess: true,
fShaderId: "simple-struct-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Simple struct with one float",
},
{
vShaderId: "simple-vs",
vShaderSuccess: true,
fShaderId: "vec-struct-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Simple struct with a vector",
},
{
vShaderId: "simple-vs",
vShaderSuccess: true,
fShaderId: "nested-struct-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Nested struct with a float",
},
{
vShaderId: "simple-vs",
vShaderSuccess: true,
fShaderId: "nested-vec-struct-fs",
fShaderSuccess: true,
linkSuccess: true,
passMsg: "Nested struct with a vector",
},
]);
debug("");
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -1,92 +1,92 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
void main() {
struct S {
$(type) field;
};
S s1[2], s2;
$(var).field = $(initializer);
gl_FragColor = $(asVec4);
}
</script>
<script>
"use strict";
description("Verifies that mixed (array vs. not array) struct declarators work correctly.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfos = [
{ type: 'float', initializer: '1.0', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' },
{ type: 'vec2', initializer: 'vec2(0.0, 1.0)', asVec4: 'vec4($(var).field,0.0,1.0)' },
{ type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', asVec4: 'vec4($(var).field,1.0)' },
{ type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', asVec4: '$(var).field' },
{ type: 'int', initializer: '1', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' },
{ type: 'ivec2', initializer: 'ivec2(0, 1)', asVec4: 'vec4($(var).field,0.0,1.0)' },
{ type: 'ivec3', initializer: 'ivec3(0, 1, 0)', asVec4: 'vec4($(var).field,1.0)' },
{ type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', asVec4: 'vec4($(var).field)' },
{ type: 'bool', initializer: 'true', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' },
{ type: 'bvec2', initializer: 'bvec2(false, true)', asVec4: 'vec4($(var).field,0.0,1.0)' },
{ type: 'bvec3', initializer: 'bvec3(false, true, false)', asVec4: 'vec4($(var).field,1.0)' },
{ type: 'bvec4', initializer: 'bvec4(false,true,false,true)',asVec4: 'vec4($(var).field)' },
];
['s1[0]', 's1[1]', 's2'].forEach(function(varName) {
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
type: typeInfo.type,
initializer: typeInfo.initializer,
var: varName,
asVec4: wtu.replaceParams(typeInfo.asVec4, {var: varName})
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: typeInfo.type,
fShaderSuccess: true,
linkSuccess: true,
render:true
});
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
void main() {
struct S {
$(type) field;
};
S s1[2], s2;
$(var).field = $(initializer);
gl_FragColor = $(asVec4);
}
</script>
<script>
"use strict";
description("Verifies that mixed (array vs. not array) struct declarators work correctly.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfos = [
{ type: 'float', initializer: '1.0', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' },
{ type: 'vec2', initializer: 'vec2(0.0, 1.0)', asVec4: 'vec4($(var).field,0.0,1.0)' },
{ type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', asVec4: 'vec4($(var).field,1.0)' },
{ type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', asVec4: '$(var).field' },
{ type: 'int', initializer: '1', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' },
{ type: 'ivec2', initializer: 'ivec2(0, 1)', asVec4: 'vec4($(var).field,0.0,1.0)' },
{ type: 'ivec3', initializer: 'ivec3(0, 1, 0)', asVec4: 'vec4($(var).field,1.0)' },
{ type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', asVec4: 'vec4($(var).field)' },
{ type: 'bool', initializer: 'true', asVec4: 'vec4(0.0,$(var).field,0.0,1.0)' },
{ type: 'bvec2', initializer: 'bvec2(false, true)', asVec4: 'vec4($(var).field,0.0,1.0)' },
{ type: 'bvec3', initializer: 'bvec3(false, true, false)', asVec4: 'vec4($(var).field,1.0)' },
{ type: 'bvec4', initializer: 'bvec4(false,true,false,true)',asVec4: 'vec4($(var).field)' },
];
['s1[0]', 's1[1]', 's2'].forEach(function(varName) {
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
type: typeInfo.type,
initializer: typeInfo.initializer,
var: varName,
asVec4: wtu.replaceParams(typeInfo.asVec4, {var: varName})
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: typeInfo.type,
fShaderSuccess: true,
linkSuccess: true,
render:true
});
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -1,95 +1,95 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
struct S { $(outer_type) u; };
void main() {
S S; // This is legal, 'S' as a typename is defined in another scope.
{
struct S { $(inner_type) a; }; // This is legal as well, 'S' is now defined as a variable name in an ancestor scope
S newvar;
newvar.a = $(initializer);
gl_FragColor = $(fragColor);
}
}
</script>
<script>
"use strict";
description("This test verifies that defining a typename in a new scope when the typename is the name of a variable that hides a typename declaration succeeds for all combinations of GLSL types.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfo = [
{ Type: 'float', initializer: '1.0', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
{ Type: 'vec2', initializer: 'vec2(0.0, 1.0)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
{ Type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', fragColor: 'vec4(newvar.a, 1.0)' },
{ Type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', fragColor: 'newvar.a' },
{ Type: 'int', initializer: '1', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
{ Type: 'ivec2', initializer: 'ivec2(0, 1)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
{ Type: 'ivec3', initializer: 'ivec3(0, 1, 0)', fragColor: 'vec4(newvar.a, 1.0)' },
{ Type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', fragColor: 'vec4(newvar.a)' },
{ Type: 'bool', initializer: 'true', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
{ Type: 'bvec2', initializer: 'bvec2(false, true)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
{ Type: 'bvec3', initializer: 'bvec3(false, true, false)', fragColor: 'vec4(newvar.a, 1.0)' },
{ Type: 'bvec4', initializer: 'bvec4(false,true,false,true)',fragColor: 'vec4(newvar.a)' },
];
typeInfo.forEach(function (outerType) {
typeInfo.forEach(function (innerType) {
var replaceParams = {
outer_type: outerType.Type,
inner_type: innerType.Type,
// use the initializer and fragColor for the inner type. Its definition should override the variable name in the outerscope.
initializer: innerType.initializer,
fragColor: innerType.fragColor
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: 'Outer struct type: ' + outerType.Type + ' inner struct type: ' + innerType.Type,
fShaderSuccess: true,
linkSuccess: true,
render: true
});
})
})
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
struct S { $(outer_type) u; };
void main() {
S S; // This is legal, 'S' as a typename is defined in another scope.
{
struct S { $(inner_type) a; }; // This is legal as well, 'S' is now defined as a variable name in an ancestor scope
S newvar;
newvar.a = $(initializer);
gl_FragColor = $(fragColor);
}
}
</script>
<script>
"use strict";
description("This test verifies that defining a typename in a new scope when the typename is the name of a variable that hides a typename declaration succeeds for all combinations of GLSL types.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfo = [
{ Type: 'float', initializer: '1.0', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
{ Type: 'vec2', initializer: 'vec2(0.0, 1.0)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
{ Type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', fragColor: 'vec4(newvar.a, 1.0)' },
{ Type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', fragColor: 'newvar.a' },
{ Type: 'int', initializer: '1', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
{ Type: 'ivec2', initializer: 'ivec2(0, 1)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
{ Type: 'ivec3', initializer: 'ivec3(0, 1, 0)', fragColor: 'vec4(newvar.a, 1.0)' },
{ Type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', fragColor: 'vec4(newvar.a)' },
{ Type: 'bool', initializer: 'true', fragColor: 'vec4(0.0, newvar.a, 0.0, 1.0)' },
{ Type: 'bvec2', initializer: 'bvec2(false, true)', fragColor: 'vec4(newvar.a, 0.0, 1.0)' },
{ Type: 'bvec3', initializer: 'bvec3(false, true, false)', fragColor: 'vec4(newvar.a, 1.0)' },
{ Type: 'bvec4', initializer: 'bvec4(false,true,false,true)',fragColor: 'vec4(newvar.a)' },
];
typeInfo.forEach(function (outerType) {
typeInfo.forEach(function (innerType) {
var replaceParams = {
outer_type: outerType.Type,
inner_type: innerType.Type,
// use the initializer and fragColor for the inner type. Its definition should override the variable name in the outerscope.
initializer: innerType.initializer,
fragColor: innerType.fragColor
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: 'Outer struct type: ' + outerType.Type + ' inner struct type: ' + innerType.Type,
fShaderSuccess: true,
linkSuccess: true,
render: true
});
})
})
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -1,86 +1,86 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
uniform struct S { $(type) field;} s;
void main() {
// All uniforms are required to be zero initialized. Add the color green
// to make the rendering test pass.
gl_FragColor = $(asVec4) + vec4(0.0, 1.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
description("Verifies that structure specifiers work with uniforms.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfos = [
{ type: 'float', asVec4: 'vec4(0.0,s.field,0.0,0.0)' },
{ type: 'vec2', asVec4: 'vec4(s.field,0.0,0.0)' },
{ type: 'vec3', asVec4: 'vec4(s.field,0.0)' },
{ type: 'vec4', asVec4: 's.field' },
{ type: 'int', asVec4: 'vec4(0.0,s.field,0.0,0.0)' },
{ type: 'ivec2', asVec4: 'vec4(s.field,0.0,0.0)' },
{ type: 'ivec3', asVec4: 'vec4(s.field,0.0)' },
{ type: 'ivec4', asVec4: 'vec4(s.field)' },
{ type: 'bool', asVec4: 'vec4(0.0,s.field,0.0,0.0)' },
{ type: 'bvec2', asVec4: 'vec4(s.field,0.0,0.0)' },
{ type: 'bvec3', asVec4: 'vec4(s.field,0.0)' },
{ type: 'bvec4', asVec4: 'vec4(s.field)' },
];
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
type: typeInfo.type,
asVec4: typeInfo.asVec4
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: typeInfo.type,
fShaderSuccess: true,
linkSuccess: true,
render:true
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
uniform struct S { $(type) field;} s;
void main() {
// All uniforms are required to be zero initialized. Add the color green
// to make the rendering test pass.
gl_FragColor = $(asVec4) + vec4(0.0, 1.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
description("Verifies that structure specifiers work with uniforms.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfos = [
{ type: 'float', asVec4: 'vec4(0.0,s.field,0.0,0.0)' },
{ type: 'vec2', asVec4: 'vec4(s.field,0.0,0.0)' },
{ type: 'vec3', asVec4: 'vec4(s.field,0.0)' },
{ type: 'vec4', asVec4: 's.field' },
{ type: 'int', asVec4: 'vec4(0.0,s.field,0.0,0.0)' },
{ type: 'ivec2', asVec4: 'vec4(s.field,0.0,0.0)' },
{ type: 'ivec3', asVec4: 'vec4(s.field,0.0)' },
{ type: 'ivec4', asVec4: 'vec4(s.field)' },
{ type: 'bool', asVec4: 'vec4(0.0,s.field,0.0,0.0)' },
{ type: 'bvec2', asVec4: 'vec4(s.field,0.0,0.0)' },
{ type: 'bvec3', asVec4: 'vec4(s.field,0.0)' },
{ type: 'bvec4', asVec4: 'vec4(s.field)' },
];
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
type: typeInfo.type,
asVec4: typeInfo.asVec4
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: typeInfo.type,
fShaderSuccess: true,
linkSuccess: true,
render:true
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -1,91 +1,91 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
struct S { $(type) t; };
void main() {
S a;
a.t = $(initializer);
S b = $(operator)a; // Unary operators not allowed
gl_FragColor = $(fragColor);
}
</script>
<script>
"use strict";
description("This test verifies that unary operators +, ++, -, --, !, and ~ do not work on structures. Per the spec, field selectors, equality and assignment are the only operators allowed on structures.");
var tests = [];
var wtu = WebGLTestUtils;
var operators = ['+', '++', '-', '--', '!', '~']
var typeInfos = [
{ type: 'float', initializer: '1.0', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' },
{ type: 'vec2', initializer: 'vec2(0.0, 1.0)', fragColor: 'vec4(b.t, 0.0, 1.0)' },
{ type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', fragColor: 'vec4(b.t, 1.0)' },
{ type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', fragColor: 'b.t' },
{ type: 'int', initializer: '1', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' },
{ type: 'ivec2', initializer: 'ivec2(0, 1)', fragColor: 'vec4(b.t, 0.0, 1.0)' },
{ type: 'ivec3', initializer: 'ivec3(0, 1, 0)', fragColor: 'vec4(b.t, 1.0)' },
{ type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', fragColor: 'vec4(b.t)' },
{ type: 'bool', initializer: 'true', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' },
{ type: 'bvec2', initializer: 'bvec2(false, true)', fragColor: 'vec4(b.t, 0.0, 1.0)' },
{ type: 'bvec3', initializer: 'bvec3(false, true, false)', fragColor: 'vec4(b.t, 1.0)' },
{ type: 'bvec4', initializer: 'bvec4(false,true,false,true)',fragColor: 'vec4(b.t)' },
];
operators.forEach(function (operator) {
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
initializer: typeInfo.initializer,
type: typeInfo.type,
fragColor: typeInfo.fragColor,
operator: operator,
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: 'Unary operator ' + operator + ' cannot be used on a struct with a ' + typeInfo.type,
fShaderSuccess: false,
linkSuccess: false
});
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
struct S { $(type) t; };
void main() {
S a;
a.t = $(initializer);
S b = $(operator)a; // Unary operators not allowed
gl_FragColor = $(fragColor);
}
</script>
<script>
"use strict";
description("This test verifies that unary operators +, ++, -, --, !, and ~ do not work on structures. Per the spec, field selectors, equality and assignment are the only operators allowed on structures.");
var tests = [];
var wtu = WebGLTestUtils;
var operators = ['+', '++', '-', '--', '!', '~']
var typeInfos = [
{ type: 'float', initializer: '1.0', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' },
{ type: 'vec2', initializer: 'vec2(0.0, 1.0)', fragColor: 'vec4(b.t, 0.0, 1.0)' },
{ type: 'vec3', initializer: 'vec3(0.0, 1.0, 0.0)', fragColor: 'vec4(b.t, 1.0)' },
{ type: 'vec4', initializer: 'vec4(0.0, 1.0, 0.0, 1.0)', fragColor: 'b.t' },
{ type: 'int', initializer: '1', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' },
{ type: 'ivec2', initializer: 'ivec2(0, 1)', fragColor: 'vec4(b.t, 0.0, 1.0)' },
{ type: 'ivec3', initializer: 'ivec3(0, 1, 0)', fragColor: 'vec4(b.t, 1.0)' },
{ type: 'ivec4', initializer: 'ivec4(0, 1, 0, 1)', fragColor: 'vec4(b.t)' },
{ type: 'bool', initializer: 'true', fragColor: 'vec4(0.0, b.t, 0.0, 1.0)' },
{ type: 'bvec2', initializer: 'bvec2(false, true)', fragColor: 'vec4(b.t, 0.0, 1.0)' },
{ type: 'bvec3', initializer: 'bvec3(false, true, false)', fragColor: 'vec4(b.t, 1.0)' },
{ type: 'bvec4', initializer: 'bvec4(false,true,false,true)',fragColor: 'vec4(b.t)' },
];
operators.forEach(function (operator) {
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
initializer: typeInfo.initializer,
type: typeInfo.type,
fragColor: typeInfo.fragColor,
operator: operator,
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: 'Unary operator ' + operator + ' cannot be used on a struct with a ' + typeInfo.type,
fShaderSuccess: false,
linkSuccess: false
});
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -1,88 +1,88 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title>Ternary Operators in Global Initializers</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
const $(type) green = $(green);
const $(type) black = $(black);
$(type) var = (true) ? green : black;
void main() {
gl_FragColor = $(asVec4);
}
</script>
<script>
"use strict";
description("This test verifies that ternary operators can be used in global initializers.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfos = [
{ type: 'float', green: '1.0', black: '0.0', asVec4: 'vec4(0.0,var,0.0,1.0)' },
{ type: 'vec2', green: 'vec2(0.0,1.0)', black: 'vec2(0.0,0.0)', asVec4: 'vec4(var,0.0,1.0)' },
{ type: 'vec3', green: 'vec3(0.0,1.0,0.0)', black: 'vec3(0.0,0.0,0.0)', asVec4: 'vec4(var,1.0)' },
{ type: 'vec4', green: 'vec4(0.0,1.0,0.0,1.0)', black: 'vec4(0.0,0.0,0.0,0.0)', asVec4: 'var' },
{ type: 'int', green: '1', black: '0', asVec4: 'vec4(0.0,var,0.0,1.0)' },
{ type: 'ivec2', green: 'ivec2(0,1)', black: 'ivec2(0,0)', asVec4: 'vec4(var,0.0,1.0)' },
{ type: 'ivec3', green: 'ivec3(0,1,0)', black: 'ivec3(0,0,0)', asVec4: 'vec4(var,1.0)' },
{ type: 'ivec4', green: 'ivec4(0,1,0,1)', black: 'ivec4(0,0,0,0)', asVec4: 'vec4(var)' },
{ type: 'bool', green: 'true', black: 'false', asVec4: 'vec4(0.0,var,0.0,1.0)' },
{ type: 'bvec2', green: 'bvec2(false,true)', black: 'bvec2(false,false)', asVec4: 'vec4(var,0.0,1.0)' },
{ type: 'bvec3', green: 'bvec3(false,true,false)', black: 'bvec3(false,false,false)', asVec4: 'vec4(var,1.0)' },
{ type: 'bvec4', green: 'bvec4(false,true,false,true)',black: 'bvec4(false,false,false,false)', asVec4: 'vec4(var)' },
];
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
type: typeInfo.type,
green: typeInfo.green,
black: typeInfo.black,
asVec4: typeInfo.asVec4,
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: typeInfo.type,
fShaderSuccess: true,
linkSuccess: true,
render: true
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title>Ternary Operators in Global Initializers</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fragmentShader" type="text/something-not-javascript">
precision mediump float;
const $(type) green = $(green);
const $(type) black = $(black);
$(type) var = (true) ? green : black;
void main() {
gl_FragColor = $(asVec4);
}
</script>
<script>
"use strict";
description("This test verifies that ternary operators can be used in global initializers.");
var tests = [];
var wtu = WebGLTestUtils;
var typeInfos = [
{ type: 'float', green: '1.0', black: '0.0', asVec4: 'vec4(0.0,var,0.0,1.0)' },
{ type: 'vec2', green: 'vec2(0.0,1.0)', black: 'vec2(0.0,0.0)', asVec4: 'vec4(var,0.0,1.0)' },
{ type: 'vec3', green: 'vec3(0.0,1.0,0.0)', black: 'vec3(0.0,0.0,0.0)', asVec4: 'vec4(var,1.0)' },
{ type: 'vec4', green: 'vec4(0.0,1.0,0.0,1.0)', black: 'vec4(0.0,0.0,0.0,0.0)', asVec4: 'var' },
{ type: 'int', green: '1', black: '0', asVec4: 'vec4(0.0,var,0.0,1.0)' },
{ type: 'ivec2', green: 'ivec2(0,1)', black: 'ivec2(0,0)', asVec4: 'vec4(var,0.0,1.0)' },
{ type: 'ivec3', green: 'ivec3(0,1,0)', black: 'ivec3(0,0,0)', asVec4: 'vec4(var,1.0)' },
{ type: 'ivec4', green: 'ivec4(0,1,0,1)', black: 'ivec4(0,0,0,0)', asVec4: 'vec4(var)' },
{ type: 'bool', green: 'true', black: 'false', asVec4: 'vec4(0.0,var,0.0,1.0)' },
{ type: 'bvec2', green: 'bvec2(false,true)', black: 'bvec2(false,false)', asVec4: 'vec4(var,0.0,1.0)' },
{ type: 'bvec3', green: 'bvec3(false,true,false)', black: 'bvec3(false,false,false)', asVec4: 'vec4(var,1.0)' },
{ type: 'bvec4', green: 'bvec4(false,true,false,true)',black: 'bvec4(false,false,false,false)', asVec4: 'vec4(var)' },
];
typeInfos.forEach(function (typeInfo) {
var replaceParams = {
type: typeInfo.type,
green: typeInfo.green,
black: typeInfo.black,
asVec4: typeInfo.asVec4,
};
tests.push({
fShaderSource: wtu.replaceParams(wtu.getScript('fragmentShader'), replaceParams),
passMsg: typeInfo.type,
fShaderSuccess: true,
linkSuccess: true,
render: true
});
});
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -1,145 +1,145 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../resources/glsl-feature-tests.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="intFragShader" type="text/something-not-javascript">
void main() {
int i = 2, j = (i > 1) ? 1 : 0;
gl_FragColor = vec4(0.0, j, 0.0, 1.0);
}
</script>
<script id="ivec2FragShader" type="text/something-not-javascript">
void main() {
ivec2 i = ivec2(2, 0), j = (i.x > 1) ? ivec2(0, 1) : ivec2(0, 0);
gl_FragColor = vec4(j, 0.0, 1.0);
}
</script>
<script id="ivec3FragShader" type="text/something-not-javascript">
void main() {
ivec3 i = ivec3(0, 2, 0), j = (i.y > 1) ? ivec3(0, 1, 0) : ivec3(0, 0, 0);
gl_FragColor = vec4(j, 1.0);
}
</script>
<script id="ivec4FragShader" type="text/something-not-javascript">
void main() {
ivec4 i = ivec4(0.0, 0.0, 2.0, 0.0), j = (i.z > 1) ? ivec4(0, 1, 0, 1) : ivec4(0, 0, 0, 1);
gl_FragColor = vec4(j);
}
</script>
<script id="floatFragShader" type="text/something-not-javascript">
void main() {
precision mediump float;
float i = 2.0, j = (i > 1.0) ? 1.0 : 0.0;
gl_FragColor = vec4(0.0, j, 0.0, 1.0);
}
</script>
<script id="vec2FragShader" type="text/something-not-javascript">
void main() {
precision mediump float;
vec2 i = vec2(2.0, 0.0), j = (i.x > 1.0) ? vec2(0.0, 1.0) : vec2(0.0, 0.0);
gl_FragColor = vec4(j, 0.0, 1.0);
}
</script>
<script id="vec3FragShader" type="text/something-not-javascript">
void main() {
precision mediump float;
vec3 i = vec3(0.0, 2.0, 0.0), j = (i.y > 1.0) ? vec3(0.0, 1.0, 0.0) : vec3(0.0, 0.0, 0.0);
gl_FragColor = vec4(j, 1.0);
}
</script>
<script id="vec4FragShader" type="text/something-not-javascript">
void main() {
precision mediump float;
vec4 i = vec4(0.0, 0.0, 2.0, 0.0), j = (i.z > 1.0) ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(0.0, 0.0, 0.0, 1.0);
gl_FragColor = j;
}
</script>
<script id="boolFragShader" type="text/something-not-javascript">
void main() {
bool i = true, j = i ? true : false;
gl_FragColor = vec4(0.0, j, 0.0, 1.0);
}
</script>
<script id="bvec2FragShader" type="text/something-not-javascript">
void main() {
bvec2 i = bvec2(true, false), j = i.x ? bvec2(false, true) : bvec2(false, false);
gl_FragColor = vec4(j, 0.0, 1.0);
}
</script>
<script id="bvec3FragShader" type="text/something-not-javascript">
void main() {
bvec3 i = bvec3(false, true, false), j = i.y ? bvec3(false, true, false) : bvec3(false, false, false);
gl_FragColor = vec4(j, 1.0);
}
</script>
<script id="bvec4FragShader" type="text/something-not-javascript">
void main() {
bvec4 i = bvec4(false, false, true, true), j = i.z ? bvec4(false, true, false, true) : bvec4(false, false, false, true);
gl_FragColor = vec4(j);
}
</script>
<script>
"use strict";
description("This test verifies initializers with ternary operators correctly initialize all variables.");
// Test fragment shaders are of the form
// void main() {
// {type} i = {initializer}, j = {ternary test using i that succeeds} ? : {green} : {black};
// gl_FragColor = vec4(...); // Emit green so that test will pass
// }
// The fragment shader must compile and link with the default vertex shader. J must be able to use the values of I as well as have its own
// values properly initialized.
var tests = [
{ fShaderId: 'intFragShader', passMsg: 'Ternary operator in integer initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'ivec2FragShader', passMsg: 'Ternary operator in ivec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'ivec3FragShader', passMsg: 'Ternary operator in ivec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'ivec4FragShader', passMsg: 'Ternary operator in ivec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'floatFragShader', passMsg: 'Ternary operator in float initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'vec2FragShader', passMsg: 'Ternary operator in vec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'vec3FragShader', passMsg: 'Ternary operator in vec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'vec4FragShader', passMsg: 'Ternary operator in vec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'boolFragShader', passMsg: 'Ternary operator in bool initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'bvec2FragShader', passMsg: 'Ternary operator in bvec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'bvec3FragShader', passMsg: 'Ternary operator in bvec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'bvec4FragShader', passMsg: 'Ternary operator in bvec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
];
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../resources/webgl-test-utils.js"></script>
<script src="../../resources/glsl-conformance-test.js"></script>
<title></title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="intFragShader" type="text/something-not-javascript">
void main() {
int i = 2, j = (i > 1) ? 1 : 0;
gl_FragColor = vec4(0.0, j, 0.0, 1.0);
}
</script>
<script id="ivec2FragShader" type="text/something-not-javascript">
void main() {
ivec2 i = ivec2(2, 0), j = (i.x > 1) ? ivec2(0, 1) : ivec2(0, 0);
gl_FragColor = vec4(j, 0.0, 1.0);
}
</script>
<script id="ivec3FragShader" type="text/something-not-javascript">
void main() {
ivec3 i = ivec3(0, 2, 0), j = (i.y > 1) ? ivec3(0, 1, 0) : ivec3(0, 0, 0);
gl_FragColor = vec4(j, 1.0);
}
</script>
<script id="ivec4FragShader" type="text/something-not-javascript">
void main() {
ivec4 i = ivec4(0.0, 0.0, 2.0, 0.0), j = (i.z > 1) ? ivec4(0, 1, 0, 1) : ivec4(0, 0, 0, 1);
gl_FragColor = vec4(j);
}
</script>
<script id="floatFragShader" type="text/something-not-javascript">
void main() {
precision mediump float;
float i = 2.0, j = (i > 1.0) ? 1.0 : 0.0;
gl_FragColor = vec4(0.0, j, 0.0, 1.0);
}
</script>
<script id="vec2FragShader" type="text/something-not-javascript">
void main() {
precision mediump float;
vec2 i = vec2(2.0, 0.0), j = (i.x > 1.0) ? vec2(0.0, 1.0) : vec2(0.0, 0.0);
gl_FragColor = vec4(j, 0.0, 1.0);
}
</script>
<script id="vec3FragShader" type="text/something-not-javascript">
void main() {
precision mediump float;
vec3 i = vec3(0.0, 2.0, 0.0), j = (i.y > 1.0) ? vec3(0.0, 1.0, 0.0) : vec3(0.0, 0.0, 0.0);
gl_FragColor = vec4(j, 1.0);
}
</script>
<script id="vec4FragShader" type="text/something-not-javascript">
void main() {
precision mediump float;
vec4 i = vec4(0.0, 0.0, 2.0, 0.0), j = (i.z > 1.0) ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(0.0, 0.0, 0.0, 1.0);
gl_FragColor = j;
}
</script>
<script id="boolFragShader" type="text/something-not-javascript">
void main() {
bool i = true, j = i ? true : false;
gl_FragColor = vec4(0.0, j, 0.0, 1.0);
}
</script>
<script id="bvec2FragShader" type="text/something-not-javascript">
void main() {
bvec2 i = bvec2(true, false), j = i.x ? bvec2(false, true) : bvec2(false, false);
gl_FragColor = vec4(j, 0.0, 1.0);
}
</script>
<script id="bvec3FragShader" type="text/something-not-javascript">
void main() {
bvec3 i = bvec3(false, true, false), j = i.y ? bvec3(false, true, false) : bvec3(false, false, false);
gl_FragColor = vec4(j, 1.0);
}
</script>
<script id="bvec4FragShader" type="text/something-not-javascript">
void main() {
bvec4 i = bvec4(false, false, true, true), j = i.z ? bvec4(false, true, false, true) : bvec4(false, false, false, true);
gl_FragColor = vec4(j);
}
</script>
<script>
"use strict";
description("This test verifies initializers with ternary operators correctly initialize all variables.");
// Test fragment shaders are of the form
// void main() {
// {type} i = {initializer}, j = {ternary test using i that succeeds} ? : {green} : {black};
// gl_FragColor = vec4(...); // Emit green so that test will pass
// }
// The fragment shader must compile and link with the default vertex shader. J must be able to use the values of I as well as have its own
// values properly initialized.
var tests = [
{ fShaderId: 'intFragShader', passMsg: 'Ternary operator in integer initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'ivec2FragShader', passMsg: 'Ternary operator in ivec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'ivec3FragShader', passMsg: 'Ternary operator in ivec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'ivec4FragShader', passMsg: 'Ternary operator in ivec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'floatFragShader', passMsg: 'Ternary operator in float initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'vec2FragShader', passMsg: 'Ternary operator in vec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'vec3FragShader', passMsg: 'Ternary operator in vec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'vec4FragShader', passMsg: 'Ternary operator in vec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'boolFragShader', passMsg: 'Ternary operator in bool initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'bvec2FragShader', passMsg: 'Ternary operator in bvec2 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'bvec3FragShader', passMsg: 'Ternary operator in bvec3 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
{ fShaderId: 'bvec4FragShader', passMsg: 'Ternary operator in bvec4 initalization', fShaderSuccess: true, linkSuccess: true, render: true },
];
GLSLConformanceTester.runTests(tests);
var successfullyParsed = true;
</script>
</body>
</html>

View file

@ -107,7 +107,7 @@ function runTest() {
var program = wtu.setupProgram(
gl, ['vshader2d' + ss, 'fshader2d'], ['vPosition', 'texCoord0'], [0, 1]);
wtu.setupUnitQuad(gl, 0, 1);
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texParameteri(
@ -129,7 +129,7 @@ function runTest() {
ctx.fillRect(0, 0, size, size);
ctx.fillStyle = "rgb(" + color.color[0] + "," + color.color[1] + "," + color.color[2] + ")";
ctx.fillRect(size / 2, 0, size / 2, size / 2);
gl.texImage2D(gl.TEXTURE_2D, ii, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c);
}

View file

@ -44,14 +44,14 @@
<script id="vshader" type="x-shader/x-vertex">
// Inputs
attribute vec4 aPosInfo;
// Outputs
varying vec2 vTargetPixelCoord;
void main()
{
{
vTargetPixelCoord = aPosInfo.zw;
gl_PointSize = 1.0;
gl_Position = vec4(aPosInfo.xy, 0.0, 1.0);
}
@ -61,20 +61,20 @@
precision mediump float;
// Inputs
varying vec2 vTargetPixelCoord;
varying vec2 vTargetPixelCoord;
// Colors used to signal correctness
// Colors used to signal correctness
const vec4 red = vec4(1.0, 0.0, 0.0, 1.0);
const vec4 green = vec4(0.0, 1.0, 0.0, 1.0);
void main()
{
// Check pixel index
bool pixelIxValid = (floor(gl_FragCoord.xy) == vTargetPixelCoord);
// Check fractional part of coordinates
bool fracCoordValid = all(lessThan(abs(fract(gl_FragCoord.xy) - vec2(0.5)), vec2(0.0001)));
gl_FragColor = (pixelIxValid && fracCoordValid) ? green : red;
}
</script>
@ -88,33 +88,33 @@
precision mediump float;
// Inputs
varying vec2 vTargetPixelCoord;
varying vec2 vTargetPixelCoord;
const vec2 pixSize = vec2(2.0/32.0, 2.0/32.0);
void main()
{
// Coordinates within a framebuffer pixel [0, 1>
vec2 inPixelCoord = fract(vTargetPixelCoord / pixSize);
// Create different color dependent on the position inside the framebuffer pixel
float r = (inPixelCoord.x < 0.4) ? 0.2 : (inPixelCoord.x > 0.6) ? 0.8 : 0.5;
float g = (inPixelCoord.y < 0.4) ? 0.2 : (inPixelCoord.y > 0.6) ? 0.8 : 0.5;
float r = (inPixelCoord.x < 0.4) ? 0.2 : (inPixelCoord.x > 0.6) ? 0.8 : 0.5;
float g = (inPixelCoord.y < 0.4) ? 0.2 : (inPixelCoord.y > 0.6) ? 0.8 : 0.5;
gl_FragColor = vec4(r, g, 0.0, 1.0);
}
</script>
<script>
"use strict";
// Test if gl_FragCoord.xy values are always of the form :
// (first framebuffer pixel index + 0.5, second framebuffer pixel index + 0.5)
// (if no multisampling)
// This is done by rendering a set of points which targets either the center of the
// This is done by rendering a set of points which targets either the center of the
// output pixel or the center of one of the quadrants
// Constants
var floatsPerAttribute = 4;
@ -125,48 +125,48 @@
var vxBuffer;
// Set data for one attribute (framebuffer.xy, pixel_index.xy)
function setPixelData(data, dIx, xx, yy, xSize, ySize, xOffset, yOffset)
function setPixelData(data, dIx, xx, yy, xSize, ySize, xOffset, yOffset)
{
// Frame buffer first coordinate [-1, 1]
data[dIx++] = (xx + 0.5) * xSize + xOffset - 1;
data[dIx++] = (xx + 0.5) * xSize + xOffset - 1;
// Frame buffer second coordinate [-1, 1]
data[dIx++] = (yy + 0.5) * ySize + yOffset - 1;
// Frame buffer pixel first index
data[dIx++] = xx;
data[dIx++] = xx;
// Frame buffer pixel second index
data[dIx++] = yy;
data[dIx++] = yy;
return dIx;
return dIx;
}
// Create attribute data
function createAttributeData(xOffset, yOffset)
function createAttributeData(xOffset, yOffset)
{
// Retrieve realised dimensions of viewport
var widthPx = gl.drawingBufferWidth;
var heightPx = gl.drawingBufferHeight;
var pixelCount = widthPx * heightPx;
var pixelCount = widthPx * heightPx;
// Pixel size in framebuffer coordinates
var pWidth = 2 / widthPx;
var pHeight = 2 / heightPx;
var pHeight = 2 / heightPx;
var data = new Float32Array(pixelCount * floatsPerAttribute);
var dIx = 0;
for (var yy = 0; yy < heightPx; ++yy)
for (var xx = 0; xx < widthPx; ++xx)
for (var yy = 0; yy < heightPx; ++yy)
for (var xx = 0; xx < widthPx; ++xx)
dIx = setPixelData(data, dIx, xx, yy, pWidth, pHeight, xOffset * pWidth, yOffset * pHeight);
if (dIx !== data.length)
wtu.error("gl-fragcoord-xy-values.html, createAttributeData(), index not correct at end");
return data;
return data;
}
// Initialize test
function init()
// Initialize test
function init()
{
description("tests gl_FragCoord.xy values");
@ -174,13 +174,13 @@
gl = wtu.create3DContext("canvas", { antialias: false });
program = wtu.setupProgram(gl, ["vshader", "fshader"], ["aPosInfo"]);
vxBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vxBuffer);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, floatsPerAttribute, gl.FLOAT, false, 0, 0);
}
// Render data
// Render data
function render(xOffset, yOffset, passMsg)
{
// Set attribute data
@ -194,7 +194,7 @@
wtu.checkCanvas(gl, green, passMsg);
}
// Run tests
// Run tests
init();
render( 0, 0, "green : sampling at center of output pixel is correct");
render( 0.25, 0.25, "green : sampling in top right quadrant of output pixel is correct");

View file

@ -91,9 +91,9 @@
];
var msg = "should be " + color;
wtu.checkCanvasRect(
gl,
xx + quarterStep + halfStep * ii,
yy + quarterStep + halfStep * ii,
gl,
xx + quarterStep + halfStep * ii,
yy + quarterStep + halfStep * ii,
1, 1, color, msg, 4);
}
}

View file

@ -47,7 +47,10 @@ description("Tests calling WebGL APIs with wrong argument types");
var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
var shader = wtu.loadStandardVertexShader(context);
var shouldGenerateGLError = wtu.shouldGenerateGLError;
function mayThrow(expression) {
wtu.shouldThrowOrGenerateGLError(context, [context.NO_ERROR, context.INVALID_VALUE, context.INVALID_OPERATION, context.INVALID_ENUM], expression);
}
assertMsg(program != null, "Program Compiled");
assertMsg(shader != null, "Shader Compiled");
@ -57,29 +60,25 @@ assertMsg(loc != null, "getUniformLocation succeeded");
var testArguments = [
{ value: "foo",
throws: true },
throws: "yes" },
{ value: 0,
throws: true },
throws: "yes" },
{ value: null,
throws: false },
throws: "maybe" },
{ value: undefined,
throws: false }
throws: "maybe" }
];
var argument;
function shouldBeEmptyString(command) {
shouldBe(command, "''");
}
for (var i = 0; i < testArguments.length; ++i) {
var func, func2;
if (testArguments[i].throws) {
if (testArguments[i].throws == "yes") {
func = shouldThrow;
func2 = shouldThrow;
} else {
func = shouldBeUndefined;
func2 = shouldBeNull;
func = mayThrow;
func2 = shouldBeUndefined;
}
argument = testArguments[i].value;
func("context.compileShader(argument)");
@ -88,28 +87,27 @@ for (var i = 0; i < testArguments.length; ++i) {
func("context.attachShader(argument, shader)");
func("context.detachShader(program, argument)");
func("context.detachShader(argument, shader)");
func("context.useProgram(argument)");
func("context.shaderSource(argument, 'foo')");
func("context.bindAttribLocation(argument, 0, 'foo')");
func("context.bindBuffer(context.ARRAY_BUFFER, argument)");
func("context.bindFramebuffer(context.FRAMEBUFFER, argument)");
func("context.bindRenderbuffer(context.RENDERBUFFER, argument)");
func("context.bindTexture(context.TEXTURE_2D, argument)");
func("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)");
func("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)");
func("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))");
func("context.uniform2iv(argument, new Int32Array([0, 0]))");
func("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))");
func2("context.getProgramInfoLog(argument)");
func2("context.getProgramParameter(argument, 0)");
func2("context.getShaderInfoLog(argument)");
func2("context.getShaderParameter(argument, 0)");
func2("context.getShaderSource(argument)");
func2("context.getUniform(argument, loc)");
func2("context.getUniform(program, argument)");
func2("context.getUniformLocation(argument, 'u_modelViewProjMatrix')");
func("context.getProgramInfoLog(argument)");
func("context.getProgramParameter(argument, 0)");
func("context.getShaderInfoLog(argument)");
func("context.getShaderParameter(argument, 0)");
func("context.getShaderSource(argument)");
func("context.getUniform(argument, loc)");
func("context.getUniform(program, argument)");
func("context.getUniformLocation(argument, 'u_modelViewProjMatrix')");
func2("context.useProgram(argument)");
func2("context.bindBuffer(context.ARRAY_BUFFER, argument)");
func2("context.bindFramebuffer(context.FRAMEBUFFER, argument)");
func2("context.bindRenderbuffer(context.RENDERBUFFER, argument)");
func2("context.bindTexture(context.TEXTURE_2D, argument)");
func2("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, argument)");
func2("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, argument, 0)");
func2("context.uniform2fv(argument, new Float32Array([0.0, 0.0]))");
func2("context.uniform2iv(argument, new Int32Array([0, 0]))");
func2("context.uniformMatrix2fv(argument, false, new Float32Array([0.0, 0.0, 0.0, 0.0]))");
}
var successfullyParsed = true;

View file

@ -53,9 +53,7 @@ var program = wtu.loadStandardProgram(context);
wtu.glErrorShouldBe(context, context.NO_ERROR);
debug("Testing getActiveAttrib");
// Synthetic OpenGL error
shouldBeNull("context.getActiveAttrib(null, 2)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getActiveAttrib(null, 2)");
// Error state should be clear by this point
wtu.glErrorShouldBe(context, context.NO_ERROR);
// Real OpenGL error
@ -65,9 +63,7 @@ wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.glErrorShouldBe(context, context.NO_ERROR);
debug("Testing getActiveUniform");
// Synthetic OpenGL error
shouldBeNull("context.getActiveUniform(null, 0)");
wtu.glErrorShouldBe(context, context.INVALID_VALUE);
wtu.shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getActiveUniform(null, 0)");
// Error state should be clear by this point
wtu.glErrorShouldBe(context, context.NO_ERROR);
// Real OpenGL error

View file

@ -48,19 +48,20 @@ var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
var shader = wtu.loadStandardVertexShader(context);
var shouldGenerateGLError = wtu.shouldGenerateGLError;
var shouldThrowOrGenerateGLError = wtu.shouldThrowOrGenerateGLError;
assertMsg(program != null, "Program Compiled");
assertMsg(shader != null, "Shader Compiled");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.compileShader(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
shouldThrow("context.bindBuffer(context.ARRAY_BUFFER, 0)");
shouldThrow("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
shouldThrow("context.bindRenderbuffer(context.RENDERBUFFER, 0)");
@ -75,13 +76,13 @@ shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(conte
shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, undefined)");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, null)");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, null, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, null)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, null)");
shouldThrowOrGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
debug("");
debug("check with bindings");

View file

@ -100,7 +100,7 @@ shouldBe("gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)");
shouldBeFalse("gl.isTexture(tex)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_2D)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, tex)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_2D, tex)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_2D)");
var texCubeMap = gl.createTexture();
@ -110,7 +110,7 @@ shouldBe("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)", "texCubeMap");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteTexture(texCubeMap)");
shouldBeFalse("gl.isTexture(texCubeMap)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCubeMap)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCubeMap)");
shouldBeNull("gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP)");
var t = gl.createTexture();
@ -118,7 +118,7 @@ shouldBeNonNull("t");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteTexture(t)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindTexture(gl.TEXTURE_2D, t)");
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)");
var t2 = gl.createTexture();
@ -152,7 +152,7 @@ shouldBe("gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHME
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)");
shouldBeFalse("gl.isRenderbuffer(rbo)");
shouldBeNull("gl.getParameter(gl.RENDERBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo)");
shouldBeNull("gl.getParameter(gl.RENDERBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindRenderbuffer(gl.RENDERBUFFER, rbo2)");
shouldBe("gl.getParameter(gl.RENDERBUFFER_BINDING)", "rbo2");
@ -337,7 +337,7 @@ shouldBe("gl.getParameter(gl.ARRAY_BUFFER_BINDING)", "buffer");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(buffer)");
shouldBeFalse("gl.isBuffer(buffer)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, buffer)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, buffer)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
var buffer2 = gl.createBuffer();
@ -348,7 +348,7 @@ shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, null)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(buffer2)");
shouldBeFalse("gl.isBuffer(buffer2)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, buffer2)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, buffer2)");
shouldBeNull("gl.getParameter(gl.ARRAY_BUFFER_BINDING)");
var bufferElement = gl.createBuffer();
@ -358,7 +358,7 @@ shouldBe("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)", "bufferElement");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(bufferElement)");
shouldBeFalse("gl.isBuffer(bufferElement)");
shouldBeNull("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferElement)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferElement)");
shouldBeNull("gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING)");
var b = gl.createBuffer();
@ -366,7 +366,7 @@ shouldBeNonNull("b");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bufferData(gl.ARRAY_BUFFER, 1, gl.STATIC_DRAW)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteBuffer(b)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindBuffer(gl.ARRAY_BUFFER, b)");
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.bufferData(gl.ARRAY_BUFFER, 1, gl.STATIC_DRAW)");
var b1 = gl.createBuffer();
@ -399,7 +399,7 @@ shouldBe("gl.getParameter(gl.FRAMEBUFFER_BINDING)", "fbo");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.deleteFramebuffer(fbo)");
shouldBeFalse("gl.isFramebuffer(fbo)");
shouldBeNull("gl.getParameter(gl.FRAMEBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo)");
shouldGenerateGLError(gl, [gl.NO_ERROR, gl.INVALID_OPERATION], "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo)");
shouldBeNull("gl.getParameter(gl.FRAMEBUFFER_BINDING)");
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.bindFramebuffer(gl.FRAMEBUFFER, fbo2)");
shouldBe("gl.getParameter(gl.FRAMEBUFFER_BINDING)", "fbo2");

View file

@ -51,6 +51,7 @@ gl.useProgram(program);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed");
debug("");

View file

@ -27,7 +27,6 @@ functions/deleteBufferBadArgs.html
functions/drawArrays.html
functions/drawArraysOutOfBounds.html
functions/drawElements.html
functions/drawElementsBadArgs.html
functions/isTests.html
--min-version 1.0.2 functions/isTestsBadArgs.html
functions/readPixels.html

View file

@ -22,7 +22,7 @@ Want to contribute?
1. Fork this repo
2. Run <code>gen_tests.rb</code>
3. Look into templates/ to see which functions lack tests (also see <a href="../raw/master/methods.txt">methods.txt</a> and <a href="http://dxr.mozilla.org/mozilla-central/source/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl">nsICanvasRenderingContextWebGL.idl</a>):
3. Look into templates/ to see which functions lack tests (also see <a href="../raw/master/methods.txt">methods.txt</a> and <a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/canvas/nsICanvasRenderingContextWebGL.idl">nsICanvasRenderingContextWebGL.idl</a>):
1. copy methodName.html to functions/methodName.html and write tests that test the results of valid inputs.
2. copy methodNameBadArgs.html to functions/methodNameBadArgs.html and write tests to assert that invalid inputs throw exceptions.
3. If your test causes a segfault, add the following to the top of the script tag: <code>Tests.autorun = false; Tests.message = "Caution: this may crash your browser";</code>

View file

@ -306,7 +306,6 @@ RGBA4 : 0x8056,
RGB5_A1 : 0x8057,
RGB565 : 0x8D62,
DEPTH_COMPONENT16 : 0x81A5,
STENCIL_INDEX : 0x1901,
STENCIL_INDEX8 : 0x8D48,
DEPTH_STENCIL : 0x84F9,
RENDERBUFFER_WIDTH : 0x8D42,

View file

@ -1,211 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<link rel="stylesheet" type="text/css" href="../unit.css" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script type="application/x-javascript" src="../unit.js"></script>
<script type="application/x-javascript" src="../util.js"></script>
<script type="application/x-javascript">
// Tests.autorun = false;
// Tests.message = "Caution: May crash your browser";
var verts = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
var normals = [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0];
var texcoords = [0.0,0.0, 1.0,0.0, 0.0,1.0];
var indices = [60000000,1,2]
Tests.startUnit = function () {
var canvas = document.getElementById('gl');
var gl = wrapGLContext(getGLContext(canvas));
var prog = new Shader(gl, 'vert', 'frag');
prog.use();
var sh = prog.shader.program;
var v = gl.getAttribLocation(sh, 'Vertex');
var n = gl.getAttribLocation(sh, 'Normal');
var t = gl.getAttribLocation(sh, 'Tex');
return [gl,prog,v,n,t];
}
Tests.setup = function(gl, prog, v,n,t) {
assert(0 == gl.getError());
return [gl, prog, v,n,t];
}
Tests.teardown = function(gl, prog, v,n,t) {
gl.disableVertexAttribArray(v);
gl.disableVertexAttribArray(n);
gl.disableVertexAttribArray(t);
}
Tests.endUnit = function(gl, prog, v,n,t) {
prog.destroy();
}
Tests.testDrawElementsVBO = function(gl, prog, v,n,t) {
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{elements:true, data:[0,1,2,2000, 40802, 5887992]});
assertFail(function(){vbo.draw(v);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOByte = function(gl, prog, v,n,t) {
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{elements:true, type:gl.UNSIGNED_BYTE, data:[0,1,2,2000, 40802, 5887992]});
assertFail(function(){vbo.draw(v);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOMulti = function(gl, prog, v,n,t) {
// creates VBOs for the quad arrays, binds them with
// vertexAttribPointer and calls drawElements
// The quad has 6 vertices
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{size:3, data:Quad.normals},
{size:2, data:Quad.texcoords},
{elements:true, data:[0,1,2,6,2000, 256]});
assertFail(function(){vbo.draw(v, n, t);});
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_SHORT, 2*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 3*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 6*2);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo.vbos[1]);
gl.vertexAttribPointer(n, 3, gl.FLOAT, false, 0, 0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 5*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1*2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_SHORT, 6*2);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testDrawElementsVBOMultiByte = function(gl, prog, v,n,t) {
// creates VBOs for the quad arrays, binds them with
// vertexAttribPointer and calls drawElements
// The quad has 6 vertices
var vbo = new VBO(gl,
{size:3, data:Quad.vertices},
{size:3, data:Quad.normals},
{size:2, data:Quad.texcoords},
{elements:true, type:gl.UNSIGNED_BYTE, data:[0,1,2,6,2000, 256]});
assertFail(function(){vbo.draw(v, n, t);});
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_BYTE, -1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, -1, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 4, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 2, gl.UNSIGNED_BYTE, 2);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 3);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 6);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo.vbos[1]);
gl.vertexAttribPointer(n, 3, gl.FLOAT, false, 0, 0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);
assertOk(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 5);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);});
assertOk(function(){gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_BYTE, 0);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 5, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 1);});
assertFail(function(){gl.drawElements(gl.TRIANGLES, 1, gl.UNSIGNED_BYTE, 6);});
vbo.destroy();
assert(gl.NO_ERROR == checkError(gl, "vbo.destroy"));
}
Tests.testSharedBuffers = function(gl, prog, v,n,t) {
var vbo = gl.createBuffer();
var vertsArr = new Uint16Array([0,1,3,3,4,5,6,7,8]);
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
assertFail(function(){gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vbo)});
gl.deleteBuffer(vbo);
}
</script>
<script id="vert" type="x-shader/x-vertex">
attribute vec3 Vertex;
attribute vec3 Normal;
attribute vec2 Tex;
varying vec4 texCoord0;
void main()
{
gl_Position = vec4(Vertex * Normal, 1.0);
texCoord0 = vec4(Tex,0.0,0.0) + gl_Position;
}
</script>
<script id="frag" type="x-shader/x-fragment">
precision mediump float;
varying vec4 texCoord0;
void main()
{
vec4 c = texCoord0;
gl_FragColor = c;
}
</script>
<style>canvas{ position:absolute; }</style>
</head><body>
<canvas id="gl" width="1" height="1"></canvas>
</body></html>

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://www.opengl.org/img/opengl_logo.jpg";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/opengl_logo.jpg";
var localImgUrl = "../../resources/opengl_logo.jpg";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://mashable.com/wp-content/uploads/2008/08/thunderbird-logo-64x64.png";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/thunderbird-logo-64x64.png";
var localImgUrl = "../../resources/thunderbird-logo-64x64.png";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -36,7 +36,7 @@
<script type="application/x-javascript" src="../../resources/webgl-test-utils.js"></script>
<script type="application/x-javascript">
var wtu = WebGLTestUtils;
var defaultImgUrl = "http://mashable.com/wp-content/uploads/2008/08/thunderbird-logo-64x64.png";
var defaultImgUrl = "https://get.webgl.org/conformance-resources/thunderbird-logo-64x64.png";
var localImgUrl = "../../resources/thunderbird-logo-64x64.png";
Tests.autoinit = false; // Prevents the test from running until the image is loaded

View file

@ -93,8 +93,8 @@ Tests.testVertexAttribPointerVBO = function(gl, prog, v,n,t) {
assertFail("bad index (big positive)",
function(){gl.vertexAttribPointer(8693948, 3, gl.FLOAT, false, 0, 0);});
gl.bindBuffer(gl.ARRAY_BUFFER, null);
assertFail("binding to null buffer",
function(){gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);});
assertFail("binding to null buffer with offset!=0",
function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 16);});
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, null);

View file

@ -48,80 +48,80 @@ OpenGLESTestRunner.run({
"tests": [
{
"referenceProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "abs_float_frag_xvary_ref.frag"
},
"model": null,
},
"model": null,
"testProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "abs_float_frag_xvary.frag"
},
"name": "abs_float_frag_xvary.test.html",
},
"name": "abs_float_frag_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "abs_vec2_frag_xvary_ref.frag"
},
"model": null,
},
"model": null,
"testProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "abs_vec2_frag_xvary.frag"
},
"name": "abs_vec2_frag_xvary.test.html",
},
"name": "abs_vec2_frag_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "abs_vec3_frag_xvary_ref.frag"
},
"model": null,
},
"model": null,
"testProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "abs_vec3_frag_xvary.frag"
},
"name": "abs_vec3_frag_xvary.test.html",
},
"name": "abs_vec3_frag_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "abs_float_vert_xvary_ref.vert",
"vertexShader": "abs_float_vert_xvary_ref.vert",
"fragmentShader": "../default/default.frag"
},
"model": "grid",
},
"model": "grid",
"testProgram": {
"vertexShader": "abs_float_vert_xvary.vert",
"vertexShader": "abs_float_vert_xvary.vert",
"fragmentShader": "../default/default.frag"
},
"name": "abs_float_vert_xvary.test.html",
},
"name": "abs_float_vert_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "abs_vec2_vert_xvary_ref.vert",
"vertexShader": "abs_vec2_vert_xvary_ref.vert",
"fragmentShader": "../default/default.frag"
},
"model": "grid",
},
"model": "grid",
"testProgram": {
"vertexShader": "abs_vec2_vert_xvary.vert",
"vertexShader": "abs_vec2_vert_xvary.vert",
"fragmentShader": "../default/default.frag"
},
"name": "abs_vec2_vert_xvary.test.html",
},
"name": "abs_vec2_vert_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "abs_vec3_vert_xvary_ref.vert",
"vertexShader": "abs_vec3_vert_xvary_ref.vert",
"fragmentShader": "../default/default.frag"
},
"model": "grid",
},
"model": "grid",
"testProgram": {
"vertexShader": "abs_vec3_vert_xvary.vert",
"vertexShader": "abs_vec3_vert_xvary.vert",
"fragmentShader": "../default/default.frag"
},
"name": "abs_vec3_vert_xvary.test.html",
},
"name": "abs_vec3_vert_xvary.test.html",
"pattern": "compare"
}
]

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(abs(c), 0.0, 0.0, 1.0);
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(abs(c), 0.0, 0.0, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
float c = 2.0 * (color.r - 0.5);
if(c < 0.0) c *= -1.0;
float c = 2.0 * (color.r - 0.5);
if(c < 0.0) c *= -1.0;
gl_FragColor = vec4(c, 0.0, 0.0, 1.0);
gl_FragColor = vec4(c, 0.0, 0.0, 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(abs(c), 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(abs(c), 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,9 +30,9 @@ varying vec4 color;
void main (void)
{
float c = 2.0 * (gtf_Color.r - 0.5);
if(c < 0.0) c *= -1.0;
float c = 2.0 * (gtf_Color.r - 0.5);
if(c < 0.0) c *= -1.0;
color = vec4(c, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(c, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(abs(c), 0.0, 1.0);
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(abs(c), 0.0, 1.0);
}

View file

@ -30,9 +30,9 @@ varying vec4 color;
void main (void)
{
vec2 c = 2.0 * (color.rg - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
vec2 c = 2.0 * (color.rg - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
gl_FragColor = vec4(c, 0.0, 1.0);
gl_FragColor = vec4(c, 0.0, 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(abs(c), 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(abs(c), 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,10 +30,10 @@ varying vec4 color;
void main (void)
{
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
color = vec4(c, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(c, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(abs(c), 1.0);
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(abs(c), 1.0);
}

View file

@ -30,11 +30,11 @@ varying vec4 color;
void main (void)
{
vec3 c = 2.0 * (color.rgb - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
if((c[2] < 0.0)) c[2] *= -1.0;
vec3 c = 2.0 * (color.rgb - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
if((c[2] < 0.0)) c[2] *= -1.0;
gl_FragColor = vec4(c, 1.0);
gl_FragColor = vec4(c, 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(abs(c), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(abs(c), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,11 +30,11 @@ varying vec4 color;
void main (void)
{
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
if((c[2] < 0.0)) c[2] *= -1.0;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
if((c[0] < 0.0)) c[0] *= -1.0;
if((c[1] < 0.0)) c[1] *= -1.0;
if((c[2] < 0.0)) c[2] *= -1.0;
color = vec4(c, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(c, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -48,80 +48,80 @@ OpenGLESTestRunner.run({
"tests": [
{
"referenceProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "acos_float_frag_xvary_ref.frag"
},
"model": null,
},
"model": null,
"testProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "acos_float_frag_xvary.frag"
},
"name": "acos_float_frag_xvary.test.html",
},
"name": "acos_float_frag_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "acos_vec2_frag_xvary_ref.frag"
},
"model": null,
},
"model": null,
"testProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "acos_vec2_frag_xvary.frag"
},
"name": "acos_vec2_frag_xvary.test.html",
},
"name": "acos_vec2_frag_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "acos_vec3_frag_xvary_ref.frag"
},
"model": null,
},
"model": null,
"testProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "acos_vec3_frag_xvary.frag"
},
"name": "acos_vec3_frag_xvary.test.html",
},
"name": "acos_vec3_frag_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "acos_float_vert_xvary_ref.vert",
"vertexShader": "acos_float_vert_xvary_ref.vert",
"fragmentShader": "../default/default.frag"
},
"model": "grid",
},
"model": "grid",
"testProgram": {
"vertexShader": "acos_float_vert_xvary.vert",
"vertexShader": "acos_float_vert_xvary.vert",
"fragmentShader": "../default/default.frag"
},
"name": "acos_float_vert_xvary.test.html",
},
"name": "acos_float_vert_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "acos_vec2_vert_xvary_ref.vert",
"vertexShader": "acos_vec2_vert_xvary_ref.vert",
"fragmentShader": "../default/default.frag"
},
"model": "grid",
},
"model": "grid",
"testProgram": {
"vertexShader": "acos_vec2_vert_xvary.vert",
"vertexShader": "acos_vec2_vert_xvary.vert",
"fragmentShader": "../default/default.frag"
},
"name": "acos_vec2_vert_xvary.test.html",
},
"name": "acos_vec2_vert_xvary.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "acos_vec3_vert_xvary_ref.vert",
"vertexShader": "acos_vec3_vert_xvary_ref.vert",
"fragmentShader": "../default/default.frag"
},
"model": "grid",
},
"model": "grid",
"testProgram": {
"vertexShader": "acos_vec3_vert_xvary.vert",
"vertexShader": "acos_vec3_vert_xvary.vert",
"fragmentShader": "../default/default.frag"
},
"name": "acos_vec3_vert_xvary.test.html",
},
"name": "acos_vec3_vert_xvary.test.html",
"pattern": "compare"
}
]

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 0.0, 0.0, 1.0);
}

View file

@ -39,73 +39,73 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
float arrVal = (c + 1.0) * 8.0;
int arr0 = int(floor(arrVal));
float weight = arrVal - floor(arrVal);
float asin_c = 0.0;
if (arr0 == 0)
asin_c = lerp(asinValues[0], asinValues[1], weight);
else if (arr0 == 1)
asin_c = lerp(asinValues[1], asinValues[2], weight);
else if (arr0 == 2)
asin_c = lerp(asinValues[2], asinValues[3], weight);
else if (arr0 == 3)
asin_c = lerp(asinValues[3], asinValues[4], weight);
else if (arr0 == 4)
asin_c = lerp(asinValues[4], asinValues[5], weight);
else if (arr0 == 5)
asin_c = lerp(asinValues[5], asinValues[6], weight);
else if (arr0 == 6)
asin_c = lerp(asinValues[6], asinValues[7], weight);
else if (arr0 == 7)
asin_c = lerp(asinValues[7], asinValues[8], weight);
else if (arr0 == 8)
asin_c = lerp(asinValues[8], asinValues[9], weight);
else if (arr0 == 9)
asin_c = lerp(asinValues[9], asinValues[10], weight);
else if (arr0 == 10)
asin_c = lerp(asinValues[10], asinValues[11], weight);
else if (arr0 == 11)
asin_c = lerp(asinValues[11], asinValues[12], weight);
else if (arr0 == 12)
asin_c = lerp(asinValues[12], asinValues[13], weight);
else if (arr0 == 13)
asin_c = lerp(asinValues[13], asinValues[14], weight);
else if (arr0 == 14)
asin_c = lerp(asinValues[14], asinValues[15], weight);
else if (arr0 == 15)
asin_c = lerp(asinValues[15], asinValues[16], weight);
else if (arr0 == 16)
asin_c = asinValues[16];
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (color.r - 0.5);
float arrVal = (c + 1.0) * 8.0;
int arr0 = int(floor(arrVal));
float weight = arrVal - floor(arrVal);
float asin_c = 0.0;
if (arr0 == 0)
asin_c = lerp(asinValues[0], asinValues[1], weight);
else if (arr0 == 1)
asin_c = lerp(asinValues[1], asinValues[2], weight);
else if (arr0 == 2)
asin_c = lerp(asinValues[2], asinValues[3], weight);
else if (arr0 == 3)
asin_c = lerp(asinValues[3], asinValues[4], weight);
else if (arr0 == 4)
asin_c = lerp(asinValues[4], asinValues[5], weight);
else if (arr0 == 5)
asin_c = lerp(asinValues[5], asinValues[6], weight);
else if (arr0 == 6)
asin_c = lerp(asinValues[6], asinValues[7], weight);
else if (arr0 == 7)
asin_c = lerp(asinValues[7], asinValues[8], weight);
else if (arr0 == 8)
asin_c = lerp(asinValues[8], asinValues[9], weight);
else if (arr0 == 9)
asin_c = lerp(asinValues[9], asinValues[10], weight);
else if (arr0 == 10)
asin_c = lerp(asinValues[10], asinValues[11], weight);
else if (arr0 == 11)
asin_c = lerp(asinValues[11], asinValues[12], weight);
else if (arr0 == 12)
asin_c = lerp(asinValues[12], asinValues[13], weight);
else if (arr0 == 13)
asin_c = lerp(asinValues[13], asinValues[14], weight);
else if (arr0 == 14)
asin_c = lerp(asinValues[14], asinValues[15], weight);
else if (arr0 == 15)
asin_c = lerp(asinValues[15], asinValues[16], weight);
else if (arr0 == 16)
asin_c = asinValues[16];
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 0.0, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(acos(c) / M_PI, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
color = vec4(acos(c) / M_PI, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,29 +30,29 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
const float M_PI = 3.14159265358979323846;
float c = 2.0 * (gtf_Color.r - 0.5);
float acos_c = 0.0;
float scale = 1.0;
float sign = 1.0;
float acos_c = 0.0;
float scale = 1.0;
float sign = 1.0;
// pow can't handle negative numbers so take advantage of symmetry
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c < 0.0)
{
sign = -1.0;
c *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c += scale * pow(c, float(i)) / float(i);
scale *= float(i) / float(i + 1);
}
acos_c = M_PI / 2.0 - sign * acos_c;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c += scale * pow(c, float(i)) / float(i);
scale *= float(i) / float(i + 1);
}
acos_c = M_PI / 2.0 - sign * acos_c;
color = vec4(acos_c / M_PI, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(acos_c / M_PI, 0.0, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 0.0, 1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 0.0, 1.0);
}

View file

@ -39,109 +39,109 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
vec2 arrVal = (c + vec2(1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
vec2 weight = arrVal - floor(arrVal);
vec2 asin_c = vec2(0.0);
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (color.rg - 0.5);
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 1.0);
vec2 arrVal = (c + vec2(1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
vec2 weight = arrVal - floor(arrVal);
vec2 asin_c = vec2(0.0);
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 0.0, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(acos(c) / M_PI, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
color = vec4(acos(c) / M_PI, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,44 +30,44 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
vec2 acos_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
const float M_PI = 3.14159265358979323846;
vec2 c = 2.0 * (gtf_Color.rg - 0.5);
vec2 acos_c = vec2(0.0);
vec2 scale = vec2(1.0);
vec2 sign = vec2(1.0);
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
acos_c.r = M_PI / 2.0 - sign.r * acos_c.r;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
acos_c.r = M_PI / 2.0 - sign.r * acos_c.r;
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
acos_c.g = M_PI / 2.0 - sign.g * acos_c.g;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
acos_c.g = M_PI / 2.0 - sign.g * acos_c.g;
color = vec4(acos_c / M_PI, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(acos_c / M_PI, 0.0, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 1.0);
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
gl_FragColor = vec4(acos(c) / M_PI, 1.0);
}

View file

@ -39,145 +39,145 @@ varying vec4 color;
float lerp(float a, float b, float s)
{
return a + (b - a) * s;
return a + (b - a) * s;
}
void main (void)
{
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
vec3 arrVal = (c + vec3(1.0, 1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
int arr0z = int(floor(arrVal.z));
vec3 weight = arrVal - floor(arrVal);
vec3 asin_c = vec3(0.0);
float asinValues[17];
asinValues[0] = -1.5708;
asinValues[1] = -1.06544;
asinValues[2] = -0.848062;
asinValues[3] = -0.675132;
asinValues[4] = -0.523599;
asinValues[5] = -0.384397;
asinValues[6] = -0.25268;
asinValues[7] = -0.125328;
asinValues[8] = 0.0;
asinValues[9] = 0.125328;
asinValues[10] = 0.25268;
asinValues[11] = 0.384397;
asinValues[12] = 0.523599;
asinValues[13] = 0.675132;
asinValues[14] = 0.848062;
asinValues[15] = 1.06544;
asinValues[16] = 1.5708;
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
if (arr0z == 0)
asin_c.z = lerp(asinValues[0], asinValues[1], weight.z);
else if (arr0z == 1)
asin_c.z = lerp(asinValues[1], asinValues[2], weight.z);
else if (arr0z == 2)
asin_c.z = lerp(asinValues[2], asinValues[3], weight.z);
else if (arr0z == 3)
asin_c.z = lerp(asinValues[3], asinValues[4], weight.z);
else if (arr0z == 4)
asin_c.z = lerp(asinValues[4], asinValues[5], weight.z);
else if (arr0z == 5)
asin_c.z = lerp(asinValues[5], asinValues[6], weight.z);
else if (arr0z == 6)
asin_c.z = lerp(asinValues[6], asinValues[7], weight.z);
else if (arr0z == 7)
asin_c.z = lerp(asinValues[7], asinValues[8], weight.z);
else if (arr0z == 8)
asin_c.z = lerp(asinValues[8], asinValues[9], weight.z);
else if (arr0z == 9)
asin_c.z = lerp(asinValues[9], asinValues[10], weight.z);
else if (arr0z == 10)
asin_c.z = lerp(asinValues[10], asinValues[11], weight.z);
else if (arr0z == 11)
asin_c.z = lerp(asinValues[11], asinValues[12], weight.z);
else if (arr0z == 12)
asin_c.z = lerp(asinValues[12], asinValues[13], weight.z);
else if (arr0z == 13)
asin_c.z = lerp(asinValues[13], asinValues[14], weight.z);
else if (arr0z == 14)
asin_c.z = lerp(asinValues[14], asinValues[15], weight.z);
else if (arr0z == 15)
asin_c.z = lerp(asinValues[15], asinValues[16], weight.z);
else if (arr0z == 16)
asin_c.z = asinValues[16];
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (color.rgb - 0.5);
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 1.0);
vec3 arrVal = (c + vec3(1.0, 1.0, 1.0)) * 8.0;
int arr0x = int(floor(arrVal.x));
int arr0y = int(floor(arrVal.y));
int arr0z = int(floor(arrVal.z));
vec3 weight = arrVal - floor(arrVal);
vec3 asin_c = vec3(0.0);
if (arr0x == 0)
asin_c.x = lerp(asinValues[0], asinValues[1], weight.x);
else if (arr0x == 1)
asin_c.x = lerp(asinValues[1], asinValues[2], weight.x);
else if (arr0x == 2)
asin_c.x = lerp(asinValues[2], asinValues[3], weight.x);
else if (arr0x == 3)
asin_c.x = lerp(asinValues[3], asinValues[4], weight.x);
else if (arr0x == 4)
asin_c.x = lerp(asinValues[4], asinValues[5], weight.x);
else if (arr0x == 5)
asin_c.x = lerp(asinValues[5], asinValues[6], weight.x);
else if (arr0x == 6)
asin_c.x = lerp(asinValues[6], asinValues[7], weight.x);
else if (arr0x == 7)
asin_c.x = lerp(asinValues[7], asinValues[8], weight.x);
else if (arr0x == 8)
asin_c.x = lerp(asinValues[8], asinValues[9], weight.x);
else if (arr0x == 9)
asin_c.x = lerp(asinValues[9], asinValues[10], weight.x);
else if (arr0x == 10)
asin_c.x = lerp(asinValues[10], asinValues[11], weight.x);
else if (arr0x == 11)
asin_c.x = lerp(asinValues[11], asinValues[12], weight.x);
else if (arr0x == 12)
asin_c.x = lerp(asinValues[12], asinValues[13], weight.x);
else if (arr0x == 13)
asin_c.x = lerp(asinValues[13], asinValues[14], weight.x);
else if (arr0x == 14)
asin_c.x = lerp(asinValues[14], asinValues[15], weight.x);
else if (arr0x == 15)
asin_c.x = lerp(asinValues[15], asinValues[16], weight.x);
else if (arr0x == 16)
asin_c.x = asinValues[16];
if (arr0y == 0)
asin_c.y = lerp(asinValues[0], asinValues[1], weight.y);
else if (arr0y == 1)
asin_c.y = lerp(asinValues[1], asinValues[2], weight.y);
else if (arr0y == 2)
asin_c.y = lerp(asinValues[2], asinValues[3], weight.y);
else if (arr0y == 3)
asin_c.y = lerp(asinValues[3], asinValues[4], weight.y);
else if (arr0y == 4)
asin_c.y = lerp(asinValues[4], asinValues[5], weight.y);
else if (arr0y == 5)
asin_c.y = lerp(asinValues[5], asinValues[6], weight.y);
else if (arr0y == 6)
asin_c.y = lerp(asinValues[6], asinValues[7], weight.y);
else if (arr0y == 7)
asin_c.y = lerp(asinValues[7], asinValues[8], weight.y);
else if (arr0y == 8)
asin_c.y = lerp(asinValues[8], asinValues[9], weight.y);
else if (arr0y == 9)
asin_c.y = lerp(asinValues[9], asinValues[10], weight.y);
else if (arr0y == 10)
asin_c.y = lerp(asinValues[10], asinValues[11], weight.y);
else if (arr0y == 11)
asin_c.y = lerp(asinValues[11], asinValues[12], weight.y);
else if (arr0y == 12)
asin_c.y = lerp(asinValues[12], asinValues[13], weight.y);
else if (arr0y == 13)
asin_c.y = lerp(asinValues[13], asinValues[14], weight.y);
else if (arr0y == 14)
asin_c.y = lerp(asinValues[14], asinValues[15], weight.y);
else if (arr0y == 15)
asin_c.y = lerp(asinValues[15], asinValues[16], weight.y);
else if (arr0y == 16)
asin_c.y = asinValues[16];
if (arr0z == 0)
asin_c.z = lerp(asinValues[0], asinValues[1], weight.z);
else if (arr0z == 1)
asin_c.z = lerp(asinValues[1], asinValues[2], weight.z);
else if (arr0z == 2)
asin_c.z = lerp(asinValues[2], asinValues[3], weight.z);
else if (arr0z == 3)
asin_c.z = lerp(asinValues[3], asinValues[4], weight.z);
else if (arr0z == 4)
asin_c.z = lerp(asinValues[4], asinValues[5], weight.z);
else if (arr0z == 5)
asin_c.z = lerp(asinValues[5], asinValues[6], weight.z);
else if (arr0z == 6)
asin_c.z = lerp(asinValues[6], asinValues[7], weight.z);
else if (arr0z == 7)
asin_c.z = lerp(asinValues[7], asinValues[8], weight.z);
else if (arr0z == 8)
asin_c.z = lerp(asinValues[8], asinValues[9], weight.z);
else if (arr0z == 9)
asin_c.z = lerp(asinValues[9], asinValues[10], weight.z);
else if (arr0z == 10)
asin_c.z = lerp(asinValues[10], asinValues[11], weight.z);
else if (arr0z == 11)
asin_c.z = lerp(asinValues[11], asinValues[12], weight.z);
else if (arr0z == 12)
asin_c.z = lerp(asinValues[12], asinValues[13], weight.z);
else if (arr0z == 13)
asin_c.z = lerp(asinValues[13], asinValues[14], weight.z);
else if (arr0z == 14)
asin_c.z = lerp(asinValues[14], asinValues[15], weight.z);
else if (arr0z == 15)
asin_c.z = lerp(asinValues[15], asinValues[16], weight.z);
else if (arr0z == 16)
asin_c.z = asinValues[16];
// acos(x) = PI/2 - asin(x)
gl_FragColor = vec4(0.5 - asin_c / M_PI, 1.0);
}

View file

@ -30,8 +30,8 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(acos(c) / M_PI, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
color = vec4(acos(c) / M_PI, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,60 +30,60 @@ varying vec4 color;
void main (void)
{
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
vec3 acos_c = vec3(0.0);
vec3 scale = vec3(1.0);
vec3 sign = vec3(1.0);
const float M_PI = 3.14159265358979323846;
vec3 c = 2.0 * (gtf_Color.rgb - 0.5);
vec3 acos_c = vec3(0.0);
vec3 scale = vec3(1.0);
vec3 sign = vec3(1.0);
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.r < 0.0)
{
sign.r = -1.0;
c.r *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
acos_c.r = M_PI / 2.0 - sign.r * acos_c.r;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.r += scale.r * pow(c.r, float(i)) / float(i);
scale.r *= float(i) / float(i + 1);
}
acos_c.r = M_PI / 2.0 - sign.r * acos_c.r;
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.g < 0.0)
{
sign.g = -1.0;
c.g *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
acos_c.g = M_PI / 2.0 - sign.g * acos_c.g;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.g += scale.g * pow(c.g, float(i)) / float(i);
scale.g *= float(i) / float(i + 1);
}
acos_c.g = M_PI / 2.0 - sign.g * acos_c.g;
// pow can't handle negative numbers so take advantage of symmetry
if(c.b < 0.0)
{
sign.b = -1.0;
c.b *= -1.0;
}
// pow can't handle negative numbers so take advantage of symmetry
if(c.b < 0.0)
{
sign.b = -1.0;
c.b *= -1.0;
}
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.b += scale.b * pow(c.b, float(i)) / float(i);
scale.b *= float(i) / float(i + 1);
}
acos_c.b = M_PI / 2.0 - sign.b * acos_c.b;
// Taylors series expansion for acos
// 1000/2 iterations necessary to get the accuracy with this method
for(int i = 1; i < 1000; i += 2)
{
acos_c.b += scale.b * pow(c.b, float(i)) / float(i);
scale.b *= float(i) / float(i + 1);
}
acos_c.b = M_PI / 2.0 - sign.b * acos_c.b;
color = vec4(acos_c / M_PI, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
color = vec4(acos_c / M_PI, 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -48,54 +48,54 @@ OpenGLESTestRunner.run({
"tests": [
{
"referenceProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "all_bvec2_frag_ref.frag"
},
"model": null,
},
"model": null,
"testProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "all_bvec2_frag.frag"
},
"name": "all_bvec2_frag.test.html",
},
"name": "all_bvec2_frag.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "all_bvec2_vert_ref.vert",
"vertexShader": "all_bvec2_vert_ref.vert",
"fragmentShader": "../default/default.frag"
},
"model": "grid",
},
"model": "grid",
"testProgram": {
"vertexShader": "all_bvec2_vert.vert",
"vertexShader": "all_bvec2_vert.vert",
"fragmentShader": "../default/default.frag"
},
"name": "all_bvec2_vert.test.html",
},
"name": "all_bvec2_vert.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "all_bvec3_frag_ref.frag"
},
"model": null,
},
"model": null,
"testProgram": {
"vertexShader": "../default/default.vert",
"vertexShader": "../default/default.vert",
"fragmentShader": "all_bvec3_frag.frag"
},
"name": "all_bvec3_frag.test.html",
},
"name": "all_bvec3_frag.test.html",
"pattern": "compare"
},
},
{
"referenceProgram": {
"vertexShader": "all_bvec3_vert_ref.vert",
"vertexShader": "all_bvec3_vert_ref.vert",
"fragmentShader": "../default/default.frag"
},
"model": "grid",
},
"model": "grid",
"testProgram": {
"vertexShader": "all_bvec3_vert.vert",
"vertexShader": "all_bvec3_vert.vert",
"fragmentShader": "../default/default.frag"
},
"name": "all_bvec3_vert.test.html",
},
"name": "all_bvec3_vert.test.html",
"pattern": "compare"
}
]

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec2 c = floor(4.0 * color.rg); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(all(bvec2(c))), 1.0);
vec2 c = floor(4.0 * color.rg); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(all(bvec2(c))), 1.0);
}

View file

@ -30,16 +30,16 @@ varying vec4 color;
bool _all(in bvec2 a)
{
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
return temp;
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
return temp;
}
void main (void)
{
vec2 c = floor(4.0 * color.rg); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(_all(bvec2(c))), 1.0);
vec2 c = floor(4.0 * color.rg); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(_all(bvec2(c))), 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec2 c = floor(4.0 * gtf_Color.rg); // 3/4 true, 1/4 false
color = vec4(vec3(all(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec2 c = floor(4.0 * gtf_Color.rg); // 3/4 true, 1/4 false
color = vec4(vec3(all(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,17 +30,17 @@ varying vec4 color;
bool _all(in bvec2 a)
{
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
return temp;
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
return temp;
}
void main (void)
{
vec2 c = floor(4.0 * gtf_Color.rg); // 3/4 true, 1/4 false
color = vec4(vec3(_all(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec2 c = floor(4.0 * gtf_Color.rg); // 3/4 true, 1/4 false
color = vec4(vec3(_all(bvec2(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

View file

@ -30,6 +30,6 @@ varying vec4 color;
void main (void)
{
vec3 c = floor(4.0 * color.rgb); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(all(bvec3(c))), 1.0);
vec3 c = floor(4.0 * color.rgb); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(all(bvec3(c))), 1.0);
}

View file

@ -30,17 +30,17 @@ varying vec4 color;
bool _all(in bvec3 a)
{
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
if(!a[2]) temp = false;
return temp;
bool temp = true;
if(!a[0]) temp = false;
if(!a[1]) temp = false;
if(!a[2]) temp = false;
return temp;
}
void main (void)
{
vec3 c = floor(4.0 * color.rgb); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(_all(bvec3(c))), 1.0);
vec3 c = floor(4.0 * color.rgb); // 3/4 true, 1/4 false
gl_FragColor = vec4(vec3(_all(bvec3(c))), 1.0);
}

View file

@ -30,7 +30,7 @@ varying vec4 color;
void main (void)
{
vec3 c = floor(4.0 * gtf_Color.rgb); // 3/4 true, 1/4 false
color = vec4(vec3(all(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
vec3 c = floor(4.0 * gtf_Color.rgb); // 3/4 true, 1/4 false
color = vec4(vec3(all(bvec3(c))), 1.0);
gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex;
}

Some files were not shown because too many files have changed in this diff Show more