UNPKG

typegpu

Version:

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

16 lines (15 loc) 1.09 kB
import type { Undecorate } from '../data/dataTypes.ts'; import type { BaseData, TypedArrayFor, WgslArray, WgslStruct } from '../data/wgslTypes.ts'; import type { BufferWriteOptions, TgpuBuffer } from '../core/buffer/buffer.ts'; import type { Prettify } from '../shared/utilityTypes.ts'; type PackedScalarFor<T> = Undecorate<T> extends WgslArray<infer TElement> ? PackedScalarFor<TElement> : Undecorate<T>; type PackedSoAInputFor<T> = TypedArrayFor<PackedScalarFor<T>>; type SoAFieldsFor<T extends Record<string, BaseData>> = { [K in keyof T as [PackedSoAInputFor<T[K]>] extends [never] ? never : K]: PackedSoAInputFor<T[K]>; }; type SoAInputFor<T extends Record<string, BaseData>> = [keyof T] extends [keyof SoAFieldsFor<T>] ? Prettify<SoAFieldsFor<T>> : never; export declare function writeSoA<TProps extends Record<string, BaseData>>(buffer: TgpuBuffer<WgslArray<WgslStruct<TProps>>>, data: SoAInputFor<TProps>, options?: BufferWriteOptions): void; export declare namespace writeSoA { type InputFor<TProps extends Record<string, BaseData>> = SoAInputFor<TProps>; } export {};