Skip to content

[RFC] chore: Don't name externals in mergeExternals#2616

Merged
aleksanderkatan merged 5 commits into
mainfrom
chore/dont-name-externals-in-merge
Jun 18, 2026
Merged

[RFC] chore: Don't name externals in mergeExternals#2616
aleksanderkatan merged 5 commits into
mainfrom
chore/dont-name-externals-in-merge

Conversation

@aleksanderkatan

@aleksanderkatan aleksanderkatan commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Currently, whether an unnamed item is autonamed in mergeExternals depends on its depth in plugin-generated externals:

  it('...', () => {
    const c1 = (() => tgpu.const(d.vec2u, d.vec2u(1)))(); // unnamed
    const ext = { c2: (() => tgpu.const(d.vec2u, d.vec2u(2)))() /* unnamed */ };
    const fn = () => {
      'use gpu';
      const a = c1.$;
      const b = ext.c2.$;
    };

    expect(tgpu.resolve([fn])).toMatchInlineSnapshot(`
      "const c1: vec2u = vec2u(1);

      const item: vec2u = vec2u(2);

      fn fn_1() {
        const a = c1;
        const b = item;
      }"
    `);
  });

As seen in #2593, an actual deep pass for proper autonaming is not only difficult, but also hits the performance due to how long isResolvable takes.

I think removing this may be a good step in order to make our externals both correct and performant.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@e0e79ca0d51373979ea1202fcca03551737a97df
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@e0e79ca0d51373979ea1202fcca03551737a97df
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@e0e79ca0d51373979ea1202fcca03551737a97df
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@e0e79ca0d51373979ea1202fcca03551737a97df
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@e0e79ca0d51373979ea1202fcca03551737a97df

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

📊 Bundle Size Comparison

🟢 Decreased ➖ Unchanged 🔴 Increased ❔ Unknown
1 324 31 0

👀 Notable results

Static test results:

No major changes.

Dynamic test results:

No major changes.

📋 All results

