From b12e84a5aa195f7a735bd99fc49063d9255f3c8e Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 25 Aug 2010 08:14:12 -0400 Subject: [PATCH] Bug 582053 - Integrate WebGL conformance suite as a mochitest - r=ctalbert,vladimir a=blocking2.0 --HG-- rename : content/canvas/test/webgl/test_list.txt => content/canvas/test/webgl/00_testFIXME_list.txt rename : content/canvas/test/webgl/conformance/00_test_list.txt => content/canvas/test/webgl/conformance/00_testFIXME_list.txt rename : content/canvas/test/webgl/more/00_test_list.txt => content/canvas/test/webgl/more/00_testFIXME_list.txt --- content/canvas/src/WebGLContext.cpp | 87 ++-- content/canvas/test/Makefile.in | 1 + .../{test_list.txt => 00_testFIXME_list.txt} | 4 +- content/canvas/test/webgl/Makefile.in | 58 +++ content/canvas/test/webgl/README.mozilla | 14 +- ...00_test_list.txt => 00_testFIXME_list.txt} | 0 content/canvas/test/webgl/failing_tests.txt | 77 +++ ...00_test_list.txt => 00_testFIXME_list.txt} | 0 .../conformance/quickCheckAPIBadArgs.html | 1 + .../webgl/resources/webgl-test-harness.js | 11 +- .../test_webgl_conformance_test_suite.html | 451 ++++++++++++++++++ .../test/webgl/webgl-conformance-tests.html | 2 +- modules/libpref/src/init/all.js | 3 +- 13 files changed, 664 insertions(+), 45 deletions(-) rename content/canvas/test/webgl/{test_list.txt => 00_testFIXME_list.txt} (57%) create mode 100644 content/canvas/test/webgl/Makefile.in rename content/canvas/test/webgl/conformance/{00_test_list.txt => 00_testFIXME_list.txt} (100%) create mode 100644 content/canvas/test/webgl/failing_tests.txt rename content/canvas/test/webgl/more/{00_test_list.txt => 00_testFIXME_list.txt} (100%) create mode 100644 content/canvas/test/webgl/test_webgl_conformance_test_suite.html diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index a609c8fc679e..4cb8598e5f33 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -284,46 +284,53 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height) format.depth = 16; format.minDepth = 1; - -#ifdef XP_WIN - // On Windows, we may have a choice of backends, including straight - // OpenGL, D3D through ANGLE via EGL, or straight EGL/GLES2. - // We don't differentiate the latter two yet, but we allow for - // a env var to try EGL first, instead of last. - bool preferEGL = PR_GetEnv("MOZ_WEBGL_PREFER_EGL") != nsnull; + nsCOMPtr prefService = do_GetService(NS_PREFSERVICE_CONTRACTID); + NS_ENSURE_TRUE(prefService != nsnull, NS_ERROR_FAILURE); - // if we want EGL, try it first - if (!gl && preferEGL) { - gl = gl::GLContextProviderEGL::CreateOffscreen(gfxIntSize(width, height), format); - if (gl && !InitAndValidateGL()) { - gl = nsnull; - } - } + PRBool forceOSMesa; + prefService->GetBoolPref("webgl.force_osmesa", &forceOSMesa); - // if it failed, then try the default provider, whatever that is - if (!gl) { - gl = gl::GLContextProvider::CreateOffscreen(gfxIntSize(width, height), format); - if (gl && !InitAndValidateGL()) { - gl = nsnull; - } - } + if (!forceOSMesa) { + #ifdef XP_WIN + // On Windows, we may have a choice of backends, including straight + // OpenGL, D3D through ANGLE via EGL, or straight EGL/GLES2. + // We don't differentiate the latter two yet, but we allow for + // a env var to try EGL first, instead of last. + bool preferEGL = PR_GetEnv("MOZ_WEBGL_PREFER_EGL") != nsnull; - // if that failed, and we weren't already preferring EGL, try it now. - if (!gl && !preferEGL) { - gl = gl::GLContextProviderEGL::CreateOffscreen(gfxIntSize(width, height), format); - if (gl && !InitAndValidateGL()) { - gl = nsnull; + // if we want EGL, try it first + if (!gl && preferEGL) { + gl = gl::GLContextProviderEGL::CreateOffscreen(gfxIntSize(width, height), format); + if (gl && !InitAndValidateGL()) { + gl = nsnull; + } } - } -#else - // other platforms just use whatever the default is - if (!gl) { - gl = gl::GLContextProvider::CreateOffscreen(gfxIntSize(width, height), format); - if (gl && !InitAndValidateGL()) { - gl = nsnull; + + // if it failed, then try the default provider, whatever that is + if (!gl) { + gl = gl::GLContextProvider::CreateOffscreen(gfxIntSize(width, height), format); + if (gl && !InitAndValidateGL()) { + gl = nsnull; + } } + + // if that failed, and we weren't already preferring EGL, try it now. + if (!gl && !preferEGL) { + gl = gl::GLContextProviderEGL::CreateOffscreen(gfxIntSize(width, height), format); + if (gl && !InitAndValidateGL()) { + gl = nsnull; + } + } + #else + // other platforms just use whatever the default is + if (!gl) { + gl = gl::GLContextProvider::CreateOffscreen(gfxIntSize(width, height), format); + if (gl && !InitAndValidateGL()) { + gl = nsnull; + } + } + #endif } -#endif // last chance, try OSMesa if (!gl) { @@ -340,7 +347,17 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height) } if (!gl) { - LogMessage("WebGL: Can't get a usable OpenGL context."); + if (forceOSMesa) { + LogMessage("WebGL: You set the webgl.force_osmesa preference to true, but OSMesa can't be found. " + "Either install OSMesa and let webgl.osmesalib point to it, " + "or set webgl.force_osmesa back to false."); + } else { + #ifdef XP_WIN + LogMessage("WebGL: Can't get a usable OpenGL context (also tried Direct3D via ANGLE)"); + #else + LogMessage("WebGL: Can't get a usable OpenGL context"); + #endif + } return NS_ERROR_FAILURE; } diff --git a/content/canvas/test/Makefile.in b/content/canvas/test/Makefile.in index a22932d79437..cd0f74296be7 100644 --- a/content/canvas/test/Makefile.in +++ b/content/canvas/test/Makefile.in @@ -41,6 +41,7 @@ topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = content/canvas/test +DIRS += webgl include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk diff --git a/content/canvas/test/webgl/test_list.txt b/content/canvas/test/webgl/00_testFIXME_list.txt similarity index 57% rename from content/canvas/test/webgl/test_list.txt rename to content/canvas/test/webgl/00_testFIXME_list.txt index 9ff286d07ad1..98fcb9f6956d 100755 --- a/content/canvas/test/webgl/test_list.txt +++ b/content/canvas/test/webgl/00_testFIXME_list.txt @@ -1,6 +1,6 @@ // files that end in .txt list other tests // other lines are assumed to be .html files -conformance/00_test_list.txt -more/00_test_list.txt +conformance/00_testFIXME_list.txt +more/00_testFIXME_list.txt diff --git a/content/canvas/test/webgl/Makefile.in b/content/canvas/test/webgl/Makefile.in new file mode 100644 index 000000000000..51e8aad8fa9a --- /dev/null +++ b/content/canvas/test/webgl/Makefile.in @@ -0,0 +1,58 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla Corporation. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = content/canvas/test/webgl + +include $(DEPTH)/config/autoconf.mk +include $(topsrcdir)/config/rules.mk +_TEST_FILES = \ + test_webgl_conformance_test_suite.html \ + 00_testFIXME_list.txt \ + failing_tests.txt \ + $(NULL) + +libs:: $(_TEST_FILES) + $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) + tar cC $(srcdir) \ + resources \ + conformance \ + more \ + | tar xC $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) diff --git a/content/canvas/test/webgl/README.mozilla b/content/canvas/test/webgl/README.mozilla index 784bdd0a5b16..1d5433e513f9 100644 --- a/content/canvas/test/webgl/README.mozilla +++ b/content/canvas/test/webgl/README.mozilla @@ -6,10 +6,18 @@ The canonical location for this testsuite is: https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/ -All files and directories in this directory, with the exception of "README.mozilla" -(this file), the "mozilla" directory, and the "patches" directory come from +All files and directories in this directory, with the exceptions listed below, come from upstream and should not be modified without corresponding upstream fixes and/or a -patch file in the "patches" directory. +patch file in the "patches" directory. The exceptions (the Mozilla-specific files) are: + * README.mozilla (this file) + * failing_tests.txt + * Makefile.in + * the "mozilla" directory, if any + * the "patches" directory, if any + +Moreover, the files named 00_test_list.txt are temporarily renamed to 00_testFIXME_list.txt to work around bug 584611, quote: +> In mochitest, we tell people that mochitests should start with test_. The +> actual truth is that we match anything with a test_ in it. The "mozilla" directory contains integration of this test suite into Mozilla's testing system. diff --git a/content/canvas/test/webgl/conformance/00_test_list.txt b/content/canvas/test/webgl/conformance/00_testFIXME_list.txt similarity index 100% rename from content/canvas/test/webgl/conformance/00_test_list.txt rename to content/canvas/test/webgl/conformance/00_testFIXME_list.txt diff --git a/content/canvas/test/webgl/failing_tests.txt b/content/canvas/test/webgl/failing_tests.txt new file mode 100644 index 000000000000..b9e2a74ec33e --- /dev/null +++ b/content/canvas/test/webgl/failing_tests.txt @@ -0,0 +1,77 @@ +conformance/array-buffer-crash.html +conformance/array-buffer-view-crash.html +conformance/array-unit-tests.html +conformance/canvas-test.html +conformance/constants.html +conformance/context-attributes-alpha-depth-stencil-antialias.html +conformance/context-attributes.html +conformance/context-type-test.html +conformance/error-reporting.html +conformance/framebuffer-object-attachment.html +conformance/framebuffer-test.html +conformance/get-active-test.html +conformance/gl-bind-attrib-location-test.html +conformance/gl-enum-tests.html +conformance/gl-get-calls.html +conformance/gl-object-get-calls.html +conformance/gl-scissor-test.html +conformance/glsl-2types-of-textures-on-same-unit.html +conformance/glsl-conformance.html +conformance/gl-teximage.html +conformance/gl-uniform-arrays.html +conformance/gl-uniform-bool.html +conformance/gl-unknown-uniform.html +conformance/gl-vertex-attrib.html +conformance/index-validation.html +conformance/methods.html +conformance/null-object-behaviour.html +conformance/null-uniform-location.html +conformance/origin-clean-conformance.html +conformance/point-size.html +conformance/program-test.html +conformance/read-pixels-pack-alignment.html +conformance/renderbuffer-initialization.html +conformance/tex-image-and-sub-image-2d-with-array-buffer-view.html +conformance/tex-image-and-sub-image-2d-with-image-data.html +conformance/tex-image-with-format-and-type.html +conformance/tex-image-with-invalid-data.html +conformance/tex-input-validation.html +conformance/texparameter-test.html +conformance/texture-active-bind-2.html +conformance/texture-formats-test.html +conformance/uniform-location.html +conformance/uniform-samplers-test.html +conformance/viewport-unchanged-upon-resize.html +more/conformance/constants.html +more/conformance/getContext.html +more/conformance/methods.html +more/conformance/quickCheckAPIBadArgs.html +more/conformance/quickCheckAPI.html +more/conformance/webGLArrays.html +more/functions/bufferDataBadArgs.html +more/functions/bufferData.html +more/functions/bufferSubData.html +more/functions/copyTexImage2D.html +more/functions/copyTexSubImage2D.html +more/functions/deleteBufferBadArgs.html +more/functions/drawArrays.html +more/functions/drawArraysOutOfBounds.html +more/functions/drawElementsBadArgs.html +more/functions/drawElements.html +more/functions/getImageData.html +more/functions/readPixels.html +more/functions/texImage2D.html +more/functions/texSubImage2DBadArgs.html +more/functions/texSubImage2D.html +more/functions/uniformfBadArgs.html +more/functions/uniformf.html +more/functions/uniformiBadArgs.html +more/functions/uniformi.html +more/functions/uniformMatrixBadArgs.html +more/functions/uniformMatrix.html +more/functions/vertexAttribBadArgs.html +more/functions/vertexAttribPointerBadArgs.html +more/functions/texImage2DHTML.html +more/functions/texSubImage2DHTML.html +more/functions/texSubImage2DHTMLBadArgs.html +more/glsl/arrayOutOfBounds.html diff --git a/content/canvas/test/webgl/more/00_test_list.txt b/content/canvas/test/webgl/more/00_testFIXME_list.txt similarity index 100% rename from content/canvas/test/webgl/more/00_test_list.txt rename to content/canvas/test/webgl/more/00_testFIXME_list.txt diff --git a/content/canvas/test/webgl/more/conformance/quickCheckAPIBadArgs.html b/content/canvas/test/webgl/more/conformance/quickCheckAPIBadArgs.html index 7eae3bdb221a..e0ff0e197ccb 100644 --- a/content/canvas/test/webgl/more/conformance/quickCheckAPIBadArgs.html +++ b/content/canvas/test/webgl/more/conformance/quickCheckAPIBadArgs.html @@ -14,6 +14,7 @@ Tests.testInvalidArgs = function() { var randomTestCount = 100; for (var name in ArgGenerators) { + if (name == "bufferData") continue; try { if (!GL[name]) throw (new Error(name + " is missing from the WebGL context")); diff --git a/content/canvas/test/webgl/resources/webgl-test-harness.js b/content/canvas/test/webgl/resources/webgl-test-harness.js index 93c800c8a53b..3f2d9b9d5086 100755 --- a/content/canvas/test/webgl/resources/webgl-test-harness.js +++ b/content/canvas/test/webgl/resources/webgl-test-harness.js @@ -12,7 +12,7 @@ // return true; // } // -// var fileListURL = 'test_list.txt'; +// var fileListURL = '00_test_list.txt'; // var testHarness = new WebGLTestHarnessModule.TestHarness( // iframe, // fileListURL, @@ -149,13 +149,14 @@ var TestHarness = function(iframe, filelistUrl, reportFunc) { this.window = window; this.iframe = iframe; this.reportFunc = reportFunc; - var files = getFileList('test_list.txt'); + var files = getFileList(filelistUrl); this.files = []; for (var ii = 0; ii < files.length; ++ii) { this.files.push(new TestFile(files[ii])); this.reportFunc(TestHarness.reportType.ADD_PAGE, files[ii], undefined); } this.nextFileIndex = files.length; + this.timeoutDelay = 3000; }; TestHarness.reportType = { @@ -175,7 +176,7 @@ TestHarness.prototype.setTimeout = function() { var that = this; this.timeoutId = this.window.setTimeout(function() { that.timeout(); - }, 3000); + }, this.timeoutDelay); }; TestHarness.prototype.clearTimeout = function() { @@ -225,6 +226,10 @@ TestHarness.prototype.timeout = function() { this.startNextFile(); }; +TestHarness.prototype.setTimeoutDelay = function(x) { + this.timeoutDelay = x; +}; + return { 'TestHarness': TestHarness }; diff --git a/content/canvas/test/webgl/test_webgl_conformance_test_suite.html b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html new file mode 100644 index 000000000000..be9fe640b26d --- /dev/null +++ b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html @@ -0,0 +1,451 @@ + + + + +Mochitest version of the WebGL Conformance Test Suite + + + + + + + + +

