UNPKG

typegpu

Version:

A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.

53 lines (52 loc) 3.7 kB
import type { BaseData } from '../../data/wgslTypes.ts'; import { type TgpuBindGroup, type TgpuBindGroupLayout } from '../../tgpuBindGroupLayout.ts'; import type { LogResources } from '../../tgsl/consoleLog/types.ts'; import type { IndexFlag, TgpuBuffer, VertexFlag } from '../buffer/buffer.ts'; import type { TgpuCommandEncoder } from '../commandEncoder/commandEncoder.ts'; import type { ComputePassInternals } from '../commandEncoder/computePass.ts'; import type { RenderPassInternals } from '../commandEncoder/renderPass.ts'; import type { ExperimentalTgpuRoot } from '../root/rootTypes.ts'; import type { TgpuVertexLayout } from '../vertexLayout/vertexLayout.ts'; import type { TgpuComputePipeline } from './computePipeline.ts'; import type { TgpuRenderPipeline } from './renderPipeline.ts'; import { type TimestampWritesPriors } from './timeable.ts'; export interface VertexBufferEntry { buffer: (TgpuBuffer<BaseData> & VertexFlag) | GPUBuffer; offset?: number | undefined; size?: number | undefined; } export interface IndexBufferEntry { buffer: (TgpuBuffer<BaseData> & IndexFlag) | GPUBuffer; indexFormat: GPUIndexFormat; offsetBytes?: number | undefined; sizeBytes?: number | undefined; } export declare class RenderDrawState { readonly bindGroups: Map<TgpuBindGroupLayout<Record<string, import("../../tgpuBindGroupLayout.ts").TgpuLayoutEntry | null>>, TgpuBindGroup | GPUBindGroup>; readonly vertexBuffers: Map<TgpuVertexLayout<import("../../data/wgslTypes.ts").WgslArray<BaseData> | import("../../data/dataTypes.ts").Disarray<BaseData>>, VertexBufferEntry>; currentPipeline: TgpuRenderPipeline | undefined; indexBuffer: IndexBufferEntry | undefined; stencilReference: GPUStencilValue | undefined; /** What the raw pass holds, starting at the WebGPU default; survives executeBundles */ appliedStencilReference: GPUStencilValue; version: number; /** Raw access via `root.unwrap(pass)` can mutate state invisibly, disabling deduplication */ rawAccessed: boolean; } export declare class ComputeDrawState { readonly bindGroups: Map<TgpuBindGroupLayout<Record<string, import("../../tgpuBindGroupLayout.ts").TgpuLayoutEntry | null>>, TgpuBindGroup | GPUBindGroup>; currentPipeline: TgpuComputePipeline | undefined; version: number; rawAccessed: boolean; } export declare function recordBindGroup(state: RenderDrawState | ComputeDrawState, first: TgpuBindGroup | TgpuBindGroupLayout, bindGroup: TgpuBindGroup | GPUBindGroup | undefined): void; /** Writes the pipeline and its bound resources into pass state; later set* calls overwrite them */ export declare function stampRenderPipeline(state: RenderDrawState, pipeline: TgpuRenderPipeline): void; /** The compute counterpart of {@link stampRenderPipeline} */ export declare function stampComputePipeline(state: ComputeDrawState, pipeline: TgpuComputePipeline): void; export declare function requireIndexBuffer(indexBuffer: IndexBufferEntry | undefined): void; export declare function finalizeOwnEncoder(encoder: TgpuCommandEncoder, core: object, logResources: LogResources | undefined, priors: TimestampWritesPriors & { readonly encoder?: TgpuCommandEncoder | undefined; }): void; export declare function emitRenderDraw(root: ExperimentalTgpuRoot, passInternals: RenderPassInternals, pipeline: TgpuRenderPipeline, usesIndexBuffer: boolean, emit: (rawPass: GPURenderPassEncoder | GPURenderBundleEncoder) => void, ownsPass?: boolean): void; export declare function emitComputeDispatch(root: ExperimentalTgpuRoot, passInternals: ComputePassInternals, pipeline: TgpuComputePipeline, emit: (rawPass: GPUComputePassEncoder) => void, ownsPass?: boolean): void;