typegpu 0.12.1 → 0.12.3

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.
@@ -0,0 +1 @@
1
+ export declare function assignInfixOperators(): void;
@@ -0,0 +1,21 @@
1
+ import { Operator } from 'tsover-runtime';
2
+ import { MatBase } from "./matrix.js";
3
+ import { VecBase } from "./vectorImpl.js";
4
+ import { assignInfixOperator } from "../tgsl/infixDispatch.js";
5
+ let infixOperatorsAssigned = false;
6
+ export function assignInfixOperators() {
7
+ if (infixOperatorsAssigned) {
8
+ return;
9
+ }
10
+ infixOperatorsAssigned = true;
11
+ assignInfixOperator(VecBase, 'add', Operator.plus);
12
+ assignInfixOperator(MatBase, 'add', Operator.plus);
13
+ assignInfixOperator(VecBase, 'sub', Operator.minus);
14
+ assignInfixOperator(MatBase, 'sub', Operator.minus);
15
+ assignInfixOperator(VecBase, 'mul', Operator.star);
16
+ assignInfixOperator(MatBase, 'mul', Operator.star);
17
+ assignInfixOperator(VecBase, 'div', Operator.slash);
18
+ assignInfixOperator(VecBase, 'mod', Operator.percent);
19
+ assignInfixOperator(VecBase, 'bitShiftLeft', Symbol()); // bitShift does not yet have tsover operator symbol
20
+ assignInfixOperator(VecBase, 'bitShiftRight', Symbol()); // bitShift does not yet have tsover operator symbol
21
+ }
package/data/index.d.ts CHANGED
@@ -1,6 +1,24 @@
1
1
  /**
2
2
  * @module typegpu/data
3
3
  */
4
+ export declare const vec2b: import("./wgslTypes.ts").Vec2b;
5
+ export declare const vec2f: import("./wgslTypes.ts").Vec2f;
6
+ export declare const vec2h: import("./wgslTypes.ts").Vec2h;
7
+ export declare const vec2i: import("./wgslTypes.ts").Vec2i;
8
+ export declare const vec2u: import("./wgslTypes.ts").Vec2u;
9
+ export declare const vec3b: import("./wgslTypes.ts").Vec3b;
10
+ export declare const vec3f: import("./wgslTypes.ts").Vec3f;
11
+ export declare const vec3h: import("./wgslTypes.ts").Vec3h;
12
+ export declare const vec3i: import("./wgslTypes.ts").Vec3i;
13
+ export declare const vec3u: import("./wgslTypes.ts").Vec3u;
14
+ export declare const vec4b: import("./wgslTypes.ts").Vec4b;
15
+ export declare const vec4f: import("./wgslTypes.ts").Vec4f;
16
+ export declare const vec4h: import("./wgslTypes.ts").Vec4h;
17
+ export declare const vec4i: import("./wgslTypes.ts").Vec4i;
18
+ export declare const vec4u: import("./wgslTypes.ts").Vec4u;
19
+ export declare const mat2x2f: import("./wgslTypes.ts").Mat2x2f;
20
+ export declare const mat3x3f: import("./wgslTypes.ts").Mat3x3f;
21
+ export declare const mat4x4f: import("./wgslTypes.ts").Mat4x4f;
4
22
  export { bool, f16, f32, i32, u16, u32 } from './numeric.ts';
5
23
  export { isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isInvariantAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, Void, } from './wgslTypes.ts';
6
24
  export type { Align, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, atomicI32, atomicU32, BaseData, BaseData as BaseWgslData, Bool, Builtin, Decorated, F16, F32, I32, Interpolate, Invariant, Location, m2x2f, m3x3f, m4x4f, Mat2x2f, Mat3x3f, Mat4x4f, matBase, Ptr, Size, StorableData, U16, U32, v2b, v2f, v2h, v2i, v2u, v3b, v3f, v3h, v3i, v3u, v4b, v4f, v4h, v4i, v4u, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, vecBase, WgslArray, WgslStruct, } from './wgslTypes.ts';
@@ -10,10 +28,9 @@ export { ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup } fr
10
28
  export type { AnyData, AnyLooseData, Disarray, LooseDecorated, Unstruct } from './dataTypes.ts';
11
29
  export { texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, type WgslExternalTexture, type WgslStorageTexture, type WgslStorageTexture1d, type WgslStorageTexture2d, type WgslStorageTexture2dArray, type WgslStorageTexture3d, type WgslStorageTextureProps, type WgslTexture, type WgslTexture1d, type WgslTexture2d, type WgslTexture2dArray, type WgslTexture3d, type WgslTextureCube, type WgslTextureCubeArray, type WgslTextureDepth2d, type WgslTextureDepth2dArray, type WgslTextureDepthCube, type WgslTextureDepthCubeArray, type WgslTextureDepthMultisampled2d, type WgslTextureMultisampled2d, } from './texture.ts';
