Skip to content

feat: Buffer regions - #3272

Open
reczkok wants to merge 9 commits into
feat/wgsl-buffer-viewfrom
feat/buffer-regions
Open

reczkok wants to merge 9 commits into
feat/wgsl-buffer-viewfrom
feat/buffer-regions

Conversation

@reczkok

@reczkok reczkok commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Implements the buffer views half of #2816, named regions here since buffer views now means the WGSL feature. buffer.region(schema, accessor) is a typed range of a buffer that reads, writes and binds only its own bytes, and works as a vertex, index or indirect buffer

@reczkok
reczkok added this pull request to stack #3273 October 24, 2026 18:46
@github-actions

github-actions Bot commented Oct 24, 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/tgpu-gen@4ba53e035f30143adbcc6f2097a936063f73e322
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@4ba53e035f30143adbcc6f2097a936063f73e322
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@4ba53e035f30143adbcc6f2097a936063f73e322
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@4ba53e035f30143adbcc6f2097a936063f73e322

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 Decreased ➖ Unchanged 🔴 Increased (max 13.30%) ❔ Unknown
0 36 319 4

import * as ... in PR vs import * as ... in target (did bundle size increase?):

Click to reveal the results table (301 entries).
Test tsdown
STATIC_std.ts 115.11 kB ($${\color{red}+13.3\%}$$)
tgpu_bindGroupLayout.ts 76.99 kB ($${\color{red}+10.0\%}$$)
tgpu_resolveWithContext.ts 169.57 kB ($${\color{red}+5.7\%}$$)
tgpu_resolve.ts 169.63 kB ($${\color{red}+5.7\%}$$)
d_struct.ts 4.06 kB ($${\color{red}+4.6\%}$$)
STATIC_allImports.ts 325.46 kB ($${\color{red}+3.2\%}$$)
tgpu_initFromDevice.ts 262.52 kB ($${\color{red}+2.9\%}$$)
tgpu_init.ts 263.06 kB ($${\color{red}+2.9\%}$$)
STATIC_tgpu.ts 274.28 kB ($${\color{red}+2.7\%}$$)
STATIC_d.ts 72.64 kB ($${\color{red}+1.7\%}$$)
d_memoryLayoutOf.ts 36.85 kB ($${\color{red}+1.7\%}$$)
d_arrayOf.ts 33.95 kB ($${\color{red}+1.2\%}$$)
d_builtin.ts 36.48 kB ($${\color{red}+1.2\%}$$)
d_deepEqual.ts 23.01 kB ($${\color{red}+1.1\%}$$)
d_schemasEqualNominally.ts 23.01 kB ($${\color{red}+1.1\%}$$)
d_schemasEqualStructurally.ts 23.01 kB ($${\color{red}+1.1\%}$$)
d_bool.ts 20.25 kB ($${\color{red}+1.1\%}$$)
d_f16.ts 20.25 kB ($${\color{red}+1.1\%}$$)
d_f32.ts 20.25 kB ($${\color{red}+1.1\%}$$)
d_i32.ts 20.25 kB ($${\color{red}+1.1\%}$$)
d_u32.ts 20.25 kB ($${\color{red}+1.1\%}$$)
d_ref.ts 20.26 kB ($${\color{red}+1.1\%}$$)
d_u16.ts 20.27 kB ($${\color{red}+1.1\%}$$)
d_abstractInt.ts 20.33 kB ($${\color{red}+1.1\%}$$)
d_abstractFloat.ts 20.33 kB ($${\color{red}+1.1\%}$$)
d_textureDepth2d.ts 20.69 kB ($${\color{red}+1.0\%}$$)
d_textureDepthCube.ts 20.70 kB ($${\color{red}+1.0\%}$$)
d_texture1d.ts 20.71 kB ($${\color{red}+1.0\%}$$)
d_texture2d.ts 20.71 kB ($${\color{red}+1.0\%}$$)
d_texture3d.ts 20.71 kB ($${\color{red}+1.0\%}$$)
d_textureCube.ts 20.71 kB ($${\color{red}+1.0\%}$$)
d_textureDepth2dArray.ts 20.71 kB ($${\color{red}+1.0\%}$$)
d_textureDepthCubeArray.ts 20.72 kB ($${\color{red}+1.0\%}$$)
d_textureDepthMultisampled2d.ts 20.72 kB ($${\color{red}+1.0\%}$$)
d_texture2dArray.ts 20.72 kB ($${\color{red}+1.0\%}$$)
d_textureCubeArray.ts 20.73 kB ($${\color{red}+1.0\%}$$)
d_textureMultisampled2d.ts 20.73 kB ($${\color{red}+1.0\%}$$)
std_isKnownAtComptime.ts 20.87 kB ($${\color{red}+1.0\%}$$)
std_subgroupElect.ts 21.44 kB ($${\color{red}+1.0\%}$$)
std_subgroupAll.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_subgroupAny.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_quadSwapX.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_quadSwapY.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_subgroupOr.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_subgroupAdd.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_subgroupAnd.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_subgroupMax.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_subgroupMin.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_subgroupMul.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_subgroupXor.ts 21.45 kB ($${\color{red}+1.0\%}$$)
std_quadSwapDiagonal.ts 21.46 kB ($${\color{red}+1.0\%}$$)
std_subgroupExclusiveAdd.ts 21.47 kB ($${\color{red}+1.0\%}$$)
std_subgroupExclusiveMul.ts 21.47 kB ($${\color{red}+1.0\%}$$)
std_subgroupInclusiveAdd.ts 21.47 kB ($${\color{red}+1.0\%}$$)
std_subgroupInclusiveMul.ts 21.47 kB ($${\color{red}+1.0\%}$$)
std_subgroupBroadcastFirst.ts 21.47 kB ($${\color{red}+1.0\%}$$)
std_storageBarrier.ts 21.49 kB ($${\color{red}+1.0\%}$$)
std_textureBarrier.ts 21.49 kB ($${\color{red}+1.0\%}$$)
std_workgroupBarrier.ts 21.50 kB ($${\color{red}+1.0\%}$$)
std_discard.ts 21.50 kB ($${\color{red}+1.0\%}$$)
std_textureNumLayers.ts 21.52 kB ($${\color{red}+1.0\%}$$)
std_textureNumLevels.ts 21.52 kB ($${\color{red}+1.0\%}$$)
std_textureNumSamples.ts 21.53 kB ($${\color{red}+1.0\%}$$)
std_typeOf.ts 22.25 kB ($${\color{red}+1.0\%}$$)
std_textureSampleCompare.ts 21.55 kB ($${\color{red}+1.0\%}$$)
std_textureSampleCompareLevel.ts 21.57 kB ($${\color{red}+1.0\%}$$)
std_textureStore.ts 21.57 kB ($${\color{red}+1.0\%}$$)
std_workgroupUniformLoad.ts 21.59 kB ($${\color{red}+1.0\%}$$)
tgpu_comptime.ts 21.60 kB ($${\color{red}+1.0\%}$$)
std_atomicLoad.ts 21.63 kB ($${\color{red}+1.0\%}$$)
std_atomicOr.ts 21.67 kB ($${\color{red}+1.0\%}$$)
std_atomicAdd.ts 21.67 kB ($${\color{red}+1.0\%}$$)
std_atomicAnd.ts 21.67 kB ($${\color{red}+1.0\%}$$)
std_atomicMax.ts 21.67 kB ($${\color{red}+1.0\%}$$)
std_atomicMin.ts 21.67 kB ($${\color{red}+1.0\%}$$)
std_atomicSub.ts 21.67 kB ($${\color{red}+1.0\%}$$)
std_atomicXor.ts 21.67 kB ($${\color{red}+1.0\%}$$)
std_atomicExchange.ts 21.68 kB ($${\color{red}+1.0\%}$$)
std_atomicStore.ts 21.71 kB ($${\color{red}+1.0\%}$$)
std_quadBroadcast.ts 21.72 kB ($${\color{red}+1.0\%}$$)
std_arrayLength.ts 21.72 kB ($${\color{red}+1.0\%}$$)
std_subgroupShuffleUp.ts 21.72 kB ($${\color{red}+1.0\%}$$)
std_subgroupShuffle.ts 21.72 kB ($${\color{red}+1.0\%}$$)
std_subgroupShuffleXor.ts 21.72 kB ($${\color{red}+1.0\%}$$)
std_subgroupShuffleDown.ts 21.73 kB ($${\color{red}+1.0\%}$$)
std_subgroupBroadcast.ts 21.73 kB ($${\color{red}+1.0\%}$$)
d_sizeOf.ts 32.97 kB ($${\color{red}+1.0\%}$$)
std_copy.ts 21.75 kB ($${\color{red}+1.0\%}$$)
d_isContiguous.ts 32.98 kB ($${\color{red}+1.0\%}$$)
d_getLongestContiguousPrefix.ts 32.99 kB ($${\color{red}+1.0\%}$$)
d_isBuiltin.ts 33.07 kB ($${\color{red}+1.0\%}$$)
std_extensionEnabled.ts 21.82 kB ($${\color{red}+1.0\%}$$)
std_range.ts 22.09 kB ($${\color{red}+1.0\%}$$)
std_isBeingTranspiled.ts 22.13 kB ($${\color{red}+1.0\%}$$)
std_getShaderStage.ts 22.19 kB ($${\color{red}+1.0\%}$$)
std_getTargetShaderLanguage.ts 22.20 kB ($${\color{red}+1.0\%}$$)
d_disarrayOf.ts 22.31 kB ($${\color{red}+1.0\%}$$)
d_size.ts 34.74 kB ($${\color{red}+1.0\%}$$)
d_align.ts 34.74 kB ($${\color{red}+1.0\%}$$)
d_location.ts 34.74 kB ($${\color{red}+1.0\%}$$)
d_interpolate.ts 34.74 kB ($${\color{red}+1.0\%}$$)
d_invariant.ts 35.11 kB ($${\color{red}+0.9\%}$$)
tgpu_vertexLayout.ts 35.00 kB ($${\color{red}+0.9\%}$$)
common_writeSoA.ts 35.59 kB ($${\color{red}+0.9\%}$$)
std_atomicCompareExchangeWeak.ts 24.27 kB ($${\color{red}+0.9\%}$$)
common_fullScreenTriangle.ts 49.15 kB ($${\color{red}+0.9\%}$$)
tgpu_fn.ts 47.40 kB ($${\color{red}+0.8\%}$$)
std_subgroupBallot.ts 27.92 kB ($${\color{red}+0.8\%}$$)
std_textureSampleBaseClampToEdge.ts 28.00 kB ($${\color{red}+0.8\%}$$)
std_textureSampleGrad.ts 28.01 kB ($${\color{red}+0.8\%}$$)
std_textureSampleBias.ts 28.07 kB ($${\color{red}+0.8\%}$$)
d_uint8.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_float16.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_float16x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_float16x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_float32.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_float32x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_float32x3.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_float32x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint16.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint16x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint16x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint32.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint32x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint32x3.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint32x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint8.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint8x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_sint8x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_snorm16.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_snorm16x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_snorm16x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_snorm8.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_snorm8x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_snorm8x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint16.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint16x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint16x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint32.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint32x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint32x3.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint32x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint8x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_uint8x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_unorm10_10_10_2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_unorm16.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_unorm16x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_unorm16x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_unorm8.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_unorm8x2.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_unorm8x4.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_unorm8x4_bgra.ts 28.21 kB ($${\color{red}+0.8\%}$$)
std_textureSample.ts 28.09 kB ($${\color{red}+0.8\%}$$)
std_textureSampleLevel.ts 28.10 kB ($${\color{red}+0.8\%}$$)
std_textureGatherCompare.ts 28.13 kB ($${\color{red}+0.8\%}$$)
std_textureDimensions.ts 28.16 kB ($${\color{red}+0.8\%}$$)
d_formatToWGSLType.ts 28.21 kB ($${\color{red}+0.8\%}$$)
d_packedFormats.ts 28.23 kB ($${\color{red}+0.8\%}$$)
d_isPackedData.ts 28.28 kB ($${\color{red}+0.8\%}$$)
std_textureGather.ts 28.33 kB ($${\color{red}+0.8\%}$$)
STATIC_common.ts 56.70 kB ($${\color{red}+0.7\%}$$)
d_alignmentOf.ts 30.08 kB ($${\color{red}+0.7\%}$$)
tgpu_computeFn.ts 46.50 kB ($${\color{red}+0.7\%}$$)
std_textureLoad.ts 29.95 kB ($${\color{red}+0.7\%}$$)
tgpu_vertexFn.ts 47.05 kB ($${\color{red}+0.7\%}$$)
tgpu_fragmentFn.ts 47.24 kB ($${\color{red}+0.7\%}$$)
std_bitcast.ts 30.73 kB ($${\color{red}+0.7\%}$$)
tgpu_accessor.ts 68.39 kB ($${\color{red}+0.7\%}$$)
tgpu_mutableAccessor.ts 68.40 kB ($${\color{red}+0.7\%}$$)
std_pack2x16float.ts 31.74 kB ($${\color{red}+0.7\%}$$)
std_unpack2x16unorm.ts 31.74 kB ($${\color{red}+0.7\%}$$)
std_unpack2x16float.ts 31.75 kB ($${\color{red}+0.7\%}$$)
std_pack4xI8.ts 31.76 kB ($${\color{red}+0.7\%}$$)
std_unpack4xI8.ts 31.76 kB ($${\color{red}+0.7\%}$$)
std_pack4xU8.ts 31.76 kB ($${\color{red}+0.7\%}$$)
std_unpack4xU8.ts 31.76 kB ($${\color{red}+0.7\%}$$)
std_unpack2x16snorm.ts 31.76 kB ($${\color{red}+0.7\%}$$)
std_unpack4x8unorm.ts 31.78 kB ($${\color{red}+0.7\%}$$)
std_unpack4x8snorm.ts 31.83 kB ($${\color{red}+0.7\%}$$)
std_pack2x16snorm.ts 31.92 kB ($${\color{red}+0.7\%}$$)
std_pack2x16unorm.ts 31.92 kB ($${\color{red}+0.7\%}$$)
std_pack4xU8Clamp.ts 31.93 kB ($${\color{red}+0.7\%}$$)
std_pack4xI8Clamp.ts 31.94 kB ($${\color{red}+0.7\%}$$)
std_pack4x8snorm.ts 32.00 kB ($${\color{red}+0.7\%}$$)
std_pack4x8unorm.ts 32.00 kB ($${\color{red}+0.7\%}$$)
std_identity2.ts 34.42 kB ($${\color{red}+0.6\%}$$)
std_identity3.ts 34.42 kB ($${\color{red}+0.6\%}$$)
std_identity4.ts 34.42 kB ($${\color{red}+0.6\%}$$)
std_rotationX4.ts 34.42 kB ($${\color{red}+0.6\%}$$)
std_rotationY4.ts 34.42 kB ($${\color{red}+0.6\%}$$)
std_rotationZ4.ts 34.42 kB ($${\color{red}+0.6\%}$$)
std_scaling4.ts 34.42 kB ($${\color{red}+0.6\%}$$)
std_translation4.ts 34.42 kB ($${\color{red}+0.6\%}$$)
d_matToArray.ts 34.55 kB ($${\color{red}+0.6\%}$$)
std_dot4I8Packed.ts 35.80 kB ($${\color{red}+0.6\%}$$)
std_dot4U8Packed.ts 35.80 kB ($${\color{red}+0.6\%}$$)
std_firstLeadingBit.ts 35.81 kB ($${\color{red}+0.6\%}$$)
std_determinant.ts 35.89 kB ($${\color{red}+0.6\%}$$)
std_dpdxFine.ts 35.89 kB ($${\color{red}+0.6\%}$$)
std_dpdyFine.ts 35.89 kB ($${\color{red}+0.6\%}$$)
std_dpdxCoarse.ts 35.90 kB ($${\color{red}+0.6\%}$$)
std_dpdyCoarse.ts 35.90 kB ($${\color{red}+0.6\%}$$)
std_fwidthFine.ts 35.90 kB ($${\color{red}+0.6\%}$$)
std_dpdx.ts 35.90 kB ($${\color{red}+0.6\%}$$)
std_dpdy.ts 35.90 kB ($${\color{red}+0.6\%}$$)
std_fwidthCoarse.ts 35.90 kB ($${\color{red}+0.6\%}$$)
std_fwidth.ts 35.91 kB ($${\color{red}+0.6\%}$$)
std_refract.ts 35.91 kB ($${\color{red}+0.6\%}$$)
std_trunc.ts 35.96 kB ($${\color{red}+0.6\%}$$)
std_reverseBits.ts 35.97 kB ($${\color{red}+0.6\%}$$)
std_quantizeToF16.ts 35.97 kB ($${\color{red}+0.6\%}$$)
std_countOneBits.ts 35.97 kB ($${\color{red}+0.6\%}$$)
std_extractBits.ts 35.98 kB ($${\color{red}+0.6\%}$$)
std_firstTrailingBit.ts 35.98 kB ($${\color{red}+0.6\%}$$)
std_countLeadingZeros.ts 35.99 kB ($${\color{red}+0.6\%}$$)
std_countTrailingZeros.ts 35.99 kB ($${\color{red}+0.6\%}$$)
std_insertBits.ts 35.99 kB ($${\color{red}+0.6\%}$$)
std_faceForward.ts 35.99 kB ($${\color{red}+0.6\%}$$)
std_intdiv.ts 36.00 kB ($${\color{red}+0.6\%}$$)
std_tan.ts 36.04 kB ($${\color{red}+0.6\%}$$)
std_degrees.ts 36.05 kB ($${\color{red}+0.6\%}$$)
std_radians.ts 36.05 kB ($${\color{red}+0.6\%}$$)
std_inverseSqrt.ts 36.08 kB ($${\color{red}+0.6\%}$$)
std_round.ts 36.09 kB ($${\color{red}+0.6\%}$$)
std_step.ts 36.22 kB ($${\color{red}+0.6\%}$$)
std_ldexp.ts 36.22 kB ($${\color{red}+0.6\%}$$)
std_fma.ts 36.22 kB ($${\color{red}+0.6\%}$$)
std_transpose.ts 36.29 kB ($${\color{red}+0.6\%}$$)
std_not.ts 36.45 kB ($${\color{red}+0.6\%}$$)
std_abs.ts 36.46 kB ($${\color{red}+0.6\%}$$)
std_gt.ts 36.83 kB ($${\color{red}+0.6\%}$$)
std_neg.ts 36.51 kB ($${\color{red}+0.6\%}$$)
std_or.ts 36.52 kB ($${\color{red}+0.6\%}$$)
std_and.ts 36.60 kB ($${\color{red}+0.6\%}$$)
std_lt.ts 36.60 kB ($${\color{red}+0.6\%}$$)
std_eq.ts 36.61 kB ($${\color{red}+0.6\%}$$)
std_cos.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_exp.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_log.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_sin.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_exp2.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_sign.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_acos.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_asin.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_atan.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_ceil.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_cosh.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_log2.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_sinh.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_sqrt.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_tanh.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_acosh.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_asinh.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_atanh.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_floor.ts 36.63 kB ($${\color{red}+0.6\%}$$)
std_fract.ts 36.64 kB ($${\color{red}+0.6\%}$$)
std_ge.ts 36.67 kB ($${\color{red}+0.6\%}$$)
std_ne.ts 36.68 kB ($${\color{red}+0.6\%}$$)
std_le.ts 36.75 kB ($${\color{red}+0.6\%}$$)
std_saturate.ts 36.78 kB ($${\color{red}+0.6\%}$$)
std_pow.ts 36.81 kB ($${\color{red}+0.6\%}$$)
std_atan2.ts 36.82 kB ($${\color{red}+0.6\%}$$)
std_mix.ts 37.18 kB ($${\color{red}+0.6\%}$$)
std_clamp.ts 36.91 kB ($${\color{red}+0.6\%}$$)
std_max.ts 36.93 kB ($${\color{red}+0.6\%}$$)
std_min.ts 36.93 kB ($${\color{red}+0.6\%}$$)
std_smoothstep.ts 37.03 kB ($${\color{red}+0.6\%}$$)
std_select.ts 37.43 kB ($${\color{red}+0.6\%}$$)
std_mod.ts 37.46 kB ($${\color{red}+0.6\%}$$)
std_div.ts 37.50 kB ($${\color{red}+0.6\%}$$)
std_add.ts 37.58 kB ($${\color{red}+0.6\%}$$)
std_frexp.ts 38.54 kB ($${\color{red}+0.6\%}$$)
std_modf.ts 38.67 kB ($${\color{red}+0.6\%}$$)
std_all.ts 39.78 kB ($${\color{red}+0.5\%}$$)
std_bitShiftLeft.ts 39.76 kB ($${\color{red}+0.5\%}$$)
std_bitShiftRight.ts 39.77 kB ($${\color{red}+0.5\%}$$)
std_dot.ts 40.06 kB ($${\color{red}+0.5\%}$$)
std_length.ts 40.16 kB ($${\color{red}+0.5\%}$$)
std_any.ts 40.60 kB ($${\color{red}+0.5\%}$$)
std_cross.ts 40.27 kB ($${\color{red}+0.5\%}$$)
std_allEq.ts 40.81 kB ($${\color{red}+0.5\%}$$)
tgpu_lazy.ts 62.91 kB ($${\color{red}+0.5\%}$$)
tgpu_const.ts 63.11 kB ($${\color{red}+0.5\%}$$)
std_isCloseTo.ts 41.09 kB ($${\color{red}+0.5\%}$$)
tgpu_workgroupVar.ts 63.69 kB ($${\color{red}+0.5\%}$$)
tgpu_privateVar.ts 63.69 kB ($${\color{red}+0.5\%}$$)
std_normalize.ts 41.18 kB ($${\color{red}+0.5\%}$$)
std_bitcastF32toU32.ts 41.97 kB ($${\color{red}+0.5\%}$$)
std_bitcastU32toF32.ts 41.97 kB ($${\color{red}+0.5\%}$$)
std_bitcastU32toI32.ts 41.97 kB ($${\color{red}+0.5\%}$$)
std_mul.ts 42.20 kB ($${\color{red}+0.5\%}$$)
std_rotateZ4.ts 42.46 kB ($${\color{red}+0.5\%}$$)
std_translate4.ts 42.46 kB ($${\color{red}+0.5\%}$$)
std_scale4.ts 42.46 kB ($${\color{red}+0.5\%}$$)
std_rotateX4.ts 42.46 kB ($${\color{red}+0.5\%}$$)
std_rotateY4.ts 42.46 kB ($${\color{red}+0.5\%}$$)
std_sub.ts 42.58 kB ($${\color{red}+0.5\%}$$)
d_buffer.ts 1.03 kB
std_bufferArrayView.ts 41.55 kB
std_bufferLength.ts 42.69 kB
std_bufferView.ts 41.55 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 Oct 24, 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 [1.05, 2.15, 4.55, 7.54, 8.85, 13.28, 27.72, 26.21]
  line [1.00, 2.11, 4.63, 7.32, 8.85, 13.64, 26.04, 26.58]
  line [1.03, 2.09, 4.53, 7.48, 8.40, 13.25, 27.27, 29.79]
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.30, 0.60, 0.78, 0.91, 1.29, 1.25, 1.50, 1.69]
  line [0.32, 0.52, 0.74, 0.97, 1.21, 1.32, 1.48, 1.64]
  line [0.30, 0.50, 0.70, 0.84, 1.22, 1.27, 1.50, 1.66]
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 [1.00, 2.43, 4.80, 7.82, 14.53, 28.02, 60.30, 121.90]
  line [0.86, 2.40, 3.98, 8.49, 14.34, 28.11, 58.82, 120.99]
  line [0.93, 2.46, 4.09, 7.51, 13.72, 28.09, 59.76, 119.83]
