Browse Source

Pass docs;

bjorn 3 năm trước cách đây
mục cha
commit
56045e5674

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

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

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

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

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

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

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

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

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

@@ -1,4 +1,5 @@
 return {
+  tag = 'pass-misc',
   summary = 'Get the type of the Pass.',
   description = [[
     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 {
+  tag = 'camera',
   summary = 'Returns the view count of a render pass.',
   description = [[
     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 {
+  tag = 'pass-misc',
   summary = 'Get the texture width of a render pass.',
   description = 'Returns the width of the textures attached to the render pass.',
   arguments = {},

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

@@ -20,32 +20,41 @@ return {
     {
       name = 'Drawing',
       tag = 'drawing',
-      description = 'TODO'
+      description = 'Draw objects and shapes.'
     },
     {
       name = 'Coordinate System',
       tag = 'transform',
-      description = 'TODO'
+      description = 'Manipulate the 3D coordinate system.'
     },
     {
       name = 'Render States',
       tag = 'pipeline',
-      description = 'TODO'
+      description = 'Set render states that change the way drawing happens.'
     },
     {
-      name = 'Shader Inputs',
+      name = 'Shader Variables',
       tag = 'shader-inputs',
-      description = 'TODO'
     },
     {
       name = 'Camera',
       tag = 'camera',
-      description = 'TODO'
     },
     {
       name = '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 {
   tag = 'drawing',
   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 = {
     x1 = {
       type = 'number',
@@ -29,7 +32,9 @@ return {
     },
     t = {
       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 = {
       type = 'Vec3',
@@ -59,5 +64,5 @@ return {
       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 {
   tag = 'drawing',
   summary = 'Draw a mesh.',
-  description = 'TODO',
+  description = 'Draws a mesh.',
   arguments = {
     vertices = {
       type = 'Buffer',
       default = 'nil',
-      description = 'TODO'
+      description = 'The buffer containing the vertices to draw.'
     },
     indices = {
       type = 'Buffer',
-      description = 'TODO'
+      description = 'The buffer containing the vertex indices to draw.'
     },
     draws = {
       type = 'Buffer',
-      description = 'TODO'
+      description = 'The buffer containing indirect draw commands.'
     },
     drawcount = {
       type = 'number',
-      description = 'TODO'
+      description = 'The number of indirect draws to draw.'
     },
     offset = {
       type = 'number',
-      description = 'TODO'
+      description = 'A byte offset into the draw buffer.'
     },
     stride = {
       type = 'number',
-      description = 'TODO'
+      description = 'The number of bytes between consecutive elements in the draw buffer.'
     },
     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 = {
       type = 'number',
@@ -49,26 +52,49 @@ return {
         the Buffers and `start`).
       ]]
     },
+    vertexcount = {
+      type = 'number',
+      description = 'The number of vertices or indices to draw.'
+    },
     instances = {
       type = 'number',
       default = '1',
       description = 'The number of copies of the mesh to render.'
+    },
+    base = {
+      type = 'number',
+      default = 'A base offset to apply to vertex indices.'
     }
   },
   returns = {},
   variants = {
     {
-      arguments = { 'vertices', 'transform', 'start', 'count', 'instances' },
+      arguments = { 'vertices', 'transform', 'start', 'count', 'instances', 'base' },
       returns = {}
     },
     {
-      arguments = { 'vertices', 'indices', 'transform', 'start', 'count', 'instances' },
+      arguments = { 'vertices', 'indices', 'transform', 'start', 'count', 'instances', 'base' },
       returns = {}
     },
     {
       arguments = { 'vertices', 'indices', 'draws', 'drawcount', 'offset', 'stride' },
       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 {
   tag = 'transfer',
   summary = 'Generate mipmaps for a texture.',
-  description = 'TODO',
+  description = 'Generates mipmaps for a texture.',
   arguments = {
     texture = {
       type = 'Texture',
-      description = 'TODO'
+      description = 'The texture to mipmap.'
     },
     base = {
       type = 'number',
-      default = '0',
-      description = 'TODO'
+      default = '1',
+      description = 'The index of the mipmap used to generate the remaining mipmaps.'
     },
     count = {
       type = 'number',
       default = 'nil',
-      description = 'TODO'
+      description = 'The number of mipmaps to generate.  If nil, generates the remaining mipmaps.'
     }
   },
   returns = {},

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

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

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

@@ -1,11 +1,14 @@
 return {
   tag = 'drawing',
-  summary = 'Draw a flat plane.',
-  description = 'TODO',
+  summary = 'Draw a plane.',
+  description = 'Draws a plane.',
   arguments = {
     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 = {
       type = 'DrawStyle',
@@ -19,7 +22,7 @@ return {
     },
     rows = {
       type = 'number',
-      default = 'cols',
+      default = 'columns',
       description = 'The number of vertical segments in the plane.'
     }
   },
@@ -29,6 +32,5 @@ return {
       arguments = { 'transform', 'style', 'columns', 'rows' },
       returns = {}
     }
-  },
-  notes = 'TODO'
+  }
 }

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

@@ -1,7 +1,7 @@
 return {
   tag = 'drawing',
   summary = 'Draw points.',
-  description = 'TODO',
+  description = 'Draws points.  `Pass:mesh` can also be used to draw points using a `Buffer`.',
   arguments = {
     x = {
       type = 'number',
@@ -43,5 +43,8 @@ return {
       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 {
   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 = {
     stack = {
       type = 'StackType',
@@ -17,10 +20,10 @@ return {
     }
   },
   notes = [[
-    TODO stack balancing/error
+    If a stack is popped without a corresponding push, the stack "underflows" which causes an error.
   ]],
   related = {
-    'lovr.graphics.push',
+    'Pass:push',
     'StackType'
   }
 }

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

@@ -1,7 +1,11 @@
 return {
   tag = 'transform',
   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 = {
     stack = {
       type = 'StackType',
@@ -17,10 +21,11 @@ return {
     }
   },
   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 = {
-    'lovr.graphics.pop',
+    'Pass:pop',
     'StackType'
   }
 }

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

@@ -1,63 +1,71 @@
 return {
   tag = 'transfer',
   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 = {
     buffer = {
       type = 'Buffer',
-      description = 'TODO'
+      description = 'The Buffer to download data from.'
     },
     texture = {
       type = 'Texture',
-      description = 'TODO'
+      description = 'The Texture to download data from.'
     },
     tally = {
       type = 'Tally',
-      description = 'TODO'
+      description = 'The Tally to download data from.'
     },
     index = {
       type = 'number',
-      description = 'TODO'
+      description = 'The index of the first item to download.'
     },
     count = {
       type = 'number',
-      description = 'TODO'
+      description = 'The number of items to download.'
     },
     x = {
       type = 'number',
       default = '0',
-      description = 'TODO'
+      description = 'The x offset of the region to download.'
     },
     y = {
       type = 'number',
       default = '0',
-      description = 'TODO'
+      description = 'The y offset of the region to download.'
     },
     layer = {
       type = 'number',
       default = '1',
-      description = 'TODO'
+      description = 'The index of the layer to download.'
     },
     level = {
       type = 'number',
       default = '1',
-      description = 'TODO'
+      description = 'The index of the mipmap level to download.'
     },
     width = {
       type = 'number',
       default = 'nil',
-      description = 'TODO'
+      description = [[
+        The width of the region to download.  If nil, the region will be as wide as possible.
+      ]]
     },
     height = {
       type = 'number',
       default = 'nil',
-      description = 'TODO'
+      description = [[
+        The height of the region to download.  If nil, the region will be as tall as possible.
+      ]]
     }
   },
   returns = {
     readback = {
       type = 'Readback',
-      description = 'TODO'
+      description = 'The new readback.'
     }
   },
   variants = {

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

@@ -1,51 +1,26 @@
 return {
   tag = 'transform',
   summary = 'Rotate the coordinate system.',
-  description = 'TODO',
+  description = 'Rotates the coordinate system.',
   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',
-      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 = {},
   variants = {
     {
-      arguments = { 'angle', 'ax', 'ay', 'az' },
-      returns = {}
-    },
-    {
-      arguments = { 'q' },
+      arguments = { 'rotation' },
       returns = {}
     }
   },
-  notes = [[
-    TODO axis does not need to be normalized
-    TODO order matters
-  ]],
   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 {
   tag = 'transform',
   summary = 'Scale the coordinate system.',
-  description = 'TODO',
+  description = 'Scales the coordinate system.',
   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',
-      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 = {},
   variants = {
     {
-      arguments = { 'x', 'y', 'z' },
-      returns = {}
-    },
-    {
-      arguments = { 'v' },
+      arguments = { 'scale' },
       returns = {}
     }
   },
   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 {
+  tag = 'shader-inputs',
   summary = 'Set the value of a shader variable.',
   description = 'TODO',
   arguments = {

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

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

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

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

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

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