Skip to content

impr: Depreacte the partialWrite API and add patch API that better matches the write features#2355

Merged
reczkok merged 20 commits intomainfrom
impr/partial-write-love
Apr 10, 2026
Merged

impr: Depreacte the partialWrite API and add patch API that better matches the write features#2355
reczkok merged 20 commits intomainfrom
impr/partial-write-love

Conversation

@reczkok
Copy link
Copy Markdown
Contributor

@reczkok reczkok commented Apr 8, 2026

This PR:

  • deprecates the partialWrite in favor of the new patch API with extended capabilities
  • simplifies internal helpers (made them non-generic since we don't really need that)
  • fixed redundant per write allocation (since buffers have their own internal array buffers)

The main API differences are:

  • now patch has similar permissiveness as the new write API (accepts tuples and typed arrays)
  • finally can pass a full array without gymnastics
  • for partial array writes we now use a record with number fields (makes it so much easier to recognize and IMO cleaner to use)

We could now move the entire patch API to use compiled writers everywhere (due to compiled writers handling start/end offsets) but I want to get this into the 0.11 release so for now let's say out of scope - I left most internals untouched. Now we use them for leaf values (since they handle padding better) - this is to be discussed since this means creating a writer per primitive data type

Here are benchmark results (for what they're worth):
image

Important to mention that they use the old API so we are paying conversion costs for each call

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

pkg.pr.new

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

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

benchmark
view benchmark

commit
view commit

@reczkok reczkok force-pushed the impr/partial-write-love branch from 0f7e47b to 1ca7e21 Compare April 8, 2026 14:39
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

📊 Bundle Size Comparison

🟢 Decreased ➖ Unchanged 🔴 Increased ❔ Unknown
0 15 335 0

👀 Notable results

Static test results:

No major changes.

Dynamic test results:

‼️ Click to reveal the results table (42 entries).
Test tsdown
Void from typegpudata.ts 734 B ($${\color{red}+4.9\%}$$)
sampler from typegpudata.ts 742 B ($${\color{red}+4.8\%}$$)
isPtr from typegpudata.ts 752 B ($${\color{red}+4.7\%}$$)
comparisonSampler from typegpudata.ts 753 B ($${\color{red}+4.7\%}$$)
isSizeAttrib from typegpudata.ts 754 B ($${\color{red}+4.7\%}$$)
isWgslArray from typegpudata.ts 754 B ($${\color{red}+4.7\%}$$)
isAlignAttrib from typegpudata.ts 755 B ($${\color{red}+4.7\%}$$)
isAtomic from typegpudata.ts 755 B ($${\color{red}+4.7\%}$$)
isWgslStruct from typegpudata.ts 755 B ($${\color{red}+4.7\%}$$)
isBuiltinAttrib from typegpudata.ts 757 B ($${\color{red}+4.7\%}$$)
isDecorated from typegpudata.ts 758 B ($${\color{red}+4.7\%}$$)
isLocationAttrib from typegpudata.ts 758 B ($${\color{red}+4.7\%}$$)
isInterpolateAttrib from typegpudata.ts 761 B ($${\color{red}+4.7\%}$$)
isTgpuFn from typegpu.ts 765 B ($${\color{red}+4.7\%}$$)
atomic from typegpudata.ts 779 B ($${\color{red}+4.6\%}$$)
ptrHandle from typegpudata.ts 851 B ($${\color{red}+4.2\%}$$)
ptrUniform from typegpudata.ts 852 B ($${\color{red}+4.2\%}$$)
ptrStorage from typegpudata.ts 856 B ($${\color{red}+4.1\%}$$)
ptrPrivate from typegpudata.ts 858 B ($${\color{red}+4.1\%}$$)
ptrFn from typegpudata.ts 859 B ($${\color{red}+4.1\%}$$)
ptrWorkgroup from typegpudata.ts 860 B ($${\color{red}+4.1\%}$$)
textureExternal from typegpudata.ts 873 B ($${\color{red}+4.1\%}$$)
isBufferShorthand from typegpu.ts 1.81 kB ($${\color{red}+3.6\%}$$)
textureStorage1d from typegpudata.ts 1.01 kB ($${\color{red}+3.4\%}$$)
textureStorage2d from typegpudata.ts 1.01 kB ($${\color{red}+3.4\%}$$)
textureStorage3d from typegpudata.ts 1.01 kB ($${\color{red}+3.4\%}$$)
textureStorage2dArray from typegpudata.ts 1.03 kB ($${\color{red}+3.3\%}$$)
NotUniformError from typegpu.ts 1.30 kB ($${\color{red}+2.6\%}$$)
isWgslData from typegpudata.ts 1.31 kB ($${\color{red}+2.6\%}$$)
MissingBindGroupsError from typegpu.ts 1.34 kB ($${\color{red}+2.5\%}$$)
MissingVertexBuffersError from typegpu.ts 1.35 kB ($${\color{red}+2.5\%}$$)
ResolutionError from typegpu.ts 1.55 kB ($${\color{red}+2.2\%}$$)
unstruct from typegpudata.ts 1.65 kB ($${\color{red}+2.1\%}$$)
isDisarray from typegpudata.ts 1.69 kB ($${\color{red}+2.0\%}$$)
isUnstruct from typegpudata.ts 1.69 kB ($${\color{red}+2.0\%}$$)
isLooseDecorated from typegpudata.ts 1.70 kB ($${\color{red}+2.0\%}$$)
isLooseData from typegpudata.ts 1.74 kB ($${\color{red}+1.9\%}$$)
ShaderGenerator from typegpu.ts 1.84 kB ($${\color{red}+1.8\%}$$)
isData from typegpudata.ts 2.39 kB ($${\color{red}+1.4\%}$$)
deepEqual from typegpudata.ts 2.77 kB ($${\color{red}+1.2\%}$$)
struct from typegpudata.ts 3.37 kB ($${\color{red}+1.0\%}$$)
ref from typegpudata.ts 4.18 kB ($${\color{red}+0.8\%}$$)

📋 All results

Click to reveal the results table (349 entries).
Test tsdown
Void from typegpudata.ts 734 B ($${\color{red}+4.9\%}$$)
sampler from typegpudata.ts 742 B ($${\color{red}+4.8\%}$$)
isPtr from typegpudata.ts 752 B ($${\color{red}+4.7\%}$$)
comparisonSampler from typegpudata.ts 753 B ($${\color{red}+4.7\%}$$)
isSizeAttrib from typegpudata.ts 754 B ($${\color{red}+4.7\%}$$)
isWgslArray from typegpudata.ts 754 B ($${\color{red}+4.7\%}$$)
isAlignAttrib from typegpudata.ts 755 B ($${\color{red}+4.7\%}$$)
isAtomic from typegpudata.ts 755 B ($${\color{red}+4.7\%}$$)
isWgslStruct from typegpudata.ts 755 B ($${\color{red}+4.7\%}$$)
isBuiltinAttrib from typegpudata.ts 757 B ($${\color{red}+4.7\%}$$)
isDecorated from typegpudata.ts 758 B ($${\color{red}+4.7\%}$$)
isLocationAttrib from typegpudata.ts 758 B ($${\color{red}+4.7\%}$$)
isInterpolateAttrib from typegpudata.ts 761 B ($${\color{red}+4.7\%}$$)
isTgpuFn from typegpu.ts 765 B ($${\color{red}+4.7\%}$$)
atomic from typegpudata.ts 779 B ($${\color{red}+4.6\%}$$)
ptrHandle from typegpudata.ts 851 B ($${\color{red}+4.2\%}$$)
ptrUniform from typegpudata.ts 852 B ($${\color{red}+4.2\%}$$)
ptrStorage from typegpudata.ts 856 B ($${\color{red}+4.1\%}$$)
ptrPrivate from typegpudata.ts 858 B ($${\color{red}+4.1\%}$$)
ptrFn from typegpudata.ts 859 B ($${\color{red}+4.1\%}$$)
ptrWorkgroup from typegpudata.ts 860 B ($${\color{red}+4.1\%}$$)
textureExternal from typegpudata.ts 873 B ($${\color{red}+4.1\%}$$)
isBufferShorthand from typegpu.ts 1.81 kB ($${\color{red}+3.6\%}$$)
textureStorage1d from typegpudata.ts 1.01 kB ($${\color{red}+3.4\%}$$)
textureStorage2d from typegpudata.ts 1.01 kB ($${\color{red}+3.4\%}$$)
textureStorage3d from typegpudata.ts 1.01 kB ($${\color{red}+3.4\%}$$)
textureStorage2dArray from typegpudata.ts 1.03 kB ($${\color{red}+3.3\%}$$)
NotUniformError from typegpu.ts 1.30 kB ($${\color{red}+2.6\%}$$)
isWgslData from typegpudata.ts 1.31 kB ($${\color{red}+2.6\%}$$)
MissingBindGroupsError from typegpu.ts 1.34 kB ($${\color{red}+2.5\%}$$)
MissingVertexBuffersError from typegpu.ts 1.35 kB ($${\color{red}+2.5\%}$$)
ResolutionError from typegpu.ts 1.55 kB ($${\color{red}+2.2\%}$$)
unstruct from typegpudata.ts 1.65 kB ($${\color{red}+2.1\%}$$)
isDisarray from typegpudata.ts 1.69 kB ($${\color{red}+2.0\%}$$)
isUnstruct from typegpudata.ts 1.69 kB ($${\color{red}+2.0\%}$$)
isLooseDecorated from typegpudata.ts 1.70 kB ($${\color{red}+2.0\%}$$)
isLooseData from typegpudata.ts 1.74 kB ($${\color{red}+1.9\%}$$)
ShaderGenerator from typegpu.ts 1.84 kB ($${\color{red}+1.8\%}$$)
isData from typegpudata.ts 2.39 kB ($${\color{red}+1.4\%}$$)
deepEqual from typegpudata.ts 2.77 kB ($${\color{red}+1.2\%}$$)
struct from typegpudata.ts 3.37 kB ($${\color{red}+1.0\%}$$)
ref from typegpudata.ts 4.18 kB ($${\color{red}+0.8\%}$$)
isUsableAsVertex from typegpu.ts 85.83 kB ($${\color{red}+0.4\%}$$)
isBuffer from typegpu.ts 85.84 kB ($${\color{red}+0.4\%}$$)
bool from typegpudata.ts 10.63 kB ($${\color{red}+0.3\%}$$)
f16 from typegpudata.ts 10.63 kB ($${\color{red}+0.3\%}$$)
f32 from typegpudata.ts 10.63 kB ($${\color{red}+0.3\%}$$)
i32 from typegpudata.ts 10.63 kB ($${\color{red}+0.3\%}$$)
u32 from typegpudata.ts 10.63 kB ($${\color{red}+0.3\%}$$)
u16 from typegpudata.ts 10.65 kB ($${\color{red}+0.3\%}$$)
textureDepth2d from typegpudata.ts 11.07 kB ($${\color{red}+0.3\%}$$)
textureDepthCube from typegpudata.ts 11.08 kB ($${\color{red}+0.3\%}$$)
texture1d from typegpudata.ts 11.08 kB ($${\color{red}+0.3\%}$$)
texture2d from typegpudata.ts 11.08 kB ($${\color{red}+0.3\%}$$)
texture3d from typegpudata.ts 11.08 kB ($${\color{red}+0.3\%}$$)
textureCube from typegpudata.ts 11.09 kB ($${\color{red}+0.3\%}$$)
textureDepth2dArray from typegpudata.ts 11.09 kB ($${\color{red}+0.3\%}$$)
textureDepthCubeArray from typegpudata.ts 11.09 kB ($${\color{red}+0.3\%}$$)
textureDepthMultisampled2d from typegpudata.ts 11.09 kB ($${\color{red}+0.3\%}$$)
texture2dArray from typegpudata.ts 11.10 kB ($${\color{red}+0.3\%}$$)
textureCubeArray from typegpudata.ts 11.10 kB ($${\color{red}+0.3\%}$$)
textureMultisampled2d from typegpudata.ts 11.11 kB ($${\color{red}+0.3\%}$$)
discard from typegpustd.ts 11.83 kB ($${\color{red}+0.3\%}$$)
arrayLength from typegpustd.ts 12.06 kB ($${\color{red}+0.3\%}$$)
extensionEnabled from typegpustd.ts 12.14 kB ($${\color{red}+0.3\%}$$)
range from typegpustd.ts 12.41 kB ($${\color{red}+0.3\%}$$)
disarrayOf from typegpudata.ts 12.58 kB ($${\color{red}+0.3\%}$$)
dpdx from typegpustd.ts 12.67 kB ($${\color{red}+0.3\%}$$)
dpdxCoarse from typegpustd.ts 12.68 kB ($${\color{red}+0.3\%}$$)
dpdxFine from typegpustd.ts 12.68 kB ($${\color{red}+0.3\%}$$)
dpdyCoarse from typegpustd.ts 12.68 kB ($${\color{red}+0.3\%}$$)
dpdyFine from typegpustd.ts 12.68 kB ($${\color{red}+0.3\%}$$)
dpdy from typegpustd.ts 12.68 kB ($${\color{red}+0.3\%}$$)
fwidthCoarse from typegpustd.ts 12.68 kB ($${\color{red}+0.3\%}$$)
fwidthFine from typegpustd.ts 12.68 kB ($${\color{red}+0.3\%}$$)
fwidth from typegpustd.ts 12.68 kB ($${\color{red}+0.3\%}$$)
atomicLoad from typegpustd.ts 13.43 kB ($${\color{red}+0.2\%}$$)
atomicStore from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
textureBarrier from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
atomicAdd from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
atomicAnd from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
atomicMax from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
atomicMin from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
atomicOr from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
atomicSub from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
atomicXor from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
storageBarrier from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
workgroupBarrier from typegpustd.ts 13.44 kB ($${\color{red}+0.2\%}$$)
tgpuImportEverything.ts 250.85 kB ($${\color{red}+0.2\%}$$)
tgpu from typegpu.ts 250.85 kB ($${\color{red}+0.2\%}$$)
tgpu.fn from typegpu.ts 250.85 kB ($${\color{red}+0.2\%}$$)
tgpu.init from typegpu.ts 250.85 kB ($${\color{red}+0.2\%}$$)
tgpu.lazy from typegpu.ts 250.85 kB ($${\color{red}+0.2\%}$$)
tgpu.slot from typegpu.ts 250.85 kB ($${\color{red}+0.2\%}$$)
tgpu.const from typegpu.ts 250.85 kB ($${\color{red}+0.2\%}$$)
tgpu.unroll from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.resolve from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.accessor from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.comptime from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.vertexFn from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.computeFn from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.fragmentFn from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.privateVar from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpuImportOne.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.vertexLayout from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.workgroupVar from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.initFromDevice from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.bindGroupLayout from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.mutableAccessor from typegpu.ts 250.86 kB ($${\color{red}+0.2\%}$$)
tgpu.resolveWithContext from typegpu.ts 250.87 kB ($${\color{red}+0.2\%}$$)
importEntireLibrary.ts 277.76 kB ($${\color{red}+0.2\%}$$)
vec2b from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec2f from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec2h from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec2i from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec2u from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec3b from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec3f from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec3h from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec3i from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec3u from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec4b from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec4f from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec4h from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec4i from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
vec4u from typegpudata.ts 17.01 kB ($${\color{red}+0.2\%}$$)
formatToWGSLType from typegpudata.ts 18.50 kB ($${\color{red}+0.2\%}$$)
uint8 from typegpudata.ts 18.50 kB ($${\color{red}+0.2\%}$$)
float16 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
float16x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
float16x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
float32 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
float32x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
float32x3 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
float32x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint16 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint16x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint16x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint32 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint32x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint32x3 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint32x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint8 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint8x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
sint8x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
snorm16 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
snorm16x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
snorm16x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
snorm8 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
snorm8x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
snorm8x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint16 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint16x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint16x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint32 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint32x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint32x3 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint32x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint8x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
uint8x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
unorm10 10 10 2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
unorm16 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
unorm16x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
unorm16x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
unorm8 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
unorm8x2 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
unorm8x4 bgra from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
unorm8x4 from typegpudata.ts 18.51 kB ($${\color{red}+0.2\%}$$)
packedFormats from typegpudata.ts 18.53 kB ($${\color{red}+0.2\%}$$)
isPackedData from typegpudata.ts 18.57 kB ($${\color{red}+0.2\%}$$)
alignmentOf from typegpudata.ts 19.55 kB ($${\color{red}+0.2\%}$$)
subgroupAdd from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupAll from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupAnd from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupAny from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupBallot from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupBroadcastFirst from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupBroadcast from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupElect from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupExclusiveAdd from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupExclusiveMul from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupInclusiveAdd from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupInclusiveMul from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupMax from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupMin from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupMul from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupOr from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupShuffleDown from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupShuffleUp from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupShuffleXor from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupShuffle from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
subgroupXor from typegpustd.ts 21.58 kB ($${\color{red}+0.2\%}$$)
isBuiltin from typegpudata.ts 22.27 kB ($${\color{red}+0.1\%}$$)
dataImportOneDirect.ts 22.32 kB ($${\color{red}+0.1\%}$$)
dataImportOneStar.ts 22.32 kB ($${\color{red}+0.1\%}$$)
sizeOf from typegpudata.ts 22.32 kB ($${\color{red}+0.1\%}$$)
isContiguous from typegpudata.ts 22.33 kB ($${\color{red}+0.1\%}$$)
getLongestContiguousPrefix from typegpudata.ts 22.34 kB ($${\color{red}+0.1\%}$$)
textureDimensions from typegpustd.ts 23.06 kB ($${\color{red}+0.1\%}$$)
textureGather from typegpustd.ts 23.06 kB ($${\color{red}+0.1\%}$$)
textureLoad from typegpustd.ts 23.07 kB ($${\color{red}+0.1\%}$$)
textureSampleBaseClampToEdge from typegpustd.ts 23.07 kB ($${\color{red}+0.1\%}$$)
textureSampleBias from typegpustd.ts 23.07 kB ($${\color{red}+0.1\%}$$)
textureSampleCompareLevel from typegpustd.ts 23.07 kB ($${\color{red}+0.1\%}$$)
textureSampleCompare from typegpustd.ts 23.07 kB ($${\color{red}+0.1\%}$$)
textureSampleLevel from typegpustd.ts 23.07 kB ($${\color{red}+0.1\%}$$)
textureSample from typegpustd.ts 23.07 kB ($${\color{red}+0.1\%}$$)
textureStore from typegpustd.ts 23.07 kB ($${\color{red}+0.1\%}$$)
arrayOf from typegpudata.ts 23.82 kB ($${\color{red}+0.1\%}$$)
size from typegpudata.ts 24.01 kB ($${\color{red}+0.1\%}$$)
align from typegpudata.ts 24.01 kB ($${\color{red}+0.1\%}$$)
location from typegpudata.ts 24.01 kB ($${\color{red}+0.1\%}$$)
interpolate from typegpudata.ts 24.02 kB ($${\color{red}+0.1\%}$$)
invariant from typegpudata.ts 24.39 kB ($${\color{red}+0.1\%}$$)
mat4x4f from typegpudata.ts 24.53 kB ($${\color{red}+0.1\%}$$)
identity2 from typegpustd.ts 24.53 kB ($${\color{red}+0.1\%}$$)
identity3 from typegpustd.ts 24.53 kB ($${\color{red}+0.1\%}$$)
identity4 from typegpustd.ts 24.53 kB ($${\color{red}+0.1\%}$$)
mat2x2f from typegpudata.ts 24.53 kB ($${\color{red}+0.1\%}$$)
mat3x3f from typegpudata.ts 24.53 kB ($${\color{red}+0.1\%}$$)
rotationX4 from typegpustd.ts 24.53 kB ($${\color{red}+0.1\%}$$)
rotationY4 from typegpustd.ts 24.53 kB ($${\color{red}+0.1\%}$$)
rotationZ4 from typegpustd.ts 24.53 kB ($${\color{red}+0.1\%}$$)
scaling4 from typegpustd.ts 24.53 kB ($${\color{red}+0.1\%}$$)
translation4 from typegpustd.ts 24.53 kB ($${\color{red}+0.1\%}$$)
matToArray from typegpudata.ts 24.67 kB ($${\color{red}+0.1\%}$$)
builtin from typegpudata.ts 26.19 kB ($${\color{red}+0.1\%}$$)
pack2x16float from typegpustd.ts 33.52 kB ($${\color{red}+0.1\%}$$)
pack4x8unorm from typegpustd.ts 33.52 kB ($${\color{red}+0.1\%}$$)
unpack2x16float from typegpustd.ts 33.52 kB ($${\color{red}+0.1\%}$$)
unpack4x8unorm from typegpustd.ts 33.52 kB ($${\color{red}+0.1\%}$$)
memoryLayoutOf from typegpudata.ts 39.62 kB ($${\color{red}+0.1\%}$$)
bitcastU32toF32 from typegpustd.ts 41.73 kB ($${\color{red}+0.1\%}$$)
bitcastU32toI32 from typegpustd.ts 41.73 kB ($${\color{red}+0.1\%}$$)
neg from typegpustd.ts 45.90 kB ($${\color{red}+0.1\%}$$)
add from typegpustd.ts 45.90 kB ($${\color{red}+0.1\%}$$)
bitShiftLeft from typegpustd.ts 45.90 kB ($${\color{red}+0.1\%}$$)
bitShiftRight from typegpustd.ts 45.90 kB ($${\color{red}+0.1\%}$$)
div from typegpustd.ts 45.90 kB ($${\color{red}+0.1\%}$$)
mod from typegpustd.ts 45.90 kB ($${\color{red}+0.1\%}$$)
mul from typegpustd.ts 45.90 kB ($${\color{red}+0.1\%}$$)
sub from typegpustd.ts 45.90 kB ($${\color{red}+0.1\%}$$)
stdImportOneDirect.ts 45.91 kB ($${\color{red}+0.1\%}$$)
stdImportOneStar.ts 45.91 kB ($${\color{red}+0.1\%}$$)
rotateX4 from typegpustd.ts 46.66 kB ($${\color{red}+0.1\%}$$)
scale4 from typegpustd.ts 46.66 kB ($${\color{red}+0.1\%}$$)
translate4 from typegpustd.ts 46.66 kB ($${\color{red}+0.1\%}$$)
rotateY4 from typegpustd.ts 46.67 kB ($${\color{red}+0.1\%}$$)
rotateZ4 from typegpustd.ts 46.67 kB ($${\color{red}+0.1\%}$$)
and from typegpustd.ts 48.42 kB ($${\color{red}+0.1\%}$$)
not from typegpustd.ts 48.42 kB ($${\color{red}+0.1\%}$$)
or from typegpustd.ts 48.42 kB ($${\color{red}+0.1\%}$$)
allEq from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
all from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
eq from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
ge from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
lt from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
ne from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
any from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
gt from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
isCloseTo from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
le from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
select from typegpustd.ts 48.43 kB ($${\color{red}+0.1\%}$$)
common from typegpu.ts 53.31 kB ($${\color{red}+0.1\%}$$)
isUsableAsUniform from typegpu.ts 60.28 kB ($${\color{red}+0.1\%}$$)
isTexture from typegpu.ts 60.29 kB ($${\color{red}+0.1\%}$$)
isSampler from typegpu.ts 60.30 kB ($${\color{red}+0.1\%}$$)
isComparisonSampler from typegpu.ts 60.31 kB ($${\color{red}+0.1\%}$$)
isVariable from typegpu.ts 62.08 kB ($${\color{red}+0.1\%}$$)
dot from typegpustd.ts 63.20 kB ($${\color{red}+0.1\%}$$)
length from typegpustd.ts 63.20 kB ($${\color{red}+0.1\%}$$)
distance from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
dot4U8Packed from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
fract from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
frexp from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
mix from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
modf from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
abs from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
acos from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
acosh from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
asin from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
asinh from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
atan2 from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
atan from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
atanh from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
ceil from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
clamp from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
cos from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
cosh from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
countLeadingZeros from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
countOneBits from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
countTrailingZeros from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
cross from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
degrees from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
determinant from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
dot4I8Packed from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
exp2 from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
exp from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
extractBits from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
faceForward from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
firstLeadingBit from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
firstTrailingBit from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
floor from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
fma from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
insertBits from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
inverseSqrt from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
ldexp from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
log2 from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
log from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
max from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
min from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
normalize from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
pow from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
quantizeToF16 from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
radians from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
reflect from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
refract from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
reverseBits from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
round from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
saturate from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
sign from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
sin from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
sinh from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
smoothstep from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
sqrt from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
step from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
tan from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
tanh from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
transpose from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
trunc from typegpustd.ts 63.21 kB ($${\color{red}+0.1\%}$$)
d from typegpu.ts 84.48 kB ($${\color{red}+0.0\%}$$)
dataImportEverything.ts 86.78 kB ($${\color{red}+0.0\%}$$)
std from typegpu.ts 98.66 kB ($${\color{red}+0.0\%}$$)
WgslGenerator from typegpu.ts 100.82 kB ($${\color{red}+0.0\%}$$)
stdImportEverything.ts 101.41 kB ($${\color{red}+0.0\%}$$)
functionWithUseGpu.ts 282 B (➖)
functionWithoutUseGpu.ts 24 B (➖)
MissingLinksError from typegpu.ts 201 B (➖)
MissingSlotValueError from typegpu.ts 151 B (➖)
isAccessor from typegpu.ts 65 B (➖)
isLazy from typegpu.ts 61 B (➖)
isMutableAccessor from typegpu.ts 73 B (➖)
isSlot from typegpu.ts 61 B (➖)
isTgpuComputeFn from typegpu.ts 69 B (➖)
isTgpuFragmentFn from typegpu.ts 70 B (➖)
isTgpuVertexFn from typegpu.ts 68 B (➖)
isUsableAsRender from typegpu.ts 55 B (➖)
isUsableAsSampled from typegpu.ts 56 B (➖)
isUsableAsStorage from typegpu.ts 56 B (➖)

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

@reczkok reczkok marked this pull request as ready for review April 8, 2026 14:40
Copilot AI review requested due to automatic review settings April 8, 2026 14:40
@reczkok reczkok marked this pull request as draft April 8, 2026 14:40

This comment was marked as outdated.

@reczkok reczkok force-pushed the impr/partial-write-love branch from 1ca7e21 to d9a6d19 Compare April 8, 2026 14:58
expect(rawBuffer).toBeDefined();

expect(device.mock.queue.writeBuffer.mock.calls).toStrictEqual([
[rawBuffer, 8, new Uint8Array([255, 127, 255, 127]), 0, 4],
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 is the difference between floor (typed binary) and round (compiled writer) (1)

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.

Could you elaborate?

Copy link
Copy Markdown
Contributor Author

@reczkok reczkok Apr 9, 2026

Choose a reason for hiding this comment

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

0.5 * 65535 = 32767.5 -> round (what the compiled writer serializers use) gives 32768 (encoded as unorm16 [0, 128]) -> The old implementation must've truncated and give 32767 (encoded as unorm16 [255 127])

This comment was marked as outdated.

@reczkok reczkok marked this pull request as ready for review April 9, 2026 14:42
reczkok and others added 14 commits April 9, 2026 17:36
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

Copilot reviewed 46 out of 46 changed files in this pull request and generated 3 comments.


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

expect(rawBuffer).toBeDefined();

expect(device.mock.queue.writeBuffer.mock.calls).toStrictEqual([
[rawBuffer, 8, new Uint8Array([255, 127, 255, 127]), 0, 4],
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.

Could you elaborate?

@reczkok reczkok changed the title impr: Modernize the partialWrite API to better match write features impr: Depreacte the partialWrite API and add patch API that better matches the write features Apr 9, 2026
Copy link
Copy Markdown
Collaborator

@iwoplaza iwoplaza left a comment

Choose a reason for hiding this comment

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

Awesome API 👏

@reczkok reczkok requested a review from cieplypolar April 10, 2026 12:19
Copy link
Copy Markdown
Collaborator

@cieplypolar cieplypolar left a comment

Choose a reason for hiding this comment

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

Very nice, very cool :shipit:

Co-authored-by: Szymon Szulc <103948576+cieplypolar@users.noreply.github.com>
@reczkok reczkok merged commit 8cf6c0d into main Apr 10, 2026
4 checks passed
@reczkok reczkok deleted the impr/partial-write-love branch April 10, 2026 17:41
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.

4 participants