Skip to content

Commit d44bc55

Browse files
authored
Add missing jsdocs to the TgpuRoot type (#768)
1 parent e0f395b commit d44bc55

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

packages/typegpu/src/core/root/rootTypes.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ export interface TgpuRoot extends Unwrapper {
188188
readonly device: GPUDevice;
189189

190190
/**
191+
* Allocates memory on the GPU, allows passing data between host and shader.
192+
*
193+
* @remarks
194+
* Typed wrapper around a GPUBuffer.
195+
*
191196
* @param typeSchema The type of data that this buffer will hold.
192197
* @param initial The initial value of the buffer. (optional)
193198
*/
@@ -197,6 +202,11 @@ export interface TgpuRoot extends Unwrapper {
197202
): TgpuBuffer<Exotic<TData>>;
198203

199204
/**
205+
* Allocates memory on the GPU, allows passing data between host and shader.
206+
*
207+
* @remarks
208+
* Typed wrapper around a GPUBuffer.
209+
*
200210
* @param typeSchema The type of data that this buffer will hold.
201211
* @param gpuBuffer A vanilla WebGPU buffer.
202212
*/
@@ -205,6 +215,30 @@ export interface TgpuRoot extends Unwrapper {
205215
gpuBuffer: GPUBuffer,
206216
): TgpuBuffer<Exotic<TData>>;
207217

218+
/**
219+
* Creates a group of resources that can be bound to a shader based on a specified layout.
220+
*
221+
* @remarks
222+
* Typed wrapper around a GPUBindGroup.
223+
*
224+
* @example
225+
* const fooLayout = tgpu.bindGroupLayout({
226+
* foo: { uniform: d.vec3f },
227+
* bar: { texture: 'float' },
228+
* });
229+
*
230+
* const fooBuffer = ...;
231+
* const barTexture = ...;
232+
*
233+
* const fooBindGroup = root.createBindGroup(fooLayout, {
234+
* foo: fooBuffer,
235+
* bar: barTexture,
236+
* });
237+
*
238+
* @param layout Layout describing the bind group to be created.
239+
* @param entries A record with values being the resources populating the bind group
240+
* and keys being their associated names, matching the layout keys.
241+
*/
208242
createBindGroup<
209243
Entries extends Record<string, TgpuLayoutEntry | null> = Record<
210244
string,
@@ -217,6 +251,11 @@ export interface TgpuRoot extends Unwrapper {
217251
},
218252
): TgpuBindGroup<Entries>;
219253

254+
/**
255+
* Destroys all underlying resources (i.e. buffers...) created through this root object.
256+
* If the object is created via `tgpu.init` instead of `tgpu.initFromDevice`,
257+
* then the inner GPU device is destroyed as well.
258+
*/
220259
destroy(): void;
221260
}
222261

0 commit comments

Comments
 (0)