Chromium Code Reviews| Index: LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html |
| diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..82c353a5d904c212988075719bb067a2591f8ebf |
| --- /dev/null |
| +++ b/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html |
| @@ -0,0 +1,193 @@ |
| +<!-- |
| + |
| +/* |
| +** 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>WebGL OES_texture_half_float_linear Conformance Tests</title> |
| +<link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| +<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script> |
| +<script src="../../resources/js-test-pre.js"></script> |
| +<script src="../resources/webgl-test.js"></script> |
| +<script src="../resources/webgl-test-utils.js"></script> |
| +</head> |
| +<body> |
| +<div id="description"></div> |
| +<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas> |
| +<div id="console"></div> |
| +<!-- Shaders for testing floating-point textures --> |
|
Ken Russell (switch to Gerrit)
2013/05/13 20:00:35
Rather than duplicating this entire test, it would
|
| +<script id="testFragmentShader" type="x-shader/x-fragment"> |
| +uniform sampler2D tex; |
| +void main() |
| +{ |
| + gl_FragColor = texture2D(tex, vec2(0.5, 0.5)) * vec4(1.0, 1.0, 1.0, 1.0); |
| +} |
| +</script> |
| +<script id="texCubFshader" type="x-shader/x-fragment"> |
| +uniform samplerCube tex; |
| +void main() |
| +{ |
| + gl_FragColor = textureCube(tex, normalize(vec3(0.5, 0.5, 1))) * vec4(1.0, 1.0, 1.0, 1.0); |
| +} |
| +</script> |
| +<!-- Shaders for testing floating-point render targets --> |
| +<script id="positionVertexShader" type="x-shader/x-vertex"> |
| +attribute vec4 vPosition; |
| +void main() |
| +{ |
| + gl_Position = vPosition; |
| +} |
| +</script> |
| +<script> |
| +"use strict"; |
| +description("This test verifies the functionality of the OES_texture_half_float_linear extension, if it is available."); |
| + |
| +debug(""); |
| +// This constant must be defined in order to run the texture creation test without the extension enabled. |
| +var extension = null; |
| +var wtu = WebGLTestUtils; |
| +var canvas = document.getElementById("canvas"); |
| +var gl = wtu.create3DContext(canvas); |
| +if (!gl) { |
| + testFailed("WebGL context does not exist"); |
| +} else { |
| + testPassed("WebGL context exists"); |
| + |
| + if (!(extension = gl.getExtension("OES_texture_half_float"))) { |
| + testPassed("No OES_texture_half_float support -- this is legal"); |
| + } else { |
| + testPassed("Successfully enabled OES_texture_half_float extension"); |
| + |
| + // Before OES_texture_half_float_linear extension is enabled |
| + var extensionEabled = false; |
| + runTestSuit(extensionEabled); |
| + |
| + if (!gl.getExtension("OES_texture_half_float_linear")) |
| + testPassed("No OES_texture_half_float_linear support -- this is legal"); |
| + else { |
| + // OES_texture_half_float_linear extension is enabled |
| + extensionEabled = true; |
| + runTestSuit(extensionEabled); |
| + } |
| + } |
| +} |
| + |
| +function runTestSuit(extensionEabled) |
| +{ |
| + var magF = [gl.NEAREST, gl.LINEAR]; |
| + var minF = [gl.NEAREST, gl.LINEAR, gl.NEAREST_MIPMAP_NEAREST, gl.NEAREST_MIPMAP_LINEAR, gl.LINEAR_MIPMAP_NEAREST, gl.LINEAR_MIPMAP_LINEAR]; |
| + |
| + var program = wtu.setupProgram(gl, ["positionVertexShader", "testFragmentShader"]); |
| + gl.useProgram(program); |
| + wtu.setupUnitQuad(gl); |
| + for (var kk = 0; kk < 2; ++kk) { |
| + for (var ii = 0; ii < 6; ++ii) { |
| + var linear = false; |
| + if (magF[kk] == gl.LINEAR || (minF[ii] != gl.NEAREST && minF[ii] != gl.NEAREST_MIPMAP_NEAREST)) |
| + linear = true; |
| + var color = (!extensionEabled && linear) ? [0, 0, 0, 255] : [0, 0, 0, 0]; |
| + runEachTest(gl.TEXTURE_2D, magF[kk], minF[ii], linear, extensionEabled, color, linear); |
| + } |
| + } |
| + |
| + var programCub = wtu.setupProgram(gl, ["positionVertexShader", "texCubFshader"]); |
| + gl.useProgram(programCub); |
| + wtu.setupUnitQuad(gl); |
| + for (var kk = 0; kk < 2; ++kk) { |
| + for (var ii = 0; ii < 6; ++ii) { |
| + var linear = false; |
| + if (magF[kk] == gl.LINEAR || (minF[ii] != gl.NEAREST && minF[ii] != gl.NEAREST_MIPMAP_NEAREST)) |
| + linear = true; |
| + var color = (!extensionEabled && linear) ? [0, 0, 0, 255] : [0, 0, 0, 0]; |
| + runEachTest(gl.TEXTURE_CUBE_MAP, magF[kk], minF[ii], linear, extensionEabled, color, linear); |
| + } |
| + } |
| +} |
| + |
| +function runEachTest(textureTarget, magFilter, minFilter, linear, extensionEnabled, expected, expectFailure) |
| +{ |
| + var format = gl.RGBA; |
| + var numberOfChannels = 4; |
| + debug(""); |
| + debug("testing target: " + wtu.glEnumToString(gl,textureTarget) + |
| + ", testing format: " + wtu.glEnumToString(gl, format) + |
| + ", magFilter is: " + wtu.glEnumToString(gl, magFilter) + |
| + ", minFilter is: " + wtu.glEnumToString(gl, minFilter) + |
| + ", OES_texture_float_linear is " + (extensionEnabled ? "enabled": "not enabled") |
| + ); |
| + var texture = gl.createTexture(); |
| + // Generate data. |
| + var width = 1; |
| + var height = 1; |
| + gl.bindTexture(textureTarget, texture); |
| + gl.texParameteri(textureTarget, gl.TEXTURE_MAG_FILTER, magFilter); |
| + gl.texParameteri(textureTarget, gl.TEXTURE_MIN_FILTER, minFilter); |
| + gl.texParameteri(textureTarget, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
| + gl.texParameteri(textureTarget, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
| + |
| + if (textureTarget == gl.TEXTURE_2D) { |
| + gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, 0, format, extension.HALF_FLOAT_OES, null); |
|
Ken Russell (switch to Gerrit)
2013/05/13 20:00:35
You can work around the fact that there's no Float
|
| + if (minFilter != gl.NEAREST && minFilter != gl.LINEAR) |
| + gl.generateMipmap(gl.TEXTURE_2D); |
| + } |
| + else if (textureTarget == gl.TEXTURE_CUBE_MAP) { |
| + var targets = [ |
| + gl.TEXTURE_CUBE_MAP_POSITIVE_X, |
| + gl.TEXTURE_CUBE_MAP_NEGATIVE_X, |
| + gl.TEXTURE_CUBE_MAP_POSITIVE_Y, |
| + gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, |
| + gl.TEXTURE_CUBE_MAP_POSITIVE_Z, |
| + gl.TEXTURE_CUBE_MAP_NEGATIVE_Z]; |
| + for (var tt = 0; tt < targets.length; ++tt) { |
| + gl.texImage2D(targets[tt], 0, format, width, height, 0, format, extension.HALF_FLOAT_OES, null); |
| + } |
| + if (minFilter != gl.NEAREST && minFilter != gl.LINEAR) |
| + gl.generateMipmap(gl.TEXTURE_CUBE_MAP); |
| + } |
| + // wtu.clearAndDrawUnitQuad(gl); |
| + wtu.drawQuad(gl); |
| + if (!linear) { |
| + glErrorShouldBe(gl, gl.NO_ERROR, "floating-point texture with non-Linear filter would succeed no matter OES_texture_half_float_linear is enabled or not"); |
| + } else if (expectFailure) { |
| + glErrorShouldBe(gl, gl.NO_ERROR, "floating-point texture with Linear filter would produe [0, 0, 0, 1.0] if OES_texture_half_float_linear isn't enabled"); |
| + } else { |
| + glErrorShouldBe(gl, gl.NO_ERROR, "floating-point texture with Linear filter would succeed if OES_texture_half_float_linear is enabled"); |
| + } |
| + |
| + wtu.checkCanvas(gl, expected, "should be " + expected[0] + "," + expected[1] + "," + expected[2] + "," + expected[3]); |
| +} |
| + |
| +debug(""); |
| +// Needs to be global for shouldBe to see it. |
| +var pixels; |
| +var successfullyParsed = true; |
| +</script> |
| +<script src="../../resources/js-test-post.js"></script> |
| + |
| +</body> |
| +</html> |