瀏覽代碼

Pass docs;

bjorn 3 年之前
父節點
當前提交
56045e5674

+ 1 - 0
api/lovr/graphics/Pass/getClear.lua

@@ -1,4 +1,5 @@
 return {
 return {
+  tag = 'pass-misc',
   summary = 'Return the clear values of the Pass.',
   summary = 'Return the clear values of the Pass.',
   description = 'Returns the clear values of the pass.',
   description = 'Returns the clear values of the pass.',
   arguments = {},
   arguments = {},

+ 1 - 0
api/lovr/graphics/Pass/getDimensions.lua

@@ -1,4 +1,5 @@
 return {
 return {
+  tag = 'pass-misc',
   summary = 'Get the texture dimensions of a render pass.',
   summary = 'Get the texture dimensions of a render pass.',
   description = 'Returns the dimensions of the textures attached to the render pass.',
   description = 'Returns the dimensions of the textures attached to the render pass.',
   arguments = {},
   arguments = {},

+ 1 - 0
api/lovr/graphics/Pass/getSampleCount.lua

@@ -1,4 +1,5 @@
 return {
 return {
+  tag = 'pass-misc',
   summary = 'Get the antialiasing setting of a render pass.',
   summary = 'Get the antialiasing setting of a render pass.',
   description = 'Returns the antialiasing setting of a render pass.',
   description = 'Returns the antialiasing setting of a render pass.',
   arguments = {},
   arguments = {},

+ 1 - 0
api/lovr/graphics/Pass/getTarget.lua

@@ -1,4 +1,5 @@
 return {
 return {
+  tag = 'pass-misc',
   summary = 'Get the textures a render pass is rendering to.',
   summary = 'Get the textures a render pass is rendering to.',
   description = 'Returns the textures a render pass is rendering to.',
   description = 'Returns the textures a render pass is rendering to.',
   arguments = {},
   arguments = {},

+ 1 - 0
api/lovr/graphics/Pass/getType.lua

@@ -1,4 +1,5 @@
 return {
 return {
+  tag = 'pass-misc',
   summary = 'Get the type of the Pass.',
   summary = 'Get the type of the Pass.',
   description = [[
   description = [[
     Returns the type of the pass (render, compute, or transfer).  The type restricts what kinds of
     Returns the type of the pass (render, compute, or transfer).  The type restricts what kinds of

+ 1 - 0
api/lovr/graphics/Pass/getViewCount.lua

@@ -1,4 +1,5 @@
 return {
 return {
+  tag = 'camera',
   summary = 'Returns the view count of a render pass.',
   summary = 'Returns the view count of a render pass.',
   description = [[
   description = [[
     Returns the view count of a render pass.  This is the layer count of the textures it is
     Returns the view count of a render pass.  This is the layer count of the textures it is

+ 1 - 0
api/lovr/graphics/Pass/getWidth.lua

@@ -1,4 +1,5 @@
 return {
 return {
+  tag = 'pass-misc',
   summary = 'Get the texture width of a render pass.',
   summary = 'Get the texture width of a render pass.',
   description = 'Returns the width of the textures attached to the render pass.',
   description = 'Returns the width of the textures attached to the render pass.',
   arguments = {},
   arguments = {},

+ 16 - 7
api/lovr/graphics/Pass/init.lua

@@ -20,32 +20,41 @@ return {
     {
     {
       name = 'Drawing',
       name = 'Drawing',
       tag = 'drawing',
       tag = 'drawing',
-      description = 'TODO'
+      description = 'Draw objects and shapes.'
     },
     },
     {
     {
       name = 'Coordinate System',
       name = 'Coordinate System',
       tag = 'transform',
       tag = 'transform',
-      description = 'TODO'
+      description = 'Manipulate the 3D coordinate system.'
     },
     },
     {
     {
       name = 'Render States',
       name = 'Render States',
       tag = 'pipeline',
       tag = 'pipeline',
-      description = 'TODO'
+      description = 'Set render states that change the way drawing happens.'
     },
     },
     {
     {
-      name = 'Shader Inputs',
+      name = 'Shader Variables',
       tag = 'shader-inputs',
       tag = 'shader-inputs',
-      description = 'TODO'
     },
     },
     {
     {
       name = 'Camera',
       name = 'Camera',
       tag = 'camera',
       tag = 'camera',
-      description = 'TODO'
     },
     },
     {
     {
       name = 'Compute',
       name = 'Compute',
       tag = 'compute',
       tag = 'compute',
-      description = 'TODO'
+    },
+    {
+      name = 'Transfers',
+      tag = 'transfer'
+    },
+    {
+      name = 'Tallies',
+      tag = 'tallies'
+    },
+    {
+      name = 'Miscellaneous',
+      tag = 'pass-misc'
     }
     }
   }
   }
 }
 }

+ 8 - 3
api/lovr/graphics/Pass/line.lua

@@ -1,7 +1,10 @@
 return {
 return {
   tag = 'drawing',
   tag = 'drawing',
   summary = 'Draw a line.',
   summary = 'Draw a line.',
-  description = 'TODO',
+  description = [[
+    Draws a line between points.  `Pass:mesh` can also be used to draw line segments using the
+    `line` `MeshMode`.
+  ]],
   arguments = {
   arguments = {
     x1 = {
     x1 = {
       type = 'number',
       type = 'number',
@@ -29,7 +32,9 @@ return {
     },
     },
     t = {
     t = {
       type = 'table',
       type = 'table',
-      description = 'A table of numbers or Vec3 objects (not both) representing points of the line.'
+      description = [[
+        A table of numbers or `Vec3` objects (not a mix) representing points of the line.
+      ]]
     },
     },
     v1 = {
     v1 = {
       type = 'Vec3',
       type = 'Vec3',
@@ -59,5 +64,5 @@ return {
       returns = {}
       returns = {}
     }
     }
   },
   },
-  notes = 'TODO'
+  notes = 'There is currently no way to increase line thickness.'
 }
 }

+ 38 - 12
api/lovr/graphics/Pass/mesh.lua

@@ -1,36 +1,39 @@
 return {
 return {
   tag = 'drawing',
   tag = 'drawing',
   summary = 'Draw a mesh.',
   summary = 'Draw a mesh.',
-  description = 'TODO',
+  description = 'Draws a mesh.',
   arguments = {
   arguments = {
     vertices = {
     vertices = {
       type = 'Buffer',
       type = 'Buffer',
       default = 'nil',
       default = 'nil',
-      description = 'TODO'
+      description = 'The buffer containing the vertices to draw.'
     },
     },
     indices = {
     indices = {
       type = 'Buffer',
       type = 'Buffer',
-      description = 'TODO'
+      description = 'The buffer containing the vertex indices to draw.'
     },
     },
     draws = {
     draws = {
       type = 'Buffer',
       type = 'Buffer',
-      description = 'TODO'
+      description = 'The buffer containing indirect draw commands.'
     },
     },
     drawcount = {
     drawcount = {
       type = 'number',
       type = 'number',
-      description = 'TODO'
+      description = 'The number of indirect draws to draw.'
     },
     },
     offset = {
     offset = {
       type = 'number',
       type = 'number',
-      description = 'TODO'
+      description = 'A byte offset into the draw buffer.'
     },
     },
     stride = {
     stride = {
       type = 'number',
       type = 'number',
-      description = 'TODO'
+      description = 'The number of bytes between consecutive elements in the draw buffer.'
     },
     },
     transform = {
     transform = {
-      type = 'transform',
-      description = 'The transform to apply to the mesh.'
+      type = 'Mat4',
+      description = [[
+        The transform to apply to the mesh.  Can also be provided as a position, 1-component scale,
+        and rotation using a combination of `Vectors` and numbers.
+      ]]
     },
     },
     start = {
     start = {
       type = 'number',
       type = 'number',
@@ -49,26 +52,49 @@ return {
         the Buffers and `start`).
         the Buffers and `start`).
       ]]
       ]]
     },
     },
+    vertexcount = {
+      type = 'number',
+      description = 'The number of vertices or indices to draw.'
+    },
     instances = {
     instances = {
       type = 'number',
       type = 'number',
       default = '1',
       default = '1',
       description = 'The number of copies of the mesh to render.'
       description = 'The number of copies of the mesh to render.'
+    },
+    base = {
+      type = 'number',
+      default = 'A base offset to apply to vertex indices.'
     }
     }
   },
   },
   returns = {},
   returns = {},
   variants = {
   variants = {
     {
     {
-      arguments = { 'vertices', 'transform', 'start', 'count', 'instances' },
+      arguments = { 'vertices', 'transform', 'start', 'count', 'instances', 'base' },
       returns = {}
       returns = {}
     },
     },
     {
     {
-      arguments = { 'vertices', 'indices', 'transform', 'start', 'count', 'instances' },
+      arguments = { 'vertices', 'indices', 'transform', 'start', 'count', 'instances', 'base' },
       returns = {}
       returns = {}
     },
     },
     {
     {
       arguments = { 'vertices', 'indices', 'draws', 'drawcount', 'offset', 'stride' },
       arguments = { 'vertices', 'indices', 'draws', 'drawcount', 'offset', 'stride' },
       returns = {}
       returns = {}
+    },
+    {
+      arguments = { 'vertexcount', 'transform' },
+      returns = {}
+    },
+    {
+      arguments = { 'vertexcount', 'indices', 'transform' },
+      returns = {}
     }
     }
   },
   },
-  notes = 'TODO'
+  notes = [[
+    The index buffer defines the order the vertices are drawn in.  It can be used to reorder, reuse,
+    or omit vertices from the mesh.
+
+    The active `MeshMode` controls whether the vertices are drawn as points, lines, or triangles.
+
+    The active `Material` is applied to the mesh.
+  ]]
 }
 }

+ 5 - 5
api/lovr/graphics/Pass/mipmap.lua

@@ -1,21 +1,21 @@
 return {
 return {
   tag = 'transfer',
   tag = 'transfer',
   summary = 'Generate mipmaps for a texture.',
   summary = 'Generate mipmaps for a texture.',
-  description = 'TODO',
+  description = 'Generates mipmaps for a texture.',
   arguments = {
   arguments = {
     texture = {
     texture = {
       type = 'Texture',
       type = 'Texture',
-      description = 'TODO'
+      description = 'The texture to mipmap.'
     },
     },
     base = {
     base = {
       type = 'number',
       type = 'number',
-      default = '0',
-      description = 'TODO'
+      default = '1',
+      description = 'The index of the mipmap used to generate the remaining mipmaps.'
     },
     },
     count = {
     count = {
       type = 'number',
       type = 'number',
       default = 'nil',
       default = 'nil',
-      description = 'TODO'
+      description = 'The number of mipmaps to generate.  If nil, generates the remaining mipmaps.'
     }
     }
   },
   },
   returns = {},
   returns = {},

+ 1 - 1
api/lovr/graphics/Pass/origin.lua

@@ -1,7 +1,7 @@
 return {
 return {
   tag = 'transform',
   tag = 'transform',
   summary = 'Reset the transform to the origin.',
   summary = 'Reset the transform to the origin.',
-  description = 'TODO',
+  description = 'Resets the transform back to the origin.',
   arguments = {},
   arguments = {},
   returns = {},
   returns = {},
   variants = {
   variants = {

+ 9 - 7
api/lovr/graphics/Pass/plane.lua

@@ -1,11 +1,14 @@
 return {
 return {
   tag = 'drawing',
   tag = 'drawing',
-  summary = 'Draw a flat plane.',
-  description = 'TODO',
+  summary = 'Draw a plane.',
+  description = 'Draws a plane.',
   arguments = {
   arguments = {
     transform = {
     transform = {
-      type = 'Transform2',
-      description = 'The transform to apply to the plane.'
+      type = 'Mat4',
+      description = [[
+        The transform of the plane.  Can also be provided as a position, 2-component scale, and
+        rotation using a combination of `Vectors`, and numbers.
+      ]]
     },
     },
     style = {
     style = {
       type = 'DrawStyle',
       type = 'DrawStyle',
@@ -19,7 +22,7 @@ return {
     },
     },
     rows = {
     rows = {
       type = 'number',
       type = 'number',
-      default = 'cols',
+      default = 'columns',
       description = 'The number of vertical segments in the plane.'
       description = 'The number of vertical segments in the plane.'
     }
     }
   },
   },
@@ -29,6 +32,5 @@ return {
       arguments = { 'transform', 'style', 'columns', 'rows' },
       arguments = { 'transform', 'style', 'columns', 'rows' },
       returns = {}
       returns = {}
     }
     }
-  },
-  notes = 'TODO'
+  }
 }
 }

+ 5 - 2
api/lovr/graphics/Pass/points.lua

@@ -1,7 +1,7 @@
 return {
 return {
   tag = 'drawing',
   tag = 'drawing',
   summary = 'Draw points.',
   summary = 'Draw points.',
-  description = 'TODO',
+  description = 'Draws points.  `Pass:mesh` can also be used to draw points using a `Buffer`.',
   arguments = {
   arguments = {
     x = {
     x = {
       type = 'number',
       type = 'number',
@@ -43,5 +43,8 @@ return {
       returns = {}
       returns = {}
     }
     }
   },
   },
-  notes = 'TODO'
+  notes = [[
+    To change the size of points, set the `pointSize` shader flag in `lovr.graphics.newShader` or
+    write to the `PointSize` variable in the vertex shader.  Points are always the same size on the screen, regardless of distance, and the units are in pixels.
+  ]]
 }
 }

+ 7 - 4
api/lovr/graphics/Pass/pop.lua

@@ -1,7 +1,10 @@
 return {
 return {
   tag = 'transform',
   tag = 'transform',
-  summary = 'Restore original state from a stack.',
-  description = 'TODO',
+  summary = 'Pop one of the stacks.',
+  description = [[
+    Pops the transform or render state stack, restoring it to the state it was in when it was last
+    pushed.
+  ]],
   arguments = {
   arguments = {
     stack = {
     stack = {
       type = 'StackType',
       type = 'StackType',
@@ -17,10 +20,10 @@ return {
     }
     }
   },
   },
   notes = [[
   notes = [[
-    TODO stack balancing/error
+    If a stack is popped without a corresponding push, the stack "underflows" which causes an error.
   ]],
   ]],
   related = {
   related = {
-    'lovr.graphics.push',
+    'Pass:push',
     'StackType'
     'StackType'
   }
   }
 }
 }

+ 8 - 3
api/lovr/graphics/Pass/push.lua

@@ -1,7 +1,11 @@
 return {
 return {
   tag = 'transform',
   tag = 'transform',
   summary = 'Push state onto a stack.',
   summary = 'Push state onto a stack.',
-  description = 'TODO',
+  description = [[
+    Saves a copy of the transform or render states.  Further changes can be made to the transform or
+    render states, and afterwards `Pass:pop` can be used to restore the original state.  Pushes and
+    pops can be nested, but it's an error to pop without a corresponding push.
+  ]],
   arguments = {
   arguments = {
     stack = {
     stack = {
       type = 'StackType',
       type = 'StackType',
@@ -17,10 +21,11 @@ return {
     }
     }
   },
   },
   notes = [[
   notes = [[
-    TODO stack balancing/error
+    Each stack has a limit of the number of copies it can store.  There can be 16 transforms and 4
+    render states saved.
   ]],
   ]],
   related = {
   related = {
-    'lovr.graphics.pop',
+    'Pass:pop',
     'StackType'
     'StackType'
   }
   }
 }
 }

+ 21 - 13
api/lovr/graphics/Pass/read.lua

@@ -1,63 +1,71 @@
 return {
 return {
   tag = 'transfer',
   tag = 'transfer',
   summary = 'Download data from a GPU resource.',
   summary = 'Download data from a GPU resource.',
-  description = 'TODO',
+  description = [[
+    Creates a `Readback` object which asynchronously downloads data from a `Buffer`, `Texture`, or
+    `Tally`.  The readback can be polled for completion, or, after this transfer pass is completed,
+    `Readback:wait` can be used to block until the download is complete.
+  ]],
   arguments = {
   arguments = {
     buffer = {
     buffer = {
       type = 'Buffer',
       type = 'Buffer',
-      description = 'TODO'
+      description = 'The Buffer to download data from.'
     },
     },
     texture = {
     texture = {
       type = 'Texture',
       type = 'Texture',
-      description = 'TODO'
+      description = 'The Texture to download data from.'
     },
     },
     tally = {
     tally = {
       type = 'Tally',
       type = 'Tally',
-      description = 'TODO'
+      description = 'The Tally to download data from.'
     },
     },
     index = {
     index = {
       type = 'number',
       type = 'number',
-      description = 'TODO'
+      description = 'The index of the first item to download.'
     },
     },
     count = {
     count = {
       type = 'number',
       type = 'number',
-      description = 'TODO'
+      description = 'The number of items to download.'
     },
     },
     x = {
     x = {
       type = 'number',
       type = 'number',
       default = '0',
       default = '0',
-      description = 'TODO'
+      description = 'The x offset of the region to download.'
     },
     },
     y = {
     y = {
       type = 'number',
       type = 'number',
       default = '0',
       default = '0',
-      description = 'TODO'
+      description = 'The y offset of the region to download.'
     },
     },
     layer = {
     layer = {
       type = 'number',
       type = 'number',
       default = '1',
       default = '1',
-      description = 'TODO'
+      description = 'The index of the layer to download.'
     },
     },
     level = {
     level = {
       type = 'number',
       type = 'number',
       default = '1',
       default = '1',
-      description = 'TODO'
+      description = 'The index of the mipmap level to download.'
     },
     },
     width = {
     width = {
       type = 'number',
       type = 'number',
       default = 'nil',
       default = 'nil',
-      description = 'TODO'
+      description = [[
+        The width of the region to download.  If nil, the region will be as wide as possible.
+      ]]
     },
     },
     height = {
     height = {
       type = 'number',
       type = 'number',
       default = 'nil',
       default = 'nil',
-      description = 'TODO'
+      description = [[
+        The height of the region to download.  If nil, the region will be as tall as possible.
+      ]]
     }
     }
   },
   },
   returns = {
   returns = {
     readback = {
     readback = {
       type = 'Readback',
       type = 'Readback',
-      description = 'TODO'
+      description = 'The new readback.'
     }
     }
   },
   },
   variants = {
   variants = {

+ 10 - 35
api/lovr/graphics/Pass/rotate.lua

@@ -1,51 +1,26 @@
 return {
 return {
   tag = 'transform',
   tag = 'transform',
   summary = 'Rotate the coordinate system.',
   summary = 'Rotate the coordinate system.',
-  description = 'TODO',
+  description = 'Rotates the coordinate system.',
   arguments = {
   arguments = {
-    angle = {
-      type = 'number',
-      default = '0',
-      description = 'The number of radians to rotate around the axis of rotation.'
-    },
-    ax = {
-      type = 'number',
-      default = '0',
-      description = 'The x component of the axis of rotation.'
-    },
-    ay = {
-      type = 'number',
-      default = '1',
-      description = 'The y component of the axis of rotation.'
-    },
-    az = {
-      type = 'number',
-      default = '0',
-      description = 'The z component of the axis of rotation.'
-    },
-    q = {
+    rotation = {
       type = 'Quat',
       type = 'Quat',
-      description = 'A quaternion containing the rotation to apply.'
+      description = [[
+        A quaternion containing the rotation to apply.  Can also be provided as 4 numbers in
+        angle-axis representation.
+      ]]
     }
     }
   },
   },
   returns = {},
   returns = {},
   variants = {
   variants = {
     {
     {
-      arguments = { 'angle', 'ax', 'ay', 'az' },
-      returns = {}
-    },
-    {
-      arguments = { 'q' },
+      arguments = { 'rotation' },
       returns = {}
       returns = {}
     }
     }
   },
   },
-  notes = [[
-    TODO axis does not need to be normalized
-    TODO order matters
-  ]],
   related = {
   related = {
-    'lovr.graphics.translate',
-    'lovr.graphics.scale',
-    'lovr.graphics.transform'
+    'Pass:translate',
+    'Pass:scale',
+    'Pass:transform'
   }
   }
 }
 }

+ 9 - 26
api/lovr/graphics/Pass/scale.lua

@@ -1,42 +1,25 @@
 return {
 return {
   tag = 'transform',
   tag = 'transform',
   summary = 'Scale the coordinate system.',
   summary = 'Scale the coordinate system.',
-  description = 'TODO',
+  description = 'Scales the coordinate system.',
   arguments = {
   arguments = {
-    x = {
-      type = 'number',
-      default = '1',
-      description = 'The amount to scale the x axis.'
-    },
-    y = {
-      type = 'number',
-      default = '1',
-      description = 'The amount to scale the y axis.'
-    },
-    z = {
-      type = 'number',
-      default = '1',
-      description = 'The amount to scale the z axis.'
-    },
-    v = {
+    scale = {
       type = 'Vec3',
       type = 'Vec3',
-      description = 'A vector to translate by.'
+      description = [[
+        The scale to apply to the coordinate system.  Can also be provided as 1 or 3 numbers.
+      ]]
     }
     }
   },
   },
   returns = {},
   returns = {},
   variants = {
   variants = {
     {
     {
-      arguments = { 'x', 'y', 'z' },
-      returns = {}
-    },
-    {
-      arguments = { 'v' },
+      arguments = { 'scale' },
       returns = {}
       returns = {}
     }
     }
   },
   },
   related = {
   related = {
-    'lovr.graphics.translate',
-    'lovr.graphics.rotate',
-    'lovr.graphics.transform'
+    'Pass:translate',
+    'Pass:rotate',
+    'Pass:transform'
   }
   }
 }
 }

+ 1 - 0
api/lovr/graphics/Pass/send.lua

@@ -1,4 +1,5 @@
 return {
 return {
+  tag = 'shader-inputs',
   summary = 'Set the value of a shader variable.',
   summary = 'Set the value of a shader variable.',
   description = 'TODO',
   description = 'TODO',
   arguments = {
   arguments = {

+ 1 - 1
api/lovr/graphics/Pass/setMeshMode.lua

@@ -1,6 +1,6 @@
 return {
 return {
   tag = 'pipeline',
   tag = 'pipeline',
-  summary = 'Change whether mesh vertices are drawn as points, lines, or triangles.',
+  summary = 'Change the way vertices are connected together.',
   description = 'TODO',
   description = 'TODO',
   arguments = {
   arguments = {
     mode = {
     mode = {

+ 1 - 1
api/lovr/graphics/Pass/tick.lua

@@ -1,5 +1,5 @@
 return {
 return {
-  tag = 'transfer',
+  tag = 'tallies',
   summary = 'Begin measuring GPU counters.',
   summary = 'Begin measuring GPU counters.',
   description = 'TODO',
   description = 'TODO',
   arguments = {
   arguments = {

+ 1 - 1
api/lovr/graphics/Pass/tock.lua

@@ -1,5 +1,5 @@
 return {
 return {
-  tag = 'transfer',
+  tag = 'tallies',
   summary = 'Stop measuring GPU counters.',
   summary = 'Stop measuring GPU counters.',
   description = 'TODO',
   description = 'TODO',
   arguments = {
   arguments = {