Repository navigation
feat: Buffer regions - #3272
feat: Buffer regions#3272reczkok wants to merge 9 commits into
Conversation
|
pkg.pr.new packages benchmark commit |
Bundle size comparison (
|
| 🟢 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 ( |
| tgpu_bindGroupLayout.ts | 76.99 kB ( |
| tgpu_resolveWithContext.ts | 169.57 kB ( |
| tgpu_resolve.ts | 169.63 kB ( |
| d_struct.ts | 4.06 kB ( |
| STATIC_allImports.ts | 325.46 kB ( |
| tgpu_initFromDevice.ts | 262.52 kB ( |
| tgpu_init.ts | 263.06 kB ( |
| STATIC_tgpu.ts | 274.28 kB ( |
| STATIC_d.ts | 72.64 kB ( |
| d_memoryLayoutOf.ts | 36.85 kB ( |
| d_arrayOf.ts | 33.95 kB ( |
| d_builtin.ts | 36.48 kB ( |
| d_deepEqual.ts | 23.01 kB ( |
| d_schemasEqualNominally.ts | 23.01 kB ( |
| d_schemasEqualStructurally.ts | 23.01 kB ( |
| d_bool.ts | 20.25 kB ( |
| d_f16.ts | 20.25 kB ( |
| d_f32.ts | 20.25 kB ( |
| d_i32.ts | 20.25 kB ( |
| d_u32.ts | 20.25 kB ( |
| d_ref.ts | 20.26 kB ( |
| d_u16.ts | 20.27 kB ( |
| d_abstractInt.ts | 20.33 kB ( |
| d_abstractFloat.ts | 20.33 kB ( |
| d_textureDepth2d.ts | 20.69 kB ( |
| d_textureDepthCube.ts | 20.70 kB ( |
| d_texture1d.ts | 20.71 kB ( |
| d_texture2d.ts | 20.71 kB ( |
| d_texture3d.ts | 20.71 kB ( |
| d_textureCube.ts | 20.71 kB ( |
| d_textureDepth2dArray.ts | 20.71 kB ( |
| d_textureDepthCubeArray.ts | 20.72 kB ( |
| d_textureDepthMultisampled2d.ts | 20.72 kB ( |
| d_texture2dArray.ts | 20.72 kB ( |
| d_textureCubeArray.ts | 20.73 kB ( |
| d_textureMultisampled2d.ts | 20.73 kB ( |
| std_isKnownAtComptime.ts | 20.87 kB ( |
| std_subgroupElect.ts | 21.44 kB ( |
| std_subgroupAll.ts | 21.45 kB ( |
| std_subgroupAny.ts | 21.45 kB ( |
| std_quadSwapX.ts | 21.45 kB ( |
| std_quadSwapY.ts | 21.45 kB ( |
| std_subgroupOr.ts | 21.45 kB ( |
| std_subgroupAdd.ts | 21.45 kB ( |
| std_subgroupAnd.ts | 21.45 kB ( |
| std_subgroupMax.ts | 21.45 kB ( |
| std_subgroupMin.ts | 21.45 kB ( |
| std_subgroupMul.ts | 21.45 kB ( |
| std_subgroupXor.ts | 21.45 kB ( |
| std_quadSwapDiagonal.ts | 21.46 kB ( |
| std_subgroupExclusiveAdd.ts | 21.47 kB ( |
| std_subgroupExclusiveMul.ts | 21.47 kB ( |
| std_subgroupInclusiveAdd.ts | 21.47 kB ( |
| std_subgroupInclusiveMul.ts | 21.47 kB ( |
| std_subgroupBroadcastFirst.ts | 21.47 kB ( |
| std_storageBarrier.ts | 21.49 kB ( |
| std_textureBarrier.ts | 21.49 kB ( |
| std_workgroupBarrier.ts | 21.50 kB ( |
| std_discard.ts | 21.50 kB ( |
| std_textureNumLayers.ts | 21.52 kB ( |
| std_textureNumLevels.ts | 21.52 kB ( |
| std_textureNumSamples.ts | 21.53 kB ( |
| std_typeOf.ts | 22.25 kB ( |
| std_textureSampleCompare.ts | 21.55 kB ( |
| std_textureSampleCompareLevel.ts | 21.57 kB ( |
| std_textureStore.ts | 21.57 kB ( |
| std_workgroupUniformLoad.ts | 21.59 kB ( |
| tgpu_comptime.ts | 21.60 kB ( |
| std_atomicLoad.ts | 21.63 kB ( |
| std_atomicOr.ts | 21.67 kB ( |
| std_atomicAdd.ts | 21.67 kB ( |
| std_atomicAnd.ts | 21.67 kB ( |
| std_atomicMax.ts | 21.67 kB ( |
| std_atomicMin.ts | 21.67 kB ( |
| std_atomicSub.ts | 21.67 kB ( |
| std_atomicXor.ts | 21.67 kB ( |
| std_atomicExchange.ts | 21.68 kB ( |
| std_atomicStore.ts | 21.71 kB ( |
| std_quadBroadcast.ts | 21.72 kB ( |
| std_arrayLength.ts | 21.72 kB ( |
| std_subgroupShuffleUp.ts | 21.72 kB ( |
| std_subgroupShuffle.ts | 21.72 kB ( |
| std_subgroupShuffleXor.ts | 21.72 kB ( |
| std_subgroupShuffleDown.ts | 21.73 kB ( |
| std_subgroupBroadcast.ts | 21.73 kB ( |
| d_sizeOf.ts | 32.97 kB ( |
| std_copy.ts | 21.75 kB ( |
| d_isContiguous.ts | 32.98 kB ( |
| d_getLongestContiguousPrefix.ts | 32.99 kB ( |
| d_isBuiltin.ts | 33.07 kB ( |
| std_extensionEnabled.ts | 21.82 kB ( |
| std_range.ts | 22.09 kB ( |
| std_isBeingTranspiled.ts | 22.13 kB ( |
| std_getShaderStage.ts | 22.19 kB ( |
| std_getTargetShaderLanguage.ts | 22.20 kB ( |
| d_disarrayOf.ts | 22.31 kB ( |
| d_size.ts | 34.74 kB ( |
| d_align.ts | 34.74 kB ( |
| d_location.ts | 34.74 kB ( |
| d_interpolate.ts | 34.74 kB ( |
| d_invariant.ts | 35.11 kB ( |
| tgpu_vertexLayout.ts | 35.00 kB ( |
| common_writeSoA.ts | 35.59 kB ( |
| std_atomicCompareExchangeWeak.ts | 24.27 kB ( |
| common_fullScreenTriangle.ts | 49.15 kB ( |
| tgpu_fn.ts | 47.40 kB ( |
| std_subgroupBallot.ts | 27.92 kB ( |
| std_textureSampleBaseClampToEdge.ts | 28.00 kB ( |
| std_textureSampleGrad.ts | 28.01 kB ( |
| std_textureSampleBias.ts | 28.07 kB ( |
| d_uint8.ts | 28.21 kB ( |
| d_float16.ts | 28.21 kB ( |
| d_float16x2.ts | 28.21 kB ( |
| d_float16x4.ts | 28.21 kB ( |
| d_float32.ts | 28.21 kB ( |
| d_float32x2.ts | 28.21 kB ( |
| d_float32x3.ts | 28.21 kB ( |
| d_float32x4.ts | 28.21 kB ( |
| d_sint16.ts | 28.21 kB ( |
| d_sint16x2.ts | 28.21 kB ( |
| d_sint16x4.ts | 28.21 kB ( |
| d_sint32.ts | 28.21 kB ( |
| d_sint32x2.ts | 28.21 kB ( |
| d_sint32x3.ts | 28.21 kB ( |
| d_sint32x4.ts | 28.21 kB ( |
| d_sint8.ts | 28.21 kB ( |
| d_sint8x2.ts | 28.21 kB ( |
| d_sint8x4.ts | 28.21 kB ( |
| d_snorm16.ts | 28.21 kB ( |
| d_snorm16x2.ts | 28.21 kB ( |
| d_snorm16x4.ts | 28.21 kB ( |
| d_snorm8.ts | 28.21 kB ( |
| d_snorm8x2.ts | 28.21 kB ( |
| d_snorm8x4.ts | 28.21 kB ( |
| d_uint16.ts | 28.21 kB ( |
| d_uint16x2.ts | 28.21 kB ( |
| d_uint16x4.ts | 28.21 kB ( |
| d_uint32.ts | 28.21 kB ( |
| d_uint32x2.ts | 28.21 kB ( |
| d_uint32x3.ts | 28.21 kB ( |
| d_uint32x4.ts | 28.21 kB ( |
| d_uint8x2.ts | 28.21 kB ( |
| d_uint8x4.ts | 28.21 kB ( |
| d_unorm10_10_10_2.ts | 28.21 kB ( |
| d_unorm16.ts | 28.21 kB ( |
| d_unorm16x2.ts | 28.21 kB ( |
| d_unorm16x4.ts | 28.21 kB ( |
| d_unorm8.ts | 28.21 kB ( |
| d_unorm8x2.ts | 28.21 kB ( |
| d_unorm8x4.ts | 28.21 kB ( |
| d_unorm8x4_bgra.ts | 28.21 kB ( |
| std_textureSample.ts | 28.09 kB ( |
| std_textureSampleLevel.ts | 28.10 kB ( |
| std_textureGatherCompare.ts | 28.13 kB ( |
| std_textureDimensions.ts | 28.16 kB ( |
| d_formatToWGSLType.ts | 28.21 kB ( |
| d_packedFormats.ts | 28.23 kB ( |
| d_isPackedData.ts | 28.28 kB ( |
| std_textureGather.ts | 28.33 kB ( |
| STATIC_common.ts | 56.70 kB ( |
| d_alignmentOf.ts | 30.08 kB ( |
| tgpu_computeFn.ts | 46.50 kB ( |
| std_textureLoad.ts | 29.95 kB ( |
| tgpu_vertexFn.ts | 47.05 kB ( |
| tgpu_fragmentFn.ts | 47.24 kB ( |
| std_bitcast.ts | 30.73 kB ( |
| tgpu_accessor.ts | 68.39 kB ( |
| tgpu_mutableAccessor.ts | 68.40 kB ( |
| std_pack2x16float.ts | 31.74 kB ( |
| std_unpack2x16unorm.ts | 31.74 kB ( |
| std_unpack2x16float.ts | 31.75 kB ( |
| std_pack4xI8.ts | 31.76 kB ( |
| std_unpack4xI8.ts | 31.76 kB ( |
| std_pack4xU8.ts | 31.76 kB ( |
| std_unpack4xU8.ts | 31.76 kB ( |
| std_unpack2x16snorm.ts | 31.76 kB ( |
| std_unpack4x8unorm.ts | 31.78 kB ( |
| std_unpack4x8snorm.ts | 31.83 kB ( |
| std_pack2x16snorm.ts | 31.92 kB ( |
| std_pack2x16unorm.ts | 31.92 kB ( |
| std_pack4xU8Clamp.ts | 31.93 kB ( |
| std_pack4xI8Clamp.ts | 31.94 kB ( |
| std_pack4x8snorm.ts | 32.00 kB ( |
| std_pack4x8unorm.ts | 32.00 kB ( |
| std_identity2.ts | 34.42 kB ( |
| std_identity3.ts | 34.42 kB ( |
| std_identity4.ts | 34.42 kB ( |
| std_rotationX4.ts | 34.42 kB ( |
| std_rotationY4.ts | 34.42 kB ( |
| std_rotationZ4.ts | 34.42 kB ( |
| std_scaling4.ts | 34.42 kB ( |
| std_translation4.ts | 34.42 kB ( |
| d_matToArray.ts | 34.55 kB ( |
| std_dot4I8Packed.ts | 35.80 kB ( |
| std_dot4U8Packed.ts | 35.80 kB ( |
| std_firstLeadingBit.ts | 35.81 kB ( |
| std_determinant.ts | 35.89 kB ( |
| std_dpdxFine.ts | 35.89 kB ( |
| std_dpdyFine.ts | 35.89 kB ( |
| std_dpdxCoarse.ts | 35.90 kB ( |
| std_dpdyCoarse.ts | 35.90 kB ( |
| std_fwidthFine.ts | 35.90 kB ( |
| std_dpdx.ts | 35.90 kB ( |
| std_dpdy.ts | 35.90 kB ( |
| std_fwidthCoarse.ts | 35.90 kB ( |
| std_fwidth.ts | 35.91 kB ( |
| std_refract.ts | 35.91 kB ( |
| std_trunc.ts | 35.96 kB ( |
| std_reverseBits.ts | 35.97 kB ( |
| std_quantizeToF16.ts | 35.97 kB ( |
| std_countOneBits.ts | 35.97 kB ( |
| std_extractBits.ts | 35.98 kB ( |
| std_firstTrailingBit.ts | 35.98 kB ( |
| std_countLeadingZeros.ts | 35.99 kB ( |
| std_countTrailingZeros.ts | 35.99 kB ( |
| std_insertBits.ts | 35.99 kB ( |
| std_faceForward.ts | 35.99 kB ( |
| std_intdiv.ts | 36.00 kB ( |
| std_tan.ts | 36.04 kB ( |
| std_degrees.ts | 36.05 kB ( |
| std_radians.ts | 36.05 kB ( |
| std_inverseSqrt.ts | 36.08 kB ( |
| std_round.ts | 36.09 kB ( |
| std_step.ts | 36.22 kB ( |
| std_ldexp.ts | 36.22 kB ( |
| std_fma.ts | 36.22 kB ( |
| std_transpose.ts | 36.29 kB ( |
| std_not.ts | 36.45 kB ( |
| std_abs.ts | 36.46 kB ( |
| std_gt.ts | 36.83 kB ( |
| std_neg.ts | 36.51 kB ( |
| std_or.ts | 36.52 kB ( |
| std_and.ts | 36.60 kB ( |
| std_lt.ts | 36.60 kB ( |
| std_eq.ts | 36.61 kB ( |
| std_cos.ts | 36.63 kB ( |
| std_exp.ts | 36.63 kB ( |
| std_log.ts | 36.63 kB ( |
| std_sin.ts | 36.63 kB ( |
| std_exp2.ts | 36.63 kB ( |
| std_sign.ts | 36.63 kB ( |
| std_acos.ts | 36.63 kB ( |
| std_asin.ts | 36.63 kB ( |
| std_atan.ts | 36.63 kB ( |
| std_ceil.ts | 36.63 kB ( |
| std_cosh.ts | 36.63 kB ( |
| std_log2.ts | 36.63 kB ( |
| std_sinh.ts | 36.63 kB ( |
| std_sqrt.ts | 36.63 kB ( |
| std_tanh.ts | 36.63 kB ( |
| std_acosh.ts | 36.63 kB ( |
| std_asinh.ts | 36.63 kB ( |
| std_atanh.ts | 36.63 kB ( |
| std_floor.ts | 36.63 kB ( |
| std_fract.ts | 36.64 kB ( |
| std_ge.ts | 36.67 kB ( |
| std_ne.ts | 36.68 kB ( |
| std_le.ts | 36.75 kB ( |
| std_saturate.ts | 36.78 kB ( |
| std_pow.ts | 36.81 kB ( |
| std_atan2.ts | 36.82 kB ( |
| std_mix.ts | 37.18 kB ( |
| std_clamp.ts | 36.91 kB ( |
| std_max.ts | 36.93 kB ( |
| std_min.ts | 36.93 kB ( |
| std_smoothstep.ts | 37.03 kB ( |
| std_select.ts | 37.43 kB ( |
| std_mod.ts | 37.46 kB ( |
| std_div.ts | 37.50 kB ( |
| std_add.ts | 37.58 kB ( |
| std_frexp.ts | 38.54 kB ( |
| std_modf.ts | 38.67 kB ( |
| std_all.ts | 39.78 kB ( |
| std_bitShiftLeft.ts | 39.76 kB ( |
| std_bitShiftRight.ts | 39.77 kB ( |
| std_dot.ts | 40.06 kB ( |
| std_length.ts | 40.16 kB ( |
| std_any.ts | 40.60 kB ( |
| std_cross.ts | 40.27 kB ( |
| std_allEq.ts | 40.81 kB ( |
| tgpu_lazy.ts | 62.91 kB ( |
| tgpu_const.ts | 63.11 kB ( |
| std_isCloseTo.ts | 41.09 kB ( |
| tgpu_workgroupVar.ts | 63.69 kB ( |
| tgpu_privateVar.ts | 63.69 kB ( |
| std_normalize.ts | 41.18 kB ( |
| std_bitcastF32toU32.ts | 41.97 kB ( |
| std_bitcastU32toF32.ts | 41.97 kB ( |
| std_bitcastU32toI32.ts | 41.97 kB ( |
| std_mul.ts | 42.20 kB ( |
| std_rotateZ4.ts | 42.46 kB ( |
| std_translate4.ts | 42.46 kB ( |
| std_scale4.ts | 42.46 kB ( |
| std_rotateX4.ts | 42.46 kB ( |
| std_rotateY4.ts | 42.46 kB ( |
| std_sub.ts | 42.58 kB ( |
| 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.
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]
---
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]
---
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]
|
df2f191 to
f672a15
Compare
f672a15 to
f5e845d
Compare
e533fdf to
04ab465
Compare
04ab465 to
b698240
Compare
b698240 to
452d437
Compare
452d437 to
d3097ce
Compare
a03f69c to
6040443
Compare
6040443 to
33a8617
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Missing boundary checks allow region operations to access neighboring data, and unsupported index-region schemas can cause runtime failures.
6 open issues
Validate accessor-created region byte extents · New Validate explicit write offsets within the region · New Reject vertex and index ranges outside the region · New Reject negative indirect offsets relative to the region · New Validate sparse patch ranges within the region · New Restrict IndexFlag regions to supported index schemas · New
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
There was a problem hiding this comment.
ℹ️ Minor suggestions only — two region boundary contracts worth a look. The core offset plumbing (region
write/patch/clear/copyFrom/readoffsets, bind-group sizing, vertex/index/indirect element→byte math) checks out; comments inline.
Reviewed changes
buffer.region(schema, accessor | { offsetBytes })(core/buffer/bufferRegion.ts) — newTgpuBufferRegionAPI with accessor navigation (fitsElementaccepts 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/readrefactored onto offset-carrying internals; typed arrays accepted as raw bytes;getPatchInstructions/readFromArrayBuffergain a base offset;navigateSchemareports the reached schema and array run. - Region binding (
bufferRegion.tsbufferBindingOf,tgpuBindGroupLayout.ts,init.ts) — regions bind with offset/size and device-limit alignment validation;root.unwrap(region)yields aGPUBufferBinding. - Region as vertex/index/indirect buffer (
drawState.tsrawRegionOf,pipelineUtils.tsresolveIndirect,renderPipeline.ts) — offsets count from the region start. - Supporting types and integration —
BindableBuffer,TgpuMutable/TgpuReadonly/TgpuUniformgenericized over the bound buffer,isBufferRegion, serial restore and exports. - Docs, example, tests — buffer-regions section in
buffers.mdx, newrendering/indirect-cullingexample,tests/bufferRegion.test.ts, and updates totests/buffer.test.ts/tests/serial.test.ts.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
33a8617 to
4ba53e0
Compare
There was a problem hiding this comment.
✅ 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 returnedGPUBufferBindingcarries the region's exactbuffer/offset/size, and that unlikeroot.createBindGroupit 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.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏



Implements the buffer views half of #2816, named
regionshere 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