getStats.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. return {
  2. tag = 'pass-misc',
  3. summary = 'Get statistics for the Pass.',
  4. description = 'Returns statistics for the Pass.',
  5. arguments = {},
  6. returns = {
  7. stats = {
  8. type = 'table',
  9. description = 'A table with statistics.',
  10. table = {
  11. {
  12. name = 'draws',
  13. type = 'number',
  14. description = 'The number of draws added to the Pass.'
  15. },
  16. {
  17. name = 'computes',
  18. type = 'number',
  19. description = 'The number of compute calls added to the Pass.'
  20. },
  21. {
  22. name = 'drawsCulled',
  23. type = 'number',
  24. description = [[
  25. The number of draw calls that were culled the last time the Pass was submitted.
  26. ]]
  27. },
  28. {
  29. name = 'cpuMemoryReserved',
  30. type = 'number',
  31. description = 'The amount of CPU memory the Pass has reserved, in bytes.'
  32. },
  33. {
  34. name = 'cpuMemoryUsed',
  35. type = 'number',
  36. description = 'The amount of CPU memory the Pass is currently using, in bytes.'
  37. },
  38. {
  39. name = 'submitTime',
  40. type = 'number',
  41. description = [[
  42. The amount of time taken on the CPU to submit the Pass the last time it was submitted,
  43. in seconds. Only updates when timing stats have been enabled with
  44. `lovr.graphics.setTimingEnabled`, and has a few frames of delay.
  45. ]]
  46. },
  47. {
  48. name = 'gpuTime',
  49. type = 'number',
  50. description = [[
  51. The amount of time taken on the GPU to process the Pass, in seconds. Only updates when
  52. timing stats have been enabled with `lovr.graphics.setTimingEnabled`, and has a few
  53. frames of delay.
  54. ]]
  55. }
  56. }
  57. }
  58. },
  59. variants = {
  60. {
  61. arguments = {},
  62. returns = { 'stats' }
  63. }
  64. },
  65. example = {
  66. description = 'See how long it takes the GPU to render a cube.',
  67. code = [[
  68. lovr.graphics.setTimingEnabled(true)
  69. function lovr.draw(pass)
  70. pass:cube(0, 1.7, -1, .5, lovr.timer.getTime() * .2, 0, 1, 0)
  71. local stats = pass:getStats()
  72. print(('Rendering a cube takes %f microseconds'):format(stats.gpuTime * 1e6))
  73. end
  74. ]]
  75. },
  76. related = {
  77. 'lovr.graphics.isTimingEnabled',
  78. 'lovr.graphics.setTimingEnabled',
  79. 'Pass:setViewCull'
  80. }
  81. }