-
-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
I think we should remove schema validation in createBuffer. Reasons:
- Logic could be moved into a type-aware lint plugin
- Prevents users from creating helper functions that accept generic types
Example of a generic function that fails
import { type TgpuRoot } from 'typegpu';
import { arrayOf } from 'typegpu/data';
export function createInstanceBuffer<StructData extends d.WgslStruct>(
root: TgpuRoot,
struct: StructData,
length: number,
) {
const instanceBuffer = root
// ❌ `d.WgslArray<StructData> is not assignable to `ValidateBufferSchema<d.WgslArray<StructData>>`
.createBuffer(d.arrayOf(struct, length))
// ❌ A very long error relating to usages
.$usage('vertex', 'storage');
const instanceLayout = tgpu.vertexLayout(
(n) => arrayOf(struct, n),
'instance',
);
return [instanceBuffer, instanceLayout] as const;
}aleksanderkatan
Metadata
Metadata
Assignees
Labels
No labels