-
Performance Optimizations (GC & WebGPU loops):
- Review
src/viewWebGPU.tsfocusing onrenderPlayfild_WebGPU. The methodrenderPlayfild_WebGPUusesMatrix.mat4.translate(this.MODELMATRIX, this.MODELMATRIX, [colom * 2.2, row * -2.2, 0.0]);which creates a new array every loop iteration. I will modify this to usethis._f32_3to pre-allocate[colom * 2.2, row * -2.2, 0.0]. - I will do the same optimization for
renderPlayfild_Border_WebGPUwhere[colom * 2.2 - 2.2, row * -2.2 + 2.2, 0.0]is created. - Refactor
renderinsrc/viewWebGPU.tsto cache WebGPU render pass descriptors (backgroundPassDescriptor,renderPassDescription,ppPassDescriptor) instead of recreating them on every frame, significantly reducing garbage collection. - I will do the same optimization in
renderwhereMatrix.mat4.lookAt(this.VIEWMATRIX, [camX, camY, camZ], [9.0, -20.0, 0.0], [0.0, 1.0, 0.0]);allocates new arrays. I will use preallocated class fields. - Run
npm run build:allto verify compilation.
- Review
-
Graphical Performance (Shader Math):
- I will optimize the
pow(x, 4.0)calculations inside theShadersfragment insrc/webgpu/shaders.ts. There are multiple lines usingpow(x, 4.0), such aspow(max(0.0, 1.0 - dotNV * (1.0 - dispersion * 0.5)), 4.0)andpow(1.0 - max(dot(N, V), 0.0), 4.0). I will replacepow(val, 4.0)with multiplication(val * val) * (val * val)or similar avoiding the expensivepowfunction. - Run
npm run build:allto verify compilation.
- I will optimize the
-
Playability & Game Feel (Jump-Buffer & Controller):
- In
src/controller.ts, I will adjust theBUFFER_WINDOWto be shorter to make rotation buffering feel snappier. I will change it from150to80. - In
src/controller.ts, I will optimize integer division in the soft drop logic by replacingMath.floor(this.actionTimers.down! / SOFT_DROP_SPEED)with(this.actionTimers.down! / SOFT_DROP_SPEED) | 0. - In
src/controller.ts, I will updateactionTimersinitialization to include allActionkeys to avoid optional key checks. - Run
npm run build:allto verify compilation.
- In
-
Testing & Verification:
- Run the test suite via
npm testin the terminal usingrun_in_bash_sessionto ensure no logic regressions occurred.
- Run the test suite via
-
Pre-commit Steps:
- Complete pre-commit steps to ensure proper testing, verification, review, and reflection are done.
-
Submit Code:
- Once all tests pass and pre-commit checks are green, submit the changes with a concise commit message.