Skip to content

Commit 870170b

Browse files
authored
feat: Stabilize tgpu.accessor and tgpu.mutableAccessor (#2167)
1 parent 5dd06ce commit 870170b

14 files changed

Lines changed: 57 additions & 73 deletions

File tree

apps/typegpu-docs/src/content/docs/reference/naming-convention.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const colorSlot = tgpu.slot(vec4f(1, 0, 0, 1));
7575
We give accessors *camelCase* names with the `Access` suffix.
7676

7777
```ts
78-
const colorAccess = tgpu['~unstable'].accessor(vec4f);
78+
const colorAccess = tgpu.accessor(vec4f);
7979
```
8080

8181
## Lazy

apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const SampleResult = d.struct({
2121
outside: d.vec2f,
2222
});
2323

24-
export const paramsAccess = tgpu['~unstable'].accessor(VisualizationParams);
24+
export const paramsAccess = tgpu.accessor(VisualizationParams);
2525

2626
export const distSampleLayout = tgpu.bindGroupLayout({
2727
distTexture: { texture: d.texture2d() },

apps/typegpu-docs/src/examples/image-processing/background-segmentation/schemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export const Params = d.struct({
4242
sampleBias: d.f32,
4343
});
4444

45-
export const paramsAccess = tgpu['~unstable'].accessor(Params);
46-
export const flipAccess = tgpu['~unstable'].accessor(d.bool);
45+
export const paramsAccess = tgpu.accessor(Params);
46+
export const flipAccess = tgpu.accessor(d.bool);
4747

4848
export interface ModelConfig {
4949
name: string;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import tgpu, { d } from 'typegpu';
22

3-
export const timeAccess = tgpu['~unstable'].accessor(d.f32);
4-
export const resolutionAccess = tgpu['~unstable'].accessor(d.vec2f); // (width, height)
3+
export const timeAccess = tgpu.accessor(d.f32);
4+
export const resolutionAccess = tgpu.accessor(d.vec2f); // (width, height)

apps/typegpu-docs/src/examples/simulation/gravity/schemas.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export const renderSkyBoxVertexLayout = tgpu.vertexLayout(
5555
d.arrayOf(SkyBoxVertex),
5656
);
5757

58-
export const cameraAccess = tgpu['~unstable'].accessor(Camera);
58+
export const cameraAccess = tgpu.accessor(Camera);
5959
export const filteringSamplerSlot = tgpu.slot<TgpuSampler>();
60-
export const lightSourceAccess = tgpu['~unstable'].accessor(d.vec3f);
61-
export const timeAccess = tgpu['~unstable'].accessor(Time);
62-
export const skyBoxAccess = tgpu['~unstable'].accessor(d.textureCube(d.f32));
60+
export const lightSourceAccess = tgpu.accessor(d.vec3f);
61+
export const timeAccess = tgpu.accessor(Time);
62+
export const skyBoxAccess = tgpu.accessor(d.textureCube(d.f32));
6363

6464
export const renderBindGroupLayout = tgpu
6565
.bindGroupLayout({

packages/typegpu-color/src/oklab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ const gamutClipPreserveChroma = tgpu.fn([vec3f], vec3f)((lab) => {
270270
return vec3f(L_clipped, C_clipped * a_, C_clipped * b_);
271271
});
272272

273-
export const oklabGamutClipAlphaAccess = tgpu['~unstable'].accessor(f32, 0.2);
273+
export const oklabGamutClipAlphaAccess = tgpu.accessor(f32, 0.2);
274274

275275
const gamutClipAdaptiveL05 = tgpu.fn([vec3f], vec3f)((lab) => {
276276
const alpha = oklabGamutClipAlphaAccess.$;

packages/typegpu-noise/src/perlin-2d/dynamic-cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ export function dynamicCacheConfig<Prefix extends string>(
132132
): DynamicPerlin2DCacheConfig<Prefix> {
133133
const { prefix = DefaultPerlin2DLayoutPrefix as Prefix } = options ?? {};
134134

135-
const sizeAccess = tgpu['~unstable'].accessor(d.vec2u);
136-
const memoryAccess = tgpu['~unstable'].accessor(MemorySchema);
135+
const sizeAccess = tgpu.accessor(d.vec2u);
136+
const memoryAccess = tgpu.accessor(MemorySchema);
137137

138138
const getJunctionGradient = tgpu.fn([d.vec2i], d.vec2f)((pos) => {
139139
const size = d.vec2i(sizeAccess.$);

packages/typegpu-noise/src/perlin-3d/dynamic-cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ export function dynamicCacheConfig<Prefix extends string>(
132132
): DynamicPerlin3DCacheConfig<Prefix> {
133133
const { prefix = DefaultPerlin3DLayoutPrefix as Prefix } = options ?? {};
134134

135-
const sizeAccess = tgpu['~unstable'].accessor(d.vec4u);
136-
const memoryAccess = tgpu['~unstable'].accessor(MemorySchema);
135+
const sizeAccess = tgpu.accessor(d.vec4u);
136+
const memoryAccess = tgpu.accessor(MemorySchema);
137137

138138
const getJunctionGradient = tgpu.fn([d.vec3i], d.vec3f)((pos) => {
139139
const size = d.vec3i(sizeAccess.$.xyz);

packages/typegpu/src/tgpu.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { resolve, resolveWithContext } from './core/resolve/tgpuResolve.ts';
77
export { init, initFromDevice } from './core/root/init.ts';
88
export { slot } from './core/slot/slot.ts';
99
export { lazy } from './core/slot/lazy.ts';
10+
export { accessor, mutableAccessor } from './core/slot/accessor.ts';
1011
export { privateVar, workgroupVar } from './core/variable/tgpuVariable.ts';
1112
export { vertexLayout } from './core/vertexLayout/vertexLayout.ts';
1213
export { bindGroupLayout } from './tgpuBindGroupLayout.ts';
Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,45 @@
11
// NOTE: This is a barrel file, internal files should not import things from this file
22

33
export {
4-
/**
5-
* @deprecated This feature is now stable, use tgpu.const.
6-
*/
4+
/** @deprecated This feature is now stable, use tgpu.const. */
75
constant as const,
86
} from './core/constant/tgpuConstant.ts';
97
export { declare } from './core/declare/tgpuDeclare.ts';
108
export {
11-
/**
12-
* @deprecated This feature is now stable, use tgpu.comptime.
13-
*/
9+
/** @deprecated This feature is now stable, use tgpu.comptime. */
1410
comptime,
1511
} from './core/function/comptime.ts';
1612
export { computeFn } from './core/function/tgpuComputeFn.ts';
1713
export {
18-
/**
19-
* @deprecated This feature is now stable, use tgpu.fn.
20-
*/
14+
/** @deprecated This feature is now stable, use tgpu.fn. */
2115
fn,
2216
} from './core/function/tgpuFn.ts';
2317
export { fragmentFn } from './core/function/tgpuFragmentFn.ts';
2418
export { vertexFn } from './core/function/tgpuVertexFn.ts';
2519
export { rawCodeSnippet } from './core/rawCodeSnippet/tgpuRawCodeSnippet.ts';
2620
export { namespace } from './core/resolve/namespace.ts';
2721
export { simulate } from './core/simulate/tgpuSimulate.ts';
28-
export { accessor, mutableAccessor } from './core/slot/accessor.ts';
2922
export {
30-
/**
31-
* @deprecated This feature is now stable, use tgpu.lazy.
32-
*/
23+
/** @deprecated This feature is now stable, use tgpu.accessor. */
24+
accessor,
25+
/** @deprecated This feature is now stable, use tgpu.mutableAccessor. */
26+
mutableAccessor,
27+
} from './core/slot/accessor.ts';
28+
export {
29+
/** @deprecated This feature is now stable, use tgpu.lazy. */
3330
lazy as derived,
3431
} from './core/slot/lazy.ts';
3532
export {
36-
/**
37-
* @deprecated This feature is now stable, use tgpu.slot.
38-
*/
33+
/** @deprecated This feature is now stable, use tgpu.slot. */
3934
slot,
4035
} from './core/slot/slot.ts';
4136
export {
42-
/**
43-
* @deprecated This feature is now stable, use tgpu.privateVar.
44-
*/
37+
/** @deprecated This feature is now stable, use tgpu.privateVar. */
4538
privateVar,
46-
/**
47-
* @deprecated This feature is now stable, use tgpu.workgroupVar.
48-
*/
39+
/** @deprecated This feature is now stable, use tgpu.workgroupVar. */
4940
workgroupVar,
5041
} from './core/variable/tgpuVariable.ts';
5142
export {
52-
/**
53-
* @deprecated This feature is now stable, use tgpu.vertexLayout.
54-
*/
43+
/** @deprecated This feature is now stable, use tgpu.vertexLayout. */
5544
vertexLayout,
5645
} from './core/vertexLayout/vertexLayout.ts';

0 commit comments

Comments
 (0)