Loading

@reczkok
reczkok force-pushed the feat/buffer-regions branch from df2f191 to f672a15 Compare October 26, 2026 13:02
@reczkok
reczkok removed this pull request from stack #3273 October 26, 2026 13:03
@reczkok
reczkok added this pull request to stack #3281 October 26, 2026 13:03
@reczkok
reczkok force-pushed the feat/buffer-regions branch from f672a15 to f5e845d Compare October 26, 2026 13:04
@reczkok
reczkok force-pushed the feat/buffer-regions branch 2 times, most recently from e533fdf to 04ab465 Compare October 27, 2026 12:14
@iwoplaza
iwoplaza force-pushed the feat/buffer-regions branch from 04ab465 to b698240 Compare October 27, 2026 12:22
@reczkok
reczkok force-pushed the feat/buffer-regions branch from b698240 to 452d437 Compare October 27, 2026 14:45
@reczkok
reczkok force-pushed the feat/buffer-regions branch from 452d437 to d3097ce Compare October 27, 2026 15:00
@reczkok
reczkok force-pushed the feat/buffer-regions branch 3 times, most recently from a03f69c to 6040443 Compare October 27, 2026 15:43
@reczkok
reczkok force-pushed the feat/buffer-regions branch from 6040443 to 33a8617 Compare October 27, 2026 15:48
@reczkok
reczkok marked this pull request as ready for review October 27, 2026 15:58
Copilot AI balanced review requested due to automatic review settings October 27, 2026 15:58

