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/reference/shader-generation.mdx
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,6 +143,7 @@ Origins are enumerable values that describe where a value came from (or didn't c
143
143
// assign it to a variable or use it.
144
144
constfirstBoid=layout.$.boids[0];
145
145
constnewBoid=Boid();
146
+
146
147
constboidPos=newBoid.pos;
147
148
};
148
149
```
@@ -151,6 +152,7 @@ Origins are enumerable values that describe where a value came from (or didn't c
151
152
fn foo() {
152
153
let firstBoid = (&boids[0]); // typed as ptr<storage, Boid, read_write>
153
154
var newBoid =Boid(); // typed as Boid
155
+
154
156
let boidPos = (&newBoid.pos); // typed as ptr<function, vec3f>
155
157
}
156
158
```
@@ -160,6 +162,11 @@ Origins are enumerable values that describe where a value came from (or didn't c
160
162
```ts
161
163
constadvance= (pos:d.v3f) => {
162
164
'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.
163
170
pos.x+=1;
164
171
};
165
172
@@ -186,7 +193,7 @@ Origins are enumerable values that describe where a value came from (or didn't c
186
193
There are essentially three types of origins:
187
194
- **Ephemeral Origins**: These origins represent values that are created or derived from other values. They are typically used for creating new instances or
188
195
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'`.
190
197
- **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'`.
192
199
- **Argument Origins**: This group is dedicated to exactly one origin: 'argument'. It represents values that are passed as arguments to functions.
0 commit comments