typegpu 0.12.1 → 0.12.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
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
+ assignInfixOperator(VecBase, 'add', Operator.plus);
6
+ assignInfixOperator(MatBase, 'add', Operator.plus);
7
+ assignInfixOperator(VecBase, 'sub', Operator.minus);
8
+ assignInfixOperator(MatBase, 'sub', Operator.minus);
9
+ assignInfixOperator(VecBase, 'mul', Operator.star);
10
+ assignInfixOperator(MatBase, 'mul', Operator.star);
11
+ assignInfixOperator(VecBase, 'div', Operator.slash);
12
+ assignInfixOperator(VecBase, 'mod', Operator.percent);
13
+ assignInfixOperator(VecBase, 'bitShiftLeft', Symbol()); // bitShift does not yet have tsover operator symbol
14
+ assignInfixOperator(VecBase, 'bitShiftRight', Symbol()); // bitShift does not yet have tsover operator symbol
package/data/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @module typegpu/data
3
3
  */
4
+ import './assignInfixOperators.ts';
4
5
  export { bool, f16, f32, i32, u16, u32 } from './numeric.ts';
5
6
  export { isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isInvariantAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, Void, } from './wgslTypes.ts';
6
7
  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';
package/data/index.js CHANGED
@@ -2,20 +2,8 @@
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
+ // oxlint-disable-next-line import/no-unassigned-import -- this import has side effects
6
+ import "./assignInfixOperators.js";
19
7
  export { bool, f16, f32, i32, u16, u32 } from "./numeric.js";
20
8
  export { isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isInvariantAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, Void, } from "./wgslTypes.js";
21
9
  export { struct } from "./struct.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typegpu",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
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",
@@ -23,7 +23,9 @@
23
23
  "directory": "packages/typegpu"
24
24
  },
25
25
  "type": "module",
26
- "sideEffects": false,
26
+ "sideEffects": [
27
+ "./data/assignInfixOperators.js"
28
+ ],
27
29
  "exports": {
28
30
  "./package.json": "./package.json",
29
31
  ".": {
package/shared/meta.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = "0.12.1";
1
+ const version = "0.12.2";
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.2";
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') {