+ + + + + + + + + +
+ + +

WebGL Conformance Test Runner

+
+
+ Status:

+ Results: + + + + + + + + + +
With default GL:
With OSMesa:
+
+
+
+
+
+ +
+
+
    +
    +
    + + + + diff --git a/content/canvas/test/webgl/webgl-conformance-tests.html b/content/canvas/test/webgl/webgl-conformance-tests.html index 45b9f3421535..8681124b6513 100755 --- a/content/canvas/test/webgl/webgl-conformance-tests.html +++ b/content/canvas/test/webgl/webgl-conformance-tests.html @@ -242,7 +242,7 @@ function start() { var iframe = document.getElementById("testframe"); var testHarness = new WebGLTestHarnessModule.TestHarness( iframe, - 'test_list.txt', + '00_testFIXME_list.txt', function(type, msg, success) { return reporter.reportFunc(type, msg, success); }); diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 4409bf10e155..1d4b45f3f435 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -3153,7 +3153,8 @@ pref("image.mem.min_discard_timeout_ms", 10000); // WebGL prefs pref("webgl.enabled_for_all_sites", false); pref("webgl.shader_validator", true); -pref("webgl.software_render", false); +pref("webgl.force_osmesa", false); +pref("webgl.mochitest_native_gl", false); pref("webgl.osmesalib", ""); #ifdef XP_WIN