refactor(gpu): eliminar GPU compute boids (prevé crash macOS)

Elimina el kernel Metal O(N²) de boids en GPU que causava GPU timeout
a macOS amb >50K boles, arrossegant WindowServer fins al crash.

- Elimina gpu_boid_buffer.hpp/cpp (GpuBoidBuffer, BallComputeData, BoidParams)
- Elimina kBoidComputeMSL i kBallComputeVertMSL de gpu_pipeline
- Elimina boid_compute_pipeline_ i ball_compute_pipeline_
- Elimina use_gpu_boids_, boid_params_, ball_screen_uniforms_ de Engine
- Elimina syncAndExitGpuBoids() i tot el compute dispatch de render()
- Mode BOIDS ara usa sempre boid_manager_ (CPU, spatial hash O(N))
  i renderitza via gpu_ball_buffer_ instanced (mateix path que PHYSICS)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-20 08:45:01 +01:00
parent badf92420b
commit d2e7f2ff86
8 changed files with 321 additions and 41 deletions

View File

@@ -16,6 +16,7 @@
#include "boids_mgr/boid_manager.hpp" // for BoidManager
#include "defines.hpp" // for GravityDirection, ColorTheme, ShapeType
#include "external/texture.hpp" // for Texture
#include "gpu/gpu_ball_buffer.hpp" // for GpuBallBuffer, BallGPUData
#include "gpu/gpu_context.hpp" // for GpuContext
#include "gpu/gpu_pipeline.hpp" // for GpuPipeline
#include "gpu/gpu_sprite_batch.hpp" // for GpuSpriteBatch
@@ -137,8 +138,10 @@ class Engine {
// === SDL_GPU rendering pipeline ===
std::unique_ptr<GpuContext> gpu_ctx_; // Device + swapchain
std::unique_ptr<GpuPipeline> gpu_pipeline_; // Sprite + postfx pipelines
std::unique_ptr<GpuSpriteBatch> sprite_batch_; // Per-frame vertex/index batch
std::unique_ptr<GpuPipeline> gpu_pipeline_; // Sprite + ball + postfx pipelines
std::unique_ptr<GpuSpriteBatch> sprite_batch_; // Per-frame vertex/index batch (bg + shape + UI)
std::unique_ptr<GpuBallBuffer> gpu_ball_buffer_; // Instanced ball instance data (PHYSICS/BOIDS)
std::vector<BallGPUData> ball_gpu_data_; // CPU-side staging vector (reused each frame)
std::unique_ptr<GpuTexture> offscreen_tex_; // Offscreen render target (Pass 1)
std::unique_ptr<GpuTexture> white_tex_; // 1×1 white (background gradient)
std::unique_ptr<GpuTexture> ui_tex_; // UI text overlay texture
@@ -246,4 +249,5 @@ class Engine {
void recreateOffscreenTexture(); // Recreate when resolution changes
void renderUIToSurface(); // Render text/UI to ui_surface_
void uploadUISurface(SDL_GPUCommandBuffer* cmd_buf); // Upload ui_surface_ → ui_tex_
};