Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/main' into fix/pointers-for-refe…
…rence-types
  • Loading branch information
Aleksander Katan committed Aug 21, 2025
commit 97eb673da0584d8e28fc17593dc34bfcfd95b01a
4 changes: 4 additions & 0 deletions packages/typegpu/src/data/wgslTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,10 @@ export type StorableData =
| WgslArray
| WgslStruct;

export type AnyFloat32VecData = Vec2f | Vec3f | Vec4f;

export type AnyFloat16VecData = Vec2h | Vec3h | Vec4h;

export type AnyWgslData =
| Bool
| F32
Expand Down
14 changes: 8 additions & 6 deletions packages/typegpu/src/std/array.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createDualImpl } from '../core/function/dualImpl.ts';
import { dualImpl } from '../core/function/dualImpl.ts';
import { stitch } from '../core/resolve/stitch.ts';
import { abstractInt, u32 } from '../data/numeric.ts';
import { ptrFn } from '../data/ptr.ts';
import { snip } from '../data/snippet.ts';
import { isPtr, isWgslArray, type StorableData } from '../data/wgslTypes.ts';
import { isPtr, isWgslArray } from '../data/wgslTypes.ts';

const sizeOfPointedToArray = (dataType: unknown) =>
isPtr(dataType) && isWgslArray(dataType.inner)
Expand All @@ -19,6 +18,9 @@ export const arrayLength = dualImpl({
returnType: sizeOfPointedToArray(ptrArg) > 0 ? abstractInt : u32,
});
},
'arrayLength',
(a) => [ptrFn(a.dataType as StorableData)],
);
normalImpl: (a: unknown[]) => a.length,
codegenImpl(a) {
const length = sizeOfPointedToArray(a.dataType);
return length > 0 ? String(length) : stitch`arrayLength(${a})`;
},
});
You are viewing a condensed version of this merge commit. You can view the full changes here.