Skip to content

refactor: Naming cleanup#2363

Open
iwoplaza wants to merge 1 commit intofix/first-class-argument-usage-trackingfrom
refactor/naming-cleanup
Open

refactor: Naming cleanup#2363
iwoplaza wants to merge 1 commit intofix/first-class-argument-usage-trackingfrom
refactor/naming-cleanup

Conversation

@iwoplaza
Copy link
Copy Markdown
Collaborator

@iwoplaza iwoplaza commented Apr 11, 2026

Blocked by #2359

  • (🚀 feature) Exposed more APIs that can be used by alternative shader generators (@typegpu/gl)
  • (🔧 fix) Moved the pushing of the function and block scope further up, so that the arg_n parameters that we're reserving are scoped to the function.
  • (🧹 cleanup) Made the API more clear as to what it's achieving
    • getUniqueName -> makeUniqueIdentifier(..., 'global')
    • makeNameValid -> makeUniqueIdentifier(..., 'block')
  • (🧹 cleanup) Removed unused namespace.on functionality (previously used by @typegpu/three).
  • (🧹 cleanup) Instead of duplicating the scope layers logic between the item state stack and name registry, the naming logic is merged into the ResolutionCtx.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2026

pkg.pr.new

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

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@d7926fa3e51520f998e13c66eb7303ce373d2414
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@d7926fa3e51520f998e13c66eb7303ce373d2414
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@d7926fa3e51520f998e13c66eb7303ce373d2414

benchmark
view benchmark

commit
view commit

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2026

📊 Bundle Size Comparison

🟢 Decreased ➖ Unchanged 🔴 Increased ❔ Unknown
23 324 3 0

👀 Notable results

Static test results:

No major changes.

Dynamic test results:

Test tsdown
common from typegpu.ts 55.46 kB ($${\color{red}+3.8\%}$$)

📋 All results

