@woosh/meep-engine 3.9.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -152
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/package.json +3 -2
- package/src/REVIEW_2026_08_06.md +610 -610
- package/src/avif/encode_image_source.d.ts +70 -0
- package/src/avif/encode_image_source.d.ts.map +1 -0
- package/src/avif/encode_image_source.js +117 -0
- package/src/avif/encoder_worker.js +15 -126
- package/src/avif/index.d.ts +4 -2
- package/src/avif/index.js +21 -2
- package/src/avif/native/DECISIONS.md +537 -0
- package/src/avif/native/NOTICE.md +61 -0
- package/src/avif/native/api/AvifDecoder.d.ts +67 -0
- package/src/avif/native/api/AvifDecoder.d.ts.map +1 -0
- package/src/avif/native/api/AvifDecoder.js +121 -0
- package/src/avif/native/api/apply_transformations.d.ts +30 -0
- package/src/avif/native/api/apply_transformations.d.ts.map +1 -0
- package/src/avif/native/api/apply_transformations.js +120 -0
- package/src/avif/native/api/avif_to_sampler2d.d.ts +25 -0
- package/src/avif/native/api/avif_to_sampler2d.d.ts.map +1 -0
- package/src/avif/native/api/avif_to_sampler2d.js +42 -0
- package/src/avif/native/api/convert_to_rgba.d.ts +54 -0
- package/src/avif/native/api/convert_to_rgba.d.ts.map +1 -0
- package/src/avif/native/api/convert_to_rgba.js +204 -0
- package/src/avif/native/api/decode_avif.d.ts +24 -0
- package/src/avif/native/api/decode_avif.d.ts.map +1 -0
- package/src/avif/native/api/decode_avif.js +111 -0
- package/src/avif/native/api/decode_image_item.d.ts +18 -0
- package/src/avif/native/api/decode_image_item.d.ts.map +1 -0
- package/src/avif/native/api/decode_image_item.js +234 -0
- package/src/avif/native/api/encode_avif.d.ts +73 -0
- package/src/avif/native/api/encode_avif.d.ts.map +1 -0
- package/src/avif/native/api/encode_avif.js +488 -0
- package/src/avif/native/api/sampler2d_to_avif.d.ts +22 -0
- package/src/avif/native/api/sampler2d_to_avif.d.ts.map +1 -0
- package/src/avif/native/api/sampler2d_to_avif.js +108 -0
- package/src/avif/native/av1/decode/Av1FrameContext.d.ts +286 -0
- package/src/avif/native/av1/decode/Av1FrameContext.d.ts.map +1 -0
- package/src/avif/native/av1/decode/Av1FrameContext.js +622 -0
- package/src/avif/native/av1/decode/block_decoded.d.ts +27 -0
- package/src/avif/native/av1/decode/block_decoded.d.ts.map +1 -0
- package/src/avif/native/av1/decode/block_decoded.js +59 -0
- package/src/avif/native/av1/decode/decode_av1_still.d.ts +22 -0
- package/src/avif/native/av1/decode/decode_av1_still.d.ts.map +1 -0
- package/src/avif/native/av1/decode/decode_av1_still.js +309 -0
- package/src/avif/native/av1/decode/decode_coefficients.d.ts +20 -0
- package/src/avif/native/av1/decode/decode_coefficients.d.ts.map +1 -0
- package/src/avif/native/av1/decode/decode_coefficients.js +259 -0
- package/src/avif/native/av1/decode/decode_palette.d.ts +28 -0
- package/src/avif/native/av1/decode/decode_palette.d.ts.map +1 -0
- package/src/avif/native/av1/decode/decode_palette.js +442 -0
- package/src/avif/native/av1/decode/decode_tile.d.ts +14 -0
- package/src/avif/native/av1/decode/decode_tile.d.ts.map +1 -0
- package/src/avif/native/av1/decode/decode_tile.js +1213 -0
- package/src/avif/native/av1/decode/get_scan.d.ts +16 -0
- package/src/avif/native/av1/decode/get_scan.d.ts.map +1 -0
- package/src/avif/native/av1/decode/get_scan.js +138 -0
- package/src/avif/native/av1/decode/read_lr.d.ts +35 -0
- package/src/avif/native/av1/decode/read_lr.d.ts.map +1 -0
- package/src/avif/native/av1/decode/read_lr.js +277 -0
- package/src/avif/native/av1/decode/read_transform_type.d.ts +19 -0
- package/src/avif/native/av1/decode/read_transform_type.d.ts.map +1 -0
- package/src/avif/native/av1/decode/read_transform_type.js +92 -0
- package/src/avif/native/av1/decode/reconstruct.d.ts +36 -0
- package/src/avif/native/av1/decode/reconstruct.d.ts.map +1 -0
- package/src/avif/native/av1/decode/reconstruct.js +241 -0
- package/src/avif/native/av1/decode/transform_type.d.ts +49 -0
- package/src/avif/native/av1/decode/transform_type.d.ts.map +1 -0
- package/src/avif/native/av1/decode/transform_type.js +137 -0
- package/src/avif/native/av1/encode/Av1BlockSnapshot.d.ts +81 -0
- package/src/avif/native/av1/encode/Av1BlockSnapshot.d.ts.map +1 -0
- package/src/avif/native/av1/encode/Av1BlockSnapshot.js +299 -0
- package/src/avif/native/av1/encode/Av1EncodeContext.d.ts +384 -0
- package/src/avif/native/av1/encode/Av1EncodeContext.d.ts.map +1 -0
- package/src/avif/native/av1/encode/Av1EncodeContext.js +590 -0
- package/src/avif/native/av1/encode/build_headers.d.ts +50 -0
- package/src/avif/native/av1/encode/build_headers.d.ts.map +1 -0
- package/src/avif/native/av1/encode/build_headers.js +359 -0
- package/src/avif/native/av1/encode/choose_chroma_alpha.d.ts +26 -0
- package/src/avif/native/av1/encode/choose_chroma_alpha.d.ts.map +1 -0
- package/src/avif/native/av1/encode/choose_chroma_alpha.js +90 -0
- package/src/avif/native/av1/encode/choose_filters.d.ts +21 -0
- package/src/avif/native/av1/encode/choose_filters.d.ts.map +1 -0
- package/src/avif/native/av1/encode/choose_filters.js +318 -0
- package/src/avif/native/av1/encode/choose_restoration.d.ts +35 -0
- package/src/avif/native/av1/encode/choose_restoration.d.ts.map +1 -0
- package/src/avif/native/av1/encode/choose_restoration.js +616 -0
- package/src/avif/native/av1/encode/decode_effort.d.ts +57 -0
- package/src/avif/native/av1/encode/decode_effort.d.ts.map +1 -0
- package/src/avif/native/av1/encode/decode_effort.js +59 -0
- package/src/avif/native/av1/encode/encode_av1_still.d.ts +17 -0
- package/src/avif/native/av1/encode/encode_av1_still.d.ts.map +1 -0
- package/src/avif/native/av1/encode/encode_av1_still.js +194 -0
- package/src/avif/native/av1/encode/encode_effort.d.ts +56 -0
- package/src/avif/native/av1/encode/encode_effort.d.ts.map +1 -0
- package/src/avif/native/av1/encode/encode_effort.js +97 -0
- package/src/avif/native/av1/encode/encode_tile.d.ts +26 -0
- package/src/avif/native/av1/encode/encode_tile.d.ts.map +1 -0
- package/src/avif/native/av1/encode/encode_tile.js +2331 -0
- package/src/avif/native/av1/encode/quantise.d.ts +51 -0
- package/src/avif/native/av1/encode/quantise.d.ts.map +1 -0
- package/src/avif/native/av1/encode/quantise.js +212 -0
- package/src/avif/native/av1/encode/write_coefficients.d.ts +42 -0
- package/src/avif/native/av1/encode/write_coefficients.d.ts.map +1 -0
- package/src/avif/native/av1/encode/write_coefficients.js +367 -0
- package/src/avif/native/av1/encode/write_lr.d.ts +33 -0
- package/src/avif/native/av1/encode/write_lr.d.ts.map +1 -0
- package/src/avif/native/av1/encode/write_lr.js +174 -0
- package/src/avif/native/av1/encode/write_transform_type.d.ts +21 -0
- package/src/avif/native/av1/encode/write_transform_type.d.ts.map +1 -0
- package/src/avif/native/av1/encode/write_transform_type.js +70 -0
- package/src/avif/native/av1/entropy/CdfContext.d.ts +167 -0
- package/src/avif/native/av1/entropy/CdfContext.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/CdfContext.js +433 -0
- package/src/avif/native/av1/entropy/SymbolReader.d.ts +103 -0
- package/src/avif/native/av1/entropy/SymbolReader.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/SymbolReader.js +317 -0
- package/src/avif/native/av1/entropy/SymbolWriter.d.ts +107 -0
- package/src/avif/native/av1/entropy/SymbolWriter.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/SymbolWriter.js +352 -0
- package/src/avif/native/av1/entropy/coefficient_context.d.ts +71 -0
- package/src/avif/native/av1/entropy/coefficient_context.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/coefficient_context.js +325 -0
- package/src/avif/native/av1/entropy/partition_cdf.d.ts +54 -0
- package/src/avif/native/av1/entropy/partition_cdf.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/partition_cdf.js +98 -0
- package/src/avif/native/av1/entropy/symbol_cost.d.ts +37 -0
- package/src/avif/native/av1/entropy/symbol_cost.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/symbol_cost.js +76 -0
- package/src/avif/native/av1/filter/cdef.d.ts +15 -0
- package/src/avif/native/av1/filter/cdef.d.ts.map +1 -0
- package/src/avif/native/av1/filter/cdef.js +313 -0
- package/src/avif/native/av1/filter/loop_filter.d.ts +14 -0
- package/src/avif/native/av1/filter/loop_filter.d.ts.map +1 -0
- package/src/avif/native/av1/filter/loop_filter.js +377 -0
- package/src/avif/native/av1/filter/loop_restoration.d.ts +42 -0
- package/src/avif/native/av1/filter/loop_restoration.d.ts.map +1 -0
- package/src/avif/native/av1/filter/loop_restoration.js +451 -0
- package/src/avif/native/av1/filter/superres.d.ts +18 -0
- package/src/avif/native/av1/filter/superres.d.ts.map +1 -0
- package/src/avif/native/av1/filter/superres.js +86 -0
- package/src/avif/native/av1/grain/FilmGrainState.d.ts +62 -0
- package/src/avif/native/av1/grain/FilmGrainState.d.ts.map +1 -0
- package/src/avif/native/av1/grain/FilmGrainState.js +87 -0
- package/src/avif/native/av1/grain/film_grain.d.ts +16 -0
- package/src/avif/native/av1/grain/film_grain.d.ts.map +1 -0
- package/src/avif/native/av1/grain/film_grain.js +623 -0
- package/src/avif/native/av1/obu/FrameHeader.d.ts +248 -0
- package/src/avif/native/av1/obu/FrameHeader.d.ts.map +1 -0
- package/src/avif/native/av1/obu/FrameHeader.js +381 -0
- package/src/avif/native/av1/obu/ObuHeader.d.ts +53 -0
- package/src/avif/native/av1/obu/ObuHeader.d.ts.map +1 -0
- package/src/avif/native/av1/obu/ObuHeader.js +62 -0
- package/src/avif/native/av1/obu/SequenceHeader.d.ts +157 -0
- package/src/avif/native/av1/obu/SequenceHeader.d.ts.map +1 -0
- package/src/avif/native/av1/obu/SequenceHeader.js +225 -0
- package/src/avif/native/av1/obu/for_each_obu.d.ts +24 -0
- package/src/avif/native/av1/obu/for_each_obu.d.ts.map +1 -0
- package/src/avif/native/av1/obu/for_each_obu.js +50 -0
- package/src/avif/native/av1/obu/parse_frame_header.d.ts +18 -0
- package/src/avif/native/av1/obu/parse_frame_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/parse_frame_header.js +841 -0
- package/src/avif/native/av1/obu/parse_obu_header.d.ts +23 -0
- package/src/avif/native/av1/obu/parse_obu_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/parse_obu_header.js +69 -0
- package/src/avif/native/av1/obu/parse_sequence_header.d.ts +17 -0
- package/src/avif/native/av1/obu/parse_sequence_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/parse_sequence_header.js +263 -0
- package/src/avif/native/av1/obu/write_frame_header.d.ts +16 -0
- package/src/avif/native/av1/obu/write_frame_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/write_frame_header.js +579 -0
- package/src/avif/native/av1/obu/write_sequence_header.d.ts +17 -0
- package/src/avif/native/av1/obu/write_sequence_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/write_sequence_header.js +189 -0
- package/src/avif/native/av1/predict/IntraPredictionState.d.ts +49 -0
- package/src/avif/native/av1/predict/IntraPredictionState.d.ts.map +1 -0
- package/src/avif/native/av1/predict/IntraPredictionState.js +58 -0
- package/src/avif/native/av1/predict/intra_filter_type.d.ts +17 -0
- package/src/avif/native/av1/predict/intra_filter_type.d.ts.map +1 -0
- package/src/avif/native/av1/predict/intra_filter_type.js +79 -0
- package/src/avif/native/av1/predict/predict_chroma_from_luma.d.ts +50 -0
- package/src/avif/native/av1/predict/predict_chroma_from_luma.d.ts.map +1 -0
- package/src/avif/native/av1/predict/predict_chroma_from_luma.js +153 -0
- package/src/avif/native/av1/predict/predict_intra.d.ts +42 -0
- package/src/avif/native/av1/predict/predict_intra.d.ts.map +1 -0
- package/src/avif/native/av1/predict/predict_intra.js +803 -0
- package/src/avif/native/av1/predict/predict_palette.d.ts +23 -0
- package/src/avif/native/av1/predict/predict_palette.d.ts.map +1 -0
- package/src/avif/native/av1/predict/predict_palette.js +36 -0
- package/src/avif/native/av1/tables/av1_symbols.d.ts +411 -0
- package/src/avif/native/av1/tables/av1_symbols.d.ts.map +1 -0
- package/src/avif/native/av1/tables/av1_symbols.js +419 -0
- package/src/avif/native/av1/tables/block_tables.d.ts +181 -0
- package/src/avif/native/av1/tables/block_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/block_tables.js +270 -0
- package/src/avif/native/av1/tables/cdf_tables.d.ts +961 -0
- package/src/avif/native/av1/tables/cdf_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/cdf_tables.js +1893 -0
- package/src/avif/native/av1/tables/coefficient_tables.d.ts +41 -0
- package/src/avif/native/av1/tables/coefficient_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/coefficient_tables.js +82 -0
- package/src/avif/native/av1/tables/derived_block_tables.d.ts +15 -0
- package/src/avif/native/av1/tables/derived_block_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/derived_block_tables.js +23 -0
- package/src/avif/native/av1/tables/filter_tables.d.ts +171 -0
- package/src/avif/native/av1/tables/filter_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/filter_tables.js +313 -0
- package/src/avif/native/av1/tables/grain_tables.d.ts +11 -0
- package/src/avif/native/av1/tables/grain_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/grain_tables.js +190 -0
- package/src/avif/native/av1/tables/prediction_tables.d.ts +141 -0
- package/src/avif/native/av1/tables/prediction_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/prediction_tables.js +223 -0
- package/src/avif/native/av1/tables/quantizer_matrix_tables.d.ts +21 -0
- package/src/avif/native/av1/tables/quantizer_matrix_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/quantizer_matrix_tables.js +38 -0
- package/src/avif/native/av1/tables/quantizer_tables.d.ts +21 -0
- package/src/avif/native/av1/tables/quantizer_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/quantizer_tables.js +160 -0
- package/src/avif/native/av1/tables/scan_tables.d.ts +321 -0
- package/src/avif/native/av1/tables/scan_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/scan_tables.js +727 -0
- package/src/avif/native/av1/tables/segmentation_tables.d.ts +31 -0
- package/src/avif/native/av1/tables/segmentation_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/segmentation_tables.js +48 -0
- package/src/avif/native/av1/tables/transform_tables.d.ts +91 -0
- package/src/avif/native/av1/tables/transform_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/transform_tables.js +140 -0
- package/src/avif/native/av1/tables/unpack_table.d.ts +33 -0
- package/src/avif/native/av1/tables/unpack_table.d.ts.map +1 -0
- package/src/avif/native/av1/tables/unpack_table.js +73 -0
- package/src/avif/native/av1/transform/forward_transform_2d.d.ts +61 -0
- package/src/avif/native/av1/transform/forward_transform_2d.d.ts.map +1 -0
- package/src/avif/native/av1/transform/forward_transform_2d.js +574 -0
- package/src/avif/native/av1/transform/inverse_transform_1d.d.ts +76 -0
- package/src/avif/native/av1/transform/inverse_transform_1d.d.ts.map +1 -0
- package/src/avif/native/av1/transform/inverse_transform_1d.js +590 -0
- package/src/avif/native/av1/transform/inverse_transform_2d.d.ts +46 -0
- package/src/avif/native/av1/transform/inverse_transform_2d.d.ts.map +1 -0
- package/src/avif/native/av1/transform/inverse_transform_2d.js +180 -0
- package/src/avif/native/av1/util/ceil_log2.d.ts +13 -0
- package/src/avif/native/av1/util/ceil_log2.d.ts.map +1 -0
- package/src/avif/native/av1/util/ceil_log2.js +18 -0
- package/src/avif/native/av1/util/floor_log2.d.ts +20 -0
- package/src/avif/native/av1/util/floor_log2.d.ts.map +1 -0
- package/src/avif/native/av1/util/floor_log2.js +20 -0
- package/src/avif/native/av1/util/round2.d.ts +22 -0
- package/src/avif/native/av1/util/round2.d.ts.map +1 -0
- package/src/avif/native/av1/util/round2.js +27 -0
- package/src/avif/native/av1/util/round2_signed.d.ts +14 -0
- package/src/avif/native/av1/util/round2_signed.d.ts.map +1 -0
- package/src/avif/native/av1/util/round2_signed.js +17 -0
- package/src/avif/native/av1/util/tile_log2.d.ts +16 -0
- package/src/avif/native/av1/util/tile_log2.d.ts.map +1 -0
- package/src/avif/native/av1/util/tile_log2.js +23 -0
- package/src/avif/native/bitstream/BitReader.d.ts +174 -0
- package/src/avif/native/bitstream/BitReader.d.ts.map +1 -0
- package/src/avif/native/bitstream/BitReader.js +391 -0
- package/src/avif/native/bitstream/BitWriter.d.ts +122 -0
- package/src/avif/native/bitstream/BitWriter.d.ts.map +1 -0
- package/src/avif/native/bitstream/BitWriter.js +351 -0
- package/src/avif/native/color/ColourTransform.d.ts +62 -0
- package/src/avif/native/color/ColourTransform.d.ts.map +1 -0
- package/src/avif/native/color/ColourTransform.js +189 -0
- package/src/avif/native/color/YuvImage.d.ts +51 -0
- package/src/avif/native/color/YuvImage.d.ts.map +1 -0
- package/src/avif/native/color/YuvImage.js +66 -0
- package/src/avif/native/color/clamp_sample.d.ts +18 -0
- package/src/avif/native/color/clamp_sample.d.ts.map +1 -0
- package/src/avif/native/color/clamp_sample.js +25 -0
- package/src/avif/native/color/linear_to_transfer.d.ts +24 -0
- package/src/avif/native/color/linear_to_transfer.d.ts.map +1 -0
- package/src/avif/native/color/linear_to_transfer.js +126 -0
- package/src/avif/native/color/primaries.d.ts +20 -0
- package/src/avif/native/color/primaries.d.ts.map +1 -0
- package/src/avif/native/color/primaries.js +94 -0
- package/src/avif/native/color/rgb_row_to_ycbcr.d.ts +20 -0
- package/src/avif/native/color/rgb_row_to_ycbcr.d.ts.map +1 -0
- package/src/avif/native/color/rgb_row_to_ycbcr.js +78 -0
- package/src/avif/native/color/transfer_to_linear.d.ts +49 -0
- package/src/avif/native/color/transfer_to_linear.d.ts.map +1 -0
- package/src/avif/native/color/transfer_to_linear.js +171 -0
- package/src/avif/native/color/upsample_chroma_row.d.ts +35 -0
- package/src/avif/native/color/upsample_chroma_row.d.ts.map +1 -0
- package/src/avif/native/color/upsample_chroma_row.js +89 -0
- package/src/avif/native/color/ycbcr_row_to_rgb.d.ts +23 -0
- package/src/avif/native/color/ycbcr_row_to_rgb.d.ts.map +1 -0
- package/src/avif/native/color/ycbcr_row_to_rgb.js +78 -0
- package/src/avif/native/heif/AvifFile.d.ts +112 -0
- package/src/avif/native/heif/AvifFile.d.ts.map +1 -0
- package/src/avif/native/heif/AvifFile.js +142 -0
- package/src/avif/native/heif/ItemProperty.d.ts +244 -0
- package/src/avif/native/heif/ItemProperty.d.ts.map +1 -0
- package/src/avif/native/heif/ItemProperty.js +321 -0
- package/src/avif/native/heif/find_item_property.d.ts +17 -0
- package/src/avif/native/heif/find_item_property.d.ts.map +1 -0
- package/src/avif/native/heif/find_item_property.js +28 -0
- package/src/avif/native/heif/find_item_references.d.ts +16 -0
- package/src/avif/native/heif/find_item_references.d.ts.map +1 -0
- package/src/avif/native/heif/find_item_references.js +29 -0
- package/src/avif/native/heif/find_items_referencing.d.ts +17 -0
- package/src/avif/native/heif/find_items_referencing.d.ts.map +1 -0
- package/src/avif/native/heif/find_items_referencing.js +36 -0
- package/src/avif/native/heif/parse_avif_file.d.ts +15 -0
- package/src/avif/native/heif/parse_avif_file.d.ts.map +1 -0
- package/src/avif/native/heif/parse_avif_file.js +383 -0
- package/src/avif/native/heif/parse_image_grid.d.ts +18 -0
- package/src/avif/native/heif/parse_image_grid.d.ts.map +1 -0
- package/src/avif/native/heif/parse_image_grid.js +48 -0
- package/src/avif/native/heif/parse_item_property.d.ts +18 -0
- package/src/avif/native/heif/parse_item_property.d.ts.map +1 -0
- package/src/avif/native/heif/parse_item_property.js +243 -0
- package/src/avif/native/heif/read_item_data.d.ts +22 -0
- package/src/avif/native/heif/read_item_data.d.ts.map +1 -0
- package/src/avif/native/heif/read_item_data.js +97 -0
- package/src/avif/native/heif/write_avif_file.d.ts +50 -0
- package/src/avif/native/heif/write_avif_file.d.ts.map +1 -0
- package/src/avif/native/heif/write_avif_file.js +348 -0
- package/src/avif/native/heif/write_item_property.d.ts +16 -0
- package/src/avif/native/heif/write_item_property.d.ts.map +1 -0
- package/src/avif/native/heif/write_item_property.js +182 -0
- package/src/avif/native/index.d.ts +14 -0
- package/src/avif/native/index.d.ts.map +1 -0
- package/src/avif/native/index.js +56 -0
- package/src/avif/native/isobmff/BoxHeader.d.ts +50 -0
- package/src/avif/native/isobmff/BoxHeader.d.ts.map +1 -0
- package/src/avif/native/isobmff/BoxHeader.js +57 -0
- package/src/avif/native/isobmff/BoxWriter.d.ts +118 -0
- package/src/avif/native/isobmff/BoxWriter.d.ts.map +1 -0
- package/src/avif/native/isobmff/BoxWriter.js +264 -0
- package/src/avif/native/isobmff/ByteCursor.d.ts +125 -0
- package/src/avif/native/isobmff/ByteCursor.d.ts.map +1 -0
- package/src/avif/native/isobmff/ByteCursor.js +298 -0
- package/src/avif/native/isobmff/for_each_box.d.ts +23 -0
- package/src/avif/native/isobmff/for_each_box.d.ts.map +1 -0
- package/src/avif/native/isobmff/for_each_box.js +39 -0
- package/src/avif/native/isobmff/read_box_header.d.ts +22 -0
- package/src/avif/native/isobmff/read_box_header.d.ts.map +1 -0
- package/src/avif/native/isobmff/read_box_header.js +59 -0
- package/src/avif/native/isobmff/read_full_box_header.d.ts +26 -0
- package/src/avif/native/isobmff/read_full_box_header.d.ts.map +1 -0
- package/src/avif/native/isobmff/read_full_box_header.js +33 -0
- package/src/avif/threaded_image_encoder.d.ts +7 -2
- package/src/avif/threaded_image_encoder.d.ts.map +1 -1
- package/src/avif/threaded_image_encoder.js +107 -21
- package/src/core/binary/BinaryBuffer.d.ts +40 -0
- package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
- package/src/core/binary/BinaryBuffer.js +100 -0
- package/src/core/binary/hash/crc32.d.ts +16 -0
- package/src/core/binary/hash/crc32.d.ts.map +1 -0
- package/src/core/binary/hash/crc32.js +96 -0
- package/src/core/binary/utf8/utf8_decode.d.ts +21 -0
- package/src/core/binary/utf8/utf8_decode.d.ts.map +1 -0
- package/src/core/binary/utf8/utf8_decode.js +43 -0
- package/src/core/binary/utf8/utf8_encode_into.d.ts +20 -0
- package/src/core/binary/utf8/utf8_encode_into.d.ts.map +1 -0
- package/src/core/binary/utf8/utf8_encode_into.js +48 -0
- package/src/core/binary/utf8/utf8_encoded_length.d.ts +14 -0
- package/src/core/binary/utf8/utf8_encoded_length.d.ts.map +1 -0
- package/src/core/binary/utf8/utf8_encoded_length.js +36 -0
- package/src/core/color/COLOR_FIX_PLAN_2026_08_28.md +417 -0
- package/src/core/color/COLOR_REVIEW_2026_08_28.md +779 -0
- package/src/core/color/Color.d.ts +128 -20
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +959 -866
- package/src/core/color/PQ/PQ_constants.d.ts +10 -0
- package/src/core/color/PQ/PQ_constants.d.ts.map +1 -1
- package/src/core/color/PQ/PQ_constants.js +10 -0
- package/src/core/color/PQ/linear_to_PQ.d.ts.map +1 -1
- package/src/core/color/PQ/linear_to_PQ.js +6 -0
- package/src/core/color/REC709_PRIMARIES.d.ts +50 -0
- package/src/core/color/REC709_PRIMARIES.d.ts.map +1 -0
- package/src/core/color/REC709_PRIMARIES.js +53 -0
- package/src/core/color/construct/color_from_hex.d.ts +21 -0
- package/src/core/color/construct/color_from_hex.d.ts.map +1 -0
- package/src/core/color/construct/color_from_hex.js +33 -0
- package/src/core/color/construct/color_from_temperature.d.ts +22 -0
- package/src/core/color/construct/color_from_temperature.d.ts.map +1 -0
- package/src/core/color/construct/color_from_temperature.js +33 -0
- package/src/core/color/construct/color_from_uint24.d.ts +19 -0
- package/src/core/color/construct/color_from_uint24.d.ts.map +1 -0
- package/src/core/color/construct/color_from_uint24.js +26 -0
- package/src/core/color/construct/color_from_uint32.d.ts +20 -0
- package/src/core/color/construct/color_from_uint32.d.ts.map +1 -0
- package/src/core/color/construct/color_from_uint32.js +39 -0
- package/src/core/color/construct/color_gray.d.ts +17 -0
- package/src/core/color/construct/color_gray.d.ts.map +1 -0
- package/src/core/color/construct/color_gray.js +22 -0
- package/src/core/color/hex/hex2rgb.d.ts +1 -11
- package/src/core/color/hex/hex2rgb.d.ts.map +1 -1
- package/src/core/color/hex/hex2rgb.js +7 -24
- package/src/core/color/hex/hex_to_rgb.d.ts +18 -0
- package/src/core/color/hex/hex_to_rgb.d.ts.map +1 -0
- package/src/core/color/hex/hex_to_rgb.js +62 -0
- package/src/core/color/hex/rgb2hex.d.ts +1 -8
- package/src/core/color/hex/rgb2hex.d.ts.map +1 -1
- package/src/core/color/hex/rgb2hex.js +7 -13
- package/src/core/color/hex/rgb_to_hex.d.ts +9 -0
- package/src/core/color/hex/rgb_to_hex.d.ts.map +1 -0
- package/src/core/color/hex/rgb_to_hex.js +13 -0
- package/src/core/color/hex/rgba_to_hex.d.ts +19 -0
- package/src/core/color/hex/rgba_to_hex.d.ts.map +1 -0
- package/src/core/color/hex/rgba_to_hex.js +23 -0
- package/src/core/color/hsv/hsv2rgb.d.ts +1 -12
- package/src/core/color/hsv/hsv2rgb.d.ts.map +1 -1
- package/src/core/color/hsv/hsv2rgb.js +8 -21
- package/src/core/color/hsv/hsv2rgb_float.d.ts +1 -12
- package/src/core/color/hsv/hsv2rgb_float.d.ts.map +1 -1
- package/src/core/color/hsv/hsv2rgb_float.js +8 -56
- package/src/core/color/hsv/hsv_to_rgb.d.ts +13 -0
- package/src/core/color/hsv/hsv_to_rgb.d.ts.map +1 -0
- package/src/core/color/hsv/hsv_to_rgb.js +39 -0
- package/src/core/color/hsv/hsv_to_rgb_uint8.d.ts +13 -0
- package/src/core/color/hsv/hsv_to_rgb_uint8.d.ts.map +1 -0
- package/src/core/color/hsv/hsv_to_rgb_uint8.js +21 -0
- package/src/core/color/hsv/hue_to_rgb_sextant.d.ts +24 -0
- package/src/core/color/hsv/hue_to_rgb_sextant.d.ts.map +1 -0
- package/src/core/color/hsv/hue_to_rgb_sextant.js +67 -0
- package/src/core/color/hsv/rgb2hsv.d.ts +1 -12
- package/src/core/color/hsv/rgb2hsv.d.ts.map +1 -1
- package/src/core/color/hsv/rgb2hsv.js +7 -42
- package/src/core/color/hsv/rgb_to_hsv.d.ts +13 -0
- package/src/core/color/hsv/rgb_to_hsv.d.ts.map +1 -0
- package/src/core/color/hsv/rgb_to_hsv.js +42 -0
- package/src/core/color/hunt/hpe_to_xyz.d.ts +2 -0
- package/src/core/color/hunt/hpe_to_xyz.d.ts.map +1 -0
- package/src/core/color/hunt/hpe_to_xyz.js +4 -0
- package/src/core/color/hunt/xyz_to_hpe.d.ts +1 -6
- package/src/core/color/hunt/xyz_to_hpe.d.ts.map +1 -1
- package/src/core/color/hunt/xyz_to_hpe.js +12 -15
- package/src/core/color/illuminant/D65_spd_tabulated.d.ts.map +1 -1
- package/src/core/color/illuminant/D65_spd_tabulated.js +107 -104
- package/src/core/color/int2rgb.d.ts +1 -10
- package/src/core/color/int2rgb.d.ts.map +1 -1
- package/src/core/color/int2rgb.js +7 -12
- package/src/core/color/int_to_rgb.d.ts +21 -0
- package/src/core/color/int_to_rgb.d.ts.map +1 -0
- package/src/core/color/int_to_rgb.js +33 -0
- package/src/core/color/kelvin/kelvin_to_rgb.d.ts.map +1 -1
- package/src/core/color/kelvin/kelvin_to_rgb.js +22 -2
- package/src/core/color/kelvin/rgb_to_kelvin.d.ts +22 -2
- package/src/core/color/kelvin/rgb_to_kelvin.d.ts.map +1 -1
- package/src/core/color/kelvin/rgb_to_kelvin.js +22 -2
- package/src/core/color/lab/lab_to_xyz.d.ts +20 -0
- package/src/core/color/lab/lab_to_xyz.d.ts.map +1 -0
- package/src/core/color/lab/lab_to_xyz.js +69 -0
- package/src/core/color/oklab/gamut_clip_adaptive_l0.d.ts +34 -0
- package/src/core/color/oklab/gamut_clip_adaptive_l0.d.ts.map +1 -0
- package/src/core/color/oklab/gamut_clip_adaptive_l0.js +46 -0
- package/src/core/color/oklab/gamut_clip_at_l0.d.ts +33 -0
- package/src/core/color/oklab/gamut_clip_at_l0.d.ts.map +1 -0
- package/src/core/color/oklab/gamut_clip_at_l0.js +84 -0
- package/src/core/color/oklab/gamut_clip_preserve_chroma.d.ts +24 -0
- package/src/core/color/oklab/gamut_clip_preserve_chroma.d.ts.map +1 -0
- package/src/core/color/oklab/gamut_clip_preserve_chroma.js +37 -0
- package/src/core/color/oklab/gamut_clip_project_to_lcusp.d.ts +23 -0
- package/src/core/color/oklab/gamut_clip_project_to_lcusp.d.ts.map +1 -0
- package/src/core/color/oklab/gamut_clip_project_to_lcusp.js +46 -0
- package/src/core/color/oklab/linear_srgb_to_okhsl.d.ts +19 -0
- package/src/core/color/oklab/linear_srgb_to_okhsl.d.ts.map +1 -0
- package/src/core/color/oklab/linear_srgb_to_okhsl.js +93 -0
- package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts +12 -4
- package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts.map +1 -1
- package/src/core/color/oklab/linear_srgb_to_okhsv.js +108 -84
- package/src/core/color/oklab/linear_srgb_to_oklab.d.ts +13 -4
- package/src/core/color/oklab/linear_srgb_to_oklab.d.ts.map +1 -1
- package/src/core/color/oklab/linear_srgb_to_oklab.js +28 -19
- package/src/core/color/oklab/okhsl_chroma_bounds.d.ts +51 -0
- package/src/core/color/oklab/okhsl_chroma_bounds.d.ts.map +1 -0
- package/src/core/color/oklab/okhsl_chroma_bounds.js +128 -0
- package/src/core/color/oklab/okhsl_to_linear_srgb.d.ts +19 -0
- package/src/core/color/oklab/okhsl_to_linear_srgb.d.ts.map +1 -0
- package/src/core/color/oklab/okhsl_to_linear_srgb.js +85 -0
- package/src/core/color/oklab/oklab_to_oklch.d.ts +24 -0
- package/src/core/color/oklab/oklab_to_oklch.d.ts.map +1 -0
- package/src/core/color/oklab/oklab_to_oklch.js +35 -0
- package/src/core/color/oklab/oklch_to_oklab.d.ts +18 -0
- package/src/core/color/oklab/oklch_to_oklab.d.ts.map +1 -0
- package/src/core/color/oklab/oklch_to_oklab.js +26 -0
- package/src/core/color/oklab/toe.d.ts +12 -0
- package/src/core/color/oklab/toe.d.ts.map +1 -1
- package/src/core/color/oklab/toe.js +34 -22
- package/src/core/color/operations/color_add.d.ts +21 -0
- package/src/core/color/operations/color_add.d.ts.map +1 -0
- package/src/core/color/operations/color_add.js +23 -0
- package/src/core/color/operations/color_add_scaled.d.ts +20 -0
- package/src/core/color/operations/color_add_scaled.d.ts.map +1 -0
- package/src/core/color/operations/color_add_scaled.js +30 -0
- package/src/core/color/operations/color_clamp.d.ts +22 -0
- package/src/core/color/operations/color_clamp.d.ts.map +1 -0
- package/src/core/color/operations/color_clamp.js +25 -0
- package/src/core/color/operations/color_darken.d.ts +2 -1
- package/src/core/color/operations/color_darken.d.ts.map +1 -1
- package/src/core/color/operations/color_darken.js +25 -24
- package/src/core/color/operations/color_desaturate.d.ts +2 -1
- package/src/core/color/operations/color_desaturate.d.ts.map +1 -1
- package/src/core/color/operations/color_desaturate.js +25 -24
- package/src/core/color/operations/color_get_hsl.d.ts +18 -0
- package/src/core/color/operations/color_get_hsl.d.ts.map +1 -0
- package/src/core/color/operations/color_get_hsl.js +60 -0
- package/src/core/color/operations/color_is_in_gamut.d.ts +20 -0
- package/src/core/color/operations/color_is_in_gamut.d.ts.map +1 -0
- package/src/core/color/operations/color_is_in_gamut.js +30 -0
- package/src/core/color/operations/color_lerp.d.ts +12 -3
- package/src/core/color/operations/color_lerp.d.ts.map +1 -1
- package/src/core/color/operations/color_lerp.js +55 -46
- package/src/core/color/operations/color_lighten.d.ts +9 -5
- package/src/core/color/operations/color_lighten.d.ts.map +1 -1
- package/src/core/color/operations/color_lighten.js +29 -24
- package/src/core/color/operations/color_mix_okhsv_channel.d.ts +24 -0
- package/src/core/color/operations/color_mix_okhsv_channel.d.ts.map +1 -0
- package/src/core/color/operations/color_mix_okhsv_channel.js +48 -0
- package/src/core/color/operations/color_multiply_rgb.d.ts +21 -0
- package/src/core/color/operations/color_multiply_rgb.d.ts.map +1 -0
- package/src/core/color/operations/color_multiply_rgb.js +26 -0
- package/src/core/color/operations/color_saturate.d.ts +9 -5
- package/src/core/color/operations/color_saturate.d.ts.map +1 -1
- package/src/core/color/operations/color_saturate.js +29 -24
- package/src/core/color/operations/color_scale_okhsv_channel.d.ts +1 -1
- package/src/core/color/operations/color_scale_okhsv_channel.d.ts.map +1 -1
- package/src/core/color/operations/color_scale_okhsv_channel.js +58 -45
- package/src/core/color/operations/color_srgb_apply.d.ts +28 -0
- package/src/core/color/operations/color_srgb_apply.d.ts.map +1 -0
- package/src/core/color/operations/color_srgb_apply.js +40 -0
- package/src/core/color/operations/color_sub.d.ts +16 -0
- package/src/core/color/operations/color_sub.d.ts.map +1 -0
- package/src/core/color/operations/color_sub.js +18 -0
- package/src/core/color/parse_color.d.ts +10 -1
- package/src/core/color/parse_color.d.ts.map +1 -1
- package/src/core/color/parse_color.js +100 -84
- package/src/core/color/parse_color_normalized.d.ts +24 -0
- package/src/core/color/parse_color_normalized.d.ts.map +1 -0
- package/src/core/color/parse_color_normalized.js +38 -0
- package/src/core/color/rgb2uint24.d.ts +1 -8
- package/src/core/color/rgb2uint24.d.ts.map +1 -1
- package/src/core/color/rgb2uint24.js +7 -20
- package/src/core/color/rgb2uint32.d.ts +1 -9
- package/src/core/color/rgb2uint32.d.ts.map +1 -1
- package/src/core/color/rgb2uint32.js +7 -18
- package/src/core/color/rgb_to_luminance.d.ts +14 -5
- package/src/core/color/rgb_to_luminance.d.ts.map +1 -1
- package/src/core/color/rgb_to_luminance.js +24 -13
- package/src/core/color/rgb_to_uint24.d.ts +9 -0
- package/src/core/color/rgb_to_uint24.d.ts.map +1 -0
- package/src/core/color/rgb_to_uint24.js +20 -0
- package/src/core/color/rgb_to_uint32.d.ts +10 -0
- package/src/core/color/rgb_to_uint32.d.ts.map +1 -0
- package/src/core/color/rgb_to_uint32.js +21 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts +7 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
- package/src/core/color/sRGB/linear_to_sRGB.js +39 -32
- package/src/core/color/xyz/hpe_to_xyz.d.ts +24 -0
- package/src/core/color/xyz/hpe_to_xyz.d.ts.map +1 -0
- package/src/core/color/xyz/hpe_to_xyz.js +39 -0
- package/src/core/color/xyz/rgb_to_xyz.d.ts +17 -2
- package/src/core/color/xyz/rgb_to_xyz.d.ts.map +1 -1
- package/src/core/color/xyz/rgb_to_xyz.js +44 -18
- package/src/core/color/xyz/xyz_cmf_tabulated.d.ts.map +1 -1
- package/src/core/color/xyz/xyz_cmf_tabulated.js +217 -211
- package/src/core/color/xyz/xyz_cmf_wyman.d.ts +4 -0
- package/src/core/color/xyz/xyz_cmf_wyman.d.ts.map +1 -1
- package/src/core/color/xyz/xyz_cmf_wyman.js +74 -65
- package/src/core/color/xyz/xyz_to_hpe.d.ts +18 -0
- package/src/core/color/xyz/xyz_to_hpe.d.ts.map +1 -0
- package/src/core/color/xyz/xyz_to_hpe.js +33 -0
- package/src/core/color/xyz/xyz_to_rgb.d.ts +17 -2
- package/src/core/color/xyz/xyz_to_rgb.d.ts.map +1 -1
- package/src/core/color/xyz/xyz_to_rgb.js +39 -16
- package/src/core/color/ycxcz/xyz_to_ycxcz.d.ts +7 -2
- package/src/core/color/ycxcz/xyz_to_ycxcz.d.ts.map +1 -1
- package/src/core/color/ycxcz/xyz_to_ycxcz.js +33 -28
- package/src/core/events/signal/Signal.js +820 -820
- package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/ConvexHullShape3D.js +28 -4
- package/src/core/math/clamp_index.d.ts +18 -0
- package/src/core/math/clamp_index.d.ts.map +1 -0
- package/src/core/math/clamp_index.js +23 -0
- package/src/engine/asset/loaders/image/IMAGE_CODEC_REVIEW_2026_08_28.md +803 -0
- package/src/engine/asset/loaders/image/jpeg/JpegFrame.d.ts +5 -3
- package/src/engine/asset/loaders/image/jpeg/JpegFrame.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/jpeg/JpegFrame.js +5 -3
- package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.d.ts +2 -1
- package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.js +2 -1
- package/src/engine/asset/loaders/image/jpeg/JpegImage.d.ts +17 -0
- package/src/engine/asset/loaders/image/jpeg/JpegImage.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/jpeg/JpegImage.js +197 -157
- package/src/engine/asset/loaders/image/jpeg/idct8x8_float.d.ts +0 -1
- package/src/engine/asset/loaders/image/jpeg/idct8x8_float.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/jpeg/idct8x8_float.js +0 -1
- package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.d.ts +28 -0
- package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.js +31 -0
- package/src/engine/asset/loaders/image/png/PNG.d.ts +3 -18
- package/src/engine/asset/loaders/image/png/PNG.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/PNG.js +3 -139
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts +16 -16
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/PNGReader.js +143 -160
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.js +3 -3
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.js +3 -3
- package/src/engine/asset/loaders/image/png/crc32.d.ts +1 -15
- package/src/engine/asset/loaders/image/png/crc32.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/crc32.js +5 -89
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts +12 -10
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js +20 -45
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts +2 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.js +2 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts +2 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.js +2 -0
- package/src/engine/asset/loaders/image/png/filter/png_unfilter.d.ts +22 -0
- package/src/engine/asset/loaders/image/png/filter/png_unfilter.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/filter/png_unfilter.js +68 -0
- package/src/engine/asset/loaders/image/png/png_inflate.d.ts +20 -0
- package/src/engine/asset/loaders/image/png/png_inflate.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/png_inflate.js +85 -0
- package/src/engine/asset/loaders/image/png/png_unpack_samples.d.ts +22 -0
- package/src/engine/asset/loaders/image/png/png_unpack_samples.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/png_unpack_samples.js +38 -0
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +135 -132
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +16 -3
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1157 -1149
- package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +26 -0
- package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
- package/src/engine/graphics/render/frame_graph/FrameGraph.js +947 -900
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +69 -81
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +83 -77
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/device/IMMEDIATE_DATA_PLAN_2026_08_28.md +451 -0
- package/src/shade/device/ShadeGPUCommandContext.d.ts +21 -0
- package/src/shade/device/ShadeGPUCommandContext.d.ts.map +1 -1
- package/src/shade/device/ShadeGPUCommandContext.js +940 -749
- package/src/shade/device/timing/GPUTimerArray.d.ts +22 -4
- package/src/shade/device/timing/GPUTimerArray.d.ts.map +1 -1
- package/src/shade/device/timing/GPUTimerArray.js +88 -14
- package/src/shade/device/timing/GPU_PROFILER_PROPOSAL_2026_08_28.md +876 -0
- package/src/shade/device/timing/profile/GPUFrameRecorder.d.ts +93 -0
- package/src/shade/device/timing/profile/GPUFrameRecorder.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUFrameRecorder.js +297 -0
- package/src/shade/device/timing/profile/GPUProfileCapture.d.ts +62 -0
- package/src/shade/device/timing/profile/GPUProfileCapture.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileCapture.js +77 -0
- package/src/shade/device/timing/profile/GPUProfileFrame.d.ts +73 -0
- package/src/shade/device/timing/profile/GPUProfileFrame.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileFrame.js +88 -0
- package/src/shade/device/timing/profile/GPUProfileLevel.d.ts +20 -0
- package/src/shade/device/timing/profile/GPUProfileLevel.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileLevel.js +50 -0
- package/src/shade/device/timing/profile/GPUProfileMeta.d.ts +63 -0
- package/src/shade/device/timing/profile/GPUProfileMeta.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileMeta.js +73 -0
- package/src/shade/device/timing/profile/GPUProfileSession.d.ts +173 -0
- package/src/shade/device/timing/profile/GPUProfileSession.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileSession.js +470 -0
- package/src/shade/device/timing/profile/GPUProfileSpan.d.ts +60 -0
- package/src/shade/device/timing/profile/GPUProfileSpan.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileSpan.js +65 -0
- package/src/shade/device/timing/profile/GPUProfileSpanKind.d.ts +19 -0
- package/src/shade/device/timing/profile/GPUProfileSpanKind.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileSpanKind.js +25 -0
- package/src/shade/device/timing/profile/GPUProfileTopology.d.ts +159 -0
- package/src/shade/device/timing/profile/GPUProfileTopology.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileTopology.js +202 -0
- package/src/shade/device/timing/profile/GPUProfileWork.d.ts +90 -0
- package/src/shade/device/timing/profile/GPUProfileWork.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileWork.js +115 -0
- package/src/shade/device/timing/profile/SGPTDefect.d.ts +43 -0
- package/src/shade/device/timing/profile/SGPTDefect.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPTDefect.js +65 -0
- package/src/shade/device/timing/profile/SGPTHeader.d.ts +38 -0
- package/src/shade/device/timing/profile/SGPTHeader.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPTHeader.js +46 -0
- package/src/shade/device/timing/profile/SGPTRecordRef.d.ts +37 -0
- package/src/shade/device/timing/profile/SGPTRecordRef.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPTRecordRef.js +45 -0
- package/src/shade/device/timing/profile/SGPTWriteStream.d.ts +103 -0
- package/src/shade/device/timing/profile/SGPTWriteStream.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPTWriteStream.js +287 -0
- package/src/shade/device/timing/profile/SGPT_DEFECT.d.ts +19 -0
- package/src/shade/device/timing/profile/SGPT_DEFECT.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_DEFECT.js +26 -0
- package/src/shade/device/timing/profile/SGPT_FLAG.d.ts +8 -0
- package/src/shade/device/timing/profile/SGPT_FLAG.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_FLAG.js +15 -0
- package/src/shade/device/timing/profile/SGPT_FORMAT.md +345 -0
- package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.d.ts +10 -0
- package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.js +9 -0
- package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.d.ts +17 -0
- package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.js +16 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.d.ts +16 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.js +15 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.d.ts +15 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.js +29 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.d.ts +7 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.js +6 -0
- package/src/shade/device/timing/profile/SGPT_MAGIC.d.ts +7 -0
- package/src/shade/device/timing/profile/SGPT_MAGIC.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_MAGIC.js +6 -0
- package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.d.ts +16 -0
- package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.js +15 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.d.ts +7 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.js +6 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.d.ts +13 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.js +23 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.d.ts +12 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.js +11 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.d.ts +18 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.js +46 -0
- package/src/shade/device/timing/profile/frame_graph_extract_topology.d.ts +20 -0
- package/src/shade/device/timing/profile/frame_graph_extract_topology.d.ts.map +1 -0
- package/src/shade/device/timing/profile/frame_graph_extract_topology.js +174 -0
- package/src/shade/device/timing/profile/make_profiling_pass_encoder.d.ts +21 -0
- package/src/shade/device/timing/profile/make_profiling_pass_encoder.d.ts.map +1 -0
- package/src/shade/device/timing/profile/make_profiling_pass_encoder.js +114 -0
- package/src/shade/device/timing/profile/parse_workgroup_size.d.ts +20 -0
- package/src/shade/device/timing/profile/parse_workgroup_size.d.ts.map +1 -0
- package/src/shade/device/timing/profile/parse_workgroup_size.js +43 -0
- package/src/shade/device/timing/profile/sgpt_fourcc.d.ts +18 -0
- package/src/shade/device/timing/profile/sgpt_fourcc.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_fourcc.js +34 -0
- package/src/shade/device/timing/profile/sgpt_frame_codec.d.ts +42 -0
- package/src/shade/device/timing/profile/sgpt_frame_codec.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_frame_codec.js +172 -0
- package/src/shade/device/timing/profile/sgpt_meta_codec.d.ts +20 -0
- package/src/shade/device/timing/profile/sgpt_meta_codec.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_meta_codec.js +65 -0
- package/src/shade/device/timing/profile/sgpt_read_capture.d.ts +19 -0
- package/src/shade/device/timing/profile/sgpt_read_capture.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_read_capture.js +134 -0
- package/src/shade/device/timing/profile/sgpt_read_header.d.ts +22 -0
- package/src/shade/device/timing/profile/sgpt_read_header.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_read_header.js +94 -0
- package/src/shade/device/timing/profile/sgpt_read_records.d.ts +27 -0
- package/src/shade/device/timing/profile/sgpt_read_records.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_read_records.js +153 -0
- package/src/shade/device/timing/profile/sgpt_topology_codec.d.ts +54 -0
- package/src/shade/device/timing/profile/sgpt_topology_codec.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_topology_codec.js +329 -0
- package/src/shade/device/timing/profile/sgpt_write_header.d.ts +22 -0
- package/src/shade/device/timing/profile/sgpt_write_header.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_write_header.js +47 -0
- package/src/shade/device/timing/profile/sgpt_write_record.d.ts +23 -0
- package/src/shade/device/timing/profile/sgpt_write_record.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_write_record.js +62 -0
- package/src/shade/renderer/Renderer.d.ts +21 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +2513 -2455
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/scene/serialization/decode_image_source_hdr.d.ts +14 -3
- package/src/shade/renderer/scene/serialization/decode_image_source_hdr.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/decode_image_source_hdr.js +50 -51
- package/src/shade/renderer/scene/serialization/deserialize_scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/deserialize_scene.js +531 -521
- package/src/shade/renderer/scene/serialization/write_image_source.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/write_image_source.js +6 -4
- package/src/shade/renderer/shader/chunk/color/chunk_rgb_to_luminance.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/chunk_rgb_to_luminance.js +34 -32
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.d.ts +31 -0
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.js +62 -31
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.d.ts +10 -0
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.js +32 -22
- package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferOETF.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js +22 -21
- package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.d.ts +6 -0
- package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.js +110 -104
- package/src/shade/renderer/shader/chunk/color/xyz/chunk_rgb_to_xyz.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/xyz/chunk_rgb_to_xyz.js +23 -21
- package/src/view/elements/ColorPickerView.js +296 -296
- package/src/avif/codec/dec/Readme.md +0 -14
- package/src/avif/codec/dec/avif_dec.cpp +0 -234
- package/src/avif/codec/dec/avif_dec.d.ts +0 -3
- package/src/avif/codec/dec/avif_dec.d.ts.map +0 -1
- package/src/avif/codec/dec/avif_dec.js +0 -16
- package/src/avif/codec/dec/avif_dec.wasm +0 -0
- package/src/avif/codec/enc/README.md +0 -37
- package/src/avif/codec/enc/avif_enc.cpp +0 -216
- package/src/avif/codec/enc/avif_enc.d.ts +0 -3
- package/src/avif/codec/enc/avif_enc.d.ts.map +0 -1
- package/src/avif/codec/enc/avif_enc.js +0 -6144
- package/src/avif/codec/enc/avif_enc.wasm +0 -0
- package/src/avif/codec/enc/avif_enc_mt.d.ts +0 -3
- package/src/avif/codec/enc/avif_enc_mt.d.ts.map +0 -1
- package/src/avif/codec/enc/avif_enc_mt.js +0 -6811
- package/src/avif/codec/enc/avif_enc_mt.wasm +0 -0
- package/src/avif/codec/enc/avif_enc_mt.worker.d.mts +0 -2
- package/src/avif/codec/enc/avif_enc_mt.worker.d.mts.map +0 -1
- package/src/avif/codec/enc/avif_enc_mt.worker.d.ts +0 -11
- package/src/avif/codec/enc/avif_enc_mt.worker.d.ts.map +0 -1
- package/src/avif/codec/enc/avif_enc_mt.worker.js +0 -171
- package/src/avif/codec/enc/avif_enc_mt.worker.mjs +0 -1
- package/src/avif/decode.d.ts +0 -3
- package/src/avif/decode.d.ts.map +0 -1
- package/src/avif/decode.js +0 -42
- package/src/avif/encode.d.ts +0 -3
- package/src/avif/encode.d.ts.map +0 -1
- package/src/avif/encode.js +0 -75
- package/src/avif/meta.d.ts +0 -24
- package/src/avif/meta.d.ts.map +0 -1
- package/src/avif/meta.js +0 -23
- package/src/avif/tsconfig.tsbuildinfo +0 -1
- package/src/avif/utils.d.ts +0 -17
- package/src/avif/utils.d.ts.map +0 -1
- package/src/avif/utils.js +0 -31
- package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.d.ts +0 -23
- package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.d.ts.map +0 -1
- package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.js +0 -214
- package/src/engine/asset/loaders/image/png/inflate.d.ts +0 -7
- package/src/engine/asset/loaders/image/png/inflate.d.ts.map +0 -1
- package/src/engine/asset/loaders/image/png/inflate.js +0 -20
- package/src/engine/save/GameStateLoader.d.ts +0 -49
- package/src/engine/save/GameStateLoader.d.ts.map +0 -1
- package/src/engine/save/GameStateLoader.js +0 -168
|
@@ -0,0 +1,876 @@
|
|
|
1
|
+
# A graphical GPU profiler for Shade — recorder, format, inspector
|
|
2
|
+
|
|
3
|
+
Proposal, 2026-08-28. Decisions folded in 2026-08-29. Alex Goldring / Company Named Limited.
|
|
4
|
+
|
|
5
|
+
Scope: a **recording** side that ships with the engine, a **binary container** that carries a
|
|
6
|
+
capture, and an **inspector** web application under `packages/gpu-inspector-tool/` that reads the
|
|
7
|
+
container and nothing else.
|
|
8
|
+
|
|
9
|
+
> The request spelled the directory `gpu-inespector-tool`. Reading that as a typo and using
|
|
10
|
+
> `packages/gpu-inspector-tool/` throughout. Say the word if the misspelling was deliberate.
|
|
11
|
+
|
|
12
|
+
**Four decisions are settled and written into the design below** — npm workspaces with the existing
|
|
13
|
+
tree moved to conform (§4.2), a user-instantiated recorder passed in rather than a renderer-owned one
|
|
14
|
+
(§6.1), the minimal `FrameGraph` bracket via `Signal` (§1.4), and an open-ended uncapped stream of
|
|
15
|
+
self-contained frame records rather than a ring buffer (§5.8). §11 records them and what each costs.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 0. Verdict
|
|
20
|
+
|
|
21
|
+
**Worth building, and the engine is further along than it looks — but not in the place you would
|
|
22
|
+
expect.**
|
|
23
|
+
|
|
24
|
+
The timing half is the *small* half. `GPUTimerArray` already lands begin/end timestamps per GPU
|
|
25
|
+
pass, and `SoftwareGPUDevice` already emulates timestamp queries well enough to test the recorder in
|
|
26
|
+
node without a GPU. What is genuinely missing is **attribution**: the timestamps are keyed by
|
|
27
|
+
`GPUComputePassDescriptor.label`, the dependency structure lives in `FrameGraph`, and *nothing
|
|
28
|
+
connects the two*. One frame-graph pass can open several GPU passes with unrelated labels
|
|
29
|
+
(`graph_build_hzb` → `hzb.build()` → its own `constructComputePass` labels), so a label is not a key.
|
|
30
|
+
Closing that gap is the central piece of engineering in this proposal, and it is about thirty lines
|
|
31
|
+
in `FrameGraph.execute` plus a field on the command context.
|
|
32
|
+
|
|
33
|
+
The dependency half is nearly free. `FrameGraph.exportToJson()`
|
|
34
|
+
([FrameGraph.js:644](src/engine/graphics/render/frame_graph/FrameGraph.js:644)) already emits passes,
|
|
35
|
+
resource nodes, versions, readers, writers, producers and cull state, keyed consistently. Resource
|
|
36
|
+
*sizes* fall out of the descriptors that graph already holds. Nesting for a flame-graph view falls
|
|
37
|
+
out of `FrameGraphScope`.
|
|
38
|
+
|
|
39
|
+
The work-size half needs a wrapper that does not exist: `beginComputePass` hands back the raw
|
|
40
|
+
`GPUComputePassEncoder`, so `dispatchWorkgroups(x, y, z)` is invisible to us. A recording-only proxy
|
|
41
|
+
around the pass encoder buys every dispatch and draw count for one class and no call-site churn.
|
|
42
|
+
|
|
43
|
+
**The single biggest risk is not ours.** Chrome quantizes WebGPU timestamps to **100 µs** unless the
|
|
44
|
+
user sets `chrome://flags/#enable-webgpu-developer-features`. Most Shade passes run well under that,
|
|
45
|
+
so on a default browser almost every pass measures as exactly 0 or exactly 100 µs. A profiler that
|
|
46
|
+
does not say this out loud, in the recording *and* in the inspector, is a profiler that lies. §2.1.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 1. What exists today
|
|
51
|
+
|
|
52
|
+
### 1.1 The timing path, end to end
|
|
53
|
+
|
|
54
|
+
| Piece | Where | What it does |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `GPUTimerArray` | [GPUTimerArray.js](src/shade/device/timing/GPUTimerArray.js) | One `GPUQuerySet` of `size * 2` timestamps. `getComputeWrites(label)` / `getRenderWrites(label)` claim a slot from an `IdPool` and return the `timestampWrites` struct. Resolve + copy to a `MAP_READ` buffer, `download_results()` maps it, `results_to_console_table()` turns slots into `{label, type, duration_ms, start, end}`. |
|
|
57
|
+
| `ShadeGPUCommandContext.enable_debug_timers(cb)` | [ShadeGPUCommandContext.js:89](src/shade/device/ShadeGPUCommandContext.js:89) | Constructs a `GPUTimerArray` for this context. `beginComputePass` / `beginRenderPass` then inject `timestampWrites` into every descriptor. |
|
|
58
|
+
| `finish()` | [ShadeGPUCommandContext.js:699](src/shade/device/ShadeGPUCommandContext.js:699) | Resolves the query set into the command buffer before `encoder.finish()`, then after submit downloads results and calls the callback, then destroys the timer array. |
|
|
59
|
+
| `Renderer.add_debug_frame(count)` | [Renderer.js:626](src/shade/renderer/Renderer.js:626) | Arms N future frames. |
|
|
60
|
+
| `Renderer.onFrameDebug` | [Renderer.js:408](src/shade/renderer/Renderer.js:408) | `send2(frame_index, table)`. **Currently has no subscribers anywhere in the tree.** |
|
|
61
|
+
| `GPUTimerStats`, `format_nanosecond_time` | `src/shade/device/timing/` | Ring-buffer averaging and human formatting. Reusable in the inspector. |
|
|
62
|
+
|
|
63
|
+
Degradation is already correct: with `timestamp-query` withheld, the query set is never created and
|
|
64
|
+
`resolve` / `download_results` / `destroy` all no-op rather than throwing. Keep that property.
|
|
65
|
+
|
|
66
|
+
### 1.2 Four defects the recorder must fix, not inherit
|
|
67
|
+
|
|
68
|
+
1. **No slot bound check.** `GPUTimerArray.#bind_slot` takes an id from the `IdPool` and never
|
|
69
|
+
compares it to `#size`. Pass 1025 in a frame (default `size = 1024`) writes a query index past
|
|
70
|
+
`querySet.count` and takes a WebGPU validation error, at the `beginRenderPass` rather than at the
|
|
71
|
+
place that overflowed. A recording session runs *more* passes instrumented than a debug frame
|
|
72
|
+
does, so this is on the path. Clamp and count drops; report the drop count in the recording.
|
|
73
|
+
2. **Per-context GPU allocation.** `enable_debug_timers` builds a query set and two buffers per
|
|
74
|
+
context and destroys them after the download. Fine for one frame; recording 600 frames means 600
|
|
75
|
+
query-set create/destroy pairs and 600 `mapAsync` round trips. Wants a small pool of timer arrays
|
|
76
|
+
cycled N-deep against frames in flight.
|
|
77
|
+
3. **Descriptor mutation.** `beginComputePass` does `let _descriptor = descriptor;` and then writes
|
|
78
|
+
`_descriptor.timestampWrites`, mutating the caller's object. Several call sites reuse descriptor
|
|
79
|
+
objects. Copy, or document the mutation.
|
|
80
|
+
4. **`beginComputePass()` with no descriptor throws** once timers are on, at
|
|
81
|
+
`timers.getComputeWrites(descriptor.label)`. Currently latent because every call site passes one.
|
|
82
|
+
|
|
83
|
+
### 1.3 The structure half
|
|
84
|
+
|
|
85
|
+
`FrameGraph.exportToJson()` is most of the dependency model already:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
{
|
|
89
|
+
passes: [{ id, name, culled, reads: [node_id], writes: [node_id] }],
|
|
90
|
+
resources: [{ id, name, transient, version?, description?, createdBy?, readers?, writers? }]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Keyed by **resource node** (per version), not by registry entry — deliberately, so
|
|
95
|
+
`passes[].reads/writes` stay resolvable across versions. The recording format must preserve that
|
|
96
|
+
choice; a registry-keyed export dangles every reference past version 0.
|
|
97
|
+
|
|
98
|
+
What it does *not* carry, and we want:
|
|
99
|
+
|
|
100
|
+
- `FrameGraphNode.scope` — the `FrameGraphScope` chain, which is the hierarchy a flame graph needs.
|
|
101
|
+
- `ref_count` and `has_side_effects` — why a pass survived culling.
|
|
102
|
+
- Typed descriptors. `description` is `resource_descriptor.toString()`, a human string
|
|
103
|
+
(`"Buffer{ size = 1,048,576, usage = STORAGE | COPY_DST }"`). We want the fields.
|
|
104
|
+
|
|
105
|
+
### 1.4 The gap: labels are not keys
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
// graph_build_hzb.js
|
|
109
|
+
const builder = graph.add("hzb/ build", data, (data, resources, context) => {
|
|
110
|
+
hzb.build(context.encoder, source, viewport); // opens N compute passes, its own labels
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`GPUTimerArray` records the labels `hzb.build` chose. `FrameGraph` records `"hzb/ build"`. Nothing
|
|
115
|
+
relates them, and the relation is not derivable after the fact — labels are not unique, not stable,
|
|
116
|
+
and one graph pass legitimately produces many GPU passes.
|
|
117
|
+
|
|
118
|
+
**Fix:** bracket `node.execute(...)` inside `FrameGraph.execute`
|
|
119
|
+
([FrameGraph.js:604](src/engine/graphics/render/frame_graph/FrameGraph.js:604)) so the context knows
|
|
120
|
+
which graph pass is open. Every GPU pass begun while that bracket is open is attributed to it. The
|
|
121
|
+
same bracket should emit `pushDebugGroup(node.name)` / `popDebugGroup()`, which costs nothing and
|
|
122
|
+
immediately improves what RenderDoc, PIX and webgpu-inspector show — worth doing on its own merits.
|
|
123
|
+
|
|
124
|
+
### 1.5 Work sizes are not observable today
|
|
125
|
+
|
|
126
|
+
`beginComputePass` / `constructComputePass` return the **raw** `GPUComputePassEncoder`. All 11
|
|
127
|
+
production `dispatchWorkgroups` call sites talk to it directly, as does every draw call across the
|
|
128
|
+
31 render-pass construction sites. Editing every one of them to report its own counts is the wrong
|
|
129
|
+
trade. A proxy encoder, installed only while recording, is one class.
|
|
130
|
+
|
|
131
|
+
`SoftwareGPUComputePassEncoder` already models exactly this: it records
|
|
132
|
+
`{pipeline, bind_groups, dynamic_offsets, group_counts}` per dispatch. The recording proxy is the
|
|
133
|
+
same shape with a real encoder behind it.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 2. What the platform will give us
|
|
138
|
+
|
|
139
|
+
### 2.1 Timestamp quantization — the headline constraint
|
|
140
|
+
|
|
141
|
+
Chrome quantizes `timestamp-query` results to **100 µs** as a timing-attack mitigation. It is
|
|
142
|
+
disabled by `chrome://flags/#enable-webgpu-developer-features`; that flag does not itself enable the
|
|
143
|
+
feature, which additionally needs the device to expose `timestamp-query`.
|
|
144
|
+
|
|
145
|
+
100 µs is 0.1 ms. A Shade frame at 60 Hz has ~16.6 ms of budget spread over a couple of hundred
|
|
146
|
+
passes. **The median pass is below the quantum.** Unmitigated, the tool reports a histogram of zeros
|
|
147
|
+
with occasional 100 µs spikes, and every conclusion drawn from it is noise.
|
|
148
|
+
|
|
149
|
+
**The decision is to leave it entirely alone.** Not measure it, not calibrate against it, not
|
|
150
|
+
correct for it, not store a period in the container. Rejected 2026-08-29, and the reasoning is
|
|
151
|
+
worth keeping because it is not obvious:
|
|
152
|
+
|
|
153
|
+
- Recovering the quantum — GCD over observed timestamps, or any equivalent — **is the timing attack
|
|
154
|
+
the mitigation exists to prevent.** Doing it *well* means defeating a browser security control on
|
|
155
|
+
purpose, inside code we ship to other people.
|
|
156
|
+
- Doing it *badly* is worse than not doing it. A period that is a multiple of the real one, or a
|
|
157
|
+
stale one from a browser update, becomes a correction applied to every number in the capture. A
|
|
158
|
+
profiler that silently skews its own data is worse than one that reports coarse data honestly.
|
|
159
|
+
- Either way it is standing complexity and a source of fragility, bought for something the reader
|
|
160
|
+
can be told in one sentence.
|
|
161
|
+
|
|
162
|
+
So: **note it, document it, do not treat it.** The capture records what the device reported —
|
|
163
|
+
zeros included. `GPUProfileMeta` documents that browsers quantize and names the flag. The inspector
|
|
164
|
+
says so where a reader will see it. What to make of a coarse capture is the reader's judgement, and
|
|
165
|
+
the honest advice is the same either way: **aggregate across frames rather than trusting any single
|
|
166
|
+
one.** That shapes the format in exactly one way, which it already did — keep every frame's raw
|
|
167
|
+
values and never pre-aggregate on the recorder side.
|
|
168
|
+
|
|
169
|
+
### 2.2 Pass granularity is the floor
|
|
170
|
+
|
|
171
|
+
WebGPU writes timestamps at pass boundaries only. Per-draw timing needs
|
|
172
|
+
`chromium-experimental-timestamp-query-inside-passes`, which is Chromium-only and experimental.
|
|
173
|
+
|
|
174
|
+
**Design for pass granularity.** Treat inside-passes as an optional capability the recorder probes
|
|
175
|
+
for and, if present, uses to add sub-pass markers — recorded as a distinct span kind so the format
|
|
176
|
+
does not pretend the two are the same measurement.
|
|
177
|
+
|
|
178
|
+
### 2.3 No CPU↔GPU clock sync
|
|
179
|
+
|
|
180
|
+
WebGPU exposes no calibration between `performance.now()` and the GPU timestamp domain. Anything
|
|
181
|
+
claiming to place CPU and GPU events on one axis is guessing.
|
|
182
|
+
|
|
183
|
+
**Be honest in the format.** Record two clocks explicitly: a CPU track from `performance.now()`
|
|
184
|
+
(encode time, submit time, callback time) and a GPU track from timestamps. The inspector shows two
|
|
185
|
+
tracks anchored per frame at submit, and says the alignment is nominal. Perfetto solves this problem
|
|
186
|
+
with explicit `ClockSnapshot` packets and a clock graph; we do not have the snapshots, so we do not
|
|
187
|
+
get to claim the sync.
|
|
188
|
+
|
|
189
|
+
### 2.4 Cross-query-set comparability
|
|
190
|
+
|
|
191
|
+
Timestamps from two different `GPUQuerySet`s are not specified to share a domain. In Dawn they do in
|
|
192
|
+
practice. Since each `ShadeGPUCommandContext` currently gets its own `GPUTimerArray`, and a frame has
|
|
193
|
+
several contexts, **every frame already spans several query sets.**
|
|
194
|
+
|
|
195
|
+
Record a `query_set_id` per span. Then the inspector can, if a capture ever looks wrong, colour
|
|
196
|
+
spans by origin and let the reader see whether the anomaly follows a set boundary. Cheap; makes an
|
|
197
|
+
otherwise unfalsifiable class of bug visible.
|
|
198
|
+
|
|
199
|
+
### 2.5 Indirect work is unknowable at encode time
|
|
200
|
+
|
|
201
|
+
`dispatchWorkgroupsIndirect` and `drawIndirect` take their counts from a GPU buffer. At encode time
|
|
202
|
+
we know only *that* it was indirect. Two options, both worth having:
|
|
203
|
+
|
|
204
|
+
- **v1:** record the indirect flag plus the source buffer's id and offset. The inspector shows
|
|
205
|
+
"indirect (unknown)" and links to the buffer.
|
|
206
|
+
- **v2 (opt-in, costly):** the recorder copies indirect argument buffers into a readback staging
|
|
207
|
+
buffer at encode time and resolves the actual counts after submit. This is the only way to see the
|
|
208
|
+
real post-cull draw count, which for a GPU-driven renderer is one of the numbers most worth seeing.
|
|
209
|
+
It changes memory traffic, so it must be a flag, and the format must mark such counts as
|
|
210
|
+
*resolved* rather than *encoded* so nobody compares the two carelessly.
|
|
211
|
+
|
|
212
|
+
### 2.6 Prior art
|
|
213
|
+
|
|
214
|
+
| Tool | What to take | What to leave |
|
|
215
|
+
|---|---|---|
|
|
216
|
+
| [webgpu_inspector](https://github.com/brendan-duncan/webgpu_inspector) (Brendan Duncan) | The reference point for WebGPU frame capture in a browser. Object inspection with creation stacktraces; frame-time plotting; buffer content view. Its recorder emits a standalone replayable HTML file. | It is a *generic API* interceptor, extension-hosted. We want *engine-semantic* data — frame graph passes, resource lifetimes, cull decisions — which a generic interceptor cannot see. Complementary, not competing. |
|
|
217
|
+
| [Perfetto](https://perfetto.dev/docs/getting-started/other-formats) | Track/slice model; nested slices; counter tracks; explicit clock domains. Its JSON importer is a free escape hatch — see §5.6. | The protobuf format and the full trace-processor stack are far more than we need, and its UI knows nothing about resource dependency. |
|
|
218
|
+
| RenderDoc / PIX / Radeon GPU Profiler | The three-pane idiom: event list, timeline, per-event detail; a resource view keyed by lifetime; "why is this bound" attribution. | Native capture, replay, driver counters. Out of reach on WebGPU. |
|
|
219
|
+
| Chrome Trace Event Format | Trivially writable, universally readable. | Text JSON at our event rates is 5–10× our binary size. Export target, not storage. |
|
|
220
|
+
| [webgpufundamentals timing](https://webgpufundamentals.org/webgpu/lessons/webgpu-timing.html) | The canonical treatment of the query-set/resolve/map dance and its pitfalls. | — |
|
|
221
|
+
|
|
222
|
+
The gap in that table is the whole reason to build this: **no existing tool knows what a Shade frame
|
|
223
|
+
graph is.** Timings without the dependency structure tell you a pass is slow; timings *with* it tell
|
|
224
|
+
you a pass is slow because it waits on a resource that a culled branch still produced.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## 3. What a recording must contain
|
|
229
|
+
|
|
230
|
+
Three axes were asked for. A fourth is needed to make the first three legible.
|
|
231
|
+
|
|
232
|
+
### 3.1 Timings
|
|
233
|
+
|
|
234
|
+
| Datum | Source | Cost |
|
|
235
|
+
|---|---|---|
|
|
236
|
+
| GPU pass begin/end, ns | `GPUTimerArray` | free, already there |
|
|
237
|
+
| Which query set a span came from | recorder | 1 byte |
|
|
238
|
+
| CPU encode time per graph pass | `performance.now()` around `node.execute` | ~2 × 200 calls/frame |
|
|
239
|
+
| CPU submit timestamp | `ShadeGPUCommandContext.finish` | free |
|
|
240
|
+
| Callback/readback latency | recorder | free |
|
|
241
|
+
| Sub-pass markers | `chromium-experimental-timestamp-query-inside-passes` if present | optional |
|
|
242
|
+
|
|
243
|
+
### 3.2 Dependencies
|
|
244
|
+
|
|
245
|
+
Straight from `FrameGraph`, enriched:
|
|
246
|
+
|
|
247
|
+
- Passes: id, name, scope chain, culled, `ref_count`, `has_side_effects`, reads/writes/creates.
|
|
248
|
+
- Resource nodes: id, name, version, transient/imported, producer, readers, writers.
|
|
249
|
+
- Per graph pass: the GPU passes it opened, in order — the join from §1.4.
|
|
250
|
+
- Resource lifetime: first write → last read, derivable from `ResourceEntry.last`, which `compile()`
|
|
251
|
+
already computes.
|
|
252
|
+
|
|
253
|
+
### 3.3 Data sizes
|
|
254
|
+
|
|
255
|
+
Descriptors carry everything:
|
|
256
|
+
|
|
257
|
+
| Resource | Fields | Footprint |
|
|
258
|
+
|---|---|---|
|
|
259
|
+
| Buffer | `size` bytes, `usage` bitmask, `ensure_cleared` range | `size` directly |
|
|
260
|
+
| Texture | `resolution[3]`, `format`, `dimension`, `mipLevelCount`, `sampleCount`, `usage` | computed from `gpu_texture_format_info` — `bytes_per_block`, `block_width`, `block_height` — summed over the mip chain, × `sampleCount` |
|
|
261
|
+
|
|
262
|
+
These are **declared** sizes, not allocated ones; a pooled allocator may serve a larger block.
|
|
263
|
+
`GraphicsContext.gpu_memory_usage` gives the real total per frame — record it as a counter track and
|
|
264
|
+
let the inspector show declared-vs-actual as the aliasing metric it is.
|
|
265
|
+
|
|
266
|
+
### 3.4 Work sizes
|
|
267
|
+
|
|
268
|
+
| Datum | Needs |
|
|
269
|
+
|---|---|
|
|
270
|
+
| `dispatchWorkgroups(x, y, z)` | proxy encoder |
|
|
271
|
+
| Workgroup size from the shader (`@workgroup_size`) | pipeline descriptor, recorded once per pipeline |
|
|
272
|
+
| Total invocations = groups × workgroup size | derived in the inspector |
|
|
273
|
+
| `draw` / `drawIndexed` vertex, index, instance counts | proxy encoder |
|
|
274
|
+
| Indirect flag + argument buffer id/offset | proxy encoder |
|
|
275
|
+
| Resolved indirect counts | §2.5 v2, opt-in |
|
|
276
|
+
| Bind group contents per dispatch | proxy encoder; **large** — gate behind a verbosity level |
|
|
277
|
+
| Render pass attachment formats and load/store ops | pass descriptor |
|
|
278
|
+
|
|
279
|
+
### 3.5 The fourth axis — context, so any of it means anything
|
|
280
|
+
|
|
281
|
+
Without this a shared recording is unreadable:
|
|
282
|
+
|
|
283
|
+
- Adapter info (`vendor`, `architecture`, `device`, `description`), features, the limits that matter.
|
|
284
|
+
- Engine version, git revision, build flags, `ENV_PRODUCTION`.
|
|
285
|
+
- Renderer settings: internal vs output resolution, upscaler, which features are on.
|
|
286
|
+
- Nothing about timestamp quantization: see §2.1 for why that is a deliberate absence.
|
|
287
|
+
- Wall-clock start, session id, user-supplied note.
|
|
288
|
+
- Scene scale: mesh/instance/light counts, resident material and geometry bytes.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 4. Architecture
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
ENGINE (ships) CONTAINER INSPECTOR (published separately)
|
|
296
|
+
───────────────────── ───────── ───────────────────────────────
|
|
297
|
+
GPUTimerArray ────┐
|
|
298
|
+
FrameGraph ───────┤ ┌── timeline / flame graph
|
|
299
|
+
proxy encoders ───┼──> GPUProfileSession ───> .sgpt ──drop──> ├── dependency graph
|
|
300
|
+
GraphicsContext ──┘ │ bytes ├── resource table
|
|
301
|
+
│ ├── pass detail
|
|
302
|
+
sgpt_write_* └── frame comparison
|
|
303
|
+
│ │
|
|
304
|
+
BinaryBuffer <─────────────────────────── sgpt_read_*
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
**Three rules that keep this from rotting.**
|
|
308
|
+
|
|
309
|
+
1. **The container is the only interface.** The inspector imports the format readers and
|
|
310
|
+
`BinaryBuffer`. It never imports Shade, `FrameGraph`, or anything under `src/shade/renderer/`.
|
|
311
|
+
This is a licensing constraint as much as an architectural one — meep is proprietary and
|
|
312
|
+
source-available, and a separately published inspector must not carry renderer internals.
|
|
313
|
+
2. **The recorder never blocks the frame.** Every buffer it touches is written at encode time or
|
|
314
|
+
read after submit. Serialization runs off the frame — accumulate into per-frame plain records,
|
|
315
|
+
encode to bytes when the session stops or when a chunk fills.
|
|
316
|
+
3. **Reader and writer live together, in the engine tree.** Under
|
|
317
|
+
`src/shade/device/timing/profile/`, one file per concern, matching the `vgeo_*` convention. The
|
|
318
|
+
inspector package imports them by path. One definition of the format; no drift.
|
|
319
|
+
|
|
320
|
+
### 4.1 Verbosity levels
|
|
321
|
+
|
|
322
|
+
A capture is a trade between fidelity and cost. Four levels, recorded in the header:
|
|
323
|
+
|
|
324
|
+
| Level | Adds | Bytes/frame, ~200 passes |
|
|
325
|
+
|---|---|---|
|
|
326
|
+
| 0 `TIMING` | GPU pass spans, frame boundaries | ~2 KB |
|
|
327
|
+
| 1 `STRUCTURE` | + frame graph topology, resource descriptors, cull state | ~2 KB amortised (§5.4) |
|
|
328
|
+
| 2 `WORKLOAD` | + dispatch/draw counts, pipeline identities, attachment state | ~6 KB |
|
|
329
|
+
| 3 `VERBOSE` | + bind group contents, indirect readback, CPU per-pass timing | ~40 KB |
|
|
330
|
+
|
|
331
|
+
Levels 0–2 are the product. Level 3 is for us, on a repro, and the inspector should say so when it
|
|
332
|
+
opens one.
|
|
333
|
+
|
|
334
|
+
Because a session is now **uncapped by default** (§5.8), those per-frame figures are also a rate.
|
|
335
|
+
At 60 Hz:
|
|
336
|
+
|
|
337
|
+
| Level | Per second | Per minute |
|
|
338
|
+
|---|---|---|
|
|
339
|
+
| 0 `TIMING` | ~120 KB | ~7 MB |
|
|
340
|
+
| 1 `STRUCTURE` | ~120 KB | ~7 MB |
|
|
341
|
+
| 2 `WORKLOAD` | ~360 KB | ~21 MB |
|
|
342
|
+
| 3 `VERBOSE` | ~2.4 MB | ~144 MB |
|
|
343
|
+
|
|
344
|
+
Levels 0–2 will run for many minutes without anyone noticing. **Level 3 will not**, and the session
|
|
345
|
+
should say so — see the byte-budget warning in §5.8. This is the honest cost of "full and uncapped
|
|
346
|
+
explicit history", and it is the right trade at levels 0–2.
|
|
347
|
+
|
|
348
|
+
### 4.2 Repository layout
|
|
349
|
+
|
|
350
|
+
The repo becomes an npm workspace root, and the engine moves down a level so the two packages are
|
|
351
|
+
siblings rather than one being nested inside the other.
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
meep/
|
|
355
|
+
package.json workspace root: { "private": true, "workspaces": ["packages/*"] }
|
|
356
|
+
.gitlab-ci.yml
|
|
357
|
+
LICENSE, README.md, CONTRIBUTING.md, CHANGELOG.md, ...
|
|
358
|
+
packages/
|
|
359
|
+
meep-engine/ @woosh/meep-engine — everything that is published today
|
|
360
|
+
package.json unchanged `exports`, `files`, version
|
|
361
|
+
src/ editor/ samples/ tools/
|
|
362
|
+
rollup.config.js vite.config.mjs vitest.config.mjs tsconfig.types.json babel.config.cjs
|
|
363
|
+
gpu-inspector-tool/ the inspector, published separately
|
|
364
|
+
package.json index.html src/ fixtures/
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
`@woosh/meep-engine`'s own `exports` map (`./src/*`, `./editor/*`) is relative to its own
|
|
368
|
+
`package.json`, so **consumers installing from npm see no change at all**. The paths that move are
|
|
369
|
+
in-repo and in anything vendoring this tree by path.
|
|
370
|
+
|
|
371
|
+
**The cost is in `moh`, not here.** This tree is vendored into the game at
|
|
372
|
+
`app/src/mir-engine/meep/`, and that is where the restructure is felt: every engine path becomes
|
|
373
|
+
`app/src/mir-engine/meep/packages/meep-engine/src/...`. Two ways to absorb it, and this is the one
|
|
374
|
+
call the restructure actually needs:
|
|
375
|
+
|
|
376
|
+
- **Re-point the vendoring one level deeper** — mount `packages/meep-engine` as
|
|
377
|
+
`app/src/mir-engine/meep`. Every path in `moh` stays byte-identical, and the whole cost collapses
|
|
378
|
+
to one submodule/copy path. **This is the one to take** unless something in `moh` needs the
|
|
379
|
+
workspace root itself.
|
|
380
|
+
- **Update paths in `moh`** — mechanical, wide, and it churns the ~20 design documents in this tree
|
|
381
|
+
that quote `app/src/mir-engine/meep/src/...` as a source root.
|
|
382
|
+
|
|
383
|
+
In-repo edits either way: `vitest.config.mjs` `include`/`coverage.include` globs, `tsconfig.types.json`
|
|
384
|
+
`include`/`rootDir`, `rollup.config.js` `input` paths, `.gitlab-ci.yml` script and artifact paths, and
|
|
385
|
+
`vite.config.mjs`. All of them are prefix changes, and all of them get shorter, not longer, because
|
|
386
|
+
they become relative to the package rather than the root.
|
|
387
|
+
|
|
388
|
+
> Worth knowing before committing: npm lets a workspace root *also* be a package, so
|
|
389
|
+
> `packages/gpu-inspector-tool` could have been added with the engine left exactly where it is and
|
|
390
|
+
> zero paths touched. That option is on the table if the `moh` re-pointing turns out to be more
|
|
391
|
+
> awkward than it looks. Proceeding with the move as decided — it is the cleaner end state and the
|
|
392
|
+
> re-pointing above makes it cheap.
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## 5. The `.sgpt` container
|
|
397
|
+
|
|
398
|
+
**S**hade **G**PU **P**rofile **T**race. Magic `0x54504753` — the ASCII bytes `S G P T` read as a
|
|
399
|
+
little-endian u32 at offset 0, matching the `VGEO_MAGIC` convention in
|
|
400
|
+
[VGEO_MAGIC.js](packages/meep-engine/src/shade/renderer/geometry/virtual/format/header/VGEO_MAGIC.js).
|
|
401
|
+
`sgpt_fourcc.js` computes these and a spec asserts every literal against it, because hand-deriving
|
|
402
|
+
a little-endian FourCC is exactly the kind of arithmetic that is wrong once and then forever.
|
|
403
|
+
|
|
404
|
+
### 5.1 Why binary, concretely
|
|
405
|
+
|
|
406
|
+
A 600-frame capture at level 2, ~200 passes/frame, in Chrome Trace Event JSON: each span is roughly
|
|
407
|
+
`{"ph":"X","name":"...","cat":"gpu","ts":123456.7,"dur":234.5,"pid":1,"tid":3,"args":{...}}` — call
|
|
408
|
+
it 140 bytes minified, times 120,000 spans, **~17 MB**, before pass arguments. The same content in
|
|
409
|
+
the layout below is **~1.5 MB**, and gzip (already a dependency via `pako`, and available natively
|
|
410
|
+
via `CompressionStream`) takes it under 400 KB. That is the difference between a capture you attach
|
|
411
|
+
to a bug report and one you do not.
|
|
412
|
+
|
|
413
|
+
### 5.2 Layout
|
|
414
|
+
|
|
415
|
+
Chunked, directory at the tail — so a writer streams forward and only seeks back once, and a reader
|
|
416
|
+
can pull the header and the frame index without reading the payload.
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
offset size field
|
|
420
|
+
──────────────────────────────────────────────────────────────────
|
|
421
|
+
0 4 magic u32 0x54504753
|
|
422
|
+
4 2 format_version u16
|
|
423
|
+
6 2 min_reader_version u16
|
|
424
|
+
8 4 flags u32 bit0 = CLOSED (writer reached stop)
|
|
425
|
+
12 4 header_checksum u32 over bytes [0, 8) only — see below
|
|
426
|
+
16 8 directory_offset u64 0 when the session never stopped
|
|
427
|
+
24 8 directory_byte_length u64
|
|
428
|
+
32 ... records, in write order
|
|
429
|
+
... ... directory record
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**The checksum stops at byte 8, short of `flags`.** Everything from `flags` onward is patched at
|
|
433
|
+
stop — the CLOSED bit and the directory pointer — and a checksum covering them would have to be
|
|
434
|
+
recomputed then. Fine for a capture that stops; exactly wrong for one that does not, which would
|
|
435
|
+
carry a checksum over bytes never written and read as corrupt. What stays under it is what a reader
|
|
436
|
+
must trust before it can do anything at all: is this an `.sgpt`, and can this build read it.
|
|
437
|
+
|
|
438
|
+
### 5.3 Chunks
|
|
439
|
+
|
|
440
|
+
| FourCC | Purpose | Cardinality |
|
|
441
|
+
|---|---|---|
|
|
442
|
+
| `META` | §3.5 context. Adapter, engine version, settings, verbosity level, session note. | 1 |
|
|
443
|
+
| `SYMS` | Symbol block. Names, labels, formats, scope names — emitted **inside the record that first needs them** and referenced by u32 index thereafter, so a truncated capture still resolves every name it references (§5.8). | 0..n |
|
|
444
|
+
| `PIPE` | Pipeline table: id, label, kind, shader module name, `@workgroup_size`, entry point, vertex layout digest. | 1 |
|
|
445
|
+
| `TOPO` | Frame-graph **topologies**: pass list, resource node list, edges, scopes, descriptors. Content-hashed and deduplicated across frames (§5.4). | 0..n |
|
|
446
|
+
| `FRAM` | One per frame: topology id, CPU timestamps, span array, dispatch/draw array, counters. | 0..n |
|
|
447
|
+
| `CNTR` | Counter tracks sampled per frame: `gpu_memory_usage`, mesh/instance/light counts, resolution. | 0..1 |
|
|
448
|
+
| `NOTE` | Free-form user annotations with a frame index — "this is where it hitches". | 0..n |
|
|
449
|
+
| `DIRE` | Directory: `{chunk_type, offset, byte_length}` plus a frame index of `{frame_number, chunk_offset, gpu_duration_ns}` so the inspector can draw the frame-time strip before parsing anything else. | 1 |
|
|
450
|
+
|
|
451
|
+
Unknown chunk types are skipped by length. That is what makes level-3 payloads addable without a
|
|
452
|
+
version bump, and what lets an old inspector open a new capture and say honestly which parts it
|
|
453
|
+
cannot show.
|
|
454
|
+
|
|
455
|
+
### 5.4 The compression that matters: topology deduplication
|
|
456
|
+
|
|
457
|
+
**A Shade frame graph is nearly identical frame to frame.** Same passes, same resources, same edges;
|
|
458
|
+
what changes is the timings, the cull decisions, and the occasional resolution change. Recording the
|
|
459
|
+
full topology 600 times is the difference between a 20 MB file and a 1.5 MB one.
|
|
460
|
+
|
|
461
|
+
So: hash the recorded topology (pass names, edges, descriptors, scope chain). If the hash matches a
|
|
462
|
+
`TOPO` already written, the frame stores only the topology id. Cull state and per-pass timings stay
|
|
463
|
+
in `FRAM`, because they are exactly what varies.
|
|
464
|
+
|
|
465
|
+
Expected behaviour on a real capture: a handful of distinct topologies over 600 frames — steady
|
|
466
|
+
state, plus the shadow-refresh variants, plus resolution changes. §4.1's "~2 KB amortised" for level
|
|
467
|
+
1 is that claim.
|
|
468
|
+
|
|
469
|
+
This must be **measured, not assumed**. If topologies turn out to churn every frame, the design
|
|
470
|
+
still works (it degrades to storing each), but the size estimates in §5.1 do not. First milestone
|
|
471
|
+
work item, §8.
|
|
472
|
+
|
|
473
|
+
### 5.5 Per-frame span encoding
|
|
474
|
+
|
|
475
|
+
Per span, level 0:
|
|
476
|
+
|
|
477
|
+
| Field | Type | Note |
|
|
478
|
+
|---|---|---|
|
|
479
|
+
| `pass_ref` | `uintVar` | index into the topology's GPU-pass list |
|
|
480
|
+
| `t_begin` | `u32` | ns offset from the frame's `gpu_epoch_ns` |
|
|
481
|
+
| `t_end_delta` | `uintVar` | ns from `t_begin` |
|
|
482
|
+
| `query_set_id` | `u8` | §2.4 |
|
|
483
|
+
|
|
484
|
+
`u32` for the frame-relative begin holds 4.29 s — three orders of magnitude of headroom over a
|
|
485
|
+
frame, and it survives a stall without overflowing. `BinaryBuffer.writeUintVar` / `readUintVar`
|
|
486
|
+
already exist and handle the two variable-length fields.
|
|
487
|
+
|
|
488
|
+
That is ~10 bytes per span against 26 for a naive absolute-u64 encoding, and the frame's absolute
|
|
489
|
+
epoch is stored once as a `u64`.
|
|
490
|
+
|
|
491
|
+
### 5.6 Chrome Trace Event export
|
|
492
|
+
|
|
493
|
+
The inspector exports the loaded capture as Chrome Trace Event JSON, for opening in
|
|
494
|
+
[ui.perfetto.dev](https://perfetto.dev/docs/getting-started/other-formats). Costs an afternoon and
|
|
495
|
+
buys: a second opinion when the inspector looks wrong, a viewer for anyone unwilling to run ours, and
|
|
496
|
+
a sanity check on our own timeline maths. Passes become `X` slices on a GPU track, scopes become
|
|
497
|
+
nesting, counters become `C` events. Lossy — the dependency graph has no representation there — which
|
|
498
|
+
is precisely why it is an export and not the storage format.
|
|
499
|
+
|
|
500
|
+
### 5.7 String encoding
|
|
501
|
+
|
|
502
|
+
Symbols live in `SYMS` blocks with u32 indices, emitted inside the record that first needs them
|
|
503
|
+
(§5.8). Not `EncodingBinaryBuffer`: it deduplicates by writing back-references to **absolute buffer
|
|
504
|
+
positions** ([EncodingBinaryBuffer.js:21](src/core/binary/EncodingBinaryBuffer.js:21)), which is
|
|
505
|
+
correct for a single flat buffer and wrong the moment records are skipped by a reader that does not
|
|
506
|
+
understand them, resynchronised after corruption, or read from a truncated file — all three of which
|
|
507
|
+
this format is explicitly built to survive. An index table costs one indirection and holds up under
|
|
508
|
+
all of them.
|
|
509
|
+
|
|
510
|
+
### 5.8 Streaming: self-contained frame records
|
|
511
|
+
|
|
512
|
+
The session is an **open-ended forward stream with an explicit stop**. No ring, no cap: `frame_limit`
|
|
513
|
+
defaults to `Infinity`, `stop()` ends it early, and everything recorded is kept.
|
|
514
|
+
|
|
515
|
+
**A frame is written as one complete, self-describing record and pushed when it closes.** That is
|
|
516
|
+
the organising decision, and three properties follow from it:
|
|
517
|
+
|
|
518
|
+
- **It is resynchronisable.** Every record opens with a sync marker, its type, its payload length and
|
|
519
|
+
a checksum. A reader that lands on garbage scans forward for the next marker and carries on. A
|
|
520
|
+
capture cut off mid-session — tab killed, GPU reset, `device.lost` — stays readable up to the last
|
|
521
|
+
intact record, and those are exactly the captures worth having.
|
|
522
|
+
- **Symbols travel with the record that introduces them.** A record carrying a new topology carries
|
|
523
|
+
the names that topology needs; a frame record reusing a known topology carries none. There is no
|
|
524
|
+
global string table to finalise, which is what would otherwise force a tail chunk and make a
|
|
525
|
+
truncated file unreadable — the failure mode where the one capture of the crash resolves no names.
|
|
526
|
+
- **Nothing is back-patched except the header's directory pointer**, and even that is optional: a
|
|
527
|
+
reader can recover the whole stream by scanning records when the directory is missing or the file
|
|
528
|
+
was truncated before `stop()` ran.
|
|
529
|
+
|
|
530
|
+
Order on the wire:
|
|
531
|
+
|
|
532
|
+
```
|
|
533
|
+
header magic, versions, flags; directory_offset patched at stop, 0 if never stopped
|
|
534
|
+
META at start — adapter, engine version, renderer settings, level
|
|
535
|
+
TOPO #0 + its symbols first frame's topology
|
|
536
|
+
FRAM #0 topology id + spans + counts
|
|
537
|
+
FRAM #1 same topology → id only
|
|
538
|
+
...
|
|
539
|
+
TOPO #1 + its symbols shadow refresh changed the graph
|
|
540
|
+
FRAM #57
|
|
541
|
+
...
|
|
542
|
+
CNTR, DIRE at stop — the directory is an index, not a dependency
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
Record framing, every record identical:
|
|
546
|
+
|
|
547
|
+
```
|
|
548
|
+
0 4 sync u32 0x43455253 ('SREC')
|
|
549
|
+
4 4 record_type u32 FourCC
|
|
550
|
+
8 4 payload_byte_length u32
|
|
551
|
+
12 4 payload_checksum u32 crc32 over the payload
|
|
552
|
+
16 ... payload
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
u32 for the length rather than u64: a record describes one frame's control flow, and resource
|
|
556
|
+
*contents* are a non-goal, so nothing in one scales with the size of what it describes. Four
|
|
557
|
+
gigabytes is not a ceiling anything can approach.
|
|
558
|
+
|
|
559
|
+
**The sync marker alone is not enough to resynchronise on**, and the reader does not treat it as
|
|
560
|
+
though it were. Four bytes of payload can spell `SREC` — a pass label could — so a candidate counts
|
|
561
|
+
only when its length also fits and its payload also checksums. There is a spec for exactly that
|
|
562
|
+
case.
|
|
563
|
+
|
|
564
|
+
**Reallocation is a non-issue, and the slack reservation settles what is left of it.** We are
|
|
565
|
+
measuring GPU time, not CPU time; a `setCapacity` copy is a heap allocation and a memcpy that may
|
|
566
|
+
evict some cache, which at worst makes the next GPU upload marginally slower. That is a rounding
|
|
567
|
+
error against what is being measured. To keep even that out of the frame interior, the writer
|
|
568
|
+
reserves at the frame boundary:
|
|
569
|
+
|
|
570
|
+
```js
|
|
571
|
+
buffer.ensureCapacity(buffer.position + FRAME_SLACK); // FRAME_SLACK = 1 MiB
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
Any growth then happens between frames, never inside a record. 1 MiB against level 2's ~6 KB per
|
|
575
|
+
frame is three orders of magnitude of headroom, so the reservation only actually forces a grow once
|
|
576
|
+
every ~170 frames. One `BinaryBuffer`, no segmentation, no assembly pass.
|
|
577
|
+
|
|
578
|
+
**Scope note, and it is what makes the above generous rather than marginal: GPU buffer and texture
|
|
579
|
+
contents are a non-goal.** The stream carries control flow and dataflow metadata — passes, edges,
|
|
580
|
+
descriptors, counts, timings. Nothing in it scales with the size of the resources it describes. That
|
|
581
|
+
is why a frame record is kilobytes and why 1 MiB of slack is never the binding constraint.
|
|
582
|
+
|
|
583
|
+
**Uncapped still means uncapped, so the session stays legible about it.** `bytes_written` is readable
|
|
584
|
+
at any time and `onBytesWritten` fires per frame, so an application can show a counter. A configurable
|
|
585
|
+
`byte_budget` — default 512 MB — does not stop the recording; it warns once, naming the level and the
|
|
586
|
+
observed rate. Silent unbounded growth in a debug tool is how you lose a browser tab and the capture
|
|
587
|
+
with it.
|
|
588
|
+
|
|
589
|
+
---
|
|
590
|
+
|
|
591
|
+
## 6. The recorder
|
|
592
|
+
|
|
593
|
+
### 6.1 Surface — the caller owns the session
|
|
594
|
+
|
|
595
|
+
**The engine never constructs a profile session.** The caller builds one and hands it in; the
|
|
596
|
+
renderer holds a nullable reference and nothing more. Nothing in `Renderer` imports the profiler.
|
|
597
|
+
|
|
598
|
+
```js
|
|
599
|
+
import { GPUProfileSession } from "@woosh/meep-engine/src/shade/device/timing/profile/GPUProfileSession.js";
|
|
600
|
+
import { GPUProfileLevel } from "@woosh/meep-engine/src/shade/device/timing/profile/GPUProfileLevel.js";
|
|
601
|
+
|
|
602
|
+
const session = new GPUProfileSession({
|
|
603
|
+
level: GPUProfileLevel.WORKLOAD,
|
|
604
|
+
frame_limit: Infinity, // default; a number caps it
|
|
605
|
+
note: "hitch on shadow refresh, RTX 3070"
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
renderer.profile_session = session; // nullable field, that is the whole API
|
|
609
|
+
|
|
610
|
+
session.start(); // META is written here; populate meta first
|
|
611
|
+
// ... frames run, for as long as you like ...
|
|
612
|
+
const bytes = await session.stop(); // ArrayBuffer, ready to save
|
|
613
|
+
|
|
614
|
+
renderer.profile_session = null;
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
Three things fall out of the caller owning it, and all three are why this is the right shape:
|
|
618
|
+
|
|
619
|
+
- **It is genuinely optional.** The profiler is a leaf module nothing in the engine imports. An
|
|
620
|
+
application that never imports `GPUProfileSession` does not have it in its bundle — the answer to
|
|
621
|
+
"does this ship in production builds" is *it ships, and it costs nothing to anyone who does not ask
|
|
622
|
+
for it*. No build flag, no strip-plugin interaction, no dead-code branch to keep honest.
|
|
623
|
+
- **Lifetime is explicit.** A session that outlives a device, or two sessions at once, are the
|
|
624
|
+
caller's problem to not create, and `start()` asserts against both rather than papering over them.
|
|
625
|
+
- **The engine surface is one nullable field.** `Renderer.profile_session`, forwarded to the
|
|
626
|
+
`GraphicsContext` so command contexts can find it. That is the entire integration.
|
|
627
|
+
|
|
628
|
+
`frame_limit` reaching zero stops the session exactly as `stop()` does. Both resolve the same
|
|
629
|
+
promise, so a caller that wants "500 frames or until I say" writes one `await`.
|
|
630
|
+
|
|
631
|
+
`add_debug_frame` and `onFrameDebug` stay exactly as they are — cheap, synchronous, console-shaped,
|
|
632
|
+
and a different tool for a different question.
|
|
633
|
+
|
|
634
|
+
### 6.2 The five hooks
|
|
635
|
+
|
|
636
|
+
1. **`FrameGraph.execute`** — bracket `node.execute(...)`. Notify listeners which graph pass is open;
|
|
637
|
+
take CPU timestamps either side; push/pop a debug group. The only edit outside `src/shade/`.
|
|
638
|
+
|
|
639
|
+
Two `Signal`s on `FrameGraph`, `onPassBegin` / `onPassEnd`, alongside the `onExecuted` that is
|
|
640
|
+
already there. **Signal, not a nullable callback field** — it is the project's standardised
|
|
641
|
+
observer interface, it supports more than one listener, and `remove` is symmetric with `add`.
|
|
642
|
+
A bare nullable callback lets the second consumer silently clobber the first, which is exactly
|
|
643
|
+
the bug that does not announce itself.
|
|
644
|
+
|
|
645
|
+
Guard the dispatch with `hasHandlers()`: `send1` on an empty signal still bumps `generation` and
|
|
646
|
+
walks a Map iterator, and this fires twice per pass — a couple of hundred passes a frame. One
|
|
647
|
+
`Map.size` comparison ahead of it keeps the disabled path honest.
|
|
648
|
+
|
|
649
|
+
`FrameGraph` still learns nothing about what a profiler is; it announces its own pass boundaries
|
|
650
|
+
and the profiler is one possible listener.
|
|
651
|
+
2. **`ShadeGPUCommandContext`** — a `#profile_sink` field. When set, `beginComputePass` /
|
|
652
|
+
`beginRenderPass` report `{label, kind, graph_pass_id, query_slot, query_set_id}` and wrap the
|
|
653
|
+
returned encoder in the recording proxy.
|
|
654
|
+
3. **The proxy encoders** — `ProfilingComputePassEncoder`, `ProfilingRenderPassEncoder`. Forward
|
|
655
|
+
everything; record `dispatchWorkgroups*`, `draw*`, `setPipeline`, `setBindGroup`. Modelled on
|
|
656
|
+
`SoftwareGPUComputePassEncoder`, which already records exactly this shape.
|
|
657
|
+
4. **`GPUTimerArray`** — pooling (§1.2.2), bound checking (§1.2.1), and expose raw slot data rather
|
|
658
|
+
than only the console table.
|
|
659
|
+
5. **`GraphicsContext`** — sample `gpu_memory_usage` and the collection counters once per frame into
|
|
660
|
+
the counter track.
|
|
661
|
+
|
|
662
|
+
### 6.3 Cost when off
|
|
663
|
+
|
|
664
|
+
Every hook is a null check against a field that is `null` in normal operation. No allocation and no
|
|
665
|
+
proxy construction; the frame-graph bracket is two comparisons per pass. This must stay true — a
|
|
666
|
+
profiler that costs something when disabled will be disabled at the build level and then rot.
|
|
667
|
+
|
|
668
|
+
Because the session is caller-constructed (§6.1), an application that never imports it pays not even
|
|
669
|
+
that: the profiler modules are unreachable from any engine entry point and drop out of the bundle
|
|
670
|
+
entirely. The null checks are the only residue, and they are the price of the feature existing.
|
|
671
|
+
|
|
672
|
+
### 6.4 Cost when on
|
|
673
|
+
|
|
674
|
+
Level 0–2 add: one `performance.now()` pair per graph pass, one small record per GPU pass, one per
|
|
675
|
+
dispatch/draw, and a `push`/`popDebugGroup` pair per graph pass. The existing per-context query set
|
|
676
|
+
churn (§1.2.2) is the largest cost and the pool removes it. Expect single-digit percent frame-time
|
|
677
|
+
overhead at level 2; measure it and record the measurement in `META`, so a reader can see how much of
|
|
678
|
+
what they are looking at is the observer.
|
|
679
|
+
|
|
680
|
+
---
|
|
681
|
+
|
|
682
|
+
## 7. The inspector
|
|
683
|
+
|
|
684
|
+
`packages/gpu-inspector-tool/`. A static site: drop a `.sgpt` on it, or pass `?file=` for a
|
|
685
|
+
bookmarkable view — the affordance `prototypeVGEOFormatViewer` already established in this codebase.
|
|
686
|
+
|
|
687
|
+
### 7.1 Technology
|
|
688
|
+
|
|
689
|
+
**Plain ES modules, Canvas 2D for the timeline, DOM for panels, no runtime dependencies, built with
|
|
690
|
+
Vite.** Reasons: the repo has no UI framework and adding one for this is unjustified; the timeline is
|
|
691
|
+
a custom-drawn virtualised widget that a framework would only get in the way of; zero dependencies
|
|
692
|
+
keeps a separately published proprietary artifact simple to reason about; and Vite is already the dev
|
|
693
|
+
server here.
|
|
694
|
+
|
|
695
|
+
The only imports from the engine tree are `src/core/binary/BinaryBuffer.js` and the `sgpt_*` readers.
|
|
696
|
+
That boundary is a build-time assertion, not a convention — a lint rule that fails the build on any
|
|
697
|
+
other engine import.
|
|
698
|
+
|
|
699
|
+
### 7.2 Views
|
|
700
|
+
|
|
701
|
+
| View | Answers |
|
|
702
|
+
|---|---|
|
|
703
|
+
| **Frame strip** | Which frame is interesting. Frame time over the session, GPU and CPU overlaid, hitches marked, brush to select a range. Drawn from the directory index alone, so it appears before the payload finishes parsing. |
|
|
704
|
+
| **Timeline / flame graph** | Where the time went in *this* frame. Spans on a GPU track, nested by `FrameGraphScope`; a CPU track above with encode time; hover for exact ns; click to select. |
|
|
705
|
+
| **Statistics** | Where the time goes *in general*. Per-pass min/median/p95/max/total across the selected frame range, sorted by total contribution. **On a quantized capture this is the only honest view** — and since the tool does not measure quantization (§2.1), it cannot detect that case and switch by itself. It says so plainly instead, always. |
|
|
706
|
+
| **Dependency graph** | Why this pass runs, and what it waits on. Passes and resource nodes, culled ones greyed, edges directed. Select a pass → highlight its transitive inputs. Select a resource → its version chain and every reader. |
|
|
707
|
+
| **Resource table** | What memory costs. Every resource node with declared bytes, format, usage, transient/imported, lifetime span, peak concurrent footprint. Sorted by size. Declared total vs `gpu_memory_usage` side by side. |
|
|
708
|
+
| **Pass detail** | Everything about one pass. Timings across frames as a sparkline, dispatch/draw counts, derived total invocations, pipeline and workgroup size, attachments, bindings at level 3. |
|
|
709
|
+
| **Frame comparison** | What changed. Two frames or two ranges side by side, per-pass deltas sorted by regression. This is the view that makes the tool useful for optimisation work rather than only for diagnosis. |
|
|
710
|
+
|
|
711
|
+
### 7.3 What it must refuse to do
|
|
712
|
+
|
|
713
|
+
- **Never invent precision the data does not have.** Durations are drawn as reported. Where many
|
|
714
|
+
spans read as exactly zero, that is shown as what it is — a quantized capture — with a note
|
|
715
|
+
naming the browser flag, not smoothed into plausible-looking small numbers.
|
|
716
|
+
- **Never present the CPU and GPU tracks as one clock** (§2.3). Two tracks, anchored per frame,
|
|
717
|
+
labelled as nominal.
|
|
718
|
+
- **Never hide dropped spans.** If the recorder dropped passes on slot exhaustion (§1.2.1), say how
|
|
719
|
+
many, on the frame that dropped them.
|
|
720
|
+
|
|
721
|
+
---
|
|
722
|
+
|
|
723
|
+
## 8. Phasing
|
|
724
|
+
|
|
725
|
+
Each milestone is independently useful and independently shippable.
|
|
726
|
+
|
|
727
|
+
### M0 — Measure the assumptions (½ day)
|
|
728
|
+
|
|
729
|
+
Before any of the below. Instrument one Sponza capture and answer three questions, because three
|
|
730
|
+
size estimates and one whole design decision rest on them:
|
|
731
|
+
|
|
732
|
+
1. How many distinct frame-graph topologies over 600 frames? (§5.4)
|
|
733
|
+
2. ~~What is the observed timestamp period~~ — dropped; the tool does not measure this (§2.1).
|
|
734
|
+
3. How many GPU passes per frame, actually? (`GPUTimerArray` default is 1024 slots; §1.2.1)
|
|
735
|
+
|
|
736
|
+
Write the answers into this document.
|
|
737
|
+
|
|
738
|
+
### M0.5 — Workspace restructure — **DONE**
|
|
739
|
+
|
|
740
|
+
Landed 2026-08-29. `packages/meep-engine/` holds the engine, the workspace root holds the two
|
|
741
|
+
`.gitignore` halves, the CI paths and a README. Suite green at 2156 files / 14580 tests. One spec
|
|
742
|
+
had to move with it: `meep_three_free.spec.js` asserts the `*.d.ts` ignore rule at the engine root,
|
|
743
|
+
so that rule lives in the package's `.gitignore` rather than the workspace's.
|
|
744
|
+
|
|
745
|
+
**`moh` still needs its vendoring re-pointed one level deeper** — mount `packages/meep-engine` where
|
|
746
|
+
it currently mounts the repository root, and every path inside it stays byte-identical.
|
|
747
|
+
|
|
748
|
+
<details><summary>Original plan</summary>
|
|
749
|
+
|
|
750
|
+
§4.2. Independent of everything else and worth landing first so no profiler work has to be moved
|
|
751
|
+
afterwards. Order: create `packages/meep-engine/`, `git mv` the tree, fix the five config files,
|
|
752
|
+
green the suite, re-point `moh`'s vendoring one level deeper, green `moh`. Land as its own commit —
|
|
753
|
+
a pure move with no content changes, so the diff stays reviewable and a bisect through it is honest.
|
|
754
|
+
|
|
755
|
+
</details>
|
|
756
|
+
|
|
757
|
+
### M1 — Timing spine — **DONE**
|
|
758
|
+
|
|
759
|
+
Landed:
|
|
760
|
+
|
|
761
|
+
- `FrameGraph.onPassBegin` / `onPassEnd`, guarded by `hasHandlers()`, closed in a `finally` so a
|
|
762
|
+
throwing pass still ends its bracket. Five specs including the exception path.
|
|
763
|
+
- `GPUTimerArray`: bound check (a full array now refuses a slot instead of addressing past its query
|
|
764
|
+
set), `dropped_count`, `traverse_results` for raw `BigInt` timestamps. Seven specs.
|
|
765
|
+
- `ShadeGPUCommandContext`: `#with_timestamp_writes` — copies the descriptor instead of stamping the
|
|
766
|
+
caller's, tolerates a missing descriptor, and leaves `timestampWrites` off when no slot is free.
|
|
767
|
+
- The whole `.sgpt` container: header, framing, resync reader, defect model, symbol interning,
|
|
768
|
+
`META`/`SYMS`/`FRAM`/`DIRE` codecs, `GPUProfileSession`, `snapshot()`. 26 specs.
|
|
769
|
+
- `GPUFrameRecorder` — holds the graph-pass ↔ timer-slot join, accumulates across every command
|
|
770
|
+
context in a frame, and rebases spans onto the frame epoch at close.
|
|
771
|
+
|
|
772
|
+
Removed again on 2026-08-29: a `timestamp_period_ns` field and the GCD estimator that filled it.
|
|
773
|
+
See §2.1 — quantization is documented and left alone.
|
|
774
|
+
|
|
775
|
+
Wired end to end: `Renderer.profile_session`, `GPUFrameRecorder` holding the graph-pass ↔ timer-slot
|
|
776
|
+
join, and `ShadeGPUCommandContext.profiling_absorbed` — which exists because `done` resolves at
|
|
777
|
+
submit, before any timestamp has been read back.
|
|
778
|
+
|
|
779
|
+
The calibration step is gone rather than outstanding: see §2.1.
|
|
780
|
+
|
|
781
|
+
<details><summary>Original plan</summary>
|
|
782
|
+
|
|
783
|
+
`GPUTimerArray` pooling and bound checks; `FrameGraph.onPassBegin`/`onPassEnd` and debug groups;
|
|
784
|
+
`GPUProfileSession` at level 0, caller-constructed, streaming framed records with per-frame slack;
|
|
785
|
+
`META`/`SYMS`/`FRAM`/`DIRE` records; round-trip and truncation-recovery tests on `SoftwareGPUDevice`.
|
|
786
|
+
Deliverable: a `.sgpt` with real spans and no viewer.
|
|
787
|
+
|
|
788
|
+
</details>
|
|
789
|
+
|
|
790
|
+
### M2 — Inspector skeleton — **DONE**
|
|
791
|
+
|
|
792
|
+
`packages/gpu-inspector-tool`. Plain ES modules, Canvas 2D, no runtime dependencies. Session strip,
|
|
793
|
+
timeline, statistics, pass detail. `make_demo_capture` builds a synthetic capture through the
|
|
794
|
+
engine's own writer, so the tool works without a GPU and the format's two halves are exercised
|
|
795
|
+
against each other.
|
|
796
|
+
|
|
797
|
+
### M3 — Structure — **DONE**
|
|
798
|
+
|
|
799
|
+
`TOPO` with content-hash deduplication — 50 frames of an unchanged graph come to under 4 KB. Scopes,
|
|
800
|
+
cull state, resource descriptors with footprints computed at record time. The inspector's Structure
|
|
801
|
+
view is two cross-linked tables rather than a node-link diagram: two hundred passes over as many
|
|
802
|
+
resource versions do not lay out into anything readable, and the questions actually asked are local.
|
|
803
|
+
|
|
804
|
+
### M4 — Workload — **DONE**
|
|
805
|
+
|
|
806
|
+
`make_profiling_pass_encoder` is a `Proxy` rather than a hand-written forwarder: a pass encoder has
|
|
807
|
+
around twenty methods and WebGPU keeps adding them, and one silently dropped would break the
|
|
808
|
+
renderer only while profiling. Dispatch and draw counts, pipeline identity, and `@workgroup_size`
|
|
809
|
+
parsed from WGSL where it is a literal — an override expression records as *unknown*, which is not
|
|
810
|
+
the same as zero.
|
|
811
|
+
|
|
812
|
+
No `PIPE` table in the end: a pass's pipeline label and workgroup size ride in its own workload
|
|
813
|
+
block, which costs a symbol reference and avoids a second id space.
|
|
814
|
+
|
|
815
|
+
### M5 — Analysis — **partly done**
|
|
816
|
+
|
|
817
|
+
Statistics view and Chrome Trace Event export are in. Frame comparison and counter tracks are not;
|
|
818
|
+
`CNTR` is reserved in the format for the latter.
|
|
819
|
+
|
|
820
|
+
### M6 — Publish — **partly done**
|
|
821
|
+
|
|
822
|
+
[`SGPT_FORMAT.md`](profile/SGPT_FORMAT.md) is the normative format specification, written for
|
|
823
|
+
somebody outside the company, with a conformance summary for readers and writers. The inspector's
|
|
824
|
+
README covers recording, levels, and the reading caveats.
|
|
825
|
+
|
|
826
|
+
Outstanding: a hosting target for the built site, and deciding the licence the inspector ships
|
|
827
|
+
under.
|
|
828
|
+
|
|
829
|
+
**Not in scope, listed so it stays that way:** buffer/texture content capture, shader source in the
|
|
830
|
+
container, replay, live attach to a running session, anything requiring a browser extension.
|
|
831
|
+
|
|
832
|
+
---
|
|
833
|
+
|
|
834
|
+
## 9. Testing
|
|
835
|
+
|
|
836
|
+
Per the established tiers:
|
|
837
|
+
|
|
838
|
+
| Tier | Covers |
|
|
839
|
+
|---|---|
|
|
840
|
+
| **Unit, node** | Format round-trip: build a synthetic session, encode, decode, assert structural equality. Every chunk. Forward compatibility: a reader skipping an unknown chunk. Truncation and corruption: a bad checksum, a short chunk, a directory pointing past EOF — all must fail with a named error, not a stack trace out of `BinaryBuffer`. |
|
|
841
|
+
| **`SoftwareGPUDevice`** | The recorder end to end without a GPU. The device already emulates `timestamp-query`, query sets and `write_pass_timestamp`, and already refuses a query set over 4096. Encode a frame graph, run a session, decode the output, assert the topology matches what was recorded. This is where the §1.4 attribution logic gets its coverage. |
|
|
842
|
+
| **Playground page** | `src/shade/playground/` gets a capture harness against Sponza, which is also how M0 gets answered. |
|
|
843
|
+
| **Inspector** | Golden captures checked into the package as fixtures. Parse-and-render smoke tests. A capture recorded before a format change must still open — that is what `min_reader_version` is for and it needs a test that proves it. |
|
|
844
|
+
|
|
845
|
+
---
|
|
846
|
+
|
|
847
|
+
## 10. Risks
|
|
848
|
+
|
|
849
|
+
| Risk | Severity | Handling |
|
|
850
|
+
|---|---|---|
|
|
851
|
+
| **Timestamp quantization makes per-frame timings unreadable on default browsers** (§2.1) | **High, and deliberately untreated** | Documented, not measured and not corrected — measuring it is the timing attack the mitigation prevents, and measuring it badly skews everything. The inspector names the flag and steers toward cross-frame aggregation, which is the honest reading of a coarse capture. |
|
|
852
|
+
| Topology dedup does not pay off | Medium | M0 measures it. Design degrades gracefully; the size claims do not. |
|
|
853
|
+
| Proxy encoder overhead distorts what it measures | Medium | Level-gate it; record measured overhead in `META`; forward-only methods, no allocation per call. |
|
|
854
|
+
| One `GPUTimerArray` per context means several query sets per frame (§2.4) | Low–Medium | Record `query_set_id`. Consider a per-frame shared array as a follow-up, which would also simplify pooling. |
|
|
855
|
+
| Format churn during development invalidates captures | Low | `min_reader_version` from day one; the inspector reads every version it ever supported; fixtures in the test suite. |
|
|
856
|
+
| Publishing a proprietary-engine tool separately | Low, but real | The §4 rule-1 boundary is what makes this tractable. Enforce it in the build. Confirm the licensing intent for the published inspector before M6. |
|
|
857
|
+
| **Uncapped session exhausts memory on a long level-3 capture** (§4.1, §5.8) | Medium | `bytes_written` readable and signalled; a `byte_budget` that warns rather than truncates. Accepted deliberately — full history is the point, and buffer/texture contents are a non-goal so nothing scales with resource size. |
|
|
858
|
+
| Workspace restructure churns `moh` (§4.2) | Medium | Re-point the vendoring one level deeper so every `moh` path stays identical. Land as a pure move, separately. |
|
|
859
|
+
|
|
860
|
+
## 11. Decisions taken — 2026-08-29
|
|
861
|
+
|
|
862
|
+
| # | Question | Decision | Where it lives |
|
|
863
|
+
|---|---|---|---|
|
|
864
|
+
| 1 | Monorepo or not | **npm workspaces, and the existing tree moves to conform.** `packages/meep-engine/` + `packages/gpu-inspector-tool/`, symmetric siblings. | §4.2, M0.5 |
|
|
865
|
+
| 2 | Does the recorder ship in production? | **Yes, but optional — the caller instantiates a `GPUProfileSession` and passes it in.** The engine never constructs one, so an application that does not import it does not carry it. | §6.1, §6.3 |
|
|
866
|
+
| 3 | The `FrameGraph.execute` bracket | **Agreed, kept minimal — via `Signal`.** `onPassBegin` / `onPassEnd` beside the existing `onExecuted`, dispatch guarded by `hasHandlers()`. `Signal` is the project's standardised observer interface and a nullable callback field would let a second consumer silently clobber the first. | §1.4, §6.2 hook 1 |
|
|
867
|
+
| 4 | Recording length policy | **Open-ended forward stream of self-contained frame records. `frame_limit` of N (1..∞) with an explicit `stop()`.** No ring buffer — full, uncapped, explicit history is the desired behaviour. Records are self-describing and checksummed, so a truncated capture stays readable; 1 MiB of slack reserved per frame keeps reallocation out of the record interior. | §5.8 |
|
|
868
|
+
|
|
869
|
+
Two consequences of (4) worth carrying forward:
|
|
870
|
+
|
|
871
|
+
- **There is no global string table.** Symbols are emitted inside the record that first needs them
|
|
872
|
+
(`SYMS`, §5.3), not gathered into a `STRS` chunk. A tail table would have made a truncated capture
|
|
873
|
+
resolve no names at all — the failure mode that hits precisely the capture of the crash you were
|
|
874
|
+
trying to record.
|
|
875
|
+
- **Records are framed and checksummed** so a reader can resynchronise. This is what buys corruption
|
|
876
|
+
and truncation resilience, and it costs 20 bytes per frame.
|