diff options
Diffstat (limited to '')
14 files changed, 488 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_001_to_006.html b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_001_to_006.html new file mode 100644 index 0000000000..d15f070e75 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_001_to_006.html @@ -0,0 +1,109 @@ +<!DOCTYPE html> +<!-- this file is auto-generated. DO NOT EDIT. --> +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> +<html> +<head> +<meta charset="utf-8"> +<title>WebGL GLSL conformance test: cos_001_to_006.html</title> +<link rel="stylesheet" href="../../../../resources/js-test-style.css" /> +<link rel="stylesheet" href="../../../../resources/ogles-tests.css" /> +<script src="../../../../js/js-test-pre.js"></script> +<script src="../../../../js/webgl-test-utils.js"></script> +<script src="../../ogles-utils.js"></script> +</head> +<body> +<canvas id="example" width="500" height="500" style="width: 16px; height: 16px;"></canvas> +<div id="description"></div> +<div id="console"></div> +</body> +<script> +"use strict"; +OpenGLESTestRunner.run({ + "tests": [ + { + "referenceProgram": { + "vertexShader": "../default/default.vert", + "fragmentShader": "cos_float_frag_xvary_ref.frag" + }, + "model": null, + "testProgram": { + "vertexShader": "../default/default.vert", + "fragmentShader": "cos_float_frag_xvary.frag" + }, + "name": "cos_float_frag_xvary.test.html", + "pattern": "compare" + }, + { + "referenceProgram": { + "vertexShader": "../default/default.vert", + "fragmentShader": "cos_vec2_frag_xvary_ref.frag" + }, + "model": null, + "testProgram": { + "vertexShader": "../default/default.vert", + "fragmentShader": "cos_vec2_frag_xvary.frag" + }, + "name": "cos_vec2_frag_xvary.test.html", + "pattern": "compare" + }, + { + "referenceProgram": { + "vertexShader": "../default/default.vert", + "fragmentShader": "cos_vec3_frag_xvary_ref.frag" + }, + "model": null, + "testProgram": { + "vertexShader": "../default/default.vert", + "fragmentShader": "cos_vec3_frag_xvary.frag" + }, + "name": "cos_vec3_frag_xvary.test.html", + "pattern": "compare" + }, + { + "referenceProgram": { + "vertexShader": "cos_float_vert_xvary_ref.vert", + "fragmentShader": "../default/default.frag" + }, + "model": "grid", + "testProgram": { + "vertexShader": "cos_float_vert_xvary.vert", + "fragmentShader": "../default/default.frag" + }, + "name": "cos_float_vert_xvary.test.html", + "pattern": "compare" + }, + { + "referenceProgram": { + "vertexShader": "cos_vec2_vert_xvary_ref.vert", + "fragmentShader": "../default/default.frag" + }, + "model": "grid", + "testProgram": { + "vertexShader": "cos_vec2_vert_xvary.vert", + "fragmentShader": "../default/default.frag" + }, + "name": "cos_vec2_vert_xvary.test.html", + "pattern": "compare" + }, + { + "referenceProgram": { + "vertexShader": "cos_vec3_vert_xvary_ref.vert", + "fragmentShader": "../default/default.frag" + }, + "model": "grid", + "testProgram": { + "vertexShader": "cos_vec3_vert_xvary.vert", + "fragmentShader": "../default/default.frag" + }, + "name": "cos_vec3_vert_xvary.test.html", + "pattern": "compare" + } + ] +}); +var successfullyParsed = true; +</script> +</html> diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_frag_xvary.frag b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_frag_xvary.frag new file mode 100644 index 0000000000..c1f5bcad68 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_frag_xvary.frag @@ -0,0 +1,18 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +#ifdef GL_ES +precision mediump float; +#endif +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + gl_FragColor = vec4(0.5 * cos(2.0 * M_PI * color.r) + 0.5, 0.0, 0.0, 1.0); +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_frag_xvary_ref.frag b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_frag_xvary_ref.frag new file mode 100644 index 0000000000..6dace29eb4 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_frag_xvary_ref.frag @@ -0,0 +1,53 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +#ifdef GL_ES +precision mediump float; +#endif +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + float c = 2.0 * M_PI * ( fract(abs(color.r)) - 0.5 ); + float sign = 1.0; + float cos_c = -1.0; + float fact_even = 1.0; + float fact_odd = 1.0; + float sum; + + // At this point c is in the range [-PI, PI) + + // Taylor-Maclaurin series expansion for cosine + // + // Apply the property that pow(a, b + c) = pow(a, b) * pow(a, c) + // and the property that 1.0/(a*b) = 1.0/a * 1.0/b + // to make sure no register ever overflows the range (-16384, +16384) + // mandated for mediump variables. + + for(int i = 2; i <= 10; i += 2) + { + // fact_even will hold at most the value 3840. + fact_even *= float(i); + + // fact_odd will always be smaller than fact_even + fact_odd *= float(i-1); + + // pow(c, float(i/2)) takes at most the value pow(PI, 5), which is approx. 306 + // abs(sum) is at most PI/2.0 + sum = sign * pow(abs(c), float(i/2))/fact_even; + + // abs(sum/fact_odd) is at most PI/2.0 + // cos_c is always bound in the range [-1.0, 1.0) + cos_c += pow(abs(c), float(i/2))*(sum/fact_odd); + + sign = -sign; + } + + gl_FragColor = vec4(0.5 * cos_c + 0.5, 0.0, 0.0, 1.0); +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_vert_xvary.vert b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_vert_xvary.vert new file mode 100644 index 0000000000..e240263025 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_vert_xvary.vert @@ -0,0 +1,19 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +attribute vec4 gtf_Color; +attribute vec4 gtf_Vertex; +uniform mat4 gtf_ModelViewProjectionMatrix; +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + color = vec4(0.5 * cos(2.0 * M_PI * gtf_Color.r) + 0.5, 0.0, 0.0, 1.0); + gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex; +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_vert_xvary_ref.vert b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_vert_xvary_ref.vert new file mode 100644 index 0000000000..38b68b78ad --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_float_vert_xvary_ref.vert @@ -0,0 +1,33 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +attribute vec4 gtf_Color; +attribute vec4 gtf_Vertex; +uniform mat4 gtf_ModelViewProjectionMatrix; +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + float c = 2.0 * M_PI * gtf_Color.r; + float sign = -1.0; + float cos_c = 1.0; + float fact = 1.0; + + // Taylor-Maclaurin series expansion for cosine + for(int i = 2; i <= 20; i += 2) + { + fact *= float(i)*float(i-1); + cos_c += sign*pow(c, float(i))/fact; + sign = -sign; + } + + color = vec4(0.5 * cos_c + 0.5, 0.0, 0.0, 1.0); + + gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex; +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_frag_xvary.frag b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_frag_xvary.frag new file mode 100644 index 0000000000..92f3d3990a --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_frag_xvary.frag @@ -0,0 +1,18 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +#ifdef GL_ES +precision mediump float; +#endif +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + gl_FragColor = vec4(0.5 * cos(2.0 * M_PI * color.rg) + 0.5, 0.0, 1.0); +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_frag_xvary_ref.frag b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_frag_xvary_ref.frag new file mode 100644 index 0000000000..ad44ee73f2 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_frag_xvary_ref.frag @@ -0,0 +1,57 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +#ifdef GL_ES +precision mediump float; +#endif +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + vec2 c = 2.0 * M_PI * ( fract(abs(color.rg)) - 0.5 ); + float sign = 1.0; + vec2 cos_c = vec2(-1.0, -1.0); + float fact_even = 1.0; + float fact_odd = 1.0; + vec2 sum; + vec2 exp; + + // At this point c is in the range [-PI, PI) + + // Taylor-Maclaurin series expansion for cosine + // + // Apply the property that pow(a, b + c) = pow(a, b) * pow(a, c) + // and the property that 1.0/(a*b) = 1.0/a * 1.0/b + // to make sure no register ever overflows the range (-16384, +16384) + // mandated for mediump variables. + + for(int i = 2; i <= 10; i += 2) + { + // fact_even will hold at most the value 3840. + fact_even *= float(i); + + // fact_odd will always be smaller than fact_even + fact_odd *= float(i-1); + + // exp is at most (5,5) + exp = vec2(float(i/2), float(i/2)); + + // pow(c, exp) takes at most the value pow(PI, 5), which is approx. 306 + // abs(sum) is at most PI/2.0 + sum = sign * pow(abs(c), exp)/fact_even; + + // abs(sum/fact_odd) is at most PI/2.0 + // cos_c is always bound in the range [-1.0, 1.0) + cos_c += pow(abs(c), exp)*(sum/fact_odd); + + sign = -sign; + } + + gl_FragColor = vec4(0.5 * cos_c + 0.5, 0.0, 1.0); +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_vert_xvary.vert b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_vert_xvary.vert new file mode 100644 index 0000000000..c3aeba8ccd --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_vert_xvary.vert @@ -0,0 +1,19 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +attribute vec4 gtf_Color; +attribute vec4 gtf_Vertex; +uniform mat4 gtf_ModelViewProjectionMatrix; +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + color = vec4(0.5 * cos(2.0 * M_PI * gtf_Color.rg) + 0.5, 0.0, 1.0); + gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex; +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_vert_xvary_ref.vert b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_vert_xvary_ref.vert new file mode 100644 index 0000000000..4aa50e3b88 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec2_vert_xvary_ref.vert @@ -0,0 +1,33 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +attribute vec4 gtf_Color; +attribute vec4 gtf_Vertex; +uniform mat4 gtf_ModelViewProjectionMatrix; +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + vec2 c = 2.0 * M_PI * gtf_Color.rg; + float sign = -1.0; + vec2 cos_c = vec2(1.0, 1.0); + float fact = 1.0; + + // Taylor-Maclaurin series expansion for cosine + for(int i = 2; i <= 20; i += 2) + { + fact *= float(i)*float(i-1); + cos_c += sign*pow(c, vec2(float(i), float(i)))/fact; + sign = -sign; + } + + color = vec4(0.5 * cos_c + 0.5, 0.0, 1.0); + + gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex; +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_frag_xvary.frag b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_frag_xvary.frag new file mode 100644 index 0000000000..a51a52db02 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_frag_xvary.frag @@ -0,0 +1,18 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +#ifdef GL_ES +precision mediump float; +#endif +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + gl_FragColor = vec4(0.5 * cos(2.0 * M_PI * color.rgb) + 0.5, 1.0); +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_frag_xvary_ref.frag b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_frag_xvary_ref.frag new file mode 100644 index 0000000000..c228a078e5 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_frag_xvary_ref.frag @@ -0,0 +1,57 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +#ifdef GL_ES +precision mediump float; +#endif +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + vec3 c = 2.0 * M_PI * ( fract(abs(color.rgb)) - 0.5 ); + float sign = 1.0; + vec3 cos_c = vec3(-1.0, -1.0, -1.0); + float fact_even = 1.0; + float fact_odd = 1.0; + vec3 sum; + vec3 exp; + + // At this point c is in the range [-PI, PI) + + // Taylor-Maclaurin series expansion for cosine + // + // Apply the property that pow(a, b + c) = pow(a, b) * pow(a, c) + // and the property that 1.0/(a*b) = 1.0/a * 1.0/b + // to make sure no register ever overflows the range (-16384, +16384) + // mandated for mediump variables. + + for(int i = 2; i <= 10; i += 2) + { + // fact_even will hold at most the value 3840. + fact_even *= float(i); + + // fact_odd will always be smaller than fact_even + fact_odd *= float(i-1); + + // exp is at most (5,5,5) + exp = vec3(float(i/2), float(i/2), float(i/2)); + + // pow(c, exp) takes at most the value pow(PI, 5), which is approx. 306 + // abs(sum) is at most PI/2.0 + sum = sign * pow(abs(c), exp)/fact_even; + + // abs(sum/fact_odd) is at most PI/2.0 + // cos_c is always bound in the range [-1.0, 1.0) + cos_c += pow(abs(c), exp)*(sum/fact_odd); + + sign = -sign; + } + + gl_FragColor = vec4(0.5 * cos_c + 0.5, 1.0); +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_vert_xvary.vert b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_vert_xvary.vert new file mode 100644 index 0000000000..7c1d8b6270 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_vert_xvary.vert @@ -0,0 +1,19 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +attribute vec4 gtf_Color; +attribute vec4 gtf_Vertex; +uniform mat4 gtf_ModelViewProjectionMatrix; +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + color = vec4(0.5 * cos(2.0 * M_PI * gtf_Color.rgb) + 0.5, 1.0); + gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex; +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_vert_xvary_ref.vert b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_vert_xvary_ref.vert new file mode 100644 index 0000000000..63ebd02500 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/cos_vec3_vert_xvary_ref.vert @@ -0,0 +1,33 @@ + +/* +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +*/ + + +attribute vec4 gtf_Color; +attribute vec4 gtf_Vertex; +uniform mat4 gtf_ModelViewProjectionMatrix; +varying vec4 color; + +void main (void) +{ + const float M_PI = 3.14159265358979323846; + vec3 c = 2.0 * M_PI * gtf_Color.rgb; + float sign = -1.0; + vec3 cos_c = vec3(1.0,1.0,1.0); + float fact = 1.0; + + // Taylor-Maclaurin series expansion for cosine + for(int i = 2; i <= 20; i += 2) + { + fact *= float(i)*float(i-1); + cos_c += sign*pow(c, vec3(float(i),float(i),float(i)))/fact; + sign = -sign; + } + + color = vec4(0.5 * cos_c + 0.5, 1.0); + + gl_Position = gtf_ModelViewProjectionMatrix * gtf_Vertex; +} diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/input.run.txt b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/input.run.txt new file mode 100644 index 0000000000..64f23d8c39 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/ogles/GL/cos/input.run.txt @@ -0,0 +1,2 @@ +# this file is auto-generated. DO NOT EDIT. +cos_001_to_006.html |