레퍼런스 compute()

compute()

This feature requires the p5.webgpu.js addon.
이 API는 실험적입니다

향후 p5.js 버전에서 동작이 변경될 수 있습니다.

Dispatches a compute shader to run on the GPU.

The first parameter, shader, is a compute shader created with buildComputeShader.

Pass a number for x to run a simple loop. Inside the shader's iteration function, index.x will count up from 0 to that number.

You can also pass y and z to loop in up to three dimensions, using index.y and index.z to get the position in each. This is useful for working with 2D grids, like in the Game of Life example below.

예제

구문

compute(shader, x, [y], [z])

매개변수

shader
p5.Shader: The compute shader to run.
x
Number: Number of invocations in the X dimension.
y
Number: Number of invocations in the Y dimension.
z
Number: Number of invocations in the Z dimension.
Notice any errors or typos? Please let us know. Please feel free to edit src/core/p5.Renderer3D.js and open a pull request!

관련 레퍼런스