Copilot AI 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.

🟡 Changes recommended

Missing boundary checks allow region operations to access neighboring data, and unsupported index-region schemas can cause runtime failures.

6 open issues
What changed in this PR

Adds typed buffer regions to TypeGPU, allowing parts of one buffer to be read, written, bound, and used independently for rendering or compute operations.

Changes:

  • Introduces region creation, byte-range operations, bindings, unwrapping, and serialization.
  • Integrates regions with vertex, index, and indirect commands.
  • Adds tests, API documentation, and an indirect-culling example.
File Description
packages/​typegpu/​tests/​serial.test.ts Tests region serialization round-trips.
packages/​typegpu/​tests/​bufferRegion.test.ts Tests region creation, operations, and bindings.
packages/​typegpu/​tests/​buffer.test.ts Updates accepted write-input type assertions.
packages/​typegpu/​src/​unwrapper.ts Adds the region unwrap overload.
packages/​typegpu/​src/​types.ts Extends usage guards to regions.
packages/​typegpu/​src/​tgpuBindGroupLayout.ts Accepts regions in bind groups.
packages/​typegpu/​src/​serial/​restore.ts Restores serialized regions.
packages/​typegpu/​src/​indexNamedExports.ts Exports region APIs and types.
packages/​typegpu/​src/​errors.ts Broadens uniform-error inputs.
packages/​typegpu/​src/​data/​partialIO.ts Adds base offsets for patches.
packages/​typegpu/​src/​data/​offsetUtils.ts Tracks selected schemas and array runs.
packages/​typegpu/​src/​data/​dataIO.ts Supports reads at byte offsets.
packages/​typegpu/​src/​core/​root/​init.ts Unwraps regions into buffer bindings.
packages/​typegpu/​src/​core/​pipeline/​renderPipeline.ts Accepts regions in rendering APIs.
packages/​typegpu/​src/​core/​pipeline/​pipelineUtils.ts Resolves region-relative indirect arguments.
packages/​typegpu/​src/​core/​pipeline/​drawState.ts Applies region vertex and index bindings.
packages/​typegpu/​src/​core/​pipeline/​computePipeline.ts Supports indirect dispatch from regions.
packages/​typegpu/​src/​core/​commandEncoder/​renderPass.ts Supports regions in render-pass commands.
packages/​typegpu/​src/​core/​commandEncoder/​computePass.ts Supports region-based indirect dispatch.
packages/​typegpu/​src/​core/​buffer/​bufferRegion.ts Implements the buffer-region API.
packages/​typegpu/​src/​core/​buffer/​bufferBinding.ts Generalizes bindings to include regions.
packages/​typegpu/​src/​core/​buffer/​buffer.ts Adds region creation and shared range operations.
apps/​typegpu-docs/​src/​examples/​rendering/​indirect-culling/​meta.json Registers the culling example.
apps/​typegpu-docs/​src/​examples/​rendering/​indirect-culling/​index.ts Demonstrates shared-buffer regions and indirect drawing.
apps/​typegpu-docs/​src/​examples/​rendering/​indirect-culling/​index.html Adds the example canvas and counter.
apps/​typegpu-docs/​src/​content/​docs/​apis/​buffers.mdx Documents region creation and usage.

