Bug 1255283. Improve the correctness of EXT_disjoint_timer_query test. r=jgilbert
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Fri, 11 Mar 2016 17:59:14 +0800
changeset 288262 f12f057ff9773714f2d2cb2c34385d0f21ab518c
parent 288229 89cfc24de8501a471b6fab892c6674645f6fce60
child 288263 406908b6e0157ae8a26aaaf518b3d445f0f86322
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1255283
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1255283. Improve the correctness of EXT_disjoint_timer_query test. r=jgilbert This is needed for us to pass on windows. There are two main changes: 1. Spin the event loop before asking for availability 2. Only test TIMESTAMP_EXT if it is supported. (It's not with D3D11)
dom/canvas/test/webgl-mochitest/test_webgl_disjoint_timer_query.html
--- a/dom/canvas/test/webgl-mochitest/test_webgl_disjoint_timer_query.html
+++ b/dom/canvas/test/webgl-mochitest/test_webgl_disjoint_timer_query.html
@@ -7,16 +7,21 @@
 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
 <script src="webgl-util.js"></script>
 </head>
 <body>
 <canvas id="c"></canvas>
 
 <script>
 
+function defer(f)
+{
+    setTimeout(f, 0);
+}
+
 function doTest() {
   var gl = WebGLUtil.getWebGL('c', true);
   var ext = gl.getExtension('EXT_disjoint_timer_query');
   if (!ext) {
     ok(true, "EXT_disjoint_timer_query may be unsupported.");
     SimpleTest.finish();
     return;
   }
@@ -31,34 +36,46 @@ function doTest() {
   ext.beginQueryEXT(ext.TIME_ELAPSED_EXT, elapsedQuery);
   is(ext.getQueryEXT(ext.TIME_ELAPSED_EXT, ext.CURRENT_QUERY_EXT), elapsedQuery,
      "Query is active after beginQueryEXT.");
   ext.endQueryEXT(ext.TIME_ELAPSED_EXT);
   gl.flush();
 
   ok(!ext.getQueryEXT(ext.TIME_ELAPSED_EXT, ext.CURRENT_QUERY_EXT),
      "Query is inactive after endQueryEXT.");
-  ok(ext.getQueryObjectEXT(elapsedQuery, ext.QUERY_RESULT_AVAILABLE_EXT),
-     "Time elapsed query is available immediately after flush.");
+
+  defer(function() {
+    ok(ext.getQueryObjectEXT(elapsedQuery, ext.QUERY_RESULT_AVAILABLE_EXT),
+       "Time elapsed query is available immediately after flush and event loop tick.");
 
-  ext.deleteQueryEXT(elapsedQuery);
-  ok(!ext.isQueryEXT(elapsedQuery), "Query is no longer valid after deletion.");
+    ext.deleteQueryEXT(elapsedQuery);
+    ok(!ext.isQueryEXT(elapsedQuery), "Query is no longer valid after deletion.");
+
+    ok(ext.getQueryEXT(ext.TIME_ELAPSED_EXT, ext.QUERY_COUNTER_BITS_EXT) >= 30,
+       "Time elapsed must be at least 30 bits to hold at least 1 second of timing.");
 
-  var timestampQuery = ext.createQueryEXT();
-  ext.queryCounterEXT(timestampQuery, ext.TIMESTAMP_EXT);
-  gl.flush();
-  ok(ext.getQueryObjectEXT(timestampQuery, ext.QUERY_RESULT_AVAILABLE_EXT),
-     "Timestamp query should be available immediately after flush.");
+    // D3D11 doesn't support TIMESTAMP_EXT so check for it before using it.
+    if (ext.getQueryEXT(ext.TIMESTAMP_EXT, ext.QUERY_COUNTER_BITS_EXT) > 0) {
+        var timestampQuery = ext.createQueryEXT();
+        ext.queryCounterEXT(timestampQuery, ext.TIMESTAMP_EXT);
+        gl.flush();
+        defer(function() {
+          ok(ext.getQueryObjectEXT(timestampQuery, ext.QUERY_RESULT_AVAILABLE_EXT),
+          "Timestamp query should be available immediately after flush and event loop tick.");
 
-  ok(ext.getQueryEXT(ext.TIMESTAMP_EXT, ext.QUERY_COUNTER_BITS_EXT) >= 30,
-     "Timestamp must be at least 30 bits to hold at least 1 second of timing.");
-  ok(ext.getQueryEXT(ext.TIME_ELAPSED_EXT, ext.QUERY_COUNTER_BITS_EXT) >= 30,
-     "Time elapsed must be at least 30 bits to hold at least 1 second of timing.");
+          ok(ext.getQueryEXT(ext.TIMESTAMP_EXT, ext.QUERY_COUNTER_BITS_EXT) >= 30,
+          "Time elapsed must be at least 30 bits to hold at least 1 second of timing.");
+
+          SimpleTest.finish();
 
-  SimpleTest.finish();
+          });
+    } else {
+      SimpleTest.finish();
+    }
+  });
 }
 
 SimpleTest.waitForExplicitFinish();
 
 SpecialPowers.pushPrefEnv({"set": [['webgl.enable-draft-extensions', true]]}, doTest);
 
 </script>
 </body>