Click to reveal the results table (355 entries).
Test tsdown
isUsableAsUniform from typegpu.ts 62.97 kB ($${\color{red}+0.1\%}$$)
isTexture from typegpu.ts 62.98 kB ($${\color{red}+0.1\%}$$)
isSampler from typegpu.ts 62.98 kB ($${\color{red}+0.1\%}$$)
isComparisonSampler from typegpu.ts 63.00 kB ($${\color{red}+0.1\%}$$)
isVariable from typegpu.ts 64.69 kB ($${\color{red}+0.1\%}$$)
isUsableAsVertex from typegpu.ts 88.54 kB ($${\color{red}+0.0\%}$$)
isBuffer from typegpu.ts 88.55 kB ($${\color{red}+0.0\%}$$)
common from typegpu.ts 58.42 kB ($${\color{green}-0.0\%}$$)
tgpuImportEverything.ts 261.49 kB ($${\color{red}+0.0\%}$$)
tgpu from typegpu.ts 261.49 kB ($${\color{red}+0.0\%}$$)
tgpu.fn from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.init from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.lazy from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.slot from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.const from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.unroll from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.resolve from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.accessor from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.comptime from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.vertexFn from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.computeFn from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.fragmentFn from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.privateVar from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpuImportOne.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.vertexLayout from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.workgroupVar from typegpu.ts 261.50 kB ($${\color{red}+0.0\%}$$)
tgpu.initFromDevice from typegpu.ts 261.51 kB ($${\color{red}+0.0\%}$$)
tgpu.bindGroupLayout from typegpu.ts 261.51 kB ($${\color{red}+0.0\%}$$)
tgpu.mutableAccessor from typegpu.ts 261.51 kB ($${\color{red}+0.0\%}$$)
tgpu.resolveWithContext from typegpu.ts 261.51 kB ($${\color{red}+0.0\%}$$)
WgslGenerator from typegpu.ts 114.90 kB ($${\color{red}+0.0\%}$$)
importEntireLibrary.ts 289.35 kB ($${\color{red}+0.0\%}$$)
dataImportEverything.ts 89.49 kB (➖)
dataImportOneDirect.ts 24.62 kB (➖)
dataImportOneStar.ts 24.62 kB (➖)
functionWithUseGpu.ts 282 B (➖)
functionWithoutUseGpu.ts 24 B (➖)
stdImportEverything.ts 105.73 kB (➖)
stdImportOneDirect.ts 48.37 kB (➖)
stdImportOneStar.ts 48.37 kB (➖)
MissingBindGroupsError from typegpu.ts 1.35 kB (➖)
MissingSlotValueError from typegpu.ts 151 B (➖)
MissingVertexBuffersError from typegpu.ts 1.36 kB (➖)
NotUniformError from typegpu.ts 1.31 kB (➖)
ResolutionError from typegpu.ts 2.33 kB (➖)
ShaderGenerator from typegpu.ts 1.66 kB (➖)
Void from typegpudata.ts 734 B (➖)
abs from typegpustd.ts 65.82 kB (➖)
acos from typegpustd.ts 65.82 kB (➖)
acosh from typegpustd.ts 65.82 kB (➖)
add from typegpustd.ts 48.37 kB (➖)
align from typegpudata.ts 26.31 kB (➖)
alignmentOf from typegpudata.ts 21.85 kB (➖)
allEq from typegpustd.ts 51.74 kB (➖)
all from typegpustd.ts 51.74 kB (➖)
and from typegpustd.ts 51.74 kB (➖)
any from typegpustd.ts 51.75 kB (➖)
arrayLength from typegpustd.ts 14.43 kB (➖)
arrayOf from typegpudata.ts 26.17 kB (➖)
asin from typegpustd.ts 65.82 kB (➖)
asinh from typegpustd.ts 65.82 kB (➖)
atan2 from typegpustd.ts 65.82 kB (➖)
atan from typegpustd.ts 65.82 kB (➖)
atanh from typegpustd.ts 65.82 kB (➖)
atomicAdd from typegpustd.ts 15.80 kB (➖)
atomicAnd from typegpustd.ts 15.80 kB (➖)
atomicLoad from typegpustd.ts 15.79 kB (➖)
atomicMax from typegpustd.ts 15.80 kB (➖)
atomicMin from typegpustd.ts 15.80 kB (➖)
atomicOr from typegpustd.ts 15.80 kB (➖)
atomicStore from typegpustd.ts 15.79 kB (➖)
atomicSub from typegpustd.ts 15.80 kB (➖)
atomicXor from typegpustd.ts 15.80 kB (➖)
atomic from typegpudata.ts 779 B (➖)
bitShiftLeft from typegpustd.ts 48.37 kB (➖)
bitShiftRight from typegpustd.ts 48.37 kB (➖)
bitcastU32toF32 from typegpustd.ts 44.19 kB (➖)
bitcastU32toI32 from typegpustd.ts 44.20 kB (➖)
bool from typegpudata.ts 12.97 kB (➖)
builtin from typegpudata.ts 28.63 kB (➖)
ceil from typegpustd.ts 65.82 kB (➖)
clamp from typegpustd.ts 65.82 kB (➖)
comparisonSampler from typegpudata.ts 753 B (➖)
copy from typegpustd.ts 14.43 kB (➖)
cos from typegpustd.ts 65.82 kB (➖)
cosh from typegpustd.ts 65.82 kB (➖)
countLeadingZeros from typegpustd.ts 65.82 kB (➖)
countOneBits from typegpustd.ts 65.82 kB (➖)
countTrailingZeros from typegpustd.ts 65.82 kB (➖)
cross from typegpustd.ts 65.82 kB (➖)
d from typegpu.ts 87.17 kB (➖)
deepEqual from typegpudata.ts 2.19 kB (➖)
degrees from typegpustd.ts 65.82 kB (➖)
determinant from typegpustd.ts 65.82 kB (➖)
disarrayOf from typegpudata.ts 15.02 kB (➖)
discard from typegpustd.ts 14.19 kB (➖)
distance from typegpustd.ts 65.82 kB (➖)
div from typegpustd.ts 48.37 kB (➖)
dot4I8Packed from typegpustd.ts 65.82 kB (➖)
dot4U8Packed from typegpustd.ts 65.82 kB (➖)
dot from typegpustd.ts 65.81 kB (➖)
dpdxCoarse from typegpustd.ts 15.04 kB (➖)
dpdxFine from typegpustd.ts 15.04 kB (➖)
dpdx from typegpustd.ts 15.03 kB (➖)
dpdyCoarse from typegpustd.ts 15.04 kB (➖)
dpdyFine from typegpustd.ts 15.04 kB (➖)
dpdy from typegpustd.ts 15.04 kB (➖)
eq from typegpustd.ts 51.74 kB (➖)
exp2 from typegpustd.ts 65.82 kB (➖)
exp from typegpustd.ts 65.82 kB (➖)
extensionEnabled from typegpustd.ts 14.58 kB (➖)
extractBits from typegpustd.ts 65.82 kB (➖)
f16 from typegpudata.ts 12.97 kB (➖)
f32 from typegpudata.ts 12.97 kB (➖)
faceForward from typegpustd.ts 65.82 kB (➖)
firstLeadingBit from typegpustd.ts 65.82 kB (➖)
firstTrailingBit from typegpustd.ts 65.82 kB (➖)
float16 from typegpudata.ts 20.91 kB (➖)
float16x2 from typegpudata.ts 20.91 kB (➖)
float16x4 from typegpudata.ts 20.91 kB (➖)
float32 from typegpudata.ts 20.91 kB (➖)
float32x2 from typegpudata.ts 20.91 kB (➖)
float32x3 from typegpudata.ts 20.91 kB (➖)
float32x4 from typegpudata.ts 20.91 kB (➖)
floor from typegpustd.ts 65.82 kB (➖)
fma from typegpustd.ts 65.82 kB (➖)
formatToWGSLType from typegpudata.ts 20.90 kB (➖)
fract from typegpustd.ts 65.82 kB (➖)
frexp from typegpustd.ts 65.82 kB (➖)
fwidthCoarse from typegpustd.ts 15.04 kB (➖)
fwidthFine from typegpustd.ts 15.04 kB (➖)
fwidth from typegpustd.ts 15.04 kB (➖)
ge from typegpustd.ts 51.75 kB (➖)
getLongestContiguousPrefix from typegpudata.ts 24.64 kB (➖)
getTargetShaderLanguage from typegpustd.ts 14.53 kB (➖)
gt from typegpustd.ts 51.75 kB (➖)
i32 from typegpudata.ts 12.97 kB (➖)
identity2 from typegpustd.ts 26.99 kB (➖)
identity3 from typegpustd.ts 26.99 kB (➖)
identity4 from typegpustd.ts 26.99 kB (➖)
insertBits from typegpustd.ts 65.82 kB (➖)
interpolate from typegpudata.ts 26.32 kB (➖)
invariant from typegpudata.ts 26.69 kB (➖)
inverseSqrt from typegpustd.ts 65.82 kB (➖)
isAccessor from typegpu.ts 65 B (➖)
isAlignAttrib from typegpudata.ts 755 B (➖)
isAtomic from typegpudata.ts 755 B (➖)
isBeingTranspiled from typegpustd.ts 14.47 kB (➖)
isBufferShorthand from typegpu.ts 1.71 kB (➖)
isBuiltinAttrib from typegpudata.ts 757 B (➖)
isBuiltin from typegpudata.ts 24.57 kB (➖)
isCloseTo from typegpustd.ts 51.75 kB (➖)
isContiguous from typegpudata.ts 24.63 kB (➖)
isData from typegpudata.ts 1.81 kB (➖)
isDecorated from typegpudata.ts 758 B (➖)
isDisarray from typegpudata.ts 1.11 kB (➖)
isInterpolateAttrib from typegpudata.ts 761 B (➖)
isLazy from typegpu.ts 61 B (➖)
isLocationAttrib from typegpudata.ts 758 B (➖)
isLooseData from typegpudata.ts 1.16 kB (➖)
isLooseDecorated from typegpudata.ts 1.12 kB (➖)
isMutableAccessor from typegpu.ts 73 B (➖)
isPackedData from typegpudata.ts 20.97 kB (➖)
isPtr from typegpudata.ts 752 B (➖)
isSizeAttrib from typegpudata.ts 754 B (➖)
isSlot from typegpu.ts 61 B (➖)
isTgpuComputeFn from typegpu.ts 69 B (➖)
isTgpuFn from typegpu.ts 765 B (➖)
isTgpuFragmentFn from typegpu.ts 70 B (➖)
isTgpuVertexFn from typegpu.ts 68 B (➖)
isUnstruct from typegpudata.ts 1.11 kB (➖)
isUsableAsRender from typegpu.ts 55 B (➖)
isUsableAsSampled from typegpu.ts 56 B (➖)
isUsableAsStorage from typegpu.ts 56 B (➖)
isWgslArray from typegpudata.ts 754 B (➖)
isWgslData from typegpudata.ts 1.31 kB (➖)
isWgslStruct from typegpudata.ts 755 B (➖)
ldexp from typegpustd.ts 65.82 kB (➖)
le from typegpustd.ts 51.75 kB (➖)
length from typegpustd.ts 65.81 kB (➖)
location from typegpudata.ts 26.31 kB (➖)
log2 from typegpustd.ts 65.82 kB (➖)
log from typegpustd.ts 65.82 kB (➖)
lt from typegpustd.ts 51.74 kB (➖)
mat2x2f from typegpudata.ts 26.99 kB (➖)
mat3x3f from typegpudata.ts 26.99 kB (➖)
mat4x4f from typegpudata.ts 26.99 kB (➖)
matToArray from typegpudata.ts 27.12 kB (➖)
max from typegpustd.ts 65.82 kB (➖)
memoryLayoutOf from typegpudata.ts 41.95 kB (➖)
min from typegpustd.ts 65.82 kB (➖)
mix from typegpustd.ts 65.82 kB (➖)
mod from typegpustd.ts 48.37 kB (➖)
modf from typegpustd.ts 65.82 kB (➖)
mul from typegpustd.ts 48.37 kB (➖)
ne from typegpustd.ts 51.74 kB (➖)
neg from typegpustd.ts 48.36 kB (➖)
normalize from typegpustd.ts 65.82 kB (➖)
not from typegpustd.ts 51.74 kB (➖)
or from typegpustd.ts 51.74 kB (➖)
pack2x16float from typegpustd.ts 35.94 kB (➖)
pack4x8unorm from typegpustd.ts 35.94 kB (➖)
packedFormats from typegpudata.ts 20.92 kB (➖)
patchArrayBuffer from typegpu.ts 51.09 kB (➖)
pow from typegpustd.ts 65.82 kB (➖)
ptrFn from typegpudata.ts 859 B (➖)
ptrHandle from typegpudata.ts 851 B (➖)
ptrPrivate from typegpudata.ts 858 B (➖)
ptrStorage from typegpudata.ts 856 B (➖)
ptrUniform from typegpudata.ts 852 B (➖)
ptrWorkgroup from typegpudata.ts 860 B (➖)
quantizeToF16 from typegpustd.ts 65.82 kB (➖)
radians from typegpustd.ts 65.82 kB (➖)
range from typegpustd.ts 14.85 kB (➖)
readFromArrayBuffer from typegpu.ts 51.69 kB (➖)
ref from typegpudata.ts 4.79 kB (➖)
reflect from typegpustd.ts 65.82 kB (➖)
refract from typegpustd.ts 65.82 kB (➖)
reverseBits from typegpustd.ts 65.82 kB (➖)
rotateX4 from typegpustd.ts 49.13 kB (➖)
rotateY4 from typegpustd.ts 49.13 kB (➖)
rotateZ4 from typegpustd.ts 49.13 kB (➖)
rotationX4 from typegpustd.ts 26.99 kB (➖)
rotationY4 from typegpustd.ts 26.99 kB (➖)
rotationZ4 from typegpustd.ts 26.99 kB (➖)
round from typegpustd.ts 65.82 kB (➖)
sampler from typegpudata.ts 742 B (➖)
saturate from typegpustd.ts 65.82 kB (➖)
scale4 from typegpustd.ts 49.13 kB (➖)
scaling4 from typegpustd.ts 26.99 kB (➖)
select from typegpustd.ts 51.74 kB (➖)
sign from typegpustd.ts 65.82 kB (➖)
sin from typegpustd.ts 65.82 kB (➖)
sinh from typegpustd.ts 65.82 kB (➖)
sint16 from typegpudata.ts 20.91 kB (➖)
sint16x2 from typegpudata.ts 20.91 kB (➖)
sint16x4 from typegpudata.ts 20.91 kB (➖)
sint32 from typegpudata.ts 20.91 kB (➖)
sint32x2 from typegpudata.ts 20.91 kB (➖)
sint32x3 from typegpudata.ts 20.91 kB (➖)
sint32x4 from typegpudata.ts 20.91 kB (➖)
sint8 from typegpudata.ts 20.91 kB (➖)
sint8x2 from typegpudata.ts 20.91 kB (➖)
sint8x4 from typegpudata.ts 20.91 kB (➖)
sizeOf from typegpudata.ts 24.62 kB (➖)
size from typegpudata.ts 26.31 kB (➖)
smoothstep from typegpustd.ts 65.82 kB (➖)
snorm16 from typegpudata.ts 20.91 kB (➖)
snorm16x2 from typegpudata.ts 20.91 kB (➖)
snorm16x4 from typegpudata.ts 20.91 kB (➖)
snorm8 from typegpudata.ts 20.91 kB (➖)
snorm8x2 from typegpudata.ts 20.91 kB (➖)
snorm8x4 from typegpudata.ts 20.91 kB (➖)
sqrt from typegpustd.ts 65.82 kB (➖)
std from typegpu.ts 102.89 kB (➖)
step from typegpustd.ts 65.82 kB (➖)
storageBarrier from typegpustd.ts 15.80 kB (➖)
struct from typegpudata.ts 3.42 kB (➖)
sub from typegpustd.ts 48.37 kB (➖)
subgroupAdd from typegpustd.ts 23.98 kB (➖)
subgroupAll from typegpustd.ts 23.99 kB (➖)
subgroupAnd from typegpustd.ts 23.99 kB (➖)
subgroupAny from typegpustd.ts 23.99 kB (➖)
subgroupBallot from typegpustd.ts 23.99 kB (➖)
subgroupBroadcastFirst from typegpustd.ts 23.99 kB (➖)
subgroupBroadcast from typegpustd.ts 23.99 kB (➖)
subgroupElect from typegpustd.ts 23.99 kB (➖)
subgroupExclusiveAdd from typegpustd.ts 23.99 kB (➖)
subgroupExclusiveMul from typegpustd.ts 23.99 kB (➖)
subgroupInclusiveAdd from typegpustd.ts 23.99 kB (➖)
subgroupInclusiveMul from typegpustd.ts 23.99 kB (➖)
subgroupMax from typegpustd.ts 23.99 kB (➖)
subgroupMin from typegpustd.ts 23.99 kB (➖)
subgroupMul from typegpustd.ts 23.99 kB (➖)
subgroupOr from typegpustd.ts 23.99 kB (➖)
subgroupShuffleDown from typegpustd.ts 23.99 kB (➖)
subgroupShuffleUp from typegpustd.ts 23.99 kB (➖)
subgroupShuffleXor from typegpustd.ts 23.99 kB (➖)
subgroupShuffle from typegpustd.ts 23.99 kB (➖)
subgroupXor from typegpustd.ts 23.99 kB (➖)
tan from typegpustd.ts 65.82 kB (➖)
tanh from typegpustd.ts 65.82 kB (➖)
texture1d from typegpudata.ts 13.43 kB (➖)
texture2dArray from typegpudata.ts 13.45 kB (➖)
texture2d from typegpudata.ts 13.43 kB (➖)
texture3d from typegpudata.ts 13.43 kB (➖)
textureBarrier from typegpustd.ts 15.79 kB (➖)
textureCubeArray from typegpudata.ts 13.45 kB (➖)
textureCube from typegpudata.ts 13.43 kB (➖)
textureDepth2dArray from typegpudata.ts 13.44 kB (➖)
textureDepth2d from typegpudata.ts 13.42 kB (➖)
textureDepthCubeArray from typegpudata.ts 13.44 kB (➖)
textureDepthCube from typegpudata.ts 13.42 kB (➖)
textureDepthMultisampled2d from typegpudata.ts 13.44 kB (➖)
textureDimensions from typegpustd.ts 25.74 kB (➖)
textureExternal from typegpudata.ts 873 B (➖)
textureGather from typegpustd.ts 25.74 kB (➖)
textureLoad from typegpustd.ts 25.75 kB (➖)
textureMultisampled2d from typegpudata.ts 13.45 kB (➖)
textureSampleBaseClampToEdge from typegpustd.ts 25.75 kB (➖)
textureSampleBias from typegpustd.ts 25.75 kB (➖)
textureSampleCompareLevel from typegpustd.ts 25.75 kB (➖)
textureSampleCompare from typegpustd.ts 25.75 kB (➖)
textureSampleGrad from typegpustd.ts 25.75 kB (➖)
textureSampleLevel from typegpustd.ts 25.75 kB (➖)
textureSample from typegpustd.ts 25.75 kB (➖)
textureStorage1d from typegpudata.ts 1.01 kB (➖)
textureStorage2dArray from typegpudata.ts 1.03 kB (➖)
textureStorage2d from typegpudata.ts 1.01 kB (➖)
textureStorage3d from typegpudata.ts 1.01 kB (➖)
textureStore from typegpustd.ts 25.75 kB (➖)
translate4 from typegpustd.ts 49.13 kB (➖)
translation4 from typegpustd.ts 26.99 kB (➖)
transpose from typegpustd.ts 65.82 kB (➖)
trunc from typegpustd.ts 65.82 kB (➖)
u16 from typegpudata.ts 13.00 kB (➖)
u32 from typegpudata.ts 12.97 kB (➖)
uint16 from typegpudata.ts 20.91 kB (➖)
uint16x2 from typegpudata.ts 20.91 kB (➖)
uint16x4 from typegpudata.ts 20.91 kB (➖)
uint32 from typegpudata.ts 20.91 kB (➖)
uint32x2 from typegpudata.ts 20.91 kB (➖)
uint32x3 from typegpudata.ts 20.91 kB (➖)
uint32x4 from typegpudata.ts 20.91 kB (➖)
uint8 from typegpudata.ts 20.90 kB (➖)
uint8x2 from typegpudata.ts 20.91 kB (➖)
uint8x4 from typegpudata.ts 20.91 kB (➖)
unorm10 10 10 2 from typegpudata.ts 20.91 kB (➖)
unorm16 from typegpudata.ts 20.91 kB (➖)
unorm16x2 from typegpudata.ts 20.91 kB (➖)
unorm16x4 from typegpudata.ts 20.91 kB (➖)
unorm8 from typegpudata.ts 20.91 kB (➖)
unorm8x2 from typegpudata.ts 20.91 kB (➖)
unorm8x4 bgra from typegpudata.ts 20.91 kB (➖)
unorm8x4 from typegpudata.ts 20.91 kB (➖)
unpack2x16float from typegpustd.ts 35.94 kB (➖)
unpack4x8unorm from typegpustd.ts 35.94 kB (➖)
unstruct from typegpudata.ts 1.55 kB (➖)
vec2b from typegpudata.ts 19.41 kB (➖)
vec2f from typegpudata.ts 19.41 kB (➖)
vec2h from typegpudata.ts 19.41 kB (➖)
vec2i from typegpudata.ts 19.41 kB (➖)
vec2u from typegpudata.ts 19.41 kB (➖)
vec3b from typegpudata.ts 19.41 kB (➖)
vec3f from typegpudata.ts 19.41 kB (➖)
vec3h from typegpudata.ts 19.41 kB (➖)
vec3i from typegpudata.ts 19.41 kB (➖)
vec3u from typegpudata.ts 19.41 kB (➖)
vec4b from typegpudata.ts 19.41 kB (➖)
vec4f from typegpudata.ts 19.41 kB (➖)
vec4h from typegpudata.ts 19.41 kB (➖)
vec4i from typegpudata.ts 19.41 kB (➖)
vec4u from typegpudata.ts 19.41 kB (➖)
workgroupBarrier from typegpustd.ts 15.80 kB (➖)
writeToArrayBuffer from typegpu.ts 50.89 kB (➖)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