Review effort: Balanced

Comment thread packages/typegpu/src/core/buffer/bufferRegion.ts
Comment thread packages/typegpu/src/core/buffer/bufferRegion.ts
Comment thread packages/typegpu/src/core/pipeline/drawState.ts
Comment thread packages/typegpu/src/core/pipeline/pipelineUtils.ts
Comment thread packages/typegpu/src/data/partialIO.ts
Comment thread packages/typegpu/src/core/pipeline/renderPipeline.ts

@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 suggestions only — two region boundary contracts worth a look. The core offset plumbing (region write/patch/clear/copyFrom/read offsets, bind-group sizing, vertex/index/indirect element→byte math) checks out; comments inline.

Reviewed changes

  • buffer.region(schema, accessor | { offsetBytes }) (core/buffer/bufferRegion.ts) — new TgpuBufferRegion API with accessor navigation (fitsElement accepts schema-equal elements, array prefixes and array runs) and raw { offsetBytes } ranges, plus offset/fit validation.
  • Offset-aware buffer IO (buffer.ts, dataIO.ts, partialIO.ts, offsetUtils.ts) — write/patch/clear/copyFrom/read refactored onto offset-carrying internals; typed arrays accepted as raw bytes; getPatchInstructions/readFromArrayBuffer gain a base offset; navigateSchema reports the reached schema and array run.
  • Region binding (bufferRegion.ts bufferBindingOf, tgpuBindGroupLayout.ts, init.ts) — regions bind with offset/size and device-limit alignment validation; root.unwrap(region) yields a GPUBufferBinding.
  • Region as vertex/index/indirect buffer (drawState.ts rawRegionOf, pipelineUtils.ts resolveIndirect, renderPipeline.ts) — offsets count from the region start.
  • Supporting types and integration — BindableBuffer, TgpuMutable/TgpuReadonly/TgpuUniform genericized over the bound buffer, isBufferRegion, serial restore and exports.
  • Docs, example, tests — buffer-regions section in buffers.mdx, new rendering/indirect-culling example, tests/bufferRegion.test.ts, and updates to tests/buffer.test.ts/tests/serial.test.ts.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Comment thread packages/typegpu/src/core/root/init.ts