Click to reveal the results table (349 entries).
Test tsdown
common from typegpu.ts 55.46 kB ($${\color{red}+3.8\%}$$)
WgslGenerator from typegpu.ts 101.14 kB ($${\color{red}+0.1\%}$$)
tgpuImportEverything.ts 250.46 kB ($${\color{green}-0.1\%}$$)
tgpu from typegpu.ts 250.46 kB ($${\color{green}-0.1\%}$$)
tgpu.fn from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.init from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.lazy from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.slot from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.const from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.unroll from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.resolve from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.accessor from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.comptime from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.vertexFn from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.computeFn from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.fragmentFn from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpu.privateVar from typegpu.ts 250.47 kB ($${\color{green}-0.1\%}$$)
tgpuImportOne.ts 250.48 kB ($${\color{green}-0.1\%}$$)
tgpu.vertexLayout from typegpu.ts 250.48 kB ($${\color{green}-0.1\%}$$)
tgpu.workgroupVar from typegpu.ts 250.48 kB ($${\color{green}-0.1\%}$$)
tgpu.initFromDevice from typegpu.ts 250.48 kB ($${\color{green}-0.1\%}$$)
tgpu.bindGroupLayout from typegpu.ts 250.48 kB ($${\color{green}-0.1\%}$$)
tgpu.mutableAccessor from typegpu.ts 250.48 kB ($${\color{green}-0.1\%}$$)
tgpu.resolveWithContext from typegpu.ts 250.48 kB ($${\color{green}-0.1\%}$$)
importEntireLibrary.ts 277.38 kB ($${\color{green}-0.1\%}$$)
isVariable from typegpu.ts 62.01 kB ($${\color{red}+0.0\%}$$)
dataImportEverything.ts 86.80 kB (➖)
dataImportOneDirect.ts 22.34 kB (➖)
dataImportOneStar.ts 22.34 kB (➖)
functionWithUseGpu.ts 282 B (➖)
functionWithoutUseGpu.ts 24 B (➖)
stdImportEverything.ts 101.42 kB (➖)
stdImportOneDirect.ts 45.92 kB (➖)
stdImportOneStar.ts 45.92 kB (➖)
MissingBindGroupsError from typegpu.ts 1.34 kB (➖)
MissingLinksError from typegpu.ts 201 B (➖)
MissingSlotValueError from typegpu.ts 151 B (➖)
MissingVertexBuffersError from typegpu.ts 1.35 kB (➖)
NotUniformError from typegpu.ts 1.30 kB (➖)
ResolutionError from typegpu.ts 1.55 kB (➖)
ShaderGenerator from typegpu.ts 1.84 kB (➖)
Void from typegpudata.ts 734 B (➖)
abs from typegpustd.ts 63.23 kB (➖)
acos from typegpustd.ts 63.23 kB (➖)
acosh from typegpustd.ts 63.23 kB (➖)
add from typegpustd.ts 45.92 kB (➖)
align from typegpudata.ts 24.03 kB (➖)
alignmentOf from typegpudata.ts 19.57 kB (➖)
allEq from typegpustd.ts 48.45 kB (➖)
all from typegpustd.ts 48.45 kB (➖)
and from typegpustd.ts 48.44 kB (➖)
any from typegpustd.ts 48.45 kB (➖)
arrayLength from typegpustd.ts 12.08 kB (➖)
arrayOf from typegpudata.ts 23.83 kB (➖)
asin from typegpustd.ts 63.23 kB (➖)
asinh from typegpustd.ts 63.23 kB (➖)
atan2 from typegpustd.ts 63.23 kB (➖)
atan from typegpustd.ts 63.23 kB (➖)
atanh from typegpustd.ts 63.23 kB (➖)
atomicAdd from typegpustd.ts 13.46 kB (➖)
atomicAnd from typegpustd.ts 13.46 kB (➖)
atomicLoad from typegpustd.ts 13.45 kB (➖)
atomicMax from typegpustd.ts 13.46 kB (➖)
atomicMin from typegpustd.ts 13.46 kB (➖)
atomicOr from typegpustd.ts 13.46 kB (➖)
atomicStore from typegpustd.ts 13.46 kB (➖)
atomicSub from typegpustd.ts 13.46 kB (➖)
atomicXor from typegpustd.ts 13.46 kB (➖)
atomic from typegpudata.ts 779 B (➖)
bitShiftLeft from typegpustd.ts 45.92 kB (➖)
bitShiftRight from typegpustd.ts 45.92 kB (➖)
bitcastU32toF32 from typegpustd.ts 41.74 kB (➖)
bitcastU32toI32 from typegpustd.ts 41.75 kB (➖)
bool from typegpudata.ts 10.64 kB (➖)
builtin from typegpudata.ts 26.21 kB (➖)
ceil from typegpustd.ts 63.23 kB (➖)
clamp from typegpustd.ts 63.23 kB (➖)
comparisonSampler from typegpudata.ts 753 B (➖)
cos from typegpustd.ts 63.23 kB (➖)
cosh from typegpustd.ts 63.23 kB (➖)
countLeadingZeros from typegpustd.ts 63.23 kB (➖)
countOneBits from typegpustd.ts 63.23 kB (➖)
countTrailingZeros from typegpustd.ts 63.23 kB (➖)
cross from typegpustd.ts 63.23 kB (➖)
d from typegpu.ts 84.50 kB (➖)
deepEqual from typegpudata.ts 2.77 kB (➖)
degrees from typegpustd.ts 63.23 kB (➖)
determinant from typegpustd.ts 63.23 kB (➖)
disarrayOf from typegpudata.ts 12.60 kB (➖)
discard from typegpustd.ts 11.85 kB (➖)
distance from typegpustd.ts 63.22 kB (➖)
div from typegpustd.ts 45.92 kB (➖)
dot4I8Packed from typegpustd.ts 63.23 kB (➖)
dot4U8Packed from typegpustd.ts 63.22 kB (➖)
dot from typegpustd.ts 63.22 kB (➖)
dpdxCoarse from typegpustd.ts 12.70 kB (➖)
dpdxFine from typegpustd.ts 12.70 kB (➖)
dpdx from typegpustd.ts 12.69 kB (➖)
dpdyCoarse from typegpustd.ts 12.70 kB (➖)
dpdyFine from typegpustd.ts 12.70 kB (➖)
dpdy from typegpustd.ts 12.70 kB (➖)
eq from typegpustd.ts 48.45 kB (➖)
exp2 from typegpustd.ts 63.23 kB (➖)
exp from typegpustd.ts 63.23 kB (➖)
extensionEnabled from typegpustd.ts 12.16 kB (➖)
extractBits from typegpustd.ts 63.23 kB (➖)
f16 from typegpudata.ts 10.64 kB (➖)
f32 from typegpudata.ts 10.64 kB (➖)
faceForward from typegpustd.ts 63.23 kB (➖)
firstLeadingBit from typegpustd.ts 63.23 kB (➖)
firstTrailingBit from typegpustd.ts 63.23 kB (➖)
float16 from typegpudata.ts 18.53 kB (➖)
float16x2 from typegpudata.ts 18.53 kB (➖)
float16x4 from typegpudata.ts 18.53 kB (➖)
float32 from typegpudata.ts 18.53 kB (➖)
float32x2 from typegpudata.ts 18.53 kB (➖)
float32x3 from typegpudata.ts 18.53 kB (➖)
float32x4 from typegpudata.ts 18.53 kB (➖)
floor from typegpustd.ts 63.23 kB (➖)
fma from typegpustd.ts 63.23 kB (➖)
formatToWGSLType from typegpudata.ts 18.52 kB (➖)
fract from typegpustd.ts 63.22 kB (➖)
frexp from typegpustd.ts 63.22 kB (➖)
fwidthCoarse from typegpustd.ts 12.70 kB (➖)
fwidthFine from typegpustd.ts 12.70 kB (➖)
fwidth from typegpustd.ts 12.70 kB (➖)
ge from typegpustd.ts 48.45 kB (➖)
getLongestContiguousPrefix from typegpudata.ts 22.36 kB (➖)
gt from typegpustd.ts 48.45 kB (➖)
i32 from typegpudata.ts 10.64 kB (➖)
identity2 from typegpustd.ts 24.55 kB (➖)
identity3 from typegpustd.ts 24.55 kB (➖)
identity4 from typegpustd.ts 24.55 kB (➖)
insertBits from typegpustd.ts 63.23 kB (➖)
interpolate from typegpudata.ts 24.04 kB (➖)
invariant from typegpudata.ts 24.40 kB (➖)
inverseSqrt from typegpustd.ts 63.23 kB (➖)
isAccessor from typegpu.ts 65 B (➖)
isAlignAttrib from typegpudata.ts 755 B (➖)
isAtomic from typegpudata.ts 755 B (➖)
isBufferShorthand from typegpu.ts 1.81 kB (➖)
isBuffer from typegpu.ts 85.75 kB (➖)
isBuiltinAttrib from typegpudata.ts 757 B (➖)
isBuiltin from typegpudata.ts 22.29 kB (➖)
isCloseTo from typegpustd.ts 48.45 kB (➖)
isComparisonSampler from typegpu.ts 60.21 kB (➖)
isContiguous from typegpudata.ts 22.35 kB (➖)
isData from typegpudata.ts 2.39 kB (➖)
isDecorated from typegpudata.ts 758 B (➖)
isDisarray from typegpudata.ts 1.69 kB (➖)
isInterpolateAttrib from typegpudata.ts 761 B (➖)
isLazy from typegpu.ts 61 B (➖)
isLocationAttrib from typegpudata.ts 758 B (➖)
isLooseData from typegpudata.ts 1.74 kB (➖)
isLooseDecorated from typegpudata.ts 1.70 kB (➖)
isMutableAccessor from typegpu.ts 73 B (➖)
isPackedData from typegpudata.ts 18.59 kB (➖)
isPtr from typegpudata.ts 752 B (➖)
isSampler from typegpu.ts 60.20 kB (➖)
isSizeAttrib from typegpudata.ts 754 B (➖)
isSlot from typegpu.ts 61 B (➖)
isTexture from typegpu.ts 60.20 kB (➖)
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.69 kB (➖)
isUsableAsRender from typegpu.ts 55 B (➖)
isUsableAsSampled from typegpu.ts 56 B (➖)
isUsableAsStorage from typegpu.ts 56 B (➖)
isUsableAsUniform from typegpu.ts 60.18 kB (➖)
isUsableAsVertex from typegpu.ts 85.74 kB (➖)
isWgslArray from typegpudata.ts 754 B (➖)
isWgslData from typegpudata.ts 1.31 kB (➖)
isWgslStruct from typegpudata.ts 755 B (➖)
ldexp from typegpustd.ts 63.23 kB (➖)
le from typegpustd.ts 48.45 kB (➖)
length from typegpustd.ts 63.22 kB (➖)
location from typegpudata.ts 24.03 kB (➖)
log2 from typegpustd.ts 63.23 kB (➖)
log from typegpustd.ts 63.23 kB (➖)
lt from typegpustd.ts 48.45 kB (➖)
mat2x2f from typegpudata.ts 24.55 kB (➖)
mat3x3f from typegpudata.ts 24.55 kB (➖)
mat4x4f from typegpudata.ts 24.55 kB (➖)
matToArray from typegpudata.ts 24.68 kB (➖)
max from typegpustd.ts 63.23 kB (➖)
memoryLayoutOf from typegpudata.ts 39.64 kB (➖)
min from typegpustd.ts 63.23 kB (➖)
mix from typegpustd.ts 63.22 kB (➖)
mod from typegpustd.ts 45.92 kB (➖)
modf from typegpustd.ts 63.22 kB (➖)
mul from typegpustd.ts 45.92 kB (➖)
ne from typegpustd.ts 48.45 kB (➖)
neg from typegpustd.ts 45.91 kB (➖)
normalize from typegpustd.ts 63.23 kB (➖)
not from typegpustd.ts 48.44 kB (➖)
or from typegpustd.ts 48.44 kB (➖)
pack2x16float from typegpustd.ts 33.54 kB (➖)
pack4x8unorm from typegpustd.ts 33.54 kB (➖)
packedFormats from typegpudata.ts 18.55 kB (➖)
pow from typegpustd.ts 63.23 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 63.23 kB (➖)
radians from typegpustd.ts 63.23 kB (➖)
range from typegpustd.ts 12.43 kB (➖)
ref from typegpudata.ts 4.18 kB (➖)
reflect from typegpustd.ts 63.23 kB (➖)
refract from typegpustd.ts 63.23 kB (➖)
reverseBits from typegpustd.ts 63.23 kB (➖)
rotateX4 from typegpustd.ts 46.68 kB (➖)
rotateY4 from typegpustd.ts 46.69 kB (➖)
rotateZ4 from typegpustd.ts 46.69 kB (➖)
rotationX4 from typegpustd.ts 24.55 kB (➖)
rotationY4 from typegpustd.ts 24.55 kB (➖)
rotationZ4 from typegpustd.ts 24.55 kB (➖)
round from typegpustd.ts 63.23 kB (➖)
sampler from typegpudata.ts 742 B (➖)
saturate from typegpustd.ts 63.23 kB (➖)
scale4 from typegpustd.ts 46.68 kB (➖)
scaling4 from typegpustd.ts 24.55 kB (➖)
select from typegpustd.ts 48.45 kB (➖)
sign from typegpustd.ts 63.23 kB (➖)
sin from typegpustd.ts 63.23 kB (➖)
sinh from typegpustd.ts 63.23 kB (➖)
sint16 from typegpudata.ts 18.53 kB (➖)
sint16x2 from typegpudata.ts 18.53 kB (➖)
sint16x4 from typegpudata.ts 18.53 kB (➖)
sint32 from typegpudata.ts 18.53 kB (➖)
sint32x2 from typegpudata.ts 18.53 kB (➖)
sint32x3 from typegpudata.ts 18.53 kB (➖)
sint32x4 from typegpudata.ts 18.53 kB (➖)
sint8 from typegpudata.ts 18.53 kB (➖)
sint8x2 from typegpudata.ts 18.53 kB (➖)
sint8x4 from typegpudata.ts 18.53 kB (➖)
sizeOf from typegpudata.ts 22.34 kB (➖)
size from typegpudata.ts 24.03 kB (➖)
smoothstep from typegpustd.ts 63.23 kB (➖)
snorm16 from typegpudata.ts 18.53 kB (➖)
snorm16x2 from typegpudata.ts 18.53 kB (➖)
snorm16x4 from typegpudata.ts 18.53 kB (➖)
snorm8 from typegpudata.ts 18.53 kB (➖)
snorm8x2 from typegpudata.ts 18.53 kB (➖)
snorm8x4 from typegpudata.ts 18.53 kB (➖)
sqrt from typegpustd.ts 63.23 kB (➖)
std from typegpu.ts 98.68 kB (➖)
step from typegpustd.ts 63.23 kB (➖)
storageBarrier from typegpustd.ts 13.46 kB (➖)
struct from typegpudata.ts 3.37 kB (➖)
sub from typegpustd.ts 45.92 kB (➖)
subgroupAdd from typegpustd.ts 21.59 kB (➖)
subgroupAll from typegpustd.ts 21.60 kB (➖)
subgroupAnd from typegpustd.ts 21.60 kB (➖)
subgroupAny from typegpustd.ts 21.60 kB (➖)
subgroupBallot from typegpustd.ts 21.60 kB (➖)
subgroupBroadcastFirst from typegpustd.ts 21.60 kB (➖)
subgroupBroadcast from typegpustd.ts 21.60 kB (➖)
subgroupElect from typegpustd.ts 21.60 kB (➖)
subgroupExclusiveAdd from typegpustd.ts 21.60 kB (➖)
subgroupExclusiveMul from typegpustd.ts 21.60 kB (➖)
subgroupInclusiveAdd from typegpustd.ts 21.60 kB (➖)
subgroupInclusiveMul from typegpustd.ts 21.60 kB (➖)
subgroupMax from typegpustd.ts 21.60 kB (➖)
subgroupMin from typegpustd.ts 21.60 kB (➖)
subgroupMul from typegpustd.ts 21.60 kB (➖)
subgroupOr from typegpustd.ts 21.60 kB (➖)
subgroupShuffleDown from typegpustd.ts 21.60 kB (➖)
subgroupShuffleUp from typegpustd.ts 21.60 kB (➖)
subgroupShuffleXor from typegpustd.ts 21.60 kB (➖)
subgroupShuffle from typegpustd.ts 21.60 kB (➖)
subgroupXor from typegpustd.ts 21.60 kB (➖)
tan from typegpustd.ts 63.23 kB (➖)
tanh from typegpustd.ts 63.23 kB (➖)
texture1d from typegpudata.ts 11.10 kB (➖)
texture2dArray from typegpudata.ts 11.12 kB (➖)
texture2d from typegpudata.ts 11.10 kB (➖)
texture3d from typegpudata.ts 11.10 kB (➖)
textureBarrier from typegpustd.ts 13.46 kB (➖)
textureCubeArray from typegpudata.ts 11.12 kB (➖)
textureCube from typegpudata.ts 11.10 kB (➖)
textureDepth2dArray from typegpudata.ts 11.10 kB (➖)
textureDepth2d from typegpudata.ts 11.09 kB (➖)
textureDepthCubeArray from typegpudata.ts 11.11 kB (➖)
textureDepthCube from typegpudata.ts 11.09 kB (➖)
textureDepthMultisampled2d from typegpudata.ts 11.11 kB (➖)
textureDimensions from typegpustd.ts 23.08 kB (➖)
textureExternal from typegpudata.ts 873 B (➖)
textureGather from typegpustd.ts 23.08 kB (➖)
textureLoad from typegpustd.ts 23.08 kB (➖)
textureMultisampled2d from typegpudata.ts 11.12 kB (➖)
textureSampleBaseClampToEdge from typegpustd.ts 23.08 kB (➖)
textureSampleBias from typegpustd.ts 23.08 kB (➖)
textureSampleCompareLevel from typegpustd.ts 23.08 kB (➖)
textureSampleCompare from typegpustd.ts 23.08 kB (➖)
textureSampleLevel from typegpustd.ts 23.08 kB (➖)
textureSample from typegpustd.ts 23.08 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 23.08 kB (➖)
translate4 from typegpustd.ts 46.68 kB (➖)
translation4 from typegpustd.ts 24.55 kB (➖)
transpose from typegpustd.ts 63.23 kB (➖)
trunc from typegpustd.ts 63.23 kB (➖)
u16 from typegpudata.ts 10.67 kB (➖)
u32 from typegpudata.ts 10.64 kB (➖)
uint16 from typegpudata.ts 18.53 kB (➖)
uint16x2 from typegpudata.ts 18.53 kB (➖)
uint16x4 from typegpudata.ts 18.53 kB (➖)
uint32 from typegpudata.ts 18.53 kB (➖)
uint32x2 from typegpudata.ts 18.53 kB (➖)
uint32x3 from typegpudata.ts 18.53 kB (➖)
uint32x4 from typegpudata.ts 18.53 kB (➖)
uint8 from typegpudata.ts 18.52 kB (➖)
uint8x2 from typegpudata.ts 18.53 kB (➖)
uint8x4 from typegpudata.ts 18.53 kB (➖)
unorm10 10 10 2 from typegpudata.ts 18.53 kB (➖)
unorm16 from typegpudata.ts 18.53 kB (➖)
unorm16x2 from typegpudata.ts 18.53 kB (➖)
unorm16x4 from typegpudata.ts 18.53 kB (➖)
unorm8 from typegpudata.ts 18.53 kB (➖)
unorm8x2 from typegpudata.ts 18.53 kB (➖)
unorm8x4 bgra from typegpudata.ts 18.53 kB (➖)
unorm8x4 from typegpudata.ts 18.53 kB (➖)
unpack2x16float from typegpustd.ts 33.54 kB (➖)
unpack4x8unorm from typegpustd.ts 33.54 kB (➖)
unstruct from typegpudata.ts 1.65 kB (➖)
vec2b from typegpudata.ts 17.03 kB (➖)
vec2f from typegpudata.ts 17.03 kB (➖)
vec2h from typegpudata.ts 17.03 kB (➖)
vec2i from typegpudata.ts 17.03 kB (➖)
vec2u from typegpudata.ts 17.03 kB (➖)
vec3b from typegpudata.ts 17.03 kB (➖)
vec3f from typegpudata.ts 17.03 kB (➖)
vec3h from typegpudata.ts 17.03 kB (➖)
vec3i from typegpudata.ts 17.03 kB (➖)
vec3u from typegpudata.ts 17.03 kB (➖)
vec4b from typegpudata.ts 17.03 kB (➖)
vec4f from typegpudata.ts 17.03 kB (➖)
vec4h from typegpudata.ts 17.03 kB (➖)
vec4i from typegpudata.ts 17.03 kB (➖)
vec4u from typegpudata.ts 17.03 kB (➖)
workgroupBarrier from typegpustd.ts 13.46 kB (➖)

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

