Skip to content

Commit b3e979e

Browse files
committed
Update shader-generation.mdx
1 parent c6b0537 commit b3e979e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

apps/typegpu-docs/src/content/docs/reference/shader-generation.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Origins are enumerable values that describe where a value came from (or didn't c
143143
// assign it to a variable or use it.
144144
const firstBoid = layout.$.boids[0];
145145
const newBoid = Boid();
146+
146147
const boidPos = newBoid.pos;
147148
};
148149
```
@@ -151,6 +152,7 @@ Origins are enumerable values that describe where a value came from (or didn't c
151152
fn foo() {
152153
let firstBoid = (&boids[0]); // typed as ptr<storage, Boid, read_write>
153154
var newBoid = Boid(); // typed as Boid
155+
154156
let boidPos = (&newBoid.pos); // typed as ptr<function, vec3f>
155157
}
156158
```
@@ -160,6 +162,11 @@ Origins are enumerable values that describe where a value came from (or didn't c
160162
```ts
161163
const advance = (pos: d.v3f) => {
162164
'use gpu';
165+
// `pos` has the origin 'argument'. Property accesses on arguments
166+
// return snippets that also have the origin 'argument'.
167+
//
168+
// If we try to mutate a snippet that has the origin 'argument',
169+
// we'll get a resolution error.
163170
pos.x += 1;
164171
};
165172

@@ -186,7 +193,7 @@ Origins are enumerable values that describe where a value came from (or didn't c
186193
There are essentially three types of origins:
187194
- **Ephemeral Origins**: These origins represent values that are created or derived from other values. They are typically used for creating new instances or
188195
performing operations that produce new values. Examples include creating a new `Boid` instance or calculating a new position based on an existing one. These
189-
include `'runtime'` and `'constant'`
196+
include `'runtime'` and `'constant'`.
190197
- **Referential Origins**: These origins represent references to existing values. They are typically used for accessing or modifying existing data. Examples
191-
include accessing the position of an existing `Boid` instance or modifying the position of an existing `Boid` instance. These include `'uniform'`, `'mutable'`, `'readonly'`, `'workgroup'`, `'private'`, `'function'`, `'handle'` and `'constant-ref'`
198+
include accessing the position of an existing `Boid` instance or modifying the position of an existing `Boid` instance. These include `'uniform'`, `'mutable'`, `'readonly'`, `'workgroup'`, `'private'`, `'function'`, `'handle'` and `'constant-ref'`.
192199
- **Argument Origins**: This group is dedicated to exactly one origin: 'argument'. It represents values that are passed as arguments to functions.

0 commit comments

Comments
 (0)