Resolution Time Benchmark

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.90, 1.87, 4.10, 6.66, 8.00, 11.11, 21.55, 25.33]
  line [0.90, 1.78, 4.10, 5.96, 7.23, 11.76, 20.98, 24.46]
  line [0.93, 1.76, 4.24, 6.51, 7.50, 11.65, 21.56, 23.71]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.33, 0.74, 0.72, 0.84, 1.15, 1.19, 1.45, 1.52]
  line [0.35, 0.48, 0.66, 0.85, 1.11, 1.14, 1.58, 1.57]
  line [0.28, 0.58, 0.76, 0.87, 1.18, 1.26, 1.51, 1.55]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.78, 2.12, 4.34, 7.27, 12.81, 26.99, 55.93, 118.22]
  line [0.77, 2.06, 3.71, 6.16, 12.08, 24.74, 53.10, 108.88]
  line [0.98, 2.12, 3.88, 6.16, 12.17, 25.49, 55.44, 110.19]
Loading

Comment on lines +571 to +577
it("resolved externals's names stay the same", () => {
const c1 = (() => tgpu.const(d.vec2u, d.vec2u(1)))(); // unnamed
tgpu.resolve([tgpu.fn([])`() { let a = myConst; }`.$uses({ myConst: c1 })]);
tgpu.resolve([tgpu.fn([])`() { let a = otherName; }`.$uses({ otherName: c1 })]);

expect(getName(c1)).toMatchInlineSnapshot(`"myConst"`);
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me wonder if we should do anything at all, though I don't think it's that much of an issue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine, I think it's unusual for a thing to be references by other names in different WGSL templates, and even if it is, it's still a valid name for it.

@aleksanderkatan aleksanderkatan marked this pull request as ready for review June 16, 2026 09:19
Copilot AI review requested due to automatic review settings June 16, 2026 09:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a very useful case for ambient naming (through external keys), as time is the result of calling useUniform, a helper API that's not instrumented by unplugin-typegpu to be auto-named.

What we could do instead, is add a separate mechanism of ambient naming to 'use gpu' shader functions. When an external is retrieved using getById, and it is namable, we can name it. Same whenever we access a prop, we can name the value using the key if its namable. Wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! I thought we could just add more cases to plugin autonaming, but this seems to do the job

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Minor suggestion inline — otherwise looks solid.

Reviewed changes — removes the auto-naming logic from mergeExternals and shifts responsibility to replaceExternalsInWgsl for raw WGSL and the plugin for TGSL, with a follow-up fix for the guarded compute pipeline.

  • Remove setName from mergeExternals — the function no longer names unnamed externals by map key, avoiding depth-dependent naming bugs and the perf cost of isResolvable in that path.
  • Add setName in replaceExternalsInWgsl — for raw WGSL functions, unnamed resolvable externals are now named from the last component of their external key (e.g. ext.n2n2) before resolution.
  • Explicit $name in createGuardedComputePipeline — the wrappedCallback was previously named by mergeExternals; added an explicit $name('wrappedCallback') call.
  • Snapshot updates — doc example tests now show item (the makeUniqueIdentifier default) instead of time for unnamed externals.

Note: 1 inline comment(s) dropped because they did not anchor to lines inside the PR diff:

  • packages/typegpu/src/core/resolve/externals.ts:18 (RIGHT) — line 18 (RIGHT) is not inside a diff hunk

Pullfrog  | Fix it ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — adds TGSL-side externals naming in getById and accessProp, completing externals naming coverage that was missing from the prior review (which only covered raw WGSL in replaceExternalsInWgsl).

  • Name externals in getById — when ItemStateStackImpl.getSnippetById fetches a nameless TgpuNamable external from layer.externalMap[id], it now names it with that ID (e.g., myConst).
  • Name externals in accessProp — when accessing a property on a comptime-known target that yields a nameless TgpuNamable value, it is named with the property name.
  • New tests for naming coverage — added "names used externals" and "names used nested externals" to tgslFn.test.ts, plus "names resolved externals" / "resolved externals's names stay the same" to rawFn.test.ts.
  • Removed doc snapshot churn — the timeitem snapshot updates in doc example tests were reverted, since unnamed externals now carry proper names.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@iwoplaza iwoplaza left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes! 💜

@aleksanderkatan aleksanderkatan merged commit 46c1932 into main Jun 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants