Browse Source

tick and tock;

bjorn 6 years ago
parent
commit
dd0c9ec927
4 changed files with 366 additions and 1362 deletions
  1. 306 1362
      api/init.lua
  2. 9 0
      api/lovr/graphics/getStats.lua
  3. 26 0
      api/lovr/graphics/tick.lua
  4. 25 0
      api/lovr/graphics/tock.lua

File diff suppressed because it is too large
+ 306 - 1362
api/init.lua


+ 9 - 0
api/lovr/graphics/getStats.lua

@@ -18,6 +18,15 @@ return {
           name = 'shaderswitches',
           name = 'shaderswitches',
           type = 'number',
           type = 'number',
           description = 'The number of times the shader has been switched.'
           description = 'The number of times the shader has been switched.'
+        },
+        {
+          name = 'timers',
+          type = 'table',
+          description = [[
+            A table containing the timer results from calls to `lovr.graphics.tick` and
+            `lovr.graphics.tock`.  The results are unreliable and may be `nil`.  The units are in
+            seconds.
+          ]]
         }
         }
       }
       }
     }
     }

+ 26 - 0
api/lovr/graphics/tick.lua

@@ -0,0 +1,26 @@
+return {
+  tag = 'window',
+  summary = 'Start a timer on the GPU.',
+  description = 'Starts a named timer on the GPU, which can be stopped using `lovr.graphics.tock`.',
+  arguments = {
+    {
+      name = 'label',
+      type = 'string',
+      description = 'The name of the timer'
+    }
+  },
+  returns = {},
+  notes = [[
+    The timer can be stopped by calling `lovr.graphics.tock` using the same name.  All drawing
+    commands between the tick and the tock will be timed.  It is not possible to nest calls to tick
+    and tock.
+
+    The amount of time elapsed can be accessed from the `timers` field of `lovr.graphics.getStats`.
+    Note that the results are delayed (because the GPU runs asynchronously), and may be `nil` if
+    they are unavailable.
+  ]],
+  related = {
+    'lovr.graphics.tock',
+    'lovr.graphics.getStats'
+  }
+}

+ 25 - 0
api/lovr/graphics/tock.lua

@@ -0,0 +1,25 @@
+return {
+  tag = 'window',
+  summary = 'Stop a timer on the GPU.',
+  description = 'Stops a named timer on the GPU, previously started with `lovr.graphics.tick`.',
+  arguments = {
+    {
+      name = 'label',
+      type = 'string',
+      description = 'The name of the timer.'
+    }
+  },
+  returns = {},
+  notes = [[
+    All drawing commands between the tick and the tock will be timed.  It is not possible to nest
+    calls to tick and tock.
+
+    The amount of time elapsed can be accessed from the `timers` field of `lovr.graphics.getStats`.
+    Note that the results are delayed (because the GPU runs asynchronously), and may be `nil` if
+    they are unavailable.
+  ]],
+  related = {
+    'lovr.graphics.tick',
+    'lovr.graphics.getStats'
+  }
+}

Some files were not shown because too many files changed in this diff