impr: More permissive options for buffer writes along with sliced writes#2279
impr: More permissive options for buffer writes along with sliced writes#2279
Conversation
Introduce InferInput and $inRepr to accept plain arrays and TypedArrays for vector/array write-side representations. Add BufferWriteOptions (startOffset/endOffset) and improve memoryLayoutOf accessor errors. Update compiled/data writers to index into array-like vector inputs and adjust tests and docs accordingly
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:
Dynamic test results:
|
| Test | tsdown |
|---|---|
| MissingBindGroupsError from typegpu.ts | 1.31 kB ( |
| MissingVertexBuffersError from typegpu.ts | 1.32 kB ( |
| NotUniformError from typegpu.ts | 1.27 kB ( |
| ResolutionError from typegpu.ts | 1.51 kB ( |
| Void from typegpudata.ts | 700 B ( |
| atomic from typegpudata.ts | 739 B ( |
| comparisonSampler from typegpudata.ts | 719 B ( |
| deepEqual from typegpudata.ts | 2.74 kB ( |
| isAlignAttrib from typegpudata.ts | 721 B ( |
| isAtomic from typegpudata.ts | 721 B ( |
| isBufferShorthand from typegpu.ts | 1.73 kB ( |
| isBuffer from typegpu.ts | 87.61 kB ( |
| isBuiltinAttrib from typegpudata.ts | 723 B ( |
| isData from typegpudata.ts | 2.35 kB ( |
| isDecorated from typegpudata.ts | 724 B ( |
| isDisarray from typegpudata.ts | 1.66 kB ( |
| isInterpolateAttrib from typegpudata.ts | 727 B ( |
| isLocationAttrib from typegpudata.ts | 724 B ( |
| isLooseData from typegpudata.ts | 1.70 kB ( |
| isLooseDecorated from typegpudata.ts | 1.67 kB ( |
| isPtr from typegpudata.ts | 718 B ( |
| isSizeAttrib from typegpudata.ts | 720 B ( |
| isTgpuFn from typegpu.ts | 731 B ( |
| isUnstruct from typegpudata.ts | 1.66 kB ( |
| isUsableAsVertex from typegpu.ts | 87.60 kB ( |
| isWgslArray from typegpudata.ts | 720 B ( |
| isWgslData from typegpudata.ts | 1.28 kB ( |
| isWgslStruct from typegpudata.ts | 721 B ( |
| ptrFn from typegpudata.ts | 825 B ( |
| ptrHandle from typegpudata.ts | 817 B ( |
| ptrPrivate from typegpudata.ts | 824 B ( |
| ptrStorage from typegpudata.ts | 822 B ( |
| ptrUniform from typegpudata.ts | 818 B ( |
| ptrWorkgroup from typegpudata.ts | 826 B ( |
| ref from typegpudata.ts | 4.12 kB ( |
| sampler from typegpudata.ts | 708 B ( |
| struct from typegpudata.ts | 3.34 kB ( |
| textureExternal from typegpudata.ts | 839 B ( |
| textureStorage1d from typegpudata.ts | 1003 B ( |
| textureStorage2dArray from typegpudata.ts | 1021 B ( |
| textureStorage2d from typegpudata.ts | 1003 B ( |
| textureStorage3d from typegpudata.ts | 1003 B ( |
| tgpu.accessor from typegpu.ts | 244.38 kB ( |
| tgpu.bindGroupLayout from typegpu.ts | 244.38 kB ( |
| tgpu.comptime from typegpu.ts | 244.38 kB ( |
| tgpu.computeFn from typegpu.ts | 244.38 kB ( |
| tgpu.const from typegpu.ts | 244.37 kB ( |
| tgpu.fn from typegpu.ts | 244.37 kB ( |
| tgpu.fragmentFn from typegpu.ts | 244.38 kB ( |
| tgpu.initFromDevice from typegpu.ts | 244.38 kB ( |
| tgpu.init from typegpu.ts | 244.37 kB ( |
| tgpu.lazy from typegpu.ts | 244.37 kB ( |
| tgpu.mutableAccessor from typegpu.ts | 244.38 kB ( |
| tgpu.privateVar from typegpu.ts | 244.38 kB ( |
| tgpu.resolveWithContext from typegpu.ts | 244.38 kB ( |
| tgpu.resolve from typegpu.ts | 244.37 kB ( |
| tgpu.slot from typegpu.ts | 244.37 kB ( |
| tgpu.unroll from typegpu.ts | 244.37 kB ( |
| tgpu.vertexFn from typegpu.ts | 244.38 kB ( |
| tgpu.vertexLayout from typegpu.ts | 244.38 kB ( |
| tgpu.workgroupVar from typegpu.ts | 244.38 kB ( |
| tgpu from typegpu.ts | 244.37 kB ( |
| unstruct from typegpudata.ts | 1.61 kB ( |
📋 All results
Click to reveal the results table (344 entries).
| Test | tsdown |
|---|---|
| dataImportEverything.ts | 84.69 kB ( |
| dataImportOneDirect.ts | 22.06 kB ( |
| dataImportOneStar.ts | 22.06 kB ( |
| functionWithUseGpu.ts | 282 B (➖) |
| functionWithoutUseGpu.ts | 24 B (➖) |
| importEntireLibrary.ts | 270.98 kB ( |
| stdImportEverything.ts | 98.93 kB ( |
| stdImportOneDirect.ts | 44.03 kB ( |
| stdImportOneStar.ts | 44.03 kB ( |
| tgpuImportEverything.ts | 244.37 kB ( |
| tgpuImportOne.ts | 244.38 kB ( |
| MissingBindGroupsError from typegpu.ts | 1.31 kB ( |
| MissingLinksError from typegpu.ts | 201 B (➖) |
| MissingSlotValueError from typegpu.ts | 146 B (➖) |
| MissingVertexBuffersError from typegpu.ts | 1.32 kB ( |
| NotUniformError from typegpu.ts | 1.27 kB ( |
| ResolutionError from typegpu.ts | 1.51 kB ( |
| Void from typegpudata.ts | 700 B ( |
| abs from typegpustd.ts | 61.33 kB ( |
| acos from typegpustd.ts | 61.33 kB ( |
| acosh from typegpustd.ts | 61.33 kB ( |
| add from typegpustd.ts | 44.02 kB ( |
| align from typegpudata.ts | 23.73 kB ( |
| alignmentOf from typegpudata.ts | 19.28 kB ( |
| allEq from typegpustd.ts | 46.55 kB ( |
| all from typegpustd.ts | 46.55 kB ( |
| and from typegpustd.ts | 46.54 kB ( |
| any from typegpustd.ts | 46.55 kB ( |
| arrayLength from typegpustd.ts | 12.16 kB ( |
| arrayOf from typegpudata.ts | 23.94 kB ( |
| asin from typegpustd.ts | 61.33 kB ( |
| asinh from typegpustd.ts | 61.33 kB ( |
| atan2 from typegpustd.ts | 61.33 kB ( |
| atan from typegpustd.ts | 61.33 kB ( |
| atanh from typegpustd.ts | 61.33 kB ( |
| atomicAdd from typegpustd.ts | 13.54 kB ( |
| atomicAnd from typegpustd.ts | 13.54 kB ( |
| atomicLoad from typegpustd.ts | 13.52 kB ( |
| atomicMax from typegpustd.ts | 13.54 kB ( |
| atomicMin from typegpustd.ts | 13.54 kB ( |
| atomicOr from typegpustd.ts | 13.54 kB ( |
| atomicStore from typegpustd.ts | 13.53 kB ( |
| atomicSub from typegpustd.ts | 13.54 kB ( |
| atomicXor from typegpustd.ts | 13.54 kB ( |
| atomic from typegpudata.ts | 739 B ( |
| bitcastU32toF32 from typegpustd.ts | 41.42 kB ( |
| bitcastU32toI32 from typegpustd.ts | 41.43 kB ( |
| bool from typegpudata.ts | 10.72 kB ( |
| builtin from typegpudata.ts | 26.29 kB ( |
| ceil from typegpustd.ts | 61.33 kB ( |
| clamp from typegpustd.ts | 61.33 kB ( |
| common from typegpu.ts | 36.34 kB ( |
| comparisonSampler from typegpudata.ts | 719 B ( |
| cos from typegpustd.ts | 61.33 kB ( |
| cosh from typegpustd.ts | 61.33 kB ( |
| countLeadingZeros from typegpustd.ts | 61.33 kB ( |
| countOneBits from typegpustd.ts | 61.33 kB ( |
| countTrailingZeros from typegpustd.ts | 61.33 kB ( |
| cross from typegpustd.ts | 61.33 kB ( |
| d from typegpu.ts | 82.40 kB ( |
| deepEqual from typegpudata.ts | 2.74 kB ( |
| degrees from typegpustd.ts | 61.33 kB ( |
| determinant from typegpustd.ts | 61.33 kB ( |
| disarrayOf from typegpudata.ts | 12.67 kB ( |
| discard from typegpustd.ts | 11.92 kB ( |
| distance from typegpustd.ts | 61.33 kB ( |
| div from typegpustd.ts | 44.02 kB ( |
| dot4I8Packed from typegpustd.ts | 61.33 kB ( |
| dot4U8Packed from typegpustd.ts | 61.33 kB ( |
| dot from typegpustd.ts | 61.32 kB ( |
| dpdxCoarse from typegpustd.ts | 12.77 kB ( |
| dpdxFine from typegpustd.ts | 12.77 kB ( |
| dpdx from typegpustd.ts | 12.77 kB ( |
| dpdyCoarse from typegpustd.ts | 12.77 kB ( |
| dpdyFine from typegpustd.ts | 12.77 kB ( |
| dpdy from typegpustd.ts | 12.77 kB ( |
| eq from typegpustd.ts | 46.55 kB ( |
| exp2 from typegpustd.ts | 61.33 kB ( |
| exp from typegpustd.ts | 61.33 kB ( |
| extensionEnabled from typegpustd.ts | 12.24 kB ( |
| extractBits from typegpustd.ts | 61.33 kB ( |
| f16 from typegpudata.ts | 10.72 kB ( |
| f32 from typegpudata.ts | 10.72 kB ( |
| faceForward from typegpustd.ts | 61.33 kB ( |
| firstLeadingBit from typegpustd.ts | 61.33 kB ( |
| firstTrailingBit from typegpustd.ts | 61.33 kB ( |
| float16 from typegpudata.ts | 18.24 kB ( |
| float16x2 from typegpudata.ts | 18.24 kB ( |
| float16x4 from typegpudata.ts | 18.24 kB ( |
| float32 from typegpudata.ts | 18.24 kB ( |
| float32x2 from typegpudata.ts | 18.24 kB ( |
| float32x3 from typegpudata.ts | 18.24 kB ( |
| float32x4 from typegpudata.ts | 18.24 kB ( |
| floor from typegpustd.ts | 61.33 kB ( |
| fma from typegpustd.ts | 61.33 kB ( |
| formatToWGSLType from typegpudata.ts | 18.24 kB ( |
| fract from typegpustd.ts | 61.33 kB ( |
| frexp from typegpustd.ts | 61.33 kB ( |
| fwidthCoarse from typegpustd.ts | 12.77 kB ( |
| fwidthFine from typegpustd.ts | 12.77 kB ( |
| fwidth from typegpustd.ts | 12.77 kB ( |
| ge from typegpustd.ts | 46.55 kB ( |
| getLongestContiguousPrefix from typegpudata.ts | 22.08 kB ( |
| gt from typegpustd.ts | 46.55 kB ( |
| i32 from typegpudata.ts | 10.72 kB ( |
| identity2 from typegpustd.ts | 24.66 kB ( |
| identity3 from typegpustd.ts | 24.66 kB ( |
| identity4 from typegpustd.ts | 24.66 kB ( |
| insertBits from typegpustd.ts | 61.33 kB ( |
| interpolate from typegpudata.ts | 23.74 kB ( |
| invariant from typegpudata.ts | 24.11 kB ( |
| inverseSqrt from typegpustd.ts | 61.33 kB ( |
| isAccessor from typegpu.ts | 65 B (➖) |
| isAlignAttrib from typegpudata.ts | 721 B ( |
| isAtomic from typegpudata.ts | 721 B ( |
| isBufferShorthand from typegpu.ts | 1.73 kB ( |
| isBuffer from typegpu.ts | 87.61 kB ( |
| isBuiltinAttrib from typegpudata.ts | 723 B ( |
| isBuiltin from typegpudata.ts | 22.01 kB ( |
| isCloseTo from typegpustd.ts | 46.55 kB ( |
| isComparisonSampler from typegpu.ts | 57.81 kB ( |
| isContiguous from typegpudata.ts | 22.07 kB ( |
| isData from typegpudata.ts | 2.35 kB ( |
| isDecorated from typegpudata.ts | 724 B ( |
| isDisarray from typegpudata.ts | 1.66 kB ( |
| isInterpolateAttrib from typegpudata.ts | 727 B ( |
| isLazy from typegpu.ts | 61 B (➖) |
| isLocationAttrib from typegpudata.ts | 724 B ( |
| isLooseData from typegpudata.ts | 1.70 kB ( |
| isLooseDecorated from typegpudata.ts | 1.67 kB ( |
| isMutableAccessor from typegpu.ts | 73 B (➖) |
| isPackedData from typegpudata.ts | 18.31 kB ( |
| isPtr from typegpudata.ts | 718 B ( |
| isSampler from typegpu.ts | 57.79 kB ( |
| isSizeAttrib from typegpudata.ts | 720 B ( |
| isSlot from typegpu.ts | 61 B (➖) |
| isTexture from typegpu.ts | 57.79 kB ( |
| isTgpuComputeFn from typegpu.ts | 69 B (➖) |
| isTgpuFn from typegpu.ts | 731 B ( |
| isTgpuFragmentFn from typegpu.ts | 70 B (➖) |
| isTgpuVertexFn from typegpu.ts | 68 B (➖) |
| isUnstruct from typegpudata.ts | 1.66 kB ( |
| isUsableAsRender from typegpu.ts | 55 B (➖) |
| isUsableAsSampled from typegpu.ts | 56 B (➖) |
| isUsableAsStorage from typegpu.ts | 56 B (➖) |
| isUsableAsUniform from typegpu.ts | 57.78 kB ( |
| isUsableAsVertex from typegpu.ts | 87.60 kB ( |
| isVariable from typegpu.ts | 59.58 kB ( |
| isWgslArray from typegpudata.ts | 720 B ( |
| isWgslData from typegpudata.ts | 1.28 kB ( |
| isWgslStruct from typegpudata.ts | 721 B ( |
| ldexp from typegpustd.ts | 61.33 kB ( |
| le from typegpustd.ts | 46.55 kB ( |
| length from typegpustd.ts | 61.32 kB ( |
| location from typegpudata.ts | 23.74 kB ( |
| log2 from typegpustd.ts | 61.33 kB ( |
| log from typegpustd.ts | 61.33 kB ( |
| lt from typegpustd.ts | 46.55 kB ( |
| mat2x2f from typegpudata.ts | 24.66 kB ( |
| mat3x3f from typegpudata.ts | 24.66 kB ( |
| mat4x4f from typegpudata.ts | 24.66 kB ( |
| matToArray from typegpudata.ts | 24.79 kB ( |
| max from typegpustd.ts | 61.33 kB ( |
| memoryLayoutOf from typegpudata.ts | 39.36 kB ( |
| min from typegpustd.ts | 61.33 kB ( |
| mix from typegpustd.ts | 61.33 kB ( |
| mod from typegpustd.ts | 44.02 kB ( |
| modf from typegpustd.ts | 61.33 kB ( |
| mul from typegpustd.ts | 44.02 kB ( |
| ne from typegpustd.ts | 46.55 kB ( |
| neg from typegpustd.ts | 44.02 kB ( |
| normalize from typegpustd.ts | 61.33 kB ( |
| not from typegpustd.ts | 46.54 kB ( |
| or from typegpustd.ts | 46.54 kB ( |
| pack2x16float from typegpustd.ts | 33.26 kB ( |
| pack4x8unorm from typegpustd.ts | 33.26 kB ( |
| packedFormats from typegpudata.ts | 18.26 kB ( |
| pow from typegpustd.ts | 61.33 kB ( |
| ptrFn from typegpudata.ts | 825 B ( |
| ptrHandle from typegpudata.ts | 817 B ( |
| ptrPrivate from typegpudata.ts | 824 B ( |
| ptrStorage from typegpudata.ts | 822 B ( |
| ptrUniform from typegpudata.ts | 818 B ( |
| ptrWorkgroup from typegpudata.ts | 826 B ( |
| quantizeToF16 from typegpustd.ts | 61.33 kB ( |
| radians from typegpustd.ts | 61.33 kB ( |
| ref from typegpudata.ts | 4.12 kB ( |
| reflect from typegpustd.ts | 61.33 kB ( |
| refract from typegpustd.ts | 61.33 kB ( |
| reverseBits from typegpustd.ts | 61.33 kB ( |
| rotateX4 from typegpustd.ts | 44.78 kB ( |
| rotateY4 from typegpustd.ts | 44.79 kB ( |
| rotateZ4 from typegpustd.ts | 44.79 kB ( |
| rotationX4 from typegpustd.ts | 24.66 kB ( |
| rotationY4 from typegpustd.ts | 24.66 kB ( |
| rotationZ4 from typegpustd.ts | 24.66 kB ( |
| round from typegpustd.ts | 61.33 kB ( |
| sampler from typegpudata.ts | 708 B ( |
| saturate from typegpustd.ts | 61.33 kB ( |
| scale4 from typegpustd.ts | 44.78 kB ( |
| scaling4 from typegpustd.ts | 24.66 kB ( |
| select from typegpustd.ts | 46.55 kB ( |
| sign from typegpustd.ts | 61.33 kB ( |
| sin from typegpustd.ts | 61.33 kB ( |
| sinh from typegpustd.ts | 61.33 kB ( |
| sint16 from typegpudata.ts | 18.24 kB ( |
| sint16x2 from typegpudata.ts | 18.24 kB ( |
| sint16x4 from typegpudata.ts | 18.24 kB ( |
| sint32 from typegpudata.ts | 18.24 kB ( |
| sint32x2 from typegpudata.ts | 18.24 kB ( |
| sint32x3 from typegpudata.ts | 18.24 kB ( |
| sint32x4 from typegpudata.ts | 18.24 kB ( |
| sint8 from typegpudata.ts | 18.24 kB ( |
| sint8x2 from typegpudata.ts | 18.24 kB ( |
| sint8x4 from typegpudata.ts | 18.24 kB ( |
| sizeOf from typegpudata.ts | 22.06 kB ( |
| size from typegpudata.ts | 23.73 kB ( |
| smoothstep from typegpustd.ts | 61.33 kB ( |
| snorm16 from typegpudata.ts | 18.24 kB ( |
| snorm16x2 from typegpudata.ts | 18.24 kB ( |
| snorm16x4 from typegpudata.ts | 18.24 kB ( |
| snorm8 from typegpudata.ts | 18.24 kB ( |
| snorm8x2 from typegpudata.ts | 18.24 kB ( |
| snorm8x4 from typegpudata.ts | 18.24 kB ( |
| sqrt from typegpustd.ts | 61.33 kB ( |
| std from typegpu.ts | 96.25 kB ( |
| step from typegpustd.ts | 61.33 kB ( |
| storageBarrier from typegpustd.ts | 13.54 kB ( |
| struct from typegpudata.ts | 3.34 kB ( |
| sub from typegpustd.ts | 44.02 kB ( |
| subgroupAdd from typegpustd.ts | 21.32 kB ( |
| subgroupAll from typegpustd.ts | 21.32 kB ( |
| subgroupAnd from typegpustd.ts | 21.32 kB ( |
| subgroupAny from typegpustd.ts | 21.32 kB ( |
| subgroupBallot from typegpustd.ts | 21.32 kB ( |
| subgroupBroadcastFirst from typegpustd.ts | 21.32 kB ( |
| subgroupBroadcast from typegpustd.ts | 21.32 kB ( |
| subgroupElect from typegpustd.ts | 21.32 kB ( |
| subgroupExclusiveAdd from typegpustd.ts | 21.32 kB ( |
| subgroupExclusiveMul from typegpustd.ts | 21.32 kB ( |
| subgroupInclusiveAdd from typegpustd.ts | 21.32 kB ( |
| subgroupInclusiveMul from typegpustd.ts | 21.32 kB ( |
| subgroupMax from typegpustd.ts | 21.32 kB ( |
| subgroupMin from typegpustd.ts | 21.32 kB ( |
| subgroupMul from typegpustd.ts | 21.32 kB ( |
| subgroupOr from typegpustd.ts | 21.32 kB ( |
| subgroupShuffleDown from typegpustd.ts | 21.32 kB ( |
| subgroupShuffleUp from typegpustd.ts | 21.32 kB ( |
| subgroupShuffleXor from typegpustd.ts | 21.32 kB ( |
| subgroupShuffle from typegpustd.ts | 21.32 kB ( |
| subgroupXor from typegpustd.ts | 21.32 kB ( |
| tan from typegpustd.ts | 61.33 kB ( |
| tanh from typegpustd.ts | 61.33 kB ( |
| texture1d from typegpudata.ts | 11.17 kB ( |
| texture2dArray from typegpudata.ts | 11.19 kB ( |
| texture2d from typegpudata.ts | 11.17 kB ( |
| texture3d from typegpudata.ts | 11.17 kB ( |
| textureBarrier from typegpustd.ts | 13.53 kB ( |
| textureCubeArray from typegpudata.ts | 11.20 kB ( |
| textureCube from typegpudata.ts | 11.18 kB ( |
| textureDepth2dArray from typegpudata.ts | 11.18 kB ( |
| textureDepth2d from typegpudata.ts | 11.16 kB ( |
| textureDepthCubeArray from typegpudata.ts | 11.19 kB ( |
| textureDepthCube from typegpudata.ts | 11.17 kB ( |
| textureDepthMultisampled2d from typegpudata.ts | 11.19 kB ( |
| textureDimensions from typegpustd.ts | 22.80 kB ( |
| textureExternal from typegpudata.ts | 839 B ( |
| textureGather from typegpustd.ts | 22.80 kB ( |
| textureLoad from typegpustd.ts | 22.81 kB ( |
| textureMultisampled2d from typegpudata.ts | 11.20 kB ( |
| textureSampleBaseClampToEdge from typegpustd.ts | 22.81 kB ( |
| textureSampleBias from typegpustd.ts | 22.81 kB ( |
| textureSampleCompareLevel from typegpustd.ts | 22.81 kB ( |
| textureSampleCompare from typegpustd.ts | 22.81 kB ( |
| textureSampleLevel from typegpustd.ts | 22.81 kB ( |
| textureSample from typegpustd.ts | 22.81 kB ( |
| textureStorage1d from typegpudata.ts | 1003 B ( |
| textureStorage2dArray from typegpudata.ts | 1021 B ( |
| textureStorage2d from typegpudata.ts | 1003 B ( |
| textureStorage3d from typegpudata.ts | 1003 B ( |
| textureStore from typegpustd.ts | 22.81 kB ( |
| tgpu.accessor from typegpu.ts | 244.38 kB ( |
| tgpu.bindGroupLayout from typegpu.ts | 244.38 kB ( |
| tgpu.comptime from typegpu.ts | 244.38 kB ( |
| tgpu.computeFn from typegpu.ts | 244.38 kB ( |
| tgpu.const from typegpu.ts | 244.37 kB ( |
| tgpu.fn from typegpu.ts | 244.37 kB ( |
| tgpu.fragmentFn from typegpu.ts | 244.38 kB ( |
| tgpu.initFromDevice from typegpu.ts | 244.38 kB ( |
| tgpu.init from typegpu.ts | 244.37 kB ( |
| tgpu.lazy from typegpu.ts | 244.37 kB ( |
| tgpu.mutableAccessor from typegpu.ts | 244.38 kB ( |
| tgpu.privateVar from typegpu.ts | 244.38 kB ( |
| tgpu.resolveWithContext from typegpu.ts | 244.38 kB ( |
| tgpu.resolve from typegpu.ts | 244.37 kB ( |
| tgpu.slot from typegpu.ts | 244.37 kB ( |
| tgpu.unroll from typegpu.ts | 244.37 kB ( |
| tgpu.vertexFn from typegpu.ts | 244.38 kB ( |
| tgpu.vertexLayout from typegpu.ts | 244.38 kB ( |
| tgpu.workgroupVar from typegpu.ts | 244.38 kB ( |
| tgpu from typegpu.ts | 244.37 kB ( |
| translate4 from typegpustd.ts | 44.78 kB ( |
| translation4 from typegpustd.ts | 24.66 kB ( |
| transpose from typegpustd.ts | 61.33 kB ( |
| trunc from typegpustd.ts | 61.33 kB ( |
| u16 from typegpudata.ts | 10.74 kB ( |
| u32 from typegpudata.ts | 10.72 kB ( |
| uint16 from typegpudata.ts | 18.24 kB ( |
| uint16x2 from typegpudata.ts | 18.24 kB ( |
| uint16x4 from typegpudata.ts | 18.24 kB ( |
| uint32 from typegpudata.ts | 18.24 kB ( |
| uint32x2 from typegpudata.ts | 18.24 kB ( |
| uint32x3 from typegpudata.ts | 18.24 kB ( |
| uint32x4 from typegpudata.ts | 18.24 kB ( |
| uint8 from typegpudata.ts | 18.24 kB ( |
| uint8x2 from typegpudata.ts | 18.24 kB ( |
| uint8x4 from typegpudata.ts | 18.24 kB ( |
| unorm10 10 10 2 from typegpudata.ts | 18.24 kB ( |
| unorm16 from typegpudata.ts | 18.24 kB ( |
| unorm16x2 from typegpudata.ts | 18.24 kB ( |
| unorm16x4 from typegpudata.ts | 18.24 kB ( |
| unorm8 from typegpudata.ts | 18.24 kB ( |
| unorm8x2 from typegpudata.ts | 18.24 kB ( |
| unorm8x4 bgra from typegpudata.ts | 18.24 kB ( |
| unorm8x4 from typegpudata.ts | 18.24 kB ( |
| unpack2x16float from typegpustd.ts | 33.26 kB ( |
| unpack4x8unorm from typegpustd.ts | 33.26 kB ( |
| unstruct from typegpudata.ts | 1.61 kB ( |
| vec2b from typegpudata.ts | 16.75 kB ( |
| vec2f from typegpudata.ts | 16.75 kB ( |
| vec2h from typegpudata.ts | 16.75 kB ( |
| vec2i from typegpudata.ts | 16.75 kB ( |
| vec2u from typegpudata.ts | 16.75 kB ( |
| vec3b from typegpudata.ts | 16.75 kB ( |
| vec3f from typegpudata.ts | 16.75 kB ( |
| vec3h from typegpudata.ts | 16.75 kB ( |
| vec3i from typegpudata.ts | 16.75 kB ( |
| vec3u from typegpudata.ts | 16.75 kB ( |
| vec4b from typegpudata.ts | 16.75 kB ( |
| vec4f from typegpudata.ts | 16.75 kB ( |
| vec4h from typegpudata.ts | 16.75 kB ( |
| vec4i from typegpudata.ts | 16.75 kB ( |
| vec4u from typegpudata.ts | 16.75 kB ( |
| workgroupBarrier from typegpustd.ts | 13.54 kB ( |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
Add runtime validation for write offsets in TgpuBuffer.write: startOffset must be a non-negative integer; endOffset must be >= startOffset and <= buffer size. Forward BufferWriteOptions through the buffer shorthand write API and add unit tests for the new checks. Clarify docs about TypeGPU wrapper allocation and byte-based endOffset behavior (partial-element writes).
There was a problem hiding this comment.
Pull request overview
This PR expands TypeGPU’s buffer write API to support more permissive “write-side” input representations (tuples/TypedArrays), adds slice-based writes via byte offsets, and improves memoryLayoutOf accessor error reporting. It also updates compiled and non-compiled writer generation plus associated tests/docs to reflect these new capabilities.
Changes:
- Add
InferInput/$inReprto widen write-side types for vectors andarrayOf(...)(including accepting flat TypedArrays for vector arrays). - Add
BufferWriteOptions(startOffset/endOffset) toTgpuBuffer.write()for slice writes and update tests/docs accordingly. - Improve
memoryLayoutOfaccessor typing/error messaging and update callsites/tests.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/tests/offsetUtils.test.ts | Update memoryLayoutOf accessors to match new typing (no as number). |
| packages/typegpu/tests/computePipeline.test.ts | Adjust memoryLayoutOf accessors used for indirect dispatch warnings. |
| packages/typegpu/tests/compiledIO.test.ts | Update writer snapshots for array-like vector inputs, add partial-mode writer tests, add InferInput-related tests. |
| packages/typegpu/tests/buffer.test.ts | Add tests for slice writes and InferInput acceptance (tuples/TypedArrays). |
| packages/typegpu/src/shared/symbols.ts | Introduce $inRepr type token. |
| packages/typegpu/src/shared/repr.ts | Add InferInput type (falls back to Infer). |
| packages/typegpu/src/data/wgslTypes.ts | Define $inRepr for Vec* and WgslArray to accept tuples/TypedArrays. |
| packages/typegpu/src/data/offsetUtils.ts | Relax accessor return type and improve memoryLayoutOf error message. |
| packages/typegpu/src/data/index.ts | Export InferInput from the public data barrel. |
| packages/typegpu/src/data/dataIO.ts | Switch vector writers to index-based access (value[0], etc.). |
| packages/typegpu/src/data/compiledIO.ts | Extend compiled writers for InferInput + slice writes (endOffset) and add vector-array TypedArray fast path. |
| packages/typegpu/src/core/buffer/bufferShorthand.ts | Update shorthand write typing to InferInput. |
| packages/typegpu/src/core/buffer/buffer.ts | Add BufferWriteOptions and implement offset-based writes using compiled writer endOffset. |
| apps/typegpu-docs/src/content/docs/fundamentals/buffers.mdx | Document permissive vector inputs and slice-writing via offsets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use actual primitive/component size when generating compiled writers instead of assuming 4-byte components. Add a runtime guard in the buffer implementation to reject flat TypedArray inputs for arrays of vectors when the compiled writer is unavailable (e.g. no-eval environments), and add tests covering float16 vec writers and array stride/offset behavior.
Introduce InferInput and
$inReprto accept plain arrays andTypedArraysfor vector/array write-side representations. AddBufferWriteOptions(startOffset/endOffset) and improvememoryLayoutOfaccessor errors. Update compiled/data writers to index into array-like vector inputs and adjust tests and docs accordingly