Files
MapLibreParticleLab/docs/50_Step记录/STEP-044_Android_OpenGL粒子数量容量基线_v2.md
OpenAI Codex a0aae48ec8
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
feat: draw all raster particle states
2026-09-03 15:04:05 +08:00

3.0 KiB
Raw Permalink Blame History

STEP-044 Android OpenGL 粒子数量容量基线 v2

  • 状态:IMPLEMENTED / WAITING FOR ANDROID VALIDATION
  • 基线:c0d1ad43c49ed6d526c3fd8b982c04840326d0d0 的容量档位实现。
  • 范围:补齐正式 RasterParticle 的 full particle draw;不是新 Step,也不是容量结论或性能优化。

v1 的实际缺口

v1 已让 State A/B 容量随 raster-particle-particle-count 改为 256 至 1,048,576,但 Trail fragment 只读取四个固定 State UV。因此当时只能证明 N 个 State 同时 simulation,不能证明 N 个粒子同时 Trail/render/composite;Android 容量验收据此暂停。

v2 补齐

  • effectiveParticleCount=N -> State N -> Trail draw N -> Composite 已进入唯一正式 RasterArraySource -> RasterParticleLayer -> RenderRasterParticleLayer 链。
  • 每个粒子在 State A/B 中对应一条静态 GPU vertex:particleIndex -> x=index%stateGridWidth, y=index/stateGridWidth。vertex buffer 仅在 resource create 或 particle-count change 重建;顶点 shader 用 (x+0.5,y+0.5)/stateGrid 采样当前 State write texture,位置从未 CPU 生成或 readback。
  • Trail write target 先由全屏 Trail fade quad 消费前一 Trail,再追加 full point draw。每粒子一个 point,trailDrawCount=N;Composite 继续消费同一 Trail A/B write target。
  • 现有 16-bit index 路径每 segment 最多 65,536 points;更高 count(包括 1M)被分为多个 segment,仍使用同一 static index buffer、同一 shader 和同一 State texture,非第二 simulation。
  • legacy ParticleValidationLayer 仍保留四个 deterministic sample 诊断;正式 RasterParticle Layer 的路径不再使用它们作为 draw 数量限制。

生命周期与冻结语义

  • particle-count change 继续只触发合理的 State A/B 和 full-draw resource rebuild,以及 SIMULATION_RESET reason=PARTICLE_COUNT_CHANGE / reseed。
  • Field T0/T1、MIX、interpolation、Field reuse、mask、A/B→B/C 及既有 State/Trail ping-pong 没有改变。MIX 仍不能导致 draw resource rebuild、Style reload、Field upload 或 reset。
  • State seed 仍是每个 State texel 的 v_uv,所以 full draw 的首次 256/1K 粒子已经 deterministic 地分布在完整 grid,而非重叠于一个点。

观测日志

资源 create/rebuild/release 日志含 effectiveParticleCount、stateGrid、trailDrawCount、particleIndexCount、fullParticleDraw=true 和 resourceGeneration。PARTICLE_DRAW_REJECTED 明确报告缺失 draw resource 或 drawable finalize failure。

待 Android 验收

用例 要求 状态
T-FULL-01 256:16x16、trailDrawCount=256、明显粒子群并持续运动 待测
T-FULL-02 1K:32x32、trailDrawCount=1024、密度明显大于 256、Trail/Composite 正常 待测
T-FULL-03 256→1K→256:draw count 同步变化,无 crash、Style reload、Field upload 或 MIX 改变 待测

只有 T-FULL-01~03 通过,才恢复 4K / 16K / 64K / 1M 的容量矩阵。Codex 未运行 Android Gradle、ADB、安装或设备测试;未加入 Jest。