@iwoplaza iwoplaza force-pushed the refactor/naming-cleanup branch 4 times, most recently from b5b49ac to 4828d22 Compare April 11, 2026 18:53
@iwoplaza iwoplaza changed the base branch from main to fix/first-class-argument-usage-tracking April 11, 2026 18:53
@iwoplaza iwoplaza force-pushed the fix/first-class-argument-usage-tracking branch from 8a474d6 to 1036589 Compare April 11, 2026 18:53
@iwoplaza iwoplaza force-pushed the refactor/naming-cleanup branch from 4828d22 to 18d3088 Compare April 11, 2026 18:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors the naming/identifier generation system by moving uniqueness + scoping logic into ResolutionCtx, simplifying the namespace implementation, and updating generators/resolvers/tests to use the new APIs.

Changes:

  • Replaced getUniqueName / makeNameValid with makeUniqueIdentifier(..., scope), plus new isIdentifierTaken / reserveIdentifier APIs.
  • Merged scope-layer naming tracking into ItemStateStack/ResolutionCtx and removed namespace.on('name', ...) event functionality.
  • Updated WGSL generator + core resolvers to use block/global-aware identifier allocation; adjusted tests accordingly.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/typegpu/tests/resolve.test.ts Updates tests to use makeUniqueIdentifier(getName(...), 'global').
