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

Unified Diff: LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html

Issue 14860016: Implement OES_texture_float_linear and OES_texture_half_float_linear extensions in WebGL. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html
new file mode 100644
index 0000000000000000000000000000000000000000..0cdf33a0787f3cf4938517d006e3e4c7c4a2cdb3
--- /dev/null
+++ b/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html
@@ -0,0 +1,201 @@
+<!--
+
+/*
+** Copyright (c) 2012 The Khronos Group Inc.
Ken Russell (switch to Gerrit) 2013/05/13 20:00:35 2013.
+**
+** 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_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 -->
+<script id="testFragmentShader" type="x-shader/x-fragment">
+uniform sampler2D tex;
+void main()
+{
+ gl_FragColor = texture2D(tex, vec2(0.5, 0.5)) * vec4(4.0, 2.0, 0.5, 1);
+}
+</script>
+<script id="texCubFshader" type="x-shader/x-fragment">
Ken Russell (switch to Gerrit) 2013/05/13 20:00:35 Typo here and throughout: texCubFshader -> texCube
+uniform samplerCube tex;
+void main()
+{
+ gl_FragColor = textureCube(tex, normalize(vec3(0.5, 0.5, 1))) * vec4(4.0, 2.0, 0.5, 1);
+}
+</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_float_linear extension, if it is available.");
+
+debug("");
+
+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 (!gl.getExtension("OES_texture_float")) {
+ testPassed("No OES_texture_float support -- this is legal");
+ } else {
+ testPassed("Successfully enabled OES_texture_float extension");
+
+ // Before OES_texture_float_linear extension is enabled
+ var extensionEabled = false;
+ runTestSuit(extensionEabled);
Ken Russell (switch to Gerrit) 2013/05/13 20:00:35 Typo here and throughout: runTestSuit -> runTestSu
+
+ if (!gl.getExtension("OES_texture_float_linear"))
+ testPassed("No OES_texture_float_linear support -- this is legal");
+ else {
+ // OES_texture_float_linear extension is enabled
+ extensionEabled = true;
+ runTestSuit(extensionEabled);
+ }
+ }
+}
+
+function runTestSuit(extensionEabled)
Ken Russell (switch to Gerrit) 2013/05/13 20:00:35 Typo here and throughout: extensionEabled -> exten
+{
+ 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];
+ // TEXTURE_2D
+ 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] : [255, 255, 255, 255];
+ runEachTest(gl.TEXTURE_2D, magF[kk], minF[ii], linear, extensionEabled, color, linear);
+ }
+ }
+
+ // TEXTURE_CUBE_MAP
+ var programCube = wtu.setupProgram(gl, ["positionVertexShader", "texCubFshader"]);
+ gl.useProgram(programCube);
+ 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] : [255, 255, 255, 255];
+ runEachTest(gl.TEXTURE_CUBE_MAP, magF[kk], minF[ii], linear, extensionEabled, color, linear);
+ }
+ }
+
+}
+
+function runEachTest(textureTarget, magFilter, minFilter, linear, extensionEnabled, expected, expectFailure)
Ken Russell (switch to Gerrit) 2013/05/13 20:00:35 The "expectFailure" argument should be removed; se
+{
+ 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;
Ken Russell (switch to Gerrit) 2013/05/13 20:00:35 Please use a larger texture, at least 2x2 if not 4
Jun Jiang 2013/05/14 02:04:00 I used size 4x4 in test and changed to 1*1 when up
+ var color = [0.25, 0.5, 2.0, 1.0];
+ var data = new Float32Array(width * height * numberOfChannels);
+ for (var ii = 0; ii < width; ++ii)
+ for (var jj = 0; jj < height; ++jj)
+ for (var kk = 0; kk < numberOfChannels; kk++)
+ data[(jj* width + ii)*numberOfChannels + kk] = color[kk];
+
+ 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, gl.FLOAT, data);
+ 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, gl.FLOAT, data);
+ }
+ if (minFilter != gl.NEAREST && minFilter != gl.LINEAR)
+ gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
+ }
+ // wtu.clearAndDrawUnitQuad(gl);
Ken Russell (switch to Gerrit) 2013/05/13 20:00:35 Remove commented-out code.
+ wtu.drawQuad(gl);
+ if (!linear) {
Ken Russell (switch to Gerrit) 2013/05/13 20:00:35 The error checks here are incorrect. According to
Jun Jiang 2013/05/14 02:04:00 Thanks for your comments. Here I set the texture s
+ glErrorShouldBe(gl, gl.NO_ERROR, "floating-point texture with non-Linear filter would succeed no matter OES_texture_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_float_linear isn't enabled");
+ } else {
+ glErrorShouldBe(gl, gl.NO_ERROR, "floating-point texture with Linear filter would succeed if OES_texture_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>

Powered by Google App Engine
This is Rietveld 408576698