From 78082d92799a416bb01ef4f5fcc3a828ad7fe244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 16 Jan 2023 17:43:48 +0800 Subject: build 3rd metas --- meta/3rd/love2d/library/love.lua | 2 +- meta/3rd/love2d/library/love/graphics.lua | 4 +- meta/3rd/lovr/library/lovr/audio.lua | 50 ++++++++++++++++---- meta/3rd/lovr/library/lovr/data.lua | 4 +- meta/3rd/lovr/library/lovr/graphics.lua | 76 ++++++++++++++++++++++++++----- 5 files changed, 111 insertions(+), 25 deletions(-) diff --git a/meta/3rd/love2d/library/love.lua b/meta/3rd/love2d/library/love.lua index fcdcc98e..7ca517a5 100644 --- a/meta/3rd/love2d/library/love.lua +++ b/meta/3rd/love2d/library/love.lua @@ -170,7 +170,7 @@ function Object:typeOf(name) end --- ---The error handler, used to display error messages. --- ----@alias love.errorhandler fun(msg: string) +---@alias love.errorhandler fun(msg: string):function --- ---Callback function triggered when a file is dragged and dropped onto the window. diff --git a/meta/3rd/love2d/library/love/graphics.lua b/meta/3rd/love2d/library/love/graphics.lua index b0c991c9..87ad4a8f 100644 --- a/meta/3rd/love2d/library/love/graphics.lua +++ b/meta/3rd/love2d/library/love/graphics.lua @@ -410,11 +410,11 @@ function love.graphics.getMeshCullMode() end ---love.graphics.getDimensions gets the dimensions of the window in units scaled by the screen's DPI scale factor, rather than pixels. Use getDimensions for calculations related to drawing to the screen and using the graphics coordinate system (calculating the center of the screen, for example), and getPixelDimensions only when dealing specifically with underlying pixels (pixel-related calculations in a pixel Shader, for example). --- --- ----[Open in Browser](https://love2d.org/wiki/love.graphics.getPixelDimenions) +---[Open in Browser](https://love2d.org/wiki/love.graphics.getPixelDimensions) --- ---@return number pixelwidth # The width of the window in pixels. ---@return number pixelheight # The height of the window in pixels. -function love.graphics.getPixelDimenions() end +function love.graphics.getPixelDimensions() end --- ---Gets the height in pixels of the window. diff --git a/meta/3rd/lovr/library/lovr/audio.lua b/meta/3rd/lovr/library/lovr/audio.lua index 99557c39..c56a37d6 100644 --- a/meta/3rd/lovr/library/lovr/audio.lua +++ b/meta/3rd/lovr/library/lovr/audio.lua @@ -15,9 +15,7 @@ lovr.audio = {} --- ---This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.). --- ----The difference between absorption and falloff is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. ---- ----This can be used to apply "underwater" effects and stuff. +---The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. This can be used to apply "underwater" effects and stuff. --- --- ---### NOTE: @@ -186,7 +184,7 @@ function lovr.audio.isStarted(type) end ---@overload fun(blob: lovr.Blob, options?: table):lovr.Source ---@overload fun(sound: lovr.Sound, options?: table):lovr.Source ---@param filename string # The filename of the sound to load. ----@param options? {decode: boolean, effects: table} # Optional options. +---@param options? {decode: boolean, pitchable: boolean, spatial: boolean, effects: table} # Optional options. ---@return lovr.Source source # The new Source. function lovr.audio.newSource(filename, options) end @@ -195,7 +193,7 @@ function lovr.audio.newSource(filename, options) end --- ---This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.). --- ----The difference between absorption and falloff is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. +---The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. --- ---This can be used to apply "underwater" effects and stuff. --- @@ -419,6 +417,20 @@ function Source:getDuration(unit) end ---@return number az # The z component of the axis of rotation. function Source:getOrientation() end +--- +---Returns the pitch of the Source. +--- +--- +---### NOTE: +---The default pitch is 1. +--- +---Every doubling/halving of the pitch will raise/lower the pitch by one octave. +--- +---Changing the pitch also changes the playback speed. +--- +---@return number pitch # The pitch. +function Source:getPitch() end + --- ---Returns the position and orientation of the Source. --- @@ -485,7 +497,7 @@ function Source:getVolume(units) end --- ---See `lovr.audio.getSpatializer` for a table showing the effects supported by each spatializer. --- ----Calling this function on a Source that was created with `{ effects = false }` will always return false. +---Calling this function on a non-spatial Source will always return false. --- ---@param effect lovr.Effect # The effect. ---@return boolean enabled # Whether the effect is enabled. @@ -503,6 +515,14 @@ function Source:isLooping() end ---@return boolean playing # Whether the Source is playing. function Source:isPlaying() end +--- +---Returns whether the Source was created with the `spatial` flag. +--- +---Non-spatial sources are routed directly to the speakers and can not use effects. +--- +---@return boolean spatial # Whether the source is spatial. +function Source:isSpatial() end + --- ---Pauses the source. --- @@ -573,7 +593,7 @@ function Source:setDirectivity(weight, power) end --- ---See `lovr.audio.getSpatializer` for a table showing the effects supported by each spatializer. --- ----Calling this function on a Source that was created with `{ effects = false }` will throw an error. +---Calling this function on a non-spatial Source will throw an error. --- ---@param effect lovr.Effect # The effect. ---@param enable boolean # Whether the effect should be enabled. @@ -598,6 +618,20 @@ function Source:setLooping(loop) end ---@param az number # The z component of the axis of rotation. function Source:setOrientation(angle, ax, ay, az) end +--- +---Sets the pitch of the Source. +--- +--- +---### NOTE: +---The default pitch is 1. +--- +---Every doubling/halving of the pitch will raise/lower the pitch by one octave. +--- +---Changing the pitch also changes the playback speed. +--- +---@param pitch number # The new pitch. +function Source:setPitch(pitch) end + --- ---Sets the position and orientation of the Source. --- @@ -763,7 +797,7 @@ function Source:tell(unit) end --- ---Decreases audio volume with distance (1 / max(distance, 1)). --- ----| "falloff" +---| "attenuation" --- ---Causes audio to drop off when the Source is occluded by geometry. --- diff --git a/meta/3rd/lovr/library/lovr/data.lua b/meta/3rd/lovr/library/lovr/data.lua index babfb014..dd47aa14 100644 --- a/meta/3rd/lovr/library/lovr/data.lua +++ b/meta/3rd/lovr/library/lovr/data.lua @@ -205,7 +205,7 @@ function Image:getHeight() end --- --- ---### NOTE: ----The following texture formats are supported: `rgba`, `rgb`, `r32f`, `rg32f`, and `rgba32f`. +---The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`. --- ---@param x number # The x coordinate of the pixel to get (0-indexed). ---@param y number # The y coordinate of the pixel to get (0-indexed). @@ -246,7 +246,7 @@ function Image:paste(source, x, y, fromX, fromY, width, height) end --- --- ---### NOTE: ----The following texture formats are supported: `rgba`, `rgb`, `r32f`, `rg32f`, and `rgba32f`. +---The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`. --- ---@param x number # The x coordinate of the pixel to set (0-indexed). ---@param y number # The y coordinate of the pixel to set (0-indexed). diff --git a/meta/3rd/lovr/library/lovr/graphics.lua b/meta/3rd/lovr/library/lovr/graphics.lua index 6c8f8330..36045f00 100644 --- a/meta/3rd/lovr/library/lovr/graphics.lua +++ b/meta/3rd/lovr/library/lovr/graphics.lua @@ -1477,7 +1477,7 @@ local Pass = {} --- ---Similar to `Pass:copy`, except the source and destination sizes can be different. --- ----The pixels from the source texture will be scaled to the destination size. +---The pixels from the source texture will be scaled to the destination size. This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. --- --- ---### NOTE: @@ -1546,6 +1546,8 @@ function Pass:circle(transform, style, angle1, angle2, segments) end --- ---Clears a Buffer or Texture. --- +---This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. +--- ---@overload fun(self: lovr.Pass, texture: lovr.Texture, color: lovr.Vec4, layer?: number, layers?: number, level?: number, levels?: number) ---@param buffer lovr.Buffer # The Buffer to clear. ---@param index? number # The index of the first item to clear. @@ -1555,24 +1557,59 @@ function Pass:clear(buffer, index, count) end --- ---Runs a compute shader. --- ----Compute shaders are run in 3D grids of workgroups. +---Before calling this, a compute shader needs to be active, using `Pass:setShader`. --- ----Each local workgroup is itself a 3D grid of invocations, declared using `local_size_x`, `local_size_y`, and `local_size_z` in the shader code. +---This can only be called on a Pass with the `compute` type, which can be created using `lovr.graphics.getPass`. --- --- ---### NOTE: ----All these 3D grids can get confusing, but the basic idea is to make the local workgroup size a small block of e.g. 8x8 pixels or 4x4x4 voxels, and then dispatch however many global workgroups are needed to cover an image or voxel field. +---Usually compute shaders are run many times in parallel: once for each pixel in an image, once per particle, once per object, etc. +--- +---The 3 arguments represent how many times to run, or "dispatch", the compute shader, in up to 3 dimensions. +--- +---Each element of this grid is called a **workgroup**. +--- +---To make things even more complicated, each workgroup itself is made up of a set of "mini GPU threads", which are called **local workgroups**. +--- +---Like workgroups, the local workgroup size can also be 3D. +--- +---It's declared in the shader code, like this: +--- +--- layout(local_size_x = w, local_size_y = h, local_size_z = d) in; +--- +---All these 3D grids can get confusing, but the basic idea is to make the local workgroup size a small block of e.g. 32 particles or 8x8 pixels or 4x4x4 voxels, and then dispatch however many workgroups are needed to cover a list of particles, image, voxel field, etc. +--- +---The reason to do it this way is that the GPU runs its threads in little fixed-size bundles called subgroups. +--- +---Subgroups are usually 32 or 64 threads (the exact size is given by the `subgroupSize` property of `lovr.graphics.getDevice`) and all run together. +--- +---If the local workgroup size was `1x1x1`, then the GPU would only run 1 thread per subgroup and waste the other 31 or 63. --- ----The reason to do it this way is that the GPU runs invocations in bundles called subgroups. +---So for the best performance, be sure to set a local workgroup size bigger than 1! --- ----Subgroups are usually 32 or 64 invocations (the exact size is given by the `subgroupSize` property of `lovr.graphics.getDevice`). +---Inside the compute shader, a few builtin variables can be used to figure out which workgroup is running: --- ----If the local workgroup size was `1x1x1`, then the GPU would only run 1 invocation per subgroup and waste the other 31 or 63. +---- `uvec3 WorkgroupCount` is the workgroup count per axis (the `Pass:compute` arguments). +---- `uvec3 WorkgroupSize` is the local workgroup size (declared in the shader). +---- `uvec3 WorkgroupID` is the index of the current (global) workgroup. +---- `uvec3 LocalThreadID` is the index of the local workgroup inside its workgroup. +---- `uint LocalThreadIndex` is a 1D version of `LocalThreadID`. +---- `uvec3 GlobalThreadID` is the unique identifier for a thread within all workgroups in a +--- dispatch. It's equivalent to `WorkgroupID * WorkgroupSize + LocalThreadID` (usually what you +--- want!) +--- +---Indirect compute dispatches are useful to "chain" compute shaders together, while keeping all of the data on the GPU. +--- +---The first dispatch can do some computation and write some results to buffers, then the second indirect dispatch can use the data in those buffers to know how many times it should run. +--- +---An example would be a compute shader that does some sort of object culling, writing the number of visible objects to a buffer along with the IDs of each one. Subsequent compute shaders can be indirectly dispatched to perform extra processing on the visible objects. +--- +---Finally, an indirect draw can be used to render them. --- ---@overload fun(self: lovr.Pass, buffer: lovr.Buffer, offset?: number) ----@param x? number # How many workgroups to dispatch in the x dimension. ----@param y? number # How many workgroups to dispatch in the y dimension. ----@param z? number # How many workgroups to dispatch in the z dimension. +---@param x? number # The number of workgroups to dispatch in the x dimension. +---@param y? number # The number of workgroups to dispatch in the y dimension. +---@param z? number # The number of workgroups to dispatch in the z dimension. function Pass:compute(x, y, z) end --- @@ -1589,7 +1626,7 @@ function Pass:cone(transform, segments) end --- ---Copies data to or between `Buffer` and `Texture` objects. --- ----This function must be called on a `transfer` pass. +---This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. --- ---@overload fun(self: lovr.Pass, blob: lovr.Blob, bufferdst: lovr.Buffer, srcoffset?: number, dstoffset?: number, size?: number) ---@overload fun(self: lovr.Pass, buffersrc: lovr.Buffer, bufferdst: lovr.Buffer, srcoffset?: number, dstoffset?: number, size?: number) @@ -1714,6 +1751,7 @@ function Pass:getTarget() end --- ---The type restricts what kinds of functions can be called on the pass. --- +---@return lovr.PassType type # The type of the Pass. function Pass:getType() end --- @@ -1802,6 +1840,10 @@ function Pass:mesh(vertices, transform, start, count, instances, base) end --- ---Generates mipmaps for a texture. --- +---This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. +--- +---When rendering to textures with a render pass, it's also possible to automatically regenerate mipmaps after rendering by adding the `mipmaps` flag when creating the pass. +--- ---@param texture lovr.Texture # The texture to mipmap. ---@param base? number # The index of the mipmap used to generate the remaining mipmaps. ---@param count? number # The number of mipmaps to generate. If nil, generates the remaining mipmaps. @@ -1871,7 +1913,9 @@ function Pass:push(stack) end --- ---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. +---The readback can be polled for completion, or, after this transfer pass is submitted, `Readback:wait` can be used to block until the download is complete. +--- +---This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. --- ---@overload fun(self: lovr.Pass, texture: lovr.Texture, x?: number, y?: number, layer?: number, level?: number, width?: number, height?: number):lovr.Readback ---@overload fun(self: lovr.Pass, tally: lovr.Tally, index: number, count: number):lovr.Readback @@ -3134,6 +3178,14 @@ function Texture:newView(type, layer, layerCount, mipmap, mipmapCount) end ---A 4x4 matrix containing sixteen 32-bit floats. --- ---| "mat4" +--- +---Like u16, but 1-indexed. +--- +---| "index16" +--- +---Like u32, but 1-indexed. +--- +---| "index32" --- ---Controls how `Sampler` objects smooth pixels in textures. -- cgit v1.2.3