Last active
April 5, 2023 00:53
-
-
Save mattebb/69aa7c504e292761229ce78fb4db02c1 to your computer and use it in GitHub Desktop.
Revisions
-
mattebb revised this gist
Apr 5, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // assembled from some stackoverflow answers const start = performance.now(); // Draw the fullscreen quad -
mattebb created this gist
Apr 5, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ const start = performance.now(); // Draw the fullscreen quad twgl.drawBufferInfo(gl, quad_bufferInfo); let sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0); checkSync = () => { const status = gl.clientWaitSync(sync, 0, 0); switch (status) { case gl.TIMEOUT_EXPIRED: return setTimeout(checkSync); case gl.WAIT_FAILED: throw new Error('should never get here'); default: gl.deleteSync(sync); const duration = (performance.now() - start); console.log(`finished rendering in ${duration.toFixed(1)}ms`); // trigger preview capture now that GL has finished rendering triggerPreview(); } } setTimeout(checkSync);