typegpu 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{chunk-BYypO7fO.js → _virtual/_rolldown/runtime.js} +1 -1
- package/builtin.d.ts +50 -0
- package/builtin.js +37 -0
- package/common/fullScreenTriangle.d.ts +26 -0
- package/common/fullScreenTriangle.js +36 -0
- package/common/index.d.ts +2 -3
- package/common/index.js +3 -4
- package/core/buffer/buffer.d.ts +74 -0
- package/core/buffer/buffer.js +197 -0
- package/core/buffer/bufferShorthand.d.ts +48 -0
- package/core/buffer/bufferShorthand.js +49 -0
- package/core/buffer/bufferUsage.d.ts +45 -0
- package/core/buffer/bufferUsage.js +163 -0
- package/core/constant/tgpuConstant.d.ts +28 -0
- package/core/constant/tgpuConstant.js +67 -0
- package/core/declare/tgpuDeclare.d.ts +18 -0
- package/core/declare/tgpuDeclare.js +40 -0
- package/core/function/autoIO.d.ts +37 -0
- package/core/function/autoIO.js +87 -0
- package/core/function/comptime.d.ts +39 -0
- package/core/function/comptime.js +51 -0
- package/core/function/createCallableSchema.js +42 -0
- package/core/function/dualImpl.js +54 -0
- package/core/function/extractArgs.js +204 -0
- package/core/function/fnCore.js +79 -0
- package/core/function/fnTypes.d.ts +34 -0
- package/core/function/ioSchema.d.ts +10 -0
- package/core/function/ioSchema.js +30 -0
- package/core/function/shelllessImpl.d.ts +28 -0
- package/core/function/shelllessImpl.js +23 -0
- package/core/function/templateUtils.js +13 -0
- package/core/function/tgpuComputeFn.d.ts +49 -0
- package/core/function/tgpuComputeFn.js +62 -0
- package/core/function/tgpuFn.d.ts +52 -0
- package/core/function/tgpuFn.js +170 -0
- package/core/function/tgpuFragmentFn.d.ts +68 -0
- package/core/function/tgpuFragmentFn.js +68 -0
- package/core/function/tgpuVertexFn.d.ts +55 -0
- package/core/function/tgpuVertexFn.js +65 -0
- package/core/pipeline/applyPipelineState.js +37 -0
- package/core/pipeline/computePipeline.d.ts +58 -0
- package/core/pipeline/computePipeline.js +226 -0
- package/core/pipeline/connectAttachmentToShader.js +26 -0
- package/core/pipeline/connectTargetsToShader.js +29 -0
- package/core/pipeline/limitsOverflow.js +13 -0
- package/core/pipeline/renderPipeline.d.ts +266 -0
- package/core/pipeline/renderPipeline.js +471 -0
- package/core/pipeline/timeable.d.ts +23 -0
- package/core/pipeline/timeable.js +61 -0
- package/core/pipeline/typeGuards.js +29 -0
- package/core/querySet/querySet.d.ts +22 -0
- package/core/querySet/querySet.js +103 -0
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +59 -0
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +96 -0
- package/core/resolve/externals.d.ts +10 -0
- package/core/resolve/externals.js +58 -0
- package/core/resolve/namespace.d.ts +38 -0
- package/core/resolve/namespace.js +41 -0
- package/core/resolve/resolveData.js +146 -0
- package/core/resolve/stitch.js +25 -0
- package/core/resolve/tgpuResolve.d.ts +151 -0
- package/core/resolve/tgpuResolve.js +68 -0
- package/core/root/configurableImpl.js +18 -0
- package/core/root/init.d.ts +69 -0
- package/core/root/init.js +457 -0
- package/core/root/rootTypes.d.ts +622 -0
- package/core/sampler/sampler.d.ts +35 -0
- package/core/sampler/sampler.js +116 -0
- package/core/simulate/tgpuSimulate.d.ts +36 -0
- package/core/simulate/tgpuSimulate.js +76 -0
- package/core/slot/accessor.d.ts +13 -0
- package/core/slot/accessor.js +97 -0
- package/core/slot/internalSlots.js +7 -0
- package/core/slot/lazy.d.ts +6 -0
- package/core/slot/lazy.js +42 -0
- package/core/slot/slot.d.ts +6 -0
- package/core/slot/slot.js +40 -0
- package/core/slot/slotTypes.d.ts +92 -0
- package/core/slot/slotTypes.js +21 -0
- package/core/texture/externalTexture.d.ts +12 -0
- package/core/texture/externalTexture.js +48 -0
- package/core/texture/texture.d.ts +118 -0
- package/core/texture/texture.js +312 -0
- package/core/texture/textureFormats.d.ts +29 -0
- package/core/texture/textureFormats.js +99 -0
- package/core/texture/textureProps.d.ts +11 -0
- package/core/texture/textureUtils.js +224 -0
- package/core/texture/usageExtension.d.ts +21 -0
- package/core/texture/usageExtension.js +21 -0
- package/core/unroll/tgpuUnroll.d.ts +13 -0
- package/core/unroll/tgpuUnroll.js +36 -0
- package/core/valueProxyUtils.js +44 -0
- package/core/variable/tgpuVariable.d.ts +38 -0
- package/core/variable/tgpuVariable.js +101 -0
- package/core/vertexLayout/connectAttributesToShader.js +59 -0
- package/core/vertexLayout/vertexAttribute.d.ts +29 -0
- package/core/vertexLayout/vertexLayout.d.ts +19 -0
- package/core/vertexLayout/vertexLayout.js +103 -0
- package/data/alignIO.js +15 -0
- package/data/alignmentOf.d.ts +10 -0
- package/data/alignmentOf.js +88 -0
- package/data/array.d.ts +28 -0
- package/data/array.js +48 -0
- package/data/atomic.d.ts +15 -0
- package/data/atomic.js +25 -0
- package/data/attributes.d.ts +121 -0
- package/data/attributes.js +145 -0
- package/data/autoStruct.d.ts +3 -0
- package/data/autoStruct.js +83 -0
- package/data/compiledIO.js +231 -0
- package/data/dataIO.js +549 -0
- package/data/dataTypes.d.ts +115 -0
- package/data/dataTypes.js +97 -0
- package/data/deepEqual.d.ts +25 -0
- package/data/deepEqual.js +58 -0
- package/data/disarray.d.ts +34 -0
- package/data/disarray.js +52 -0
- package/data/getLongestContiguousPrefix.d.ts +10 -0
- package/data/getLongestContiguousPrefix.js +15 -0
- package/data/index.d.ts +26 -4
- package/data/index.js +27 -7
- package/data/instanceToSchema.d.ts +33 -0
- package/data/isContiguous.d.ts +10 -0
- package/data/isContiguous.js +15 -0
- package/data/matrix.d.ts +126 -0
- package/data/matrix.js +517 -0
- package/data/numberOps.js +24 -0
- package/data/numeric.d.ts +81 -0
- package/data/numeric.js +234 -0
- package/data/offsetUtils.d.ts +33 -0
- package/data/offsetUtils.js +167 -0
- package/data/offsets.js +36 -0
- package/data/partialIO.js +68 -0
- package/data/ptr.d.ts +12 -0
- package/data/ptr.js +46 -0
- package/data/ref.d.ts +37 -0
- package/data/ref.js +96 -0
- package/data/sampler.d.ts +107 -0
- package/data/sampler.js +26 -0
- package/data/schemaCallWrapper.js +32 -0
- package/data/schemaMemoryLayout.js +200 -0
- package/data/sizeOf.d.ts +10 -0
- package/data/sizeOf.js +15 -0
- package/data/snippet.d.ts +26 -0
- package/data/snippet.js +61 -0
- package/data/struct.d.ts +17 -0
- package/data/struct.js +46 -0
- package/data/texture.d.ts +292 -0
- package/{texture-BagDrrks.js → data/texture.js} +6 -3
- package/data/unstruct.d.ts +24 -0
- package/data/unstruct.js +43 -0
- package/data/vector.d.ts +191 -0
- package/data/vector.js +247 -0
- package/data/vectorImpl.js +516 -0
- package/data/vectorOps.js +664 -0
- package/data/vertexFormatData.d.ts +190 -0
- package/data/vertexFormatData.js +110 -0
- package/data/wgslTypes.d.ts +896 -0
- package/data/wgslTypes.js +215 -0
- package/errors.d.ts +44 -0
- package/errors.js +128 -0
- package/execMode.js +51 -0
- package/extension.d.ts +11 -0
- package/extension.js +18 -0
- package/getGPUValue.js +9 -0
- package/index.d.ts +40 -243
- package/index.js +19 -6318
- package/indexNamedExports.d.ts +38 -0
- package/mathUtils.js +13 -0
- package/memo.js +22 -0
- package/nameRegistry.d.ts +30 -0
- package/nameRegistry.js +449 -0
- package/package.js +5 -0
- package/package.json +23 -23
- package/resolutionCtx.d.ts +29 -0
- package/resolutionCtx.js +546 -0
- package/shared/env.js +13 -0
- package/shared/generators.js +14 -0
- package/shared/meta.d.ts +39 -0
- package/shared/meta.js +63 -0
- package/shared/repr.d.ts +108 -0
- package/shared/stringify.js +22 -0
- package/shared/symbols.d.ts +61 -0
- package/shared/symbols.js +71 -0
- package/shared/utilityTypes.d.ts +29 -0
- package/shared/utilityTypes.js +7 -0
- package/shared/vertexFormat.d.ts +70 -0
- package/shared/vertexFormat.js +64 -0
- package/std/array.d.ts +7 -0
- package/std/array.js +27 -0
- package/std/atomic.d.ts +19 -0
- package/std/atomic.js +113 -0
- package/std/bitcast.d.ts +10 -0
- package/std/bitcast.js +43 -0
- package/std/boolean.d.ts +127 -0
- package/std/boolean.js +274 -0
- package/std/derivative.d.ts +16 -0
- package/std/derivative.js +89 -0
- package/std/discard.d.ts +6 -0
- package/std/discard.js +16 -0
- package/std/extensions.d.ts +8 -0
- package/std/extensions.js +14 -0
- package/std/index.d.ts +15 -3
- package/std/index.js +16 -5
- package/std/matrix.d.ts +41 -0
- package/std/matrix.js +87 -0
- package/std/numeric.d.ts +254 -0
- package/std/numeric.js +847 -0
- package/std/operators.d.ts +48 -0
- package/std/operators.js +153 -0
- package/std/packing.d.ts +26 -0
- package/std/packing.js +86 -0
- package/std/subgroup.d.ts +47 -0
- package/std/subgroup.js +220 -0
- package/std/texture.d.ts +108 -0
- package/std/texture.js +197 -0
- package/tgpu.js +44 -0
- package/tgpuBindGroupLayout.d.ts +161 -0
- package/tgpuBindGroupLayout.js +271 -0
- package/tgpuUnstable.d.ts +48 -0
- package/tgpuUnstable.js +66 -0
- package/tgsl/accessIndex.js +45 -0
- package/tgsl/accessProp.js +113 -0
- package/tgsl/consoleLog/deserializers.js +117 -0
- package/tgsl/consoleLog/logGenerator.js +86 -0
- package/tgsl/consoleLog/serializers.js +225 -0
- package/tgsl/consoleLog/types.d.ts +54 -0
- package/tgsl/consoleLog/types.js +12 -0
- package/tgsl/conversion.js +200 -0
- package/tgsl/forOfUtils.js +45 -0
- package/tgsl/generationHelpers.d.ts +37 -0
- package/tgsl/generationHelpers.js +67 -0
- package/tgsl/math.js +45 -0
- package/tgsl/shaderGenerator.d.ts +18 -0
- package/tgsl/shellless.d.ts +11 -0
- package/tgsl/shellless.js +53 -0
- package/tgsl/wgslGenerator.js +585 -0
- package/types.d.ts +255 -0
- package/types.js +43 -0
- package/unwrapper.d.ts +27 -0
- package/wgslExtensions.d.ts +5 -0
- package/wgslExtensions.js +18 -0
- package/builtin-DdtWpk2t.js +0 -818
- package/builtin-DdtWpk2t.js.map +0 -1
- package/common/index.d.ts.map +0 -1
- package/common/index.js.map +0 -1
- package/data/index.d.ts.map +0 -1
- package/data/index.js.map +0 -1
- package/deepEqual-DQxK4vdp.js +0 -413
- package/deepEqual-DQxK4vdp.js.map +0 -1
- package/extensions-DIVuAfBM.js +0 -2032
- package/extensions-DIVuAfBM.js.map +0 -1
- package/fullScreenTriangle-CfFyQd_0.js +0 -543
- package/fullScreenTriangle-CfFyQd_0.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/indexNamedExports-oL6tyaJ9.d.ts +0 -5697
- package/indexNamedExports-oL6tyaJ9.d.ts.map +0 -1
- package/operators-d-PMVTo7.js +0 -4158
- package/operators-d-PMVTo7.js.map +0 -1
- package/std/index.d.ts.map +0 -1
- package/std/index.js.map +0 -1
- package/texture-BagDrrks.js.map +0 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { $invalidSchemaReason, $repr, $validVertexSchema } from "../shared/symbols.js";
|
|
2
|
+
import { VertexFormat } from "../shared/vertexFormat.js";
|
|
3
|
+
import { WithCast } from "../types.js";
|
|
4
|
+
import { BaseData, F16, F32, I32, U32, Vec2f, Vec2h, Vec2i, Vec2u, Vec3f, Vec3h, Vec3i, Vec3u, Vec4f, Vec4h, Vec4i, Vec4u } from "./wgslTypes.js";
|
|
5
|
+
import { Infer } from "../shared/repr.js";
|
|
6
|
+
|
|
7
|
+
//#region src/data/vertexFormatData.d.ts
|
|
8
|
+
type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
|
|
9
|
+
interface TgpuVertexFormatData<T extends VertexFormat> extends BaseData, WithCast<FormatToWGSLType<T>> {
|
|
10
|
+
readonly type: T;
|
|
11
|
+
readonly [$repr]: Infer<FormatToWGSLType<T>>;
|
|
12
|
+
readonly [$validVertexSchema]: true;
|
|
13
|
+
readonly [$invalidSchemaReason]: 'Vertex formats are not host-shareable, use concrete types instead';
|
|
14
|
+
}
|
|
15
|
+
declare const formatToWGSLType: {
|
|
16
|
+
readonly uint8: U32;
|
|
17
|
+
readonly uint8x2: Vec2u;
|
|
18
|
+
readonly uint8x4: Vec4u;
|
|
19
|
+
readonly sint8: I32;
|
|
20
|
+
readonly sint8x2: Vec2i;
|
|
21
|
+
readonly sint8x4: Vec4i;
|
|
22
|
+
readonly unorm8: F32;
|
|
23
|
+
readonly unorm8x2: Vec2f;
|
|
24
|
+
readonly unorm8x4: Vec4f;
|
|
25
|
+
readonly snorm8: F32;
|
|
26
|
+
readonly snorm8x2: Vec2f;
|
|
27
|
+
readonly snorm8x4: Vec4f;
|
|
28
|
+
readonly uint16: U32;
|
|
29
|
+
readonly uint16x2: Vec2u;
|
|
30
|
+
readonly uint16x4: Vec4u;
|
|
31
|
+
readonly sint16: I32;
|
|
32
|
+
readonly sint16x2: Vec2i;
|
|
33
|
+
readonly sint16x4: Vec4i;
|
|
34
|
+
readonly unorm16: F32;
|
|
35
|
+
readonly unorm16x2: Vec2f;
|
|
36
|
+
readonly unorm16x4: Vec4f;
|
|
37
|
+
readonly snorm16: F32;
|
|
38
|
+
readonly snorm16x2: Vec2f;
|
|
39
|
+
readonly snorm16x4: Vec4f;
|
|
40
|
+
readonly float16: F32;
|
|
41
|
+
readonly float16x2: Vec2f;
|
|
42
|
+
readonly float16x4: Vec4f;
|
|
43
|
+
readonly float32: F32;
|
|
44
|
+
readonly float32x2: Vec2f;
|
|
45
|
+
readonly float32x3: Vec3f;
|
|
46
|
+
readonly float32x4: Vec4f;
|
|
47
|
+
readonly uint32: U32;
|
|
48
|
+
readonly uint32x2: Vec2u;
|
|
49
|
+
readonly uint32x3: Vec3u;
|
|
50
|
+
readonly uint32x4: Vec4u;
|
|
51
|
+
readonly sint32: I32;
|
|
52
|
+
readonly sint32x2: Vec2i;
|
|
53
|
+
readonly sint32x3: Vec3i;
|
|
54
|
+
readonly sint32x4: Vec4i;
|
|
55
|
+
readonly 'unorm10-10-10-2': Vec4f;
|
|
56
|
+
readonly 'unorm8x4-bgra': Vec4f;
|
|
57
|
+
};
|
|
58
|
+
declare const packedFormats: Set<string>;
|
|
59
|
+
type uint8 = TgpuVertexFormatData<'uint8'>;
|
|
60
|
+
declare const uint8: uint8;
|
|
61
|
+
type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
|
|
62
|
+
declare const uint8x2: uint8x2;
|
|
63
|
+
type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
|
|
64
|
+
declare const uint8x4: uint8x4;
|
|
65
|
+
type sint8 = TgpuVertexFormatData<'sint8'>;
|
|
66
|
+
declare const sint8: sint8;
|
|
67
|
+
type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
|
|
68
|
+
declare const sint8x2: sint8x2;
|
|
69
|
+
type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
|
|
70
|
+
declare const sint8x4: sint8x4;
|
|
71
|
+
type unorm8 = TgpuVertexFormatData<'unorm8'>;
|
|
72
|
+
declare const unorm8: unorm8;
|
|
73
|
+
type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
|
|
74
|
+
declare const unorm8x2: unorm8x2;
|
|
75
|
+
type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
|
|
76
|
+
declare const unorm8x4: unorm8x4;
|
|
77
|
+
type snorm8 = TgpuVertexFormatData<'snorm8'>;
|
|
78
|
+
declare const snorm8: snorm8;
|
|
79
|
+
type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
|
|
80
|
+
declare const snorm8x2: snorm8x2;
|
|
81
|
+
type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
|
|
82
|
+
declare const snorm8x4: snorm8x4;
|
|
83
|
+
type uint16 = TgpuVertexFormatData<'uint16'>;
|
|
84
|
+
declare const uint16: uint16;
|
|
85
|
+
type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
|
|
86
|
+
declare const uint16x2: uint16x2;
|
|
87
|
+
type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
|
|
88
|
+
declare const uint16x4: uint16x4;
|
|
89
|
+
type sint16 = TgpuVertexFormatData<'sint16'>;
|
|
90
|
+
declare const sint16: sint16;
|
|
91
|
+
type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
|
|
92
|
+
declare const sint16x2: sint16x2;
|
|
93
|
+
type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
|
|
94
|
+
declare const sint16x4: sint16x4;
|
|
95
|
+
type unorm16 = TgpuVertexFormatData<'unorm16'>;
|
|
96
|
+
declare const unorm16: unorm16;
|
|
97
|
+
type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
|
|
98
|
+
declare const unorm16x2: unorm16x2;
|
|
99
|
+
type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
|
|
100
|
+
declare const unorm16x4: unorm16x4;
|
|
101
|
+
type snorm16 = TgpuVertexFormatData<'snorm16'>;
|
|
102
|
+
declare const snorm16: snorm16;
|
|
103
|
+
type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
|
|
104
|
+
declare const snorm16x2: snorm16x2;
|
|
105
|
+
type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
|
|
106
|
+
declare const snorm16x4: snorm16x4;
|
|
107
|
+
type float16 = TgpuVertexFormatData<'float16'>;
|
|
108
|
+
declare const float16: float16;
|
|
109
|
+
type float16x2 = TgpuVertexFormatData<'float16x2'>;
|
|
110
|
+
declare const float16x2: float16x2;
|
|
111
|
+
type float16x4 = TgpuVertexFormatData<'float16x4'>;
|
|
112
|
+
declare const float16x4: float16x4;
|
|
113
|
+
type float32 = TgpuVertexFormatData<'float32'>;
|
|
114
|
+
declare const float32: float32;
|
|
115
|
+
type float32x2 = TgpuVertexFormatData<'float32x2'>;
|
|
116
|
+
declare const float32x2: float32x2;
|
|
117
|
+
type float32x3 = TgpuVertexFormatData<'float32x3'>;
|
|
118
|
+
declare const float32x3: float32x3;
|
|
119
|
+
type float32x4 = TgpuVertexFormatData<'float32x4'>;
|
|
120
|
+
declare const float32x4: float32x4;
|
|
121
|
+
type uint32 = TgpuVertexFormatData<'uint32'>;
|
|
122
|
+
declare const uint32: uint32;
|
|
123
|
+
type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
|
|
124
|
+
declare const uint32x2: uint32x2;
|
|
125
|
+
type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
|
|
126
|
+
declare const uint32x3: uint32x3;
|
|
127
|
+
type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
|
|
128
|
+
declare const uint32x4: uint32x4;
|
|
129
|
+
type sint32 = TgpuVertexFormatData<'sint32'>;
|
|
130
|
+
declare const sint32: sint32;
|
|
131
|
+
type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
|
|
132
|
+
declare const sint32x2: sint32x2;
|
|
133
|
+
type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
|
|
134
|
+
declare const sint32x3: sint32x3;
|
|
135
|
+
type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
|
|
136
|
+
declare const sint32x4: sint32x4;
|
|
137
|
+
type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;
|
|
138
|
+
declare const unorm10_10_10_2: unorm10_10_10_2;
|
|
139
|
+
type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;
|
|
140
|
+
declare const unorm8x4_bgra: unorm8x4_bgra;
|
|
141
|
+
type PackedData = uint8 | uint8x2 | uint8x4 | sint8 | sint8x2 | sint8x4 | unorm8 | unorm8x2 | unorm8x4 | snorm8 | snorm8x2 | snorm8x4 | uint16 | uint16x2 | uint16x4 | sint16 | sint16x2 | sint16x4 | unorm16 | unorm16x2 | unorm16x4 | snorm16 | snorm16x2 | snorm16x4 | float16 | float16x2 | float16x4 | float32 | float32x2 | float32x3 | float32x4 | uint32 | uint32x2 | uint32x3 | uint32x4 | sint32 | sint32x2 | sint32x3 | sint32x4 | unorm10_10_10_2 | unorm8x4_bgra;
|
|
142
|
+
declare function isPackedData(value: unknown): value is PackedData;
|
|
143
|
+
type U32Data = U32 | Vec2u | Vec3u | Vec4u;
|
|
144
|
+
type I32Data = I32 | Vec2i | Vec3i | Vec4i;
|
|
145
|
+
type FloatData = F32 | Vec2f | Vec3f | Vec4f | F16 | Vec2h | Vec3h | Vec4h;
|
|
146
|
+
type FormatToAcceptedData = {
|
|
147
|
+
uint8: U32Data;
|
|
148
|
+
uint8x2: U32Data;
|
|
149
|
+
uint8x4: U32Data;
|
|
150
|
+
sint8: I32Data;
|
|
151
|
+
sint8x2: I32Data;
|
|
152
|
+
sint8x4: I32Data;
|
|
153
|
+
unorm8: FloatData;
|
|
154
|
+
unorm8x2: FloatData;
|
|
155
|
+
unorm8x4: FloatData;
|
|
156
|
+
snorm8: FloatData;
|
|
157
|
+
snorm8x2: FloatData;
|
|
158
|
+
snorm8x4: FloatData;
|
|
159
|
+
uint16: U32Data;
|
|
160
|
+
uint16x2: U32Data;
|
|
161
|
+
uint16x4: U32Data;
|
|
162
|
+
sint16: I32Data;
|
|
163
|
+
sint16x2: I32Data;
|
|
164
|
+
sint16x4: I32Data;
|
|
165
|
+
unorm16: FloatData;
|
|
166
|
+
unorm16x2: FloatData;
|
|
167
|
+
unorm16x4: FloatData;
|
|
168
|
+
snorm16: FloatData;
|
|
169
|
+
snorm16x2: FloatData;
|
|
170
|
+
snorm16x4: FloatData;
|
|
171
|
+
float16: FloatData;
|
|
172
|
+
float16x2: FloatData;
|
|
173
|
+
float16x4: FloatData;
|
|
174
|
+
float32: FloatData;
|
|
175
|
+
float32x2: FloatData;
|
|
176
|
+
float32x3: FloatData;
|
|
177
|
+
float32x4: FloatData;
|
|
178
|
+
uint32: U32Data;
|
|
179
|
+
uint32x2: U32Data;
|
|
180
|
+
uint32x3: U32Data;
|
|
181
|
+
uint32x4: U32Data;
|
|
182
|
+
sint32: I32Data;
|
|
183
|
+
sint32x2: I32Data;
|
|
184
|
+
sint32x3: I32Data;
|
|
185
|
+
sint32x4: I32Data;
|
|
186
|
+
'unorm10-10-10-2': FloatData;
|
|
187
|
+
'unorm8x4-bgra': FloatData;
|
|
188
|
+
};
|
|
189
|
+
//#endregion
|
|
190
|
+
export { FormatToAcceptedData, FormatToWGSLType, PackedData, TgpuVertexFormatData, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, isPackedData, packedFormats, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { $cast, $gpuCallable, $internal, isMarkedInternal } from "../shared/symbols.js";
|
|
2
|
+
import { schemaCallWrapper, schemaCallWrapperGPU } from "./schemaCallWrapper.js";
|
|
3
|
+
import { f32, i32, u32 } from "./numeric.js";
|
|
4
|
+
import { vec2f, vec2i, vec2u, vec3f, vec3i, vec3u, vec4f, vec4i, vec4u } from "./vector.js";
|
|
5
|
+
|
|
6
|
+
//#region src/data/vertexFormatData.ts
|
|
7
|
+
var TgpuVertexFormatDataImpl = class {
|
|
8
|
+
[$internal] = {};
|
|
9
|
+
[$gpuCallable];
|
|
10
|
+
constructor(type) {
|
|
11
|
+
this.type = type;
|
|
12
|
+
this[$gpuCallable] = { call: (ctx, [v]) => {
|
|
13
|
+
return schemaCallWrapperGPU(ctx, formatToWGSLType[this.type], v);
|
|
14
|
+
} };
|
|
15
|
+
}
|
|
16
|
+
[$cast](v) {
|
|
17
|
+
return schemaCallWrapper(formatToWGSLType[this.type], v);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const formatToWGSLType = {
|
|
21
|
+
uint8: u32,
|
|
22
|
+
uint8x2: vec2u,
|
|
23
|
+
uint8x4: vec4u,
|
|
24
|
+
sint8: i32,
|
|
25
|
+
sint8x2: vec2i,
|
|
26
|
+
sint8x4: vec4i,
|
|
27
|
+
unorm8: f32,
|
|
28
|
+
unorm8x2: vec2f,
|
|
29
|
+
unorm8x4: vec4f,
|
|
30
|
+
snorm8: f32,
|
|
31
|
+
snorm8x2: vec2f,
|
|
32
|
+
snorm8x4: vec4f,
|
|
33
|
+
uint16: u32,
|
|
34
|
+
uint16x2: vec2u,
|
|
35
|
+
uint16x4: vec4u,
|
|
36
|
+
sint16: i32,
|
|
37
|
+
sint16x2: vec2i,
|
|
38
|
+
sint16x4: vec4i,
|
|
39
|
+
unorm16: f32,
|
|
40
|
+
unorm16x2: vec2f,
|
|
41
|
+
unorm16x4: vec4f,
|
|
42
|
+
snorm16: f32,
|
|
43
|
+
snorm16x2: vec2f,
|
|
44
|
+
snorm16x4: vec4f,
|
|
45
|
+
float16: f32,
|
|
46
|
+
float16x2: vec2f,
|
|
47
|
+
float16x4: vec4f,
|
|
48
|
+
float32: f32,
|
|
49
|
+
float32x2: vec2f,
|
|
50
|
+
float32x3: vec3f,
|
|
51
|
+
float32x4: vec4f,
|
|
52
|
+
uint32: u32,
|
|
53
|
+
uint32x2: vec2u,
|
|
54
|
+
uint32x3: vec3u,
|
|
55
|
+
uint32x4: vec4u,
|
|
56
|
+
sint32: i32,
|
|
57
|
+
sint32x2: vec2i,
|
|
58
|
+
sint32x3: vec3i,
|
|
59
|
+
sint32x4: vec4i,
|
|
60
|
+
"unorm10-10-10-2": vec4f,
|
|
61
|
+
"unorm8x4-bgra": vec4f
|
|
62
|
+
};
|
|
63
|
+
const packedFormats = new Set(Object.keys(formatToWGSLType));
|
|
64
|
+
const uint8 = new TgpuVertexFormatDataImpl("uint8");
|
|
65
|
+
const uint8x2 = new TgpuVertexFormatDataImpl("uint8x2");
|
|
66
|
+
const uint8x4 = new TgpuVertexFormatDataImpl("uint8x4");
|
|
67
|
+
const sint8 = new TgpuVertexFormatDataImpl("sint8");
|
|
68
|
+
const sint8x2 = new TgpuVertexFormatDataImpl("sint8x2");
|
|
69
|
+
const sint8x4 = new TgpuVertexFormatDataImpl("sint8x4");
|
|
70
|
+
const unorm8 = new TgpuVertexFormatDataImpl("unorm8");
|
|
71
|
+
const unorm8x2 = new TgpuVertexFormatDataImpl("unorm8x2");
|
|
72
|
+
const unorm8x4 = new TgpuVertexFormatDataImpl("unorm8x4");
|
|
73
|
+
const snorm8 = new TgpuVertexFormatDataImpl("snorm8");
|
|
74
|
+
const snorm8x2 = new TgpuVertexFormatDataImpl("snorm8x2");
|
|
75
|
+
const snorm8x4 = new TgpuVertexFormatDataImpl("snorm8x4");
|
|
76
|
+
const uint16 = new TgpuVertexFormatDataImpl("uint16");
|
|
77
|
+
const uint16x2 = new TgpuVertexFormatDataImpl("uint16x2");
|
|
78
|
+
const uint16x4 = new TgpuVertexFormatDataImpl("uint16x4");
|
|
79
|
+
const sint16 = new TgpuVertexFormatDataImpl("sint16");
|
|
80
|
+
const sint16x2 = new TgpuVertexFormatDataImpl("sint16x2");
|
|
81
|
+
const sint16x4 = new TgpuVertexFormatDataImpl("sint16x4");
|
|
82
|
+
const unorm16 = new TgpuVertexFormatDataImpl("unorm16");
|
|
83
|
+
const unorm16x2 = new TgpuVertexFormatDataImpl("unorm16x2");
|
|
84
|
+
const unorm16x4 = new TgpuVertexFormatDataImpl("unorm16x4");
|
|
85
|
+
const snorm16 = new TgpuVertexFormatDataImpl("snorm16");
|
|
86
|
+
const snorm16x2 = new TgpuVertexFormatDataImpl("snorm16x2");
|
|
87
|
+
const snorm16x4 = new TgpuVertexFormatDataImpl("snorm16x4");
|
|
88
|
+
const float16 = new TgpuVertexFormatDataImpl("float16");
|
|
89
|
+
const float16x2 = new TgpuVertexFormatDataImpl("float16x2");
|
|
90
|
+
const float16x4 = new TgpuVertexFormatDataImpl("float16x4");
|
|
91
|
+
const float32 = new TgpuVertexFormatDataImpl("float32");
|
|
92
|
+
const float32x2 = new TgpuVertexFormatDataImpl("float32x2");
|
|
93
|
+
const float32x3 = new TgpuVertexFormatDataImpl("float32x3");
|
|
94
|
+
const float32x4 = new TgpuVertexFormatDataImpl("float32x4");
|
|
95
|
+
const uint32 = new TgpuVertexFormatDataImpl("uint32");
|
|
96
|
+
const uint32x2 = new TgpuVertexFormatDataImpl("uint32x2");
|
|
97
|
+
const uint32x3 = new TgpuVertexFormatDataImpl("uint32x3");
|
|
98
|
+
const uint32x4 = new TgpuVertexFormatDataImpl("uint32x4");
|
|
99
|
+
const sint32 = new TgpuVertexFormatDataImpl("sint32");
|
|
100
|
+
const sint32x2 = new TgpuVertexFormatDataImpl("sint32x2");
|
|
101
|
+
const sint32x3 = new TgpuVertexFormatDataImpl("sint32x3");
|
|
102
|
+
const sint32x4 = new TgpuVertexFormatDataImpl("sint32x4");
|
|
103
|
+
const unorm10_10_10_2 = new TgpuVertexFormatDataImpl("unorm10-10-10-2");
|
|
104
|
+
const unorm8x4_bgra = new TgpuVertexFormatDataImpl("unorm8x4-bgra");
|
|
105
|
+
function isPackedData(value) {
|
|
106
|
+
return isMarkedInternal(value) && packedFormats.has(value?.type);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
export { float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, isPackedData, packedFormats, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra };
|