Skip to main content

ComputeLua

The handler for the Dispatcher, threads, and data keys

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ComputeLua = require(ReplicatedStorage.ComputeLua)

Types

BufferDataType

type BufferDataType = Vector2 | Vector3 | CFrame | Color3 | UDim | UDim2 | number | boolean | string

The only data types allowed in buffers

ComputeBufferDataType

type ComputeBufferDataType = {[number]BufferDataType | ComputeBufferDataType}

Type for the data of a ComputeBuffer

Functions

CreateDispatcher

Parallel Unsafe
since v1.0.0
</>
ComputeLua.CreateDispatcher(
numWorkersnumber,--

How many workers to use, balanced this with performance and speed

workerScript | LocalScript--

The template script to clone as the worker

) → Dispatcher

Create a Dispatcher to run a bunch of workers in parallel

CreateThread

Serial Unsafe
since v1.3.0
</>
ComputeLua.CreateThread(
actorActor,--

The Actor to bind the thread to, this should be the same actor as the parent of the worker.

threadNamestring,--

The unique name of the thread.

callback(
idnumber,
bufferDataSharedTable
) → {any}--

The function that will be executed when the thread is called and what returns the data

) → ()

Create a thread for the Dispatcher to execute

GetBufferDataKey

since v1.3.0
</>
ComputeLua.GetBufferDataKey(
bufferNamestring--

The name of the buffer

) → number

Get a ComputeBuffer's data key through its name

Show raw api
{
    "functions": [
        {
            "name": "CreateDispatcher",
            "desc": "Create a Dispatcher to run a bunch of workers in parallel",
            "params": [
                {
                    "name": "numWorkers",
                    "desc": "How many workers to use, balanced this with performance and speed",
                    "lua_type": "number"
                },
                {
                    "name": "worker",
                    "desc": "The template script to clone as the worker",
                    "lua_type": "Script | LocalScript"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Dispatcher"
                }
            ],
            "function_type": "static",
            "tags": [
                "Parallel Unsafe"
            ],
            "since": "v1.0.0",
            "source": {
                "line": 335,
                "path": "src/init.lua"
            }
        },
        {
            "name": "CreateThread",
            "desc": "Create a thread for the Dispatcher to execute",
            "params": [
                {
                    "name": "actor",
                    "desc": "The Actor to bind the thread to, this should be the same actor as the parent of the worker.",
                    "lua_type": "Actor"
                },
                {
                    "name": "threadName",
                    "desc": "The unique name of the thread.",
                    "lua_type": "string"
                },
                {
                    "name": "callback",
                    "desc": "The function that will be executed when the thread is called and what returns the data",
                    "lua_type": "(id: number, bufferData: SharedTable) -> {any}"
                }
            ],
            "returns": [],
            "function_type": "static",
            "tags": [
                "Serial Unsafe"
            ],
            "since": "v1.3.0",
            "source": {
                "line": 348,
                "path": "src/init.lua"
            }
        },
        {
            "name": "GetBufferDataKey",
            "desc": "Get a ComputeBuffer's data key through its name",
            "params": [
                {
                    "name": "bufferName",
                    "desc": "The name of the buffer",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "since": "v1.3.0",
            "source": {
                "line": 382,
                "path": "src/init.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "BufferDataType",
            "desc": "The only data types allowed in buffers",
            "lua_type": "Vector2 | Vector3 | CFrame | Color3 | UDim | UDim2 | number | boolean | string",
            "source": {
                "line": 46,
                "path": "src/init.lua"
            }
        },
        {
            "name": "ComputeBufferDataType",
            "desc": "Type for the data of a ComputeBuffer",
            "lua_type": "{ [number]: BufferDataType | ComputeBufferDataType }",
            "source": {
                "line": 57,
                "path": "src/init.lua"
            }
        }
    ],
    "name": "ComputeLua",
    "desc": "The handler for the Dispatcher, threads, and data keys\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal ComputeLua = require(ReplicatedStorage.ComputeLua)\n```",
    "source": {
        "line": 324,
        "path": "src/init.lua"
    }
}