Skip to content

Commit dbfd03c

Browse files
authored
chore(typegpu): Make tgpu.vertexLayout stable (#862)
* chore(typegpu): Version bump to 0.4.1
1 parent 6dc4f50 commit dbfd03c

File tree

10 files changed

+26
-34
lines changed

10 files changed

+26
-34
lines changed

apps/typegpu-docs/src/components/stackblitz/openInStackBlitz.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ${example.htmlCode}
6161
},
6262
"dependencies": {
6363
"@webgpu/types": "^0.1.44",
64-
"typegpu": "^0.4.0"
64+
"typegpu": "^0.4.1"
6565
}
6666
}`,
6767
},

apps/typegpu-docs/src/content/examples/simulation/boids-next/index.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,8 @@ const colorPaletteBuffer = root
181181

182182
const TriangleDataArray = (n: number) => d.arrayOf(TriangleData, n);
183183

184-
const vertexLayout = tgpu['~unstable'].vertexLayout((n: number) =>
185-
d.arrayOf(d.vec2f, n),
186-
);
187-
const instanceLayout = tgpu['~unstable'].vertexLayout(
188-
TriangleDataArray,
189-
'instance',
190-
);
184+
const vertexLayout = tgpu.vertexLayout((n: number) => d.arrayOf(d.vec2f, n));
185+
const instanceLayout = tgpu.vertexLayout(TriangleDataArray, 'instance');
191186

192187
const renderPipeline = root['~unstable']
193188
.withVertex(mainVert, {

apps/typegpu-docs/src/content/examples/simulation/boids/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ const computeModule = root.device.createShaderModule({
273273
}),
274274
});
275275

276-
const vertexLayout = tgpu['~unstable'].vertexLayout((n: number) =>
276+
const vertexLayout = tgpu.vertexLayout((n: number) =>
277277
d.arrayOf(d.location(0, d.vec2f), n),
278278
);
279279

apps/typegpu-docs/src/content/examples/simulation/confetti/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ const particleDataStorage = particleDataBuffer.as('mutable');
7777

7878
// layouts
7979

80-
const geometryLayout = tgpu['~unstable']
80+
const geometryLayout = tgpu
8181
.vertexLayout((n: number) => d.arrayOf(ParticleGeometry, n), 'instance')
8282
.$name('geometry');
8383

84-
const dataLayout = tgpu['~unstable']
84+
const dataLayout = tgpu
8585
.vertexLayout((n: number) => d.arrayOf(ParticleData, n), 'instance')
8686
.$name('data');
8787

apps/typegpu-docs/src/content/examples/simulation/fluid-with-atomics/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,11 @@ const fragment = tgpu['~unstable']
341341
return d.vec4f(0, 0, std.max(0.5, res), res);
342342
});
343343

344-
const vertexInstanceLayout = tgpu['~unstable'].vertexLayout(
344+
const vertexInstanceLayout = tgpu.vertexLayout(
345345
(n: number) => d.arrayOf(d.u32, n),
346346
'instance',
347347
);
348-
const vertexLayout = tgpu['~unstable'].vertexLayout(
348+
const vertexLayout = tgpu.vertexLayout(
349349
(n: number) => d.arrayOf(d.vec2f, n),
350350
'vertex',
351351
);

apps/typegpu-docs/src/content/examples/simulation/game-of-life/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ const squareBuffer = root
8383
.createBuffer(d.arrayOf(d.u32, 8), [0, 0, 1, 0, 0, 1, 1, 1])
8484
.$usage('vertex');
8585

86-
const squareVertexLayout = tgpu['~unstable'].vertexLayout(
86+
const squareVertexLayout = tgpu.vertexLayout(
8787
(n: number) => d.arrayOf(d.location(1, d.vec2u), n),
8888
'vertex',
8989
);
9090

91-
const cellsVertexLayout = tgpu['~unstable'].vertexLayout(
91+
const cellsVertexLayout = tgpu.vertexLayout(
9292
(n: number) => d.arrayOf(d.location(0, d.u32), n),
9393
'instance',
9494
);

packages/typegpu/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "typegpu",
33
"private": true,
4-
"version": "0.4.0",
4+
"version": "0.4.1",
55
"description": "A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.",
66
"license": "MIT",
77
"type": "module",

packages/typegpu/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { bindGroupLayout } from './tgpuBindGroupLayout';
2121

2222
export const tgpu = {
2323
bindGroupLayout,
24+
vertexLayout,
2425

2526
init,
2627
initFromDevice,

packages/typegpu/tests/root.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('TgpuRoot', () => {
105105
it('should return the correct GPUVertexBufferLayout for a simple vertex layout', ({
106106
root,
107107
}) => {
108-
const vertexLayout = tgpu['~unstable'].vertexLayout(
108+
const vertexLayout = tgpu.vertexLayout(
109109
(n: number) => d.arrayOf(d.location(0, d.vec2u), n),
110110
'vertex',
111111
);
@@ -132,7 +132,7 @@ describe('TgpuRoot', () => {
132132
something: d.location(2, d.u32),
133133
});
134134

135-
const vertexLayout = tgpu['~unstable'].vertexLayout(
135+
const vertexLayout = tgpu.vertexLayout(
136136
(n: number) => d.disarrayOf(VertexData, n),
137137
'instance',
138138
);

packages/typegpu/tests/vertexLayout.test.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('ArrayToContainedAttribs', () => {
7878

7979
describe('tgpu.vertexLayout', () => {
8080
it('creates attributes from loose array of vec3f', () => {
81-
const vertexLayout = tgpu['~unstable'].vertexLayout((count: number) =>
81+
const vertexLayout = tgpu.vertexLayout((count: number) =>
8282
d.disarrayOf(d.vec3f, count),
8383
);
8484

@@ -97,7 +97,7 @@ describe('tgpu.vertexLayout', () => {
9797
c: d.f32, // + 4
9898
});
9999

100-
const vertexLayout = tgpu['~unstable'].vertexLayout((count: number) =>
100+
const vertexLayout = tgpu.vertexLayout((count: number) =>
101101
d.disarrayOf(VertexData, count),
102102
);
103103

@@ -128,7 +128,7 @@ describe('tgpu.vertexLayout', () => {
128128
c: d.f32, // + 4
129129
});
130130

131-
const vertexLayout = tgpu['~unstable'].vertexLayout((count: number) =>
131+
const vertexLayout = tgpu.vertexLayout((count: number) =>
132132
d.disarrayOf(VertexData, count),
133133
);
134134

@@ -153,7 +153,7 @@ describe('tgpu.vertexLayout', () => {
153153
});
154154

155155
it('creates attributes from loose array with f16 variants', () => {
156-
const vertexLayout = tgpu['~unstable'].vertexLayout((count: number) =>
156+
const vertexLayout = tgpu.vertexLayout((count: number) =>
157157
d.disarrayOf(d.float16x4, count),
158158
);
159159

@@ -169,9 +169,7 @@ describe('tgpu.vertexLayout', () => {
169169
describe('connectAttributesToShader', () => {
170170
it('connects a single f32 attribute', () => {
171171
const shaderInputLayout = d.f32;
172-
const layout = tgpu['~unstable'].vertexLayout((n: number) =>
173-
d.arrayOf(d.f32, n),
174-
);
172+
const layout = tgpu.vertexLayout((n: number) => d.arrayOf(d.f32, n));
175173
const attrib = layout.attrib;
176174

177175
expect(connectAttributesToShader(shaderInputLayout, attrib)).toEqual({
@@ -194,7 +192,7 @@ describe('connectAttributesToShader', () => {
194192

195193
it('connects a single vec4f attribute (with custom shader location)', () => {
196194
const shaderInputLayout = d.location(3, d.vec4f);
197-
const layout = tgpu['~unstable'].vertexLayout((n: number) =>
195+
const layout = tgpu.vertexLayout((n: number) =>
198196
d.disarrayOf(d.unorm16x4, n),
199197
);
200198
const attrib = layout.attrib;
@@ -224,7 +222,7 @@ describe('connectAttributesToShader', () => {
224222
c: d.u32 /* should get @location(4) automatically */,
225223
};
226224

227-
const layout = tgpu['~unstable'].vertexLayout((n: number) =>
225+
const layout = tgpu.vertexLayout((n: number) =>
228226
d.disarrayOf(
229227
d.unstruct({
230228
alpha: d.f32, // 4 bytes
@@ -278,7 +276,7 @@ describe('connectAttributesToShader', () => {
278276
c: d.u32 /* should get @location(4) automatically */,
279277
};
280278

281-
const alphaBetaLayout = tgpu['~unstable'].vertexLayout((n: number) =>
279+
const alphaBetaLayout = tgpu.vertexLayout((n: number) =>
282280
d.disarrayOf(
283281
d.unstruct({
284282
alpha: d.f32, // 4 bytes
@@ -288,9 +286,7 @@ describe('connectAttributesToShader', () => {
288286
),
289287
);
290288

291-
const gammaLayout = tgpu['~unstable'].vertexLayout((n: number) =>
292-
d.arrayOf(d.u32, n),
293-
);
289+
const gammaLayout = tgpu.vertexLayout((n: number) => d.arrayOf(d.u32, n));
294290

295291
const result = connectAttributesToShader(shaderInputLayout, {
296292
// purposefully out of order, which should be controlled by the shader input.
@@ -335,7 +331,7 @@ describe('connectAttributesToShader', () => {
335331

336332
it('connects a single vec4h attribute', () => {
337333
const shaderInputLayout = d.vec4h;
338-
const layout = tgpu['~unstable'].vertexLayout((n: number) =>
334+
const layout = tgpu.vertexLayout((n: number) =>
339335
d.disarrayOf(d.float16x4, n),
340336
);
341337
const attrib = layout.attrib;
@@ -366,7 +362,7 @@ describe('connectAttributesToShader', () => {
366362
d: d.f32,
367363
};
368364

369-
const layout = tgpu['~unstable'].vertexLayout((n: number) =>
365+
const layout = tgpu.vertexLayout((n: number) =>
370366
d.disarrayOf(
371367
d.unstruct({
372368
alpha: d.f16, // 2 bytes
@@ -421,7 +417,7 @@ describe('connectAttributesToShader', () => {
421417

422418
it('throws when trying to use type that has no attribute representation', () => {
423419
expect(() =>
424-
tgpu['~unstable'].vertexLayout((n: number) => d.disarrayOf(d.vec3h, n)),
420+
tgpu.vertexLayout((n: number) => d.disarrayOf(d.vec3h, n)),
425421
).toThrow();
426422
});
427423
});

0 commit comments

Comments
 (0)