|
| 1 | +// You can grab the text of other files like so. Note the `?raw` at the end. |
| 2 | +// import exampleShader from "./exampleShader.wgsl?raw" |
| 3 | + |
| 4 | +interface Params { |
| 5 | + navigator: Navigator; |
| 6 | + canvas: HTMLCanvasElement; |
| 7 | + context: GPUCanvasContext; |
| 8 | + /** |
| 9 | + * A logger for sending messages to the UI log |
| 10 | + */ |
| 11 | + logger: Record< |
| 12 | + "trace" | "debug" | "info" | "warn" | "error", |
| 13 | + (msg: string) => void |
| 14 | + >; |
| 15 | + /** |
| 16 | + * Contains the text of any other files in the folder given to Jacket |
| 17 | + * |
| 18 | + * More useful if you aren't using a bundler. |
| 19 | + */ |
| 20 | + files: Record<string, string>; |
| 21 | +} |
| 22 | + |
| 23 | +/** |
| 24 | + * The entry point exposed to Jacket. |
| 25 | + * You typically put your one-time setup code here, and return a closure to draw/compute repeatedly. |
| 26 | + * |
| 27 | + * > It is important that you use the {@link Navigator} and {@link GPUCanvasContext} supplied in the params, |
| 28 | + * > rather than obtaining them by normal means. These objects are proxied in order to track execution. |
| 29 | + * |
| 30 | + * @param params Inputs to your program from Jacket |
| 31 | + * @returns A function called by Jacket repeatedly, once per frame |
| 32 | + * |
| 33 | + * ## Useful links |
| 34 | + * - https://webgpufundamentals.org/ |
| 35 | + * - https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API |
| 36 | + * |
| 37 | + * ## WebGPU diagrams |
| 38 | + * ### Draw Process |
| 39 | + *  |
| 40 | + * ### Compute Process |
| 41 | + *  |
| 42 | + */ |
1 | 43 | export async function program({ |
2 | 44 | navigator, |
3 | 45 | canvas, |
| 46 | + context, |
4 | 47 | files, |
5 | 48 | logger, |
6 | | -}: { |
7 | | - navigator: Navigator; |
8 | | - canvas: HTMLCanvasElement; |
9 | | - logger: Record<string, (msg: string) => void>; |
10 | | - files: Record<string, string>; |
11 | | -}) { |
| 49 | +}: Params) { |
12 | 50 | const frame = async () => {}; |
13 | 51 | return frame; |
14 | 52 | } |
0 commit comments