Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-half-float.html

Issue 13842017: Add OES_texture_half_float extension support in WebGL. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: move test cases to directory LayoutTest/webgl/ Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!--
2
3 /*
4 ** Copyright (c) 2013 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
1 <!DOCTYPE html> 28 <!DOCTYPE html>
2 <html> 29 <html>
3 <head> 30 <head>
4 <meta charset="utf-8"> 31 <meta charset="utf-8">
5 <title>WebGL OES_texture_half_float Conformance Tests</title> 32 <title>WebGL OES_texture_half_float Conformance Tests</title>
6 <link rel="stylesheet" href="../../js/resources/js-test-style.css"/> 33 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
7 <script src="resources/desktop-gl-constants.js" type="text/javascript"></script> 34 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></s cript>
8 <script src="../../js/resources/js-test-pre.js"></script> 35 <script src="../../resources/js-test-pre.js"></script>
9 <script src="resources/webgl-test.js"></script> 36 <script src="../resources/webgl-test.js"></script>
10 <script src="resources/webgl-test-utils.js"></script> 37 <script src="../resources/webgl-test-utils.js"></script>
11 </head> 38 </head>
12 <body> 39 <body>
13 <div id="description"></div> 40 <div id="description"></div>
14 <canvas id="canvas" style="width: 50px; height: 50px;"> </canvas> 41 <canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
15 <div id="console"></div> 42 <div id="console"></div>
16 <script id="testFragmentShader" type="x-shader/x-fragment"> 43 <script id="testFragmentShader" type="x-shader/x-fragment">
17 precision mediump float; 44 precision mediump float;
18 uniform sampler2D tex; 45 uniform sampler2D tex;
19 uniform vec4 subtractor; 46 uniform vec4 subtractor;
20 varying vec2 texCoord; 47 varying vec2 texCoord;
21 void main() 48 void main()
22 { 49 {
23 vec4 color = texture2D(tex, texCoord); 50 vec4 color = texture2D(tex, texCoord);
24 if (abs(color.r - subtractor.r) + 51 if (abs(color.r - subtractor.r) +
25 abs(color.g - subtractor.g) + 52 abs(color.g - subtractor.g) +
26 abs(color.b - subtractor.b) + 53 abs(color.b - subtractor.b) +
27 abs(color.a - subtractor.a) < 8.0) { 54 abs(color.a - subtractor.a) < 8.0) {
28 gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); 55 gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
29 } else { 56 } else {
30 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); 57 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
31 } 58 }
32 } 59 }
33 </script> 60 </script>
34 <!-- Shaders for testing half floating-point render targets --> 61 <!-- Shaders for testing half-floating-point render targets -->
35 <script id="positionVertexShader" type="x-shader/x-vertex"> 62 <script id="positionVertexShader" type="x-shader/x-vertex">
36 attribute vec4 vPosition; 63 attribute vec4 vPosition;
37 void main() 64 void main()
38 { 65 {
39 gl_Position = vPosition; 66 gl_Position = vPosition;
40 } 67 }
41 </script> 68 </script>
42 <script id="floatingPointFragmentShader" type="x-shader/x-fragment"> 69 <script id="floatingPointFragmentShader" type="x-shader/x-fragment">
43 void main() 70 void main()
44 { 71 {
45 gl_FragColor = vec4(10000.0, 10000.0, 10000.0, 10000.0); 72 gl_FragColor = vec4(10000.0, 10000.0, 10000.0, 10000.0);
46 } 73 }
47 </script> 74 </script>
48 <script> 75 <script>
76 "use strict"
49 description("This test verifies the functionality of OES_texture_half_float with null/non-null ArrayBufferView"); 77 description("This test verifies the functionality of OES_texture_half_float with null/non-null ArrayBufferView");
78
50 debug(""); 79 debug("");
51
52 if (window.internals)
53 window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
54
55 var wtu = WebGLTestUtils; 80 var wtu = WebGLTestUtils;
56 var canvas = document.getElementById("canvas"); 81 var canvas = document.getElementById("canvas");
57 var gl = wtu.create3DContext(canvas); 82 var gl = wtu.create3DContext(canvas);
83 // This constant must be defined in order to run the texture creation test witho ut the extension enabled.
84 var halfFloatOESEnum = 0x8D61;
85 var ext = null;
58 86
59 if (!gl) { 87 if (!gl) {
60 testFailed("WebGL context does not exists"); 88 testFailed("WebGL context does not exists");
61 } else { 89 } else {
62 testPassed("WebGL context exists"); 90 testPassed("WebGL context exists");
63 91
64 // Verify that allocation of texture fails if extension is not enabled 92 // Verify that allocation of texture fails if extension is not enabled
65 runTextureCreationTest(false); 93 runTextureCreationTest(false);
66 94
67 if(!gl.getExtension("OES_texture_half_float")) { 95 if (!(ext = gl.getExtension("OES_texture_half_float"))) {
68 testPassed("No OES_texture_half_float support. This is legal"); 96 testPassed("No OES_texture_half_float support. This is legal");
69 } else { 97 } else {
70 testPassed("Successfully enabled OES_texture_half_float extension"); 98 testPassed("Successfully enabled OES_texture_half_float extension");
71 99
72 // Check if creation of texture succeed's with various formats and null ArrayBufferView 100 // Check if creation of texture succeed's with various formats and null ArrayBufferView
73 var formats = [gl.RGBA, gl.RGB, gl.LUMINANCE, gl.ALPHA, gl.LUMINANCE_ALP HA]; 101 var formats = [gl.RGBA, gl.RGB, gl.LUMINANCE, gl.ALPHA, gl.LUMINANCE_ALP HA];
74 for (var i = 0; i < formats.length; i++) { 102 for (var i = 0; i < formats.length; i++) {
75 runTextureCreationTest(true, formats[i], null); 103 runTextureCreationTest(true, formats[i], null);
76 } 104 }
77 105
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 183
156 if (!extensionEnabled || data) 184 if (!extensionEnabled || data)
157 expectSuccess = false; 185 expectSuccess = false;
158 debug("Testing texture creation with extension " + (extensionEnabled ? "enab led" : "disabled") + 186 debug("Testing texture creation with extension " + (extensionEnabled ? "enab led" : "disabled") +
159 ", format " + getFormatName(format) + ", and data " + (data ? "non-nul l" : "null") + 187 ", format " + getFormatName(format) + ", and data " + (data ? "non-nul l" : "null") +
160 ". Expect " + (expectSuccess ? "Success" : "Failure")); 188 ". Expect " + (expectSuccess ? "Success" : "Failure"));
161 189
162 var texture = allocateTexture(); 190 var texture = allocateTexture();
163 var width = 2; 191 var width = 2;
164 var height = 2; 192 var height = 2;
165 gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, 0, format, gl.HALF_FL OAT_OES, data); 193 gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, 0, format, halfFloatO ESEnum, data);
166 if(!extensionEnabled) { 194 if(!extensionEnabled) {
167 glErrorShouldBe(gl, gl.INVALID_ENUM, "Half floating point texture must b e diallowed if OES_texture_half_float isn't enabled"); 195 glErrorShouldBe(gl, gl.INVALID_ENUM, "Half floating point texture must b e diallowed if OES_texture_half_float isn't enabled");
168 return; 196 return;
169 } else if (data) { 197 } else if (data) {
170 glErrorShouldBe(gl, gl.INVALID_OPERATION, "Half floating point texture a llocation must be diallowed when ArrayBufferView is not-null"); 198 glErrorShouldBe(gl, gl.INVALID_OPERATION, "Half floating point texture a llocation must be diallowed when ArrayBufferView is not-null");
171 return; 199 return;
172 } else { 200 } else {
173 glErrorShouldBe(gl, gl.NO_ERROR, "Half floating point texture allocation should succeed if OES_texture_half_float is enabled"); 201 glErrorShouldBe(gl, gl.NO_ERROR, "Half floating point texture allocation should succeed if OES_texture_half_float is enabled");
174 } 202 }
175 } 203 }
176 204
177 function checkRenderingResults() 205 function checkRenderingResults()
178 { 206 {
179 wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green"); 207 wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
180 } 208 }
181 209
182 function runRenderTargetTest(testProgram) 210 function runRenderTargetTest(testProgram)
183 { 211 {
184 debug(""); 212 debug("");
185 debug("Testing half floating point render target"); 213 debug("Testing half floating point render target");
186 214
187 var texture = allocateTexture(); 215 var texture = allocateTexture();
188 var width = 2; 216 var width = 2;
189 var height = 2; 217 var height = 2;
190 218
191 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.HALF_ FLOAT_OES, null); 219 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, ext.HALF _FLOAT_OES, null);
192 glErrorShouldBe(gl, gl.NO_ERROR, "Half floating point texture allocation sho uld succeed if OES_texture_half_float is enabled"); 220 glErrorShouldBe(gl, gl.NO_ERROR, "Half floating point texture allocation sho uld succeed if OES_texture_half_float is enabled");
193 221
194 // Try to use this texture as render target 222 // Try to use this texture as render target
195 var fbo = gl.createFramebuffer(); 223 var fbo = gl.createFramebuffer();
196 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); 224 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
197 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); 225 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
198 gl.bindTexture(gl.TEXTURE_2D, null); 226 gl.bindTexture(gl.TEXTURE_2D, null);
199 227
200 // It is legal for a WebGL implementation exposing the OES_texture_half_floa t extension to 228 // It is legal for a WebGL implementation exposing the OES_texture_half_floa t extension to
201 // support half floating point textures but not as attachments to framebuffe r objects. 229 // support half floating point textures but not as attachments to framebuffe r objects.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 { 264 {
237 debug("Testing that getExtension() returns the same object each time"); 265 debug("Testing that getExtension() returns the same object each time");
238 gl.getExtension("OES_texture_half_float").myProperty = 2; 266 gl.getExtension("OES_texture_half_float").myProperty = 2;
239 gc(); 267 gc();
240 shouldBe('gl.getExtension("OES_texture_half_float").myProperty', '2'); 268 shouldBe('gl.getExtension("OES_texture_half_float").myProperty', '2');
241 } 269 }
242 270
243 debug(""); 271 debug("");
244 var successfullyParsed = true; 272 var successfullyParsed = true;
245 </script> 273 </script>
246 <script src="../../js/resources/js-test-post.js"></script> 274 <script src="../../resources/js-test-post.js"></script>
247 275
248 </body> 276 </body>
249 </html> 277 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698