packages/typegpu/tests/namespace.test.ts Removes namespace.on('name') test and drops unused vi import.
packages/typegpu/src/types.ts Extends scope layer + ResolutionCtx interface with new identifier APIs.
packages/typegpu/src/tgsl/wgslGenerator.ts Migrates local variable naming to 'block' identifiers and adds _blockStatement helper.
packages/typegpu/src/resolutionCtx.ts Implements new identifier generation/reservation logic and adjusts function/block scoping behavior.
packages/typegpu/src/nameRegistry.ts Removes registry classes; keeps/export identifier utilities + token sets for reuse.
packages/typegpu/src/data/struct.ts Switches prop validation import to nameUtils.
packages/typegpu/src/data/autoStruct.ts Switches prop validation import to nameUtils.
packages/typegpu/src/core/variable/tgpuVariable.ts Uses makeUniqueIdentifier(..., 'global') for variable declarations.
packages/typegpu/src/core/texture/texture.ts Uses makeUniqueIdentifier(..., 'global') for texture view declarations.
packages/typegpu/src/core/texture/externalTexture.ts Uses makeUniqueIdentifier(..., 'global') for external texture declarations.
packages/typegpu/src/core/sampler/sampler.ts Uses makeUniqueIdentifier(..., 'global') for sampler declarations.
packages/typegpu/src/core/resolve/resolveData.ts Uses makeUniqueIdentifier(..., 'global') for struct/unstruct names.
packages/typegpu/src/core/resolve/namespace.ts Simplifies namespace internals (drops NameRegistry + event listeners; tracks taken globals + strategy).
packages/typegpu/src/core/function/fnCore.ts Changes entry-input argument naming for string implementations and adds identifier validation.
packages/typegpu/src/core/constant/tgpuConstant.ts Uses makeUniqueIdentifier(..., 'global') for constant declarations.
packages/typegpu/src/core/buffer/bufferUsage.ts Uses makeUniqueIdentifier(..., 'global') for buffer declarations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +424 to +431
makeUniqueIdentifier(primer: string = 'item', scope: 'global' | 'block'): string {
if (scope === 'block' && isValidIdentifier(primer) && !this.isIdentifierTaken(primer)) {
// Preserving local definitions as they are, provided they are valid and not already taken.
this.reserveIdentifier(primer, 'block');
return primer;
}

const base = sanitizePrimer(primer);
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

ResolutionCtx.makeUniqueIdentifier is declared in the interface as primer: string | undefined, but the implementation currently narrows it to string (primer: string = 'item'). This will break type compatibility and also prevents passing getName(...) if it can be undefined. Make the parameter type accept undefined (e.g. primer: string | undefined = 'item') and keep the defaulting logic inside the function.

Suggested change
makeUniqueIdentifier(primer: string = 'item', scope: 'global' | 'block'): string {
if (scope === 'block' && isValidIdentifier(primer) && !this.isIdentifierTaken(primer)) {
// Preserving local definitions as they are, provided they are valid and not already taken.
this.reserveIdentifier(primer, 'block');
return primer;
}
const base = sanitizePrimer(primer);
makeUniqueIdentifier(primer: string | undefined, scope: 'global' | 'block'): string {
const effectivePrimer = primer ?? 'item';
if (
scope === 'block' &&
isValidIdentifier(effectivePrimer) &&
!this.isIdentifierTaken(effectivePrimer)
) {
// Preserving local definitions as they are, provided they are valid and not already taken.
this.reserveIdentifier(effectivePrimer, 'block');
return effectivePrimer;
}
const base = sanitizePrimer(effectivePrimer);

Copilot uses AI. Check for mistakes.
Comment on lines +76 to 88
if (entryInput) {
for (const arg of entryInput.positionalArgs) {
if (!isValidIdentifier(arg.schemaKey)) {
throw new Error(`Invalid argument name: ${arg.schemaKey}`);
}
}

if (validArgNames && Object.keys(validArgNames).length > 0) {
applyExternals(externalMap, { in: validArgNames });
applyExternals(externalMap, {
in: Object.fromEntries(
entryInput.positionalArgs.map((a) => [a.schemaKey, a.schemaKey]),
),
});
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

isValidIdentifier can throw (e.g. whitespace / leading underscores), so if (!isValidIdentifier(...)) will not reliably produce the intended Invalid argument name: ... error; it will often throw a different error message instead. Also, this is a behavior change from the previous ctx.makeNameValid(...) approach: previously, schema keys that weren't safe WGSL identifiers could be mapped/renamed; now they hard-error. If the intent is only to improve error reporting, wrap validation in a try/catch and rethrow with a consistent message. If the intent is to preserve prior behavior, reintroduce a mapping step (generate safe identifiers and pass that mapping to applyExternals) rather than requiring schemaKey to already be usable as a WGSL parameter name.

Copilot uses AI. Check for mistakes.
}
}

public _blockStatement(block: tinyest.Block, externalMap?: ExternalMap): string {
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

This introduces a new public method with a leading underscore (_blockStatement), which typically signals a non-public API. If this is an internal helper, make it private/protected (or remove the underscore and treat it as part of the public surface). Keeping it public makes it harder to evolve without breaking external consumers.

Suggested change
public _blockStatement(block: tinyest.Block, externalMap?: ExternalMap): string {
protected _blockStatement(block: tinyest.Block, externalMap?: ExternalMap): string {

Copilot uses AI. Check for mistakes.
Comment on lines +417 to +424
isIdentifierTaken(name: string): boolean {
return (
this.#namespaceInternal.takenGlobalIdentifiers.has(name) ||
!!this._itemStateStack.isIdentifierTakenLocally(name)
);
}

makeNameValid(name: string): string {
return this.#namespaceInternal.nameRegistry.makeValid(name);
makeUniqueIdentifier(primer: string = 'item', scope: 'global' | 'block'): string {
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The new identifier API (isIdentifierTaken, makeUniqueIdentifier, reserveIdentifier) adds important scoping semantics ('global' vs 'block', and visibility across nested blocks/functions). There are test updates for call sites, but there doesn't appear to be coverage specifically asserting the new scoping rules (e.g., block identifiers not shadowing visible names, identifiers becoming available after popping a block scope, and global uniqueness across the resolution). Add focused unit tests around the new naming behavior to prevent regressions.

Copilot uses AI. Check for mistakes.
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.

2 participants