typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
50 lines (49 loc) • 4.04 kB
TypeScript
import { type TgpuBuffer, type TgpuBufferSoul } from '../core/buffer/buffer.ts';
import type { BaseData } from '../data/wgslTypes.ts';
import { TgpuBufferBindingImpl, type TgpuBufferBindingSoul } from '../core/buffer/bufferBinding.ts';
import { type TgpuConstSoul } from '../core/constant/tgpuConstant.ts';
import { type TgpuComputePipelineSoul } from '../core/pipeline/computePipeline.ts';
import { type TgpuRenderPipelineSoul } from '../core/pipeline/renderPipeline.ts';
import type { TgpuQuerySetSoul } from '../core/querySet/querySet.ts';
import type { TgpuGuardedComputePipelineSoul, TgpuRootSoul } from '../core/root/rootTypes.ts';
import type { TgpuSamplerSoul } from '../core/sampler/sampler.ts';
import type { TgpuAccessorSoul, TgpuMutableAccessor, TgpuSlotSoul } from '../core/slot/slotTypes.ts';
import { type TgpuTextureSoul } from '../core/texture/texture.ts';
import { type TgpuVertexLayoutSoul } from '../core/vertexLayout/vertexLayout.ts';
import type { AnyData } from '../data/dataTypes.ts';
import { type AnyWgslData } from '../data/wgslTypes.ts';
import type { TextureProps } from '../core/texture/textureProps.ts';
import { type TgpuBindGroupLayoutSoul, type TgpuBindGroupSoul } from '../tgpuBindGroupLayout.ts';
import type { TgpuSoul } from '../shared/soul.ts';
import type { RestoreContext } from './types.ts';
/** Every soul that can cross a device boundary, discriminated by `type` */
export type TgpuResourceSoul = TgpuBufferSoul | TgpuBufferBindingSoul | TgpuTextureSoul | TgpuSamplerSoul | TgpuQuerySetSoul | TgpuBindGroupLayoutSoul | TgpuBindGroupSoul | TgpuVertexLayoutSoul | TgpuConstSoul | TgpuSlotSoul | TgpuAccessorSoul | TgpuComputePipelineSoul | TgpuRenderPipelineSoul | TgpuGuardedComputePipelineSoul | TgpuRootSoul;
type Restorer<TSoul extends TgpuSoul> = (soul: TSoul, ctx: RestoreContext) => unknown;
declare function restoreBufferBinding(soul: TgpuBufferBindingSoul): TgpuBufferBindingImpl<"uniform" | "mutable" | "readonly", BaseData>;
/**
* The one place a soul turns back into a resource. Importing this module opts
* into every restorer, so it is kept out of the resources themselves
*/
export declare const soulRestorers: {
buffer: (soul: TgpuBufferSoul, ctx: RestoreContext) => TgpuBuffer<AnyData>;
uniform: typeof restoreBufferBinding;
mutable: typeof restoreBufferBinding;
readonly: typeof restoreBufferBinding;
texture: (soul: TgpuTextureSoul, ctx: RestoreContext) => import("../indexNamedExports.ts").TgpuTexture<TextureProps>;
sampler: (soul: TgpuSamplerSoul, ctx: RestoreContext) => import("../indexNamedExports.ts").TgpuFixedSampler;
'sampler-comparison': (soul: TgpuSamplerSoul, ctx: RestoreContext) => import("../indexNamedExports.ts").TgpuFixedComparisonSampler;
'query-set': (soul: TgpuQuerySetSoul, ctx: RestoreContext) => import("../indexNamedExports.ts").TgpuQuerySet<GPUQueryType>;
'bind-group-layout': (soul: TgpuBindGroupLayoutSoul) => import("../tgpuBindGroupLayout.ts").TgpuBindGroupLayout<Record<string, import("../tgpuBindGroupLayout.ts").TgpuLayoutEntry | null>>;
'bind-group': Restorer<TgpuBindGroupSoul>;
'vertex-layout': (soul: TgpuVertexLayoutSoul) => import("../indexNamedExports.ts").TgpuVertexLayout<import("../data/wgslTypes.ts").WgslArray<AnyWgslData>> | import("../indexNamedExports.ts").TgpuVertexLayout<import("../data/dataTypes.ts").Disarray<AnyData>>;
const: (soul: TgpuConstSoul) => import("../indexNamedExports.ts").TgpuConst<AnyData>;
slot: (soul: TgpuSlotSoul) => import("../indexNamedExports.ts").TgpuSlot<unknown>;
accessor: (soul: TgpuAccessorSoul) => import("../indexNamedExports.ts").TgpuAccessor<AnyData>;
'mutable-accessor': (soul: TgpuAccessorSoul) => TgpuMutableAccessor<AnyData>;
'compute-pipeline': Restorer<TgpuComputePipelineSoul>;
'render-pipeline': Restorer<TgpuRenderPipelineSoul>;
'guarded-compute-pipeline': Restorer<TgpuGuardedComputePipelineSoul>;
root: Restorer<TgpuRootSoul>;
};
export type TransferableResourceType = TgpuResourceSoul['type'];
export {};