12
30
  export { comparisonSampler, sampler, type WgslComparisonSampler, type WgslSampler, } from './sampler.ts';
13
- export { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, } from './vector.ts';
14
31
  export { disarrayOf } from './disarray.ts';
15
32
  export { unstruct } from './unstruct.ts';
16
- export { mat2x2f, mat3x3f, mat4x4f, matToArray } from './matrix.ts';
33
+ export { matToArray } from './matrix.ts';
17
34
  export * from './vertexFormatData.ts';
18
35
  export { atomic } from './atomic.ts';
19
36
  export { _ref as ref } from './ref.ts';
package/data/index.js CHANGED
@@ -2,20 +2,27 @@
2
2
  * @module typegpu/data
3
3
  */
4
4
  // NOTE: This is a barrel file, internal files should not import things from this file
5
- import { Operator } from 'tsover-runtime';
6
- import { MatBase } from "./matrix.js";
7
- import { VecBase } from "./vectorImpl.js";
8
- import { assignInfixOperator } from "../tgsl/infixDispatch.js";
9
- assignInfixOperator(VecBase, 'add', Operator.plus);
10
- assignInfixOperator(MatBase, 'add', Operator.plus);
11
- assignInfixOperator(VecBase, 'sub', Operator.minus);
12
- assignInfixOperator(MatBase, 'sub', Operator.minus);
13
- assignInfixOperator(VecBase, 'mul', Operator.star);
14
- assignInfixOperator(MatBase, 'mul', Operator.star);
15
- assignInfixOperator(VecBase, 'div', Operator.slash);
16
- assignInfixOperator(VecBase, 'mod', Operator.percent);
17
- assignInfixOperator(VecBase, 'bitShiftLeft', Symbol()); // bitShift does not yet have tsover operator symbol
18
- assignInfixOperator(VecBase, 'bitShiftRight', Symbol()); // bitShift does not yet have tsover operator symbol
5
+ import { assignInfixOperators } from "./assignInfixOperators.js";
6
+ import { vec2b as _vec2b, vec2f as _vec2f, vec2h as _vec2h, vec2i as _vec2i, vec2u as _vec2u, vec3b as _vec3b, vec3f as _vec3f, vec3h as _vec3h, vec3i as _vec3i, vec3u as _vec3u, vec4b as _vec4b, vec4f as _vec4f, vec4h as _vec4h, vec4i as _vec4i, vec4u as _vec4u, } from "./vector.js";
7
+ export const vec2b = (() => (assignInfixOperators(), _vec2b))();
8
+ export const vec2f = (() => (assignInfixOperators(), _vec2f))();
9
+ export const vec2h = (() => (assignInfixOperators(), _vec2h))();
10
+ export const vec2i = (() => (assignInfixOperators(), _vec2i))();
11
+ export const vec2u = (() => (assignInfixOperators(), _vec2u))();
12
+ export const vec3b = (() => (assignInfixOperators(), _vec3b))();
13
+ export const vec3f = (() => (assignInfixOperators(), _vec3f))();
14
+ export const vec3h = (() => (assignInfixOperators(), _vec3h))();
15
+ export const vec3i = (() => (assignInfixOperators(), _vec3i))();
16
+ export const vec3u = (() => (assignInfixOperators(), _vec3u))();
17
+ export const vec4b = (() => (assignInfixOperators(), _vec4b))();
18
+ export const vec4f = (() => (assignInfixOperators(), _vec4f))();
19
+ export const vec4h = (() => (assignInfixOperators(), _vec4h))();
20
+ export const vec4i = (() => (assignInfixOperators(), _vec4i))();
21
+ export const vec4u = (() => (assignInfixOperators(), _vec4u))();
22
+ import { mat2x2f as _mat2x2f, mat3x3f as _mat3x3f, mat4x4f as _mat4x4f } from "./matrix.js";
23
+ export const mat2x2f = (() => (assignInfixOperators(), _mat2x2f))();
24
+ export const mat3x3f = (() => (assignInfixOperators(), _mat3x3f))();
25
+ export const mat4x4f = (() => (assignInfixOperators(), _mat4x4f))();
19
26
  export { bool, f16, f32, i32, u16, u32 } from "./numeric.js";
20
27
  export { isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isInvariantAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, Void, } from "./wgslTypes.js";
21
28
  export { struct } from "./struct.js";
@@ -23,10 +30,9 @@ export { arrayOf } from "./array.js";
23
30
  export { ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup } from "./ptr.js";
24
31
  export { texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, } from "./texture.js";
25
32
  export { comparisonSampler, sampler, } from "./sampler.js";
26
- export { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, } from "./vector.js";
27
33
  export { disarrayOf } from "./disarray.js";
28
34
  export { unstruct } from "./unstruct.js";
