Skip to content

Commit c1f831e

Browse files
impr: Simplify pipelines with method (#1767)
1 parent a3fc10a commit c1f831e

File tree

26 files changed

+168
-77
lines changed

26 files changed

+168
-77
lines changed

apps/typegpu-docs/src/content/docs/ecosystem/typegpu-noise.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ let bindGroup = initBindGroup(d.vec3u(10, 10, 1));
260260

261261
// Dispatching the pipeline
262262
pipeline
263-
.with(dynamicLayout, bindGroup)
263+
.with(bindGroup)
264264
.dispatchWorkgroups(1);
265265

266266
// Can be called again to reinitialize the cache with

apps/typegpu-docs/src/content/docs/fundamentals/pipelines.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ renderPipeline
277277

278278
### Resource bindings
279279

280-
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 a pair of arguments: [a bind group layout and 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).
280+
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).
281281

282282
```ts
283283
// vertex layout
@@ -305,11 +305,11 @@ const bindGroup = root.createBindGroup(bindGroupLayout, {
305305
// binding and execution
306306
renderPipeline
307307
.with(vertexLayout, vertexBuffer)
308-
.with(bindGroupLayout, bindGroup)
308+
.with(bindGroup)
309309
.draw(8);
310310

311311
computePipeline
312-
.with(bindGroupLayout, bindGroup)
312+
.with(bindGroup)
313313
.dispatchWorkgroups(1);
314314
```
315315

apps/typegpu-docs/src/content/docs/fundamentals/utils.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ prepareDispatch(root, (x, y) => {
6262
console.log(await waterLevelMutable.read());
6363
```
6464

65-
Analogously to `TgpuComputePipeline`, the result of `prepareDispatch` can have bind groups bound using the `with` method.
65+
The result of `prepareDispatch` can have bind groups bound using the `with` method.
6666

6767
```ts twoslash
6868
import tgpu, { prepareDispatch } from 'typegpu';
@@ -89,8 +89,8 @@ const test = prepareDispatch(root, (x) => {
8989
layout.$.buffer[x] *= 2;
9090
});
9191

92-
test.with(layout, bindGroup1).dispatch(3);
93-
test.with(layout, bindGroup2).dispatch(4);
92+
test.with(bindGroup1).dispatch(3);
93+
test.with(bindGroup2).dispatch(4);
9494

9595
console.log(await buffer1.read()); // [2, 4, 6];
9696
console.log(await buffer2.read()); // [4, 8, 16, 32];

apps/typegpu-docs/src/examples/algorithms/matrix-next/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async function compute() {
176176
};
177177

178178
pipelines[state.strategy]
179-
.with(computeLayout, bindGroup)
179+
.with(bindGroup)
180180
.dispatchWorkgroups(workgroupCount.x, workgroupCount.y);
181181

182182
await root.device.queue.onSubmittedWorkDone();

apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ function createNetwork(layers: [LayerData, LayerData][]): Network {
165165
const isLastLayer = i === buffers.length - 1;
166166

167167
let boundPipeline = pipeline
168-
.with(ioLayout, ioBindGroups[i])
169-
.with(weightsBiasesLayout, weightsBindGroups[i]);
168+
.with(ioBindGroups[i])
169+
.with(weightsBindGroups[i]);
170170

171171
if (querySet && (isFirstLayer || isLastLayer)) {
172172
const descriptor = {

apps/typegpu-docs/src/examples/algorithms/probability/executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class Executor {
123123
}
124124

125125
pipeline
126-
.with(this.#bindGroupLayout, this.#bindGroup)
126+
.with(this.#bindGroup)
127127
.dispatchWorkgroups(Math.ceil(this.#count / 64));
128128

129129
return await this.#samplesBuffer.read();

apps/typegpu-docs/src/examples/image-processing/ascii-filter/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function processVideoFrame(
234234
}
235235

236236
pipeline
237-
.with(layout, bindGroup)
237+
.with(bindGroup)
238238
.withColorAttachment({
239239
loadOp: 'clear',
240240
storeOp: 'store',

apps/typegpu-docs/src/examples/rendering/3d-fish/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function frame(timestamp: DOMHighResTimeStamp) {
257257
cameraBuffer.write(camera);
258258

259259
computePipeline
260-
.with(computeBindGroupLayout, computeBindGroups[odd ? 1 : 0])
260+
.with(computeBindGroups[odd ? 1 : 0])
261261
.dispatchWorkgroups(p.fishAmount / p.workGroupSize);
262262

263263
renderPipeline
@@ -280,7 +280,7 @@ function frame(timestamp: DOMHighResTimeStamp) {
280280
})
281281
.with(modelVertexLayout, oceanFloorModel.vertexBuffer)
282282
.with(renderInstanceLayout, oceanFloorDataBuffer)
283-
.with(renderBindGroupLayout, renderOceanFloorBindGroup)
283+
.with(renderOceanFloorBindGroup)
284284
.draw(oceanFloorModel.polygonCount, 1);
285285

286286
renderPipeline
@@ -303,7 +303,7 @@ function frame(timestamp: DOMHighResTimeStamp) {
303303
})
304304
.with(modelVertexLayout, fishModel.vertexBuffer)
305305
.with(renderInstanceLayout, fishDataBuffers[odd ? 1 : 0])
306-
.with(renderBindGroupLayout, renderFishBindGroups[odd ? 1 : 0])
306+
.with(renderFishBindGroups[odd ? 1 : 0])
307307
.draw(fishModel.polygonCount, p.fishAmount);
308308

309309
root['~unstable'].flush();

apps/typegpu-docs/src/examples/rendering/cubemap-reflection/icosphere.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class IcosphereGenerator {
307307
);
308308

309309
this.pipeline
310-
.with(generatorLayout, bindGroup)
310+
.with(bindGroup)
311311
.dispatchWorkgroups(xGroups, yGroups, 1);
312312

313313
this.root['~unstable'].flush();

apps/typegpu-docs/src/examples/rendering/cubemap-reflection/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ function render() {
300300
storeOp: 'store',
301301
})
302302
.with(cubeVertexLayout, cubeVertexBuffer)
303-
.with(renderLayout, renderBindGroup)
304-
.with(textureLayout, textureBindGroup)
303+
.with(renderBindGroup)
304+
.with(textureBindGroup)
305305
.draw(cubeVertices.length);
306306

307307
pipeline
@@ -312,8 +312,8 @@ function render() {
312312
storeOp: 'store',
313313
})
314314
.with(vertexLayout, vertexBuffer)
315-
.with(renderLayout, renderBindGroup)
316-
.with(textureLayout, textureBindGroup)
315+
.with(renderBindGroup)
316+
.with(textureBindGroup)
317317
.draw(vertexBuffer.dataType.elementCount);
318318

319319
root['~unstable'].flush();

0 commit comments

Comments
 (0)