Comment thread packages/typegpu/src/core/pipeline/pipelineUtils.ts
@reczkok
reczkok force-pushed the feat/buffer-regions branch from 33a8617 to 4ba53e0 Compare October 27, 2026 16:18

@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

The only content change to any PR file since the prior pullfrog review (33a8617) is documentation. The branch was rebased onto a rewritten base tip and re-recorded, but every source, test, and example blob is byte-identical to the previously-reviewed revision (confirmed via matching git ls-tree blob hashes); the one non-doc difference, .../apis/buffer-views.mdx, belongs to the rewritten base branch, not this PR.

  • root.unwrap(region) contract documented (apps/typegpu-docs/src/content/docs/apis/buffers.mdx) — the region section now states the returned GPUBufferBinding carries the region's exact buffer/offset/size, and that unlike root.createBindGroup it neither rounds the size up to 4 bytes nor checks the offset alignment.

That wording matches the code at packages/typegpu/src/core/root/init.ts:589 (return { buffer: buffer.buffer, offset, size: resource.size }), which performs no rounding or alignment validation — versus bufferBindingOf, which does both. Both prior review threads (init.ts:589, pipelineUtils.ts:99) are resolved: the first by documenting the raw escape-hatch contract, the second by the author's deliberate "regions trust the caller" decision.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

This branch has not been deployed

No deployments
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