29
- export { mat2x2f, mat3x3f, mat4x4f, matToArray } from "./matrix.js";
35
+ export { matToArray } from "./matrix.js";
30
36
  export * from "./vertexFormatData.js";
31
37
  export { atomic } from "./atomic.js";
32
38
  export { _ref as ref } from "./ref.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typegpu",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.",
5
5
  "keywords": [
6
6
  "compute",
package/shared/meta.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = "0.12.1";
1
+ const version = "0.12.3";
2
2
  import { DEV, TEST } from "./env.js";
3
3
  import { $getNameForward, $soul, isMarkedInternal } from "./symbols.js";
4
4
  import { normalizeMetadata } from "./normalizeMetadata.js";
package/shared/symbols.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = "0.12.1";
1
+ const version = "0.12.3";
2
2
  export const $internal = Symbol(`typegpu:${version}:$internal`);
3
3
  /** A plain record of all definitional state of a resource, surviving transfer between runtimes */
4
4
  export const $soul = Symbol(`typegpu:${version}:$soul`);
package/std/texture.js CHANGED
@@ -5,13 +5,16 @@ import { f32, i32, u32 } from "../data/numeric.js";
5
5
  import { vec2u, vec3u, vec4f, vec4i, vec4u } from "../data/vector.js";
6
6
  import { Void, } from "../data/wgslTypes.js";
7
7
  import { getTextureFormatInfo, } from "../core/texture/textureFormats.js";
8
+ function compactSnippetArgs(args) {
9
+ return args.filter((arg) => arg !== undefined);
10
+ }
8
11
  function sampleCpu(_texture, _sampler, _coords, _offsetOrArrayIndex, _maybeOffset) {
9
12
  throw new MissingCpuImplError('Texture sampling relies on GPU resources and cannot be executed outside of a draw call');
10
13
  }
11
14
  export const textureSample = dualImpl({
12
15
  name: 'textureSample',
13
16
  normalImpl: sampleCpu,
14
- codegenImpl: (_ctx, args) => stitch `textureSample(${args})`,
17
+ codegenImpl: (ctx, args) => ctx.gen.emitCall('textureSample', [], compactSnippetArgs(args)),
15
18
  signature: (...args) => {
16
19
  const isDepth = args[0].type.startsWith('texture_depth');
17
20
  return {
@@ -27,7 +30,7 @@ function sampleBiasCpu(_texture, _sampler, _coords, _biasOrArrayIndex, _biasOrOf
27
30
  export const textureSampleBias = dualImpl({
28
31
  name: 'textureSampleBias',
29
32
  normalImpl: sampleBiasCpu,
30
- codegenImpl: (_ctx, args) => stitch `textureSampleBias(${args})`,
33
+ codegenImpl: (ctx, args) => ctx.gen.emitCall('textureSampleBias', [], compactSnippetArgs(args)),
31
34
  signature: (...args) => ({
32
35
  argTypes: args,
33
36
  returnType: vec4f,
@@ -40,7 +43,7 @@ function sampleLevelCpu(_texture, _sampler, _coords, _level, _offsetOrArrayIndex
40
43
  export const textureSampleLevel = dualImpl({
41
44
  name: 'textureSampleLevel',
42
45
  normalImpl: sampleLevelCpu,
43
- codegenImpl: (_ctx, args) => stitch `textureSampleLevel(${args})`,
46
+ codegenImpl: (ctx, args) => ctx.gen.emitCall('textureSampleLevel', [], compactSnippetArgs(args)),
44
47
  signature: (...args) => {
45
48
  const isDepth = args[0].type.startsWith('texture_depth');
46
49
  return {
@@ -56,7 +59,7 @@ function textureLoadCpu(_texture, _coords, _levelOrArrayIndex) {
56
59
  export const textureLoad = dualImpl({
57
60
  name: 'textureLoad',
58
61
  normalImpl: textureLoadCpu,
59
- codegenImpl: (_ctx, args) => stitch `textureLoad(${args})`,
62
+ codegenImpl: (ctx, args) => ctx.gen.emitCall('textureLoad', [], compactSnippetArgs(args)),
60
63
  signature: (...args) => {
61
64
  const texture = args[0];
62
65
  if (isWgslTexture(texture)) {
@@ -104,7 +107,7 @@ function textureDimensionsCpu(_texture, _level) {
104
107
  export const textureDimensions = dualImpl({
105
108
  name: 'textureDimensions',
106
109
  normalImpl: textureDimensionsCpu,
107
- codegenImpl: (_ctx, args) => stitch `textureDimensions(${args})`,
110
+ codegenImpl: (ctx, args) => ctx.gen.emitCall('textureDimensions', [], compactSnippetArgs(args)),
108
111
  signature: (...args) => {
109
112
  const dim = args[0].dimension;
110
113
  if (dim === '1d') {