getLimits.lua 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. return {
  2. tag = 'graphics-misc',
  3. summary = 'Get the limits of the current GPU.',
  4. description = 'Returns limits of the current GPU.',
  5. arguments = {},
  6. returns = {
  7. limits = {
  8. type = 'table',
  9. description = '',
  10. table = {
  11. {
  12. name = 'textureSize2D',
  13. type = 'number',
  14. description = 'The maximum width/height of `2d` and `array` textures.'
  15. },
  16. {
  17. name = 'textureSize3D',
  18. type = 'number',
  19. description = 'The maximum width/height/depth of `3d` textures.'
  20. },
  21. {
  22. name = 'textureSizeCube',
  23. type = 'number',
  24. description = 'The maximum width/height of `cube` textures.'
  25. },
  26. {
  27. name = 'textureLayers',
  28. type = 'number',
  29. description = 'The maximum depth of `array` textures.'
  30. },
  31. {
  32. name = 'renderSize',
  33. type = 'table',
  34. description = [[
  35. The maximum width, height, and layer count of a texture (or texture view) used as a
  36. render target.
  37. ]]
  38. },
  39. {
  40. name = 'uniformBuffersPerStage',
  41. type = 'number',
  42. description = 'The maximum number of uniform buffers in a shader stage.'
  43. },
  44. {
  45. name = 'storageBuffersPerStage',
  46. type = 'number',
  47. description = 'The maximum number of storage buffers in a shader stage.'
  48. },
  49. {
  50. name = 'sampledTexturesPerStage',
  51. type = 'number',
  52. description = 'The maximum number of sampled textures in a shader stage.'
  53. },
  54. {
  55. name = 'storageTexturesPerStage',
  56. type = 'number',
  57. description = 'The maximum number of storage textures in a shader stage.'
  58. },
  59. {
  60. name = 'samplersPerStage',
  61. type = 'number',
  62. description = 'The maximum number of samplers in a shader stage.'
  63. },
  64. {
  65. name = 'resourcesPerShader',
  66. type = 'number',
  67. description = [[
  68. The maximum combined number of buffers, textures, and sampler variables in a Shader.
  69. ]]
  70. },
  71. {
  72. name = 'uniformBufferRange',
  73. type = 'number',
  74. description = [[
  75. The maximum range of bytes that can be bound to a uniform buffer in a shader.
  76. ]]
  77. },
  78. {
  79. name = 'storageBufferRange',
  80. type = 'number',
  81. description = [[
  82. The maximum range of bytes that can be bound to a storage buffer in a shader.
  83. ]]
  84. },
  85. {
  86. name = 'uniformBufferAlign',
  87. type = 'number',
  88. description = [[
  89. When binding a range of bytes to a uniform buffer binding in a shader, the byte offset
  90. of the range must be a multiple of this limit's value.
  91. ]]
  92. },
  93. {
  94. name = 'storageBufferAlign',
  95. type = 'number',
  96. description = [[
  97. When binding a range of bytes to a storage buffer binding in a shader, the byte offset
  98. of the range must be a multiple of this limit's value.
  99. ]]
  100. },
  101. {
  102. name = 'vertexAttributes',
  103. type = 'number',
  104. description = 'The maximum number of input attributes in a vertex shader.'
  105. },
  106. {
  107. name = 'vertexBufferStride',
  108. type = 'number',
  109. description = 'The maximum stride of a buffer used as a vertex buffer, in bytes.'
  110. },
  111. {
  112. name = 'vertexShaderOutputs',
  113. type = 'number',
  114. description = 'The maximum number of components output from a vertex shader.'
  115. },
  116. {
  117. name = 'clipDistances',
  118. type = 'number',
  119. description = 'The maximum number of clipping planes declared by a shader.'
  120. },
  121. {
  122. name = 'cullDistances',
  123. type = 'number',
  124. description = 'The maximum number of cull distances declared by a shader.'
  125. },
  126. {
  127. name = 'clipAndCullDistances',
  128. type = 'number',
  129. description = [[
  130. The maximum number of clipping planes and cull distances declared by a shader.
  131. ]]
  132. },
  133. {
  134. name = 'workgroupCount',
  135. type = 'table',
  136. description = 'The maximum values of `x`, `y`, and `z` in `Pass:compute`.'
  137. },
  138. {
  139. name = 'workgroupSize',
  140. type = 'table',
  141. description = [[
  142. The maximum values of `local_size_x`, `local_size_y`, and `local_size_z` declared in a
  143. compute shader.
  144. ]]
  145. },
  146. {
  147. name = 'totalWorkgroupSize',
  148. type = 'number',
  149. description = [[
  150. The maximum product of `local_size_x`, `local_size_y`, and `local_size_z` in a compute
  151. shader.
  152. ]]
  153. },
  154. {
  155. name = 'computeSharedMemory',
  156. type = 'number',
  157. description = 'The maximum number of bytes used by `shared` variables in compute shaders.'
  158. },
  159. {
  160. name = 'shaderConstantSize',
  161. type = 'number',
  162. description = [[
  163. The maximum number of bytes of push constants that can be in a Shader. Push constants
  164. are shared between stages, so the stage with the largest amount of push constant data
  165. will count towards this limit.
  166. ]]
  167. },
  168. {
  169. name = 'indirectDrawCount',
  170. type = 'number',
  171. description = 'The maximum number of draws that can be issued by an indirect draw call.'
  172. },
  173. {
  174. name = 'instances',
  175. type = 'number',
  176. description = 'The maximum number of instances that can be rendered in a draw call.'
  177. },
  178. {
  179. name = 'anisotropy',
  180. type = 'number',
  181. description = [[
  182. The maximum value of the `anisotropy` parameter in `lovr.graphics.newSampler`.
  183. ]]
  184. },
  185. {
  186. name = 'pointSize',
  187. type = 'number',
  188. description = 'The maximum point size.'
  189. }
  190. }
  191. }
  192. },
  193. variants = {
  194. {
  195. arguments = {},
  196. returns = { 'limits' }
  197. }
  198. },
  199. notes = [[
  200. The limit ranges are as follows:
  201. <table>
  202. <thead>
  203. <tr>
  204. <td>Limit</td>
  205. <td>Minimum</td>
  206. <td>Maximum</td>
  207. </tr>
  208. </thead>
  209. <tbody>
  210. <tr>
  211. <td><code>textureSize2D</code></td>
  212. <td>4096</td>
  213. <td></td>
  214. </tr>
  215. <tr>
  216. <td><code>textureSize3D</code></td>
  217. <td>256</td>
  218. <td></td>
  219. </tr>
  220. <tr>
  221. <td><code>textureSizeCube</code></td>
  222. <td>4096</td>
  223. <td></td>
  224. </tr>
  225. <tr>
  226. <td><code>textureLayers</code></td>
  227. <td>256</td>
  228. <td></td>
  229. </tr>
  230. <tr>
  231. <td><code>renderSize</code></td>
  232. <td>{ 4096, 4096, 6 }</td>
  233. <td></td>
  234. </tr>
  235. <tr>
  236. <td><code>uniformBuffersPerStage</code></td>
  237. <td>9</td>
  238. <td>32*</td>
  239. </tr>
  240. <tr>
  241. <td><code>storageBuffersPerStage</code></td>
  242. <td>4</td>
  243. <td>32*</td>
  244. </tr>
  245. <tr>
  246. <td><code>sampledTexturesPerStage</code></td>
  247. <td>32</td>
  248. <td>32*</td>
  249. </tr>
  250. <tr>
  251. <td><code>storageTexturesPerStage</code></td>
  252. <td>4</td>
  253. <td>32*</td>
  254. </tr>
  255. <tr>
  256. <td><code>samplersPerStage</code></td>
  257. <td>15</td>
  258. <td>32*</td>
  259. </tr>
  260. <tr>
  261. <td><code>resourcesPerShader</code></td>
  262. <td>32</td>
  263. <td>32*</td>
  264. </tr>
  265. <tr>
  266. <td><code>uniformBufferRange</code></td>
  267. <td>65536</td>
  268. <td></td>
  269. </tr>
  270. <tr>
  271. <td><code>storageBufferRange</code></td>
  272. <td>134217728 (128MB)</td>
  273. <td>1073741824 (1GB)*</td>
  274. </tr>
  275. <tr>
  276. <td><code>uniformBufferAlign</code></td>
  277. <td></td>
  278. <td>256</td>
  279. </tr>
  280. <tr>
  281. <td><code>storageBufferAlign</code></td>
  282. <td></td>
  283. <td>64</td>
  284. </tr>
  285. <tr>
  286. <td><code>vertexAttributes</code></td>
  287. <td>16</td>
  288. <td>16*</td>
  289. </tr>
  290. <tr>
  291. <td><code>vertexBufferStride</code></td>
  292. <td>2048</td>
  293. <td>65535*</td>
  294. </tr>
  295. <tr>
  296. <td><code>vertexShaderOutputs</code></td>
  297. <td>64</td>
  298. <td></td>
  299. </tr>
  300. <tr>
  301. <td><code>clipDistances</code></td>
  302. <td>0</td>
  303. <td></td>
  304. </tr>
  305. <tr>
  306. <td><code>cullDistances</code></td>
  307. <td>0</td>
  308. <td></td>
  309. </tr>
  310. <tr>
  311. <td><code>clipAndCullDistances</code></td>
  312. <td>0</td>
  313. <td></td>
  314. </tr>
  315. <tr>
  316. <td><code>computeDispatchCount</code></td>
  317. <td>{ 65536, 65536, 65536 }</td>
  318. <td></td>
  319. </tr>
  320. <tr>
  321. <td><code>computeWorkgroupSize</code></td>
  322. <td>{ 128, 128, 64 }</td>
  323. <td></td>
  324. </tr>
  325. <tr>
  326. <td><code>computeWorkgroupVolume</code></td>
  327. <td>128</td>
  328. <td></td>
  329. </tr>
  330. <tr>
  331. <td><code>computeSharedMemory</code></td>
  332. <td>16384 (16KB)</td>
  333. <td></td>
  334. </tr>
  335. <tr>
  336. <td><code>pushConstantSize</code></td>
  337. <td>128</td>
  338. <td>256*</td>
  339. </tr>
  340. <tr>
  341. <td><code>indirectDrawCount</code></td>
  342. <td>1</td>
  343. <td></td>
  344. </tr>
  345. <tr>
  346. <td><code>instances</code></td>
  347. <td>134217727</td>
  348. <td></td>
  349. </tr>
  350. <tr>
  351. <td><code>anisotropy</code></td>
  352. <td>0.0</td>
  353. <td></td>
  354. </tr>
  355. <tr>
  356. <td><code>pointSize</code></td>
  357. <td>1.0</td>
  358. <td></td>
  359. </tr>
  360. </tbody>
  361. </table>
  362. Note: in the table above, `*` means that LÖVR itself is imposing a cap on the limit, instead of
  363. the GPU.
  364. ]],
  365. related = {
  366. 'lovr.graphics.isFormatSupported',
  367. 'lovr.graphics.getDevice',
  368. 'lovr.graphics.getFeatures'
  369. }
  370. }