You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/typegpu-docs/src/content/docs/advanced/timestamp-queries.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ This feature is under heavy development and is yet to reach stability.
10
10
To measure shader execution time, you can use **timestamp queries**, which instruct compute or render passes to write timestamps at the start and end of execution. By reading back these timestamps, you can calculate the pipeline’s execution duration in nanoseconds.
11
11
12
12
:::tip
13
-
To use performance callbacks and timestamp queries, you must enable the `timestamp-query` feature on your GPU device. See [Enabling Features](/TypeGPU/fundamentals/enabling-features) for details.
13
+
To use performance callbacks and timestamp queries, you must enable the `timestamp-query` feature on your GPU device. See [Enabling Features](/TypeGPU/advanced/enabling-features) for details.
14
14
:::
15
15
16
16
TypeGPU offers two ways to employ timestamp queries:
Copy file name to clipboardExpand all lines: apps/typegpu-docs/src/content/docs/apis/accessors.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Accessors
3
3
description: Accessors are schema-aware typed placeholders for GPU resources, allowing reusable GPU functions to reference buffers, variables, textures, and more without coupling to a specific resource.
4
4
---
5
5
6
-
When writing reusable GPU functions in TypeGPU, you often need to reference "some global value" without coupling to a specific buffer, texture or variable. [Slots](/TypeGPU/fundamentals/slots) seem like the right tool for the job, but they encode the delivery mechanism into the slot type (e.g. a buffer or texture), making it inflexible for reusable functions.
6
+
When writing reusable GPU functions in TypeGPU, you often need to reference "some global value" without coupling to a specific buffer, texture or variable. [Slots](/TypeGPU/apis/slots) seem like the right tool for the job, but they encode the delivery mechanism into the slot type (e.g. a buffer or texture), making it inflexible for reusable functions.
7
7
8
8
```ts twoslash
9
9
importtgpu, { typeTgpuUniform, d } from'typegpu';
@@ -76,7 +76,7 @@ tgpu.resolve([getColor]);
76
76
77
77
## Overriding the binding
78
78
79
-
Use `.with(accessor, value)` on a function or pipeline — the same pattern as [slots](/fundamentals/slots):
79
+
Use `.with(accessor, value)` on a function or pipeline — the same pattern as [slots](/apis/slots):
80
80
81
81
```ts twoslash
82
82
importtgpu, { d } from'typegpu';
@@ -499,5 +499,5 @@ Bind groups operate at **runtime**: the WGSL is fixed, and the GPU receives diff
499
499
:::
500
500
501
501
Accessors and slots are complementary — you can combine them. For example, an accessor's default can reference a bind group layout entry (`() => layout.$.image`), and you can override it with `.with()` the same way as a slot.
502
-
For more on slots, see the [Slots guide](/TypeGPU/fundamentals/slots).
503
-
For more on bind groups, see the [Bind Groups guide](/TypeGPU/fundamentals/bind-groups).
502
+
For more on slots, see the [Slots guide](/TypeGPU/apis/slots).
503
+
For more on bind groups, see the [Bind Groups guide](/TypeGPU/apis/bind-groups).
Copy file name to clipboardExpand all lines: apps/typegpu-docs/src/content/docs/apis/buffers.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ This buffer can then be used and/or updated by a WGSL shader.
63
63
## Creating a buffer
64
64
65
65
To create a buffer, you will need to define its schema by composing data types imported from `typegpu/data`. Every WGSL data-type can be represented as JS schemas, including
66
-
structs and arrays. They will be explored in more detail in [a following chapter](/TypeGPU/fundamentals/data-schemas).
66
+
structs and arrays. They will be explored in more detail in [a following chapter](/TypeGPU/apis/data-schemas).
67
67
68
68
```ts twoslash
69
69
importtgpu, { d } from'typegpu';
@@ -541,7 +541,7 @@ import ListItem from '../../../components/ListItem.astro';
541
541
542
542
## Index Buffers
543
543
TypeGPU also allows for the use of index buffers. An index buffer is a buffer containing a sequence of `u32` or `u16` indices, which indicate in which order vertices will be processed. This is particulary useful for rendering geometry, where vertices are often shared between multiple primitives (e.g., triangles), as it avoids duplicating vertex data.
544
-
You may refer to the [pipelines](/TypeGPU/fundamentals/pipelines/#drawing-with-drawindexed) section for usage details.
544
+
You may refer to the [pipelines](/TypeGPU/apis/pipelines/#drawing-with-drawindexed) section for usage details.
545
545
546
546
```ts twoslash
547
547
importtgpu, { d } from'typegpu';
@@ -562,7 +562,7 @@ There are two approaches provided by TypeGPU.
562
562
### Manual binding
563
563
564
564
The default option is to create bind group layouts and bind your buffers via bind groups.
565
-
Read more in the chapter dedicated to [bind groups](/TypeGPU/fundamentals/bind-groups).
565
+
Read more in the chapter dedicated to [bind groups](/TypeGPU/apis/bind-groups).
TypeGPU automatically generates a "catch-all" bind group and populates it with the fixed resources.
622
622
623
-
You can also use [`resolveWithContext`](/TypeGPU/fundamentals/resolve/#resolvewithcontext) to access the automatically generated bind group and layout containing your fixed resources.
623
+
You can also use [`resolveWithContext`](/TypeGPU/apis/resolve/#resolvewithcontext) to access the automatically generated bind group and layout containing your fixed resources.
You can also call `d.arrayOf` without specifying the array length. This returns a partially applied schema function, allowing you to provide the length later or use the schema to declare WGSL [runtime-sized arrays](/TypeGPU/fundamentals/bind-groups#runtime-sized-example).
346
+
You can also call `d.arrayOf` without specifying the array length. This returns a partially applied schema function, allowing you to provide the length later or use the schema to declare WGSL [runtime-sized arrays](/TypeGPU/apis/bind-groups#runtime-sized-example).
To make this all work, we perform a small transformation to functions marked with `'use gpu'`. Every project's setup is different, and we want to be as non-invasive as possible. The [unplugin-typegpu](/TypeGPU/tooling/unplugin-typegpu) package hooks into existing bundlers and build tools, extracts ASTs from TypeGPU functions and compacts them into our custom format called [tinyest](https://www.npmjs.com/package/tinyest). This metadata is injected into the final JS bundle, then used to efficiently generate equivalent WGSL at runtime.
107
107
108
108
:::tip
109
-
If all your shader code is predetermined, or you want to precompute a set of variants ahead of time, you can combine [unplugin-macros](https://github.com/unplugin/unplugin-macros) and our [resolve API](/TypeGPU/fundamentals/resolve).
109
+
If all your shader code is predetermined, or you want to precompute a set of variants ahead of time, you can combine [unplugin-macros](https://github.com/unplugin/unplugin-macros) and our [resolve API](/TypeGPU/apis/resolve).
110
110
:::
111
111
112
112
@@ -240,7 +240,7 @@ fact that these values are known at shader compilation time, and can be optimize
240
240
since they use values known only during shader execution.
241
241
242
242
:::tip
243
-
To avoid inlining, use [tgpu.const](/TypeGPU/fundamentals/variables#const-variables).
243
+
To avoid inlining, use [tgpu.const](/TypeGPU/apis/variables#const-variables).
244
244
:::
245
245
246
246
After seeing this, you might be tempted to use this mechanism for sharing data between the CPU and GPU, or for defining
@@ -274,8 +274,8 @@ pipeline.dispatchThreads();
274
274
```
275
275
276
276
There are explicit mechanisms that allow you to achieve this:
277
-
-[Use buffers to efficiently share data between the CPU and GPU](/TypeGPU/fundamentals/buffers)
278
-
-[Use variables to share state between functions](/TypeGPU/fundamentals/variables)
277
+
-[Use buffers to efficiently share data between the CPU and GPU](/TypeGPU/apis/buffers)
278
+
-[Use variables to share state between functions](/TypeGPU/apis/variables)
279
279
280
280
### Supported JavaScript functionality
281
281
@@ -292,7 +292,7 @@ Without it, you can still use operators for numbers,
292
292
but for vectors and matrices you have to use supplementary functions from `typegpu/std` (*add, mul, eq, lt, ge...*), or use a fluent interface (*abc.mul(xyz), ...*)
293
293
294
294
***Calling other functions** --
295
-
Only functions marked with `'use gpu'` can be called from within a shader. There are two exceptions to that rule: [`console.log`](/TypeGPU/fundamentals/utils#consolelog), which allows for tracking runtime behavior
295
+
Only functions marked with `'use gpu'` can be called from within a shader. There are two exceptions to that rule: [`console.log`](/TypeGPU/apis/utils#consolelog), which allows for tracking runtime behavior
296
296
of shaders in a familiar way, as well as most `Math` functions.
297
297
298
298
:::caution
@@ -324,7 +324,7 @@ function manhattanDistance(a: d.v3f, b: d.v3f) {
324
324
## Function shells
325
325
326
326
In order to limit a function's signature to specific types, you can wrap it in a *shell*, an object holding only the input and output types.
327
-
The shell constructor `tgpu.fn` relies on [TypeGPU schemas](/TypeGPU/fundamentals/data-schemas), objects that represent WGSL data types and assist in generating shader code at runtime.
327
+
The shell constructor `tgpu.fn` relies on [TypeGPU schemas](/TypeGPU/apis/data-schemas), objects that represent WGSL data types and assist in generating shader code at runtime.
328
328
It accepts two arguments:
329
329
330
330
- An array of schemas representing argument types,
You can see for yourself what `getGradientColor` resolves to by calling [`tgpu.resolve`](/TypeGPU/fundamentals/resolve), all relevant definitions will be automatically included:
421
+
You can see for yourself what `getGradientColor` resolves to by calling [`tgpu.resolve`](/TypeGPU/apis/resolve), all relevant definitions will be automatically included:
422
422
423
423
```wgsl
424
424
// results of calling tgpu.resolve([getGradientColor])
@@ -625,7 +625,7 @@ struct mainFragment_Input {
625
625
Pipelines are an *unstable* feature. The API may be subject to change in the near future.
626
626
:::
627
627
628
-
Typed functions are crucial for simplified [pipeline](/TypeGPU/fundamentals/pipelines) creation offered by TypeGPU. You can define and run pipelines as follows:
628
+
Typed functions are crucial for simplified [pipeline](/TypeGPU/apis/pipelines) creation offered by TypeGPU. You can define and run pipelines as follows:
Before executing pipelines, it is necessary to bind all of the utilized resources, like bind groups, vertex buffers and slots. It is done using the `with` method. It accepts either [a bind group](/TypeGPU/fundamentals/bind-groups) (render and compute pipelines) or [a vertex layout and a vertex buffer](/TypeGPU/fundamentals/vertex-layouts) (render pipelines only).
291
+
Before executing pipelines, it is necessary to bind all of the utilized resources, like bind groups, vertex buffers and slots. It is done using the `with` method. It accepts either [a bind group](/TypeGPU/apis/bind-groups) (render and compute pipelines) or [a vertex layout and a vertex buffer](/TypeGPU/apis/vertex-layouts) (render pipelines only).
292
292
293
293
```ts
294
294
// vertex layout
@@ -327,7 +327,7 @@ computePipeline
327
327
### Timing performance
328
328
329
329
Pipelines also expose the `withPerformanceCallback` and `withTimestampWrites` methods for timing the execution time on the GPU.
330
-
For more info about them, refer to the [Timing Your Pipelines guide](/TypeGPU/fundamentals/timestamp-queries/).
330
+
For more info about them, refer to the [Timing Your Pipelines guide](/TypeGPU/advanced/timestamp-queries/).
331
331
332
332
### *draw*, *dispatchWorkgroups*
333
333
@@ -339,7 +339,7 @@ Compute pipelines are executed using the `dispatchWorkgroups` method, which acce
339
339
340
340
### Drawing with `drawIndexed`
341
341
342
-
The `drawIndexed` is analogous to draw, but takes advantage of [index buffer](/TypeGPU/fundamentals/buffers/#index-buffers) to explicitly map vertex data onto primitives. When using an index buffer, you don't need to list every vertex for every primitive explicitly. Instead, you provide a list of unique vertices in a vertex buffer. Then, the index buffer defines how these vertices are connected to form primitives.
342
+
The `drawIndexed` is analogous to draw, but takes advantage of [index buffer](/TypeGPU/apis/buffers/#index-buffers) to explicitly map vertex data onto primitives. When using an index buffer, you don't need to list every vertex for every primitive explicitly. Instead, you provide a list of unique vertices in a vertex buffer. Then, the index buffer defines how these vertices are connected to form primitives.
Copy file name to clipboardExpand all lines: apps/typegpu-docs/src/content/docs/apis/resolve.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ The second `tgpu.resolve` overload has only one argument -- an object with optio
109
109
The goal of this overload is to extend the existing WGSL code provided as `template`, with additional definitions from `externals`.
110
110
111
111
:::tip
112
-
This variant of `tgpu.resolve` can often be omitted by using [WGSL-implemented functions](/TypeGPU/fundamentals/functions/#implementing-functions-in-wgsl).
112
+
This variant of `tgpu.resolve` can often be omitted by using [WGSL-implemented functions](/TypeGPU/apis/functions/#implementing-functions-in-wgsl).
113
113
Use it when you are already provided with existing WGSL code and want to extend it.
0 commit comments