# FikoYT 3D CAD Motoru - GPU Compute Entegrasyon Plani

**Tarih:** 2026-03-13
**Durum:** Taslak
**Hedef:** WebGL2 GPGPU optimizasyonu + WebGPU Compute migration + Full GPU-driven pipeline

---

## 1. Mevcut Durum Analizi

### 1.1 WebGL2 GPGPU (FikoScopedGPUCompute)

**Dosya:** `src/service/fikoyt-ui/src/lib/fiko-three-js/fiko-scoped/FikoScopedGPUCompute.ts`

Mevcut durum: Iskelet implementasyon. GPU availability kontrolu yapiliyor (WebGL2 + EXT_color_buffer_float) ancak tum metodlar CPU fallback donduruyor:

| Metod | Durum | Notlar |
|---|---|---|
| `computeBoundingBoxes()` | CPU fallback | `Box3.applyMatrix4` ile |
| `computeFrustumCulling()` | CPU fallback | `Frustum.intersectsSphere` ile |
| `sortMeshesByDepth()` | CPU fallback | `distanceToSquared` sort |
| `gpuPick()` | Bos (null) | ID-encoded rendering gerekli |
| `queryOcclusion()` | CPU fallback | Her sey visible dondurulur |

**Altyapi hazir:** RenderTarget olusturma, scope-based lifecycle, dispose pattern.
**Eksik:** Shader programlari, transform feedback, float texture encode/decode.

### 1.2 WebGPU Compute (SPH Sivi Simulasyonu)

**Dosya:** `src/service/fikoyt-ui/src/lib/fiko-three-js/IFikoThreeJS/fiko-sph-sivi/gpu/FikoSPHGPUHesap.ts`

Olgun WebGPU compute pipeline:
- `GPUDevice` / `GPUBuffer` / `GPUBindGroup` / `GPUComputePipeline` kullanimi
- Storage buffer, uniform buffer, indirect dispatch
- Sensor readback (`mapAsync` + staging buffer)
- Grid spatial hashing (8 pass pipeline: clear -> count -> prefix sum -> scatter)
- Solver: PBF, PCISPH, DFSPH destek
- WGSL shader'lar `.wgsl.ts` dosyalarinda inline string olarak

**Mevcut WGSL shader'lar (17 adet):**
- `sph-ortak-shaders.wgsl.ts` - Ortak struct ve kernel fonksiyonlari
- `sph-grid-shaders.wgsl.ts` - Spatial hash grid (8 pass)
- `sph-pbf-shaders.wgsl.ts` - Position Based Fluids
- `sph-pcisph-shaders.wgsl.ts` - Predictive-Corrective
- `sph-dfsph-shaders.wgsl.ts` - Divergence-Free
- `sph-termal-shaders.wgsl.ts` - Termal simulasyon
- `sph-spawn-shaders.wgsl.ts` - Parca olusturma
- `sph-sensor-shaders.wgsl.ts` - Sanal sensor
- `sph-sdf-shaders.wgsl.ts` - SDF carpishma
- `sph-eleman-shaders.wgsl.ts` - Eleman etkilesim
- `sph-gaz-shaders.wgsl.ts` - Gaz simulasyonu
- Render: `sph-particle-render.wgsl.ts`, `sph-fluid-render.wgsl.ts`, `sph-heatmap-render.wgsl.ts`

### 1.3 WebGPU Camera Operations

**Dosya:** `src/service/fikoyt-ui/src/lib/fiko-three-js/IFikoThreeJS/FikoWebGPUCameraOps.ts`

Kamera odakli GPU compute:
- Batch frustum culling (tek pass, tum objeler)
- LOD mesafe hesaplama
- Screen-space boyut tahmini
- Depth-based sorting
- Inline WGSL shader (ObjectBounds -> ObjectResult)

### 1.4 WASM CPU Fallback (Rust/glam SIMD)

**Dosya:** `fikoyt-wasm/src/gpu/`

4 modul, hepsi CPU-based glam SIMD:

| Modul | Dosya | Kapasite |
|---|---|---|
| `SimdThicknessAnalyzer` | `thickness.rs` | Moller-Trumbore ray-tri, renk haritalama |
| `SimdEdgeDetector` | `edge_detector.rs` | MVP projeksiyon, nokta-segment mesafe |
| `SimdFrustumCuller` | `frustum_culler.rs` | 6-plane sphere test + LOD |
| `SimdSurfaceRecognizer` | `surface_recognizer.rs` | Plane/sphere/cylinder fitting |

### 1.5 Dokum Simulasyonu (WASM CPU)

**Dosya:** `fikoyt-wasm/src/dokum/`

| Modul | Dosya | Aciklama |
|---|---|---|
| `lbm_cpu` | `lbm_cpu.rs` | D3Q19 Lattice Boltzmann (BGK collision + streaming + VOF fill) |
| `thermal_cpu` | `thermal_cpu.rs` | Fourier isil iletim (6-neighbor Laplacian + latent heat + HTC) |
| `niyama` | `niyama.rs` | Niyama cekme kriteri (G / sqrt(dT/dt)) |

**Onemli:** `lbm_cpu.rs` ve `thermal_cpu.rs` basliklarinda `Matches FikoDokumLBM.wgsl` / `FikoDokumThermal.wgsl` referanslari var, yani GPU shader karsiliklari planlanmis ama henuz repo'da yok.

### 1.6 Mevcut Fallback Zinciri

```
WASM SIMD (10x) -> GPU WebGL2 (iskelet) -> CPU JS (baseline)
WebGPU Compute (SPH, Camera) -> yok fallback (sadece WebGPU destekleyen tarayicilarda)
```

---

## 2. Faz 1: WebGL2 GPGPU Quick Wins (2-3 hafta)

### 2.1 FikoScopedGPUCompute - Gercek GPU Implementasyonu

Mevcut CPU fallback'leri WebGL2 fragment shader compute ile degistir:

#### 2.1.1 GPU Frustum Culling (Oncelik: YUKSEK)

```
Hedef: 10K+ obje icin <1ms (CPU: ~5ms)
Yaklasim: Float texture encode -> fragment shader -> readPixels
```

- **Input:** Bounding sphere'ler (center + radius) -> RGBA32F texture
- **Shader:** Her pixel = 1 obje. 6 frustum plane test.
- **Output:** R = visible (0/1), G = LOD level, B = distance, A = screen size
- **Dosya:** `FikoScopedGPUCompute.ts` icine `computeFrustumCullingGPU()` ekle

#### 2.1.2 GPU ID Picking (Oncelik: YUKSEK)

```
Hedef: Mouse altindaki objeyi <0.5ms'de bul
Yaklasim: Color-coded render -> readPixels(1x1)
```

- Sahneyi ozel material ile render et: `MeshBasicMaterial({ color: objectId })`
- Mouse pikselini oku: `readPixels(mouseX, mouseY, 1, 1)`
- ID'den obje'ye ters lookup
- **Dosya:** `FikoScopedGPUCompute.ts` icine `gpuPickImplementation()` ekle

#### 2.1.3 GPU Occlusion Culling via HZB (Oncelik: ORTA)

```
Hedef: 50K objeli sahnelerde %40-60 culling orani
Yaklasim: Hierarchical Z-Buffer
```

- Ana depth buffer'i kopyala
- Mipmap chain olustur (her seviye max depth)
- Bounding box'i en kucuk kaplayici mipmap seviyesinde test et
- **Dosya:** Yeni `FikoHZBOcclusion.ts`

#### 2.1.4 GPU Depth Sort (Oncelik: DUSUK)

```
Hedef: Transparan objeler icin dogru siralama
Yaklasim: Bitonic sort on GPU (fragment shader pairs)
```

### 2.2 Transform Feedback Kullanim Alanlari

WebGL2'nin transform feedback ozelligi ile vertex shader output'unu buffer'a yaz:

#### 2.2.1 GPU Skinning / Morph Targets

```
Vertex shader'da pozisyon + normal transform -> output buffer
Tekrar render etmeden geometri guncelleme
```

#### 2.2.2 GPU Particle Update

```
Particle pozisyon/velocity update GPU'da
CAD parcik efektleri (kesme talaslari, kaynak kirpintilari)
```

### 2.3 Float Texture Encoding/Decoding Yardimcilari

```typescript
// Yeni utility: FikoGPUTextureCodec.ts

class FikoGPUTextureCodec {
  // Float32 array -> RGBA32F texture (her pixel = 4 float)
  static encodeToTexture(data: Float32Array, stride: number): THREE.DataTexture;

  // RGBA32F render target -> Float32 array
  static decodeFromRenderTarget(
    renderer: THREE.WebGLRenderer,
    target: THREE.WebGLRenderTarget
  ): Float32Array;

  // Optimal texture boyutu hesapla (POT, max texture size icinde)
  static computeTextureSize(itemCount: number, floatsPerItem: number): {w: number, h: number};
}
```

---

## 3. Faz 2: WebGPU Compute Migration (4-6 hafta)

### 3.1 Three.js WebGPU Renderer Entegrasyonu

Three.js r177 `WebGPURenderer` destegi:

```typescript
// FikoWebGPUManager.ts - Merkezi WebGPU yonetici

class FikoWebGPUManager {
  private device: GPUDevice | null;
  private adapter: GPUAdapter | null;

  // Three.js WebGPURenderer ile entegrasyon
  async init(renderer: THREE.WebGPURenderer): Promise<boolean>;

  // Standalone compute (render olmadan)
  async initCompute(): Promise<boolean>;

  // Feature detection
  getFeatures(): {
    maxBufferSize: number;
    maxComputeWorkgroupSize: [number, number, number];
    maxStorageBufferSize: number;
    timestampQuery: boolean;
    float16: boolean;
    subgroups: boolean;
  };

  // Pipeline cache
  getOrCreatePipeline(key: string, shaderCode: string, layout: GPUPipelineLayout): GPUComputePipeline;

  // Buffer pool (reuse)
  acquireBuffer(size: number, usage: number): GPUBuffer;
  releaseBuffer(buffer: GPUBuffer): void;
}
```

### 3.2 Compute Shader Pipeline Tasarimi

Mevcut SPH patternini genellestir:

```typescript
// FikoGPUComputeTask.ts - Genel compute task abstraction

interface IComputeTask<TInput, TOutput> {
  name: string;
  shaderCode: string;
  workgroupSize: [number, number, number];

  // Input/output buffer tanimlari
  bufferLayout: BufferLayoutDescriptor[];

  // Encode input data
  encodeInput(input: TInput): ArrayBuffer[];

  // Decode output
  decodeOutput(buffers: ArrayBuffer[]): TOutput;

  // Dispatch boyutu hesapla
  computeDispatchSize(input: TInput): [number, number, number];
}
```

### 3.3 Storage Buffer Management

```typescript
// FikoGPUBufferManager.ts

class FikoGPUBufferManager {
  // Ring buffer pool (frame bazli reuse)
  private bufferPools: Map<number, GPUBuffer[]>;

  // Staging buffer (GPU->CPU readback)
  private stagingBuffers: GPUBuffer[];

  // Upload data efficiently
  uploadToBuffer(device: GPUDevice, buffer: GPUBuffer, data: ArrayBuffer, offset?: number): void;

  // Async readback (staging buffer pattern)
  async readbackBuffer(
    device: GPUDevice,
    encoder: GPUCommandEncoder,
    source: GPUBuffer,
    size: number
  ): Promise<ArrayBuffer>;

  // Double-buffering for compute (ping-pong)
  getPingPongBuffers(size: number, usage: number): [GPUBuffer, GPUBuffer];
}
```

### 3.4 Workgroup Optimization

```
Genel kurallar:
- 1D compute: workgroup_size(256, 1, 1) - cogu GPU icin optimal
- 2D compute (goruntu): workgroup_size(16, 16, 1)
- 3D compute (voxel): workgroup_size(8, 8, 4)

Dinamik boyut secimi:
- GPU limits sorgula: maxComputeWorkgroupSizeX/Y/Z
- Occupancy hesapla: register kullanimi vs shared memory
- Subgroup size kullan (varsa): @builtin(subgroup_size)
```

---

## 4. Faz 3: GPU-Accelerated CAD Operasyonlari (6-10 hafta)

### 4.1 GPU BVH Construction (LBVH - Linear BVH)

```
Dosya: FikoGPUBVH.ts + fiko-bvh-shaders.wgsl.ts

Adimlar:
1. Morton kodlari hesapla (GPU): position -> 30-bit Morton code
2. Radix sort (GPU): Morton kodlarina gore sirala
3. BVH agac olustur (GPU): Karras 2012 algoritmasi
4. AABB hesapla (GPU): bottom-up traversal

Performans: 1M ucgen BVH < 10ms (CPU: 200ms+)

WGSL:
- morton_codes.wgsl: 3D koordinat -> 30-bit interleaved Morton code
- radix_sort.wgsl: 4-pass radix sort (8-bit per pass)
- bvh_build.wgsl: Internal node split planes (Karras algorithm)
- bvh_aabb.wgsl: Bottom-up AABB propagation

Mevcut three-mesh-bvh ile entegrasyon:
- GPU-built BVH'i three-mesh-bvh formatina cevir
- Raycast, nearest point, frustum culling icin kullan
```

### 4.2 GPU Mesh Boolean (CSG on GPU)

```
Dosya: FikoGPUCSG.ts + fiko-csg-shaders.wgsl.ts

Operasyonlar: Union, Intersection, Difference

Yaklasim: GPU-accelerated BSP-tree veya
           Voxel-based CSG (daha stabil):

1. Her iki mesh'i GPU'da voxelize et (3D texture)
2. Voxel boolean operasyonu (fragment shader veya compute)
3. Marching Cubes ile mesh reconstruct (GPU compute)

Alternatif: GPU ray-based intersection detection
- Her ucgen caifti icin ray-triangle intersection
- Intersection curve cikart
- Re-tessellate

Performans hedefi: 100K ucgen CSG < 50ms
```

### 4.3 GPU Tessellation

```
Dosya: FikoGPUTessellation.ts + fiko-tess-shaders.wgsl.ts

Kullanim alanlari:
- NURBS yuzey tessellasyonu
- Adaptive tessellation (ekran boyutuna gore)
- Displacement mapping

Compute shader:
- NURBS evaluation: de Boor algoritmasi GPU'da
- Adaptive subdivision: edge length heuristic
- Output: vertex + index buffer (storage buffer)

Entegrasyon: FikoImporter.STP.ts'den cagir
```

### 4.4 GPU-Based Measurement

```
Dosya: FikoGPUMeasure.ts + fiko-measure-shaders.wgsl.ts

Operasyonlar:
- Min distance between meshes (BVH traversal on GPU)
- Mesh-mesh interference detection
- Wall thickness (mevcut WASM'i GPU'ya tasi)
- Surface area / volume (parallel reduction)
- Center of mass (parallel reduction)

GPU advantage: N mesh x M triangle -> parallel reduction
```

### 4.5 GPU Point-in-Polygon / Point-in-Mesh

```
Dosya: FikoGPUPointQuery.ts + fiko-point-query-shaders.wgsl.ts

Yaklasim: Winding number method (GPU)
- Her sorgu noktasi icin tum ucgenlerin solid angle'ini topla
- Paralel reduction ile toplam winding number
- |winding| > 0.5 -> icerde

Kullanim: Nesting, stock placement, interference detection
```

### 4.6 GPU Nearest Neighbor Search

```
Dosya: FikoGPUNearestNeighbor.ts + fiko-nn-shaders.wgsl.ts

Yaklasim: GPU spatial hash + BVH hybrid
- Grid-based icin: SPH'deki spatial hash pattern'ini reuse et
- BVH-based icin: GPU BVH traversal

Kullanim: ICP registration, mesh alignment, deformation
```

### 4.7 GPU Convex Hull

```
Dosya: FikoGPUConvexHull.ts + fiko-hull-shaders.wgsl.ts

Yaklasim: GPU Quickhull
1. 6 extreme point'i bul (parallel reduction)
2. Initial tetrahedron olustur
3. Her face icin en uzak noktayi bul (parallel)
4. Horizon edge detection + face creation
5. Iterate until done

Kullanim: Collision shape simplification, bounding volume
```

---

## 5. Faz 4: GPU-Driven Rendering Pipeline (4-6 hafta)

### 5.1 Indirect Draw Buffer Olusturma

```
Dosya: FikoGPUIndirectDraw.ts + fiko-indirect-shaders.wgsl.ts

Mevcut: Three.js CPU'da draw call olusturur
Hedef: GPU compute shader draw call listesi oluijtursun

Compute shader:
1. Frustum cull
2. Occlusion cull (HZB)
3. LOD sec
4. Instance count yaz
5. DrawIndirect buffer'a sort key'e gore yaz

Sonuc: Zero CPU overhead draw call submission
```

### 5.2 GPU Frustum Culling (Compute Shader)

```
Mevcut: FikoWebGPUCameraOps.ts (zaten var)
Iyilestirme: Multi-frustum (shadow cascades), temporal coherence

Temporal coherence:
- Onceki frame'de gorunen objeler -> quick pass (sadece boundary test)
- Yeni eklenen/silinen objeler -> full test
- %50 daha az GPU is yuku
```

### 5.3 GPU Occlusion Culling (HZB - Hierarchical Z-Buffer)

```
Dosya: FikoGPUHZB.ts + fiko-hzb-shaders.wgsl.ts

Adimlar:
1. Depth pre-pass render
2. HZB mipmap chain olustur (compute shader, her level = max(4 pixels))
3. Occludee bounding box'i project et
4. Uygun mipmap level'da test et
5. Visible liste olustur

Two-phase approach:
Phase 1: Onceki frame'in HZB'si ile cull (conservative)
Phase 2: Bu frame'in depth ile re-cull (accurate)

Performans: 100K obje sahnesinde %60-80 culling
```

### 5.4 GPU LOD Selection

```
Dosya: FikoGPULODSelector.ts + fiko-lod-shaders.wgsl.ts

Mevcut: FikoWebGPUCameraOps.ts'de distance-based LOD var
Iyilestirme:

Screen-space error metric:
- Object bounding sphere'in screen-space piksel boyutu
- Error = geometric_error * screen_projection_factor
- LOD degistir eger error < threshold

Hysteresis:
- LOD yukselme/dusme icin farkli threshold (flip-flop engelle)
- LOD level smoothing (birdenbire degismesin)

Transition:
- Dithered LOD transition (cross-fade)
- Geomorphing (vertex interpolation between LOD levels)
```

### 5.5 Meshlet Pipeline (Gelecek)

```
Dosya: FikoGPUMeshlet.ts + fiko-meshlet-shaders.wgsl.ts

NOT: WebGPU mesh shader henuz standart degil.
Three.js destegi yoklugunda erken asamada kalacak.

Hazirlik:
1. Meshlet olusturma (CPU, build-time): metis/meshoptimizer
2. Meshlet BVH
3. Meshlet culling (compute shader)
4. Meshlet rendering (vertex shader + instance ile emulate)

Her meshlet: 64-128 vertex, 126 triangle (max)
Meshlet BVH: Coarse culling before fine
```

---

## 6. Faz 5: Dokum Simulasyonu GPU (4-6 hafta)

### 6.1 LBM GPU (Lattice Boltzmann Method)

```
Dosya: FikoDokumLBM.wgsl.ts (referenced in lbm_cpu.rs but not yet created)

Mevcut CPU: lbm_cpu.rs - D3Q19 BGK collision + streaming + VOF fill
GPU versiyonu:

Pass 1 - Collide & Stream:
@compute @workgroup_size(8, 8, 4)
fn collide_stream(...) {
  // Her thread = 1 voxel
  // Read 19 distribution fonksiyonu
  // Compute macroscopic rho, u
  // Gravity + Darcy damping
  // BGK collision: f_out = f - (f - f_eq) / tau
  // Stream to neighbor (veya bounce-back)
}

Pass 2 - Fill Update (VOF):
@compute @workgroup_size(8, 8, 4)
fn fill_update(...) {
  // Her thread = 1 metal/runner voxel
  // Accumulate incoming from filled neighbors
  // Update fill fraction
}

Buffer layout:
- lbm_data[2]: ping-pong (f32 x 19 per voxel x 2)
- velocity: f32 x 4 per voxel (vx, vy, vz, rho)
- material: u32 per voxel
- fill_fraction: f32 per voxel

Performans hedefi: 128^3 grid @ 60 FPS (CPU: ~2 FPS)
```

### 6.2 Termal Simulasyon GPU

```
Dosya: FikoDokumThermal.wgsl.ts (referenced in thermal_cpu.rs)

Mevcut CPU: thermal_cpu.rs - Fourier isil iletim
GPU versiyonu:

@compute @workgroup_size(8, 8, 4)
fn thermal_step(...) {
  // Her thread = 1 voxel
  // 6-neighbor Laplacian
  // Material-based k, rho, cp
  // Interface HTC (metal-mold, mold-air)
  // Mushy zone: effective Cp with latent heat
  // Temperature update: T_new = T + dt * alpha * laplacian / dx^2
  // Solid fraction update
}

Optimization:
- Shared memory: 3D tile'daki komsulari paylas (8+2)^3 = 1000 per workgroup
- Async compute: LBM ve thermal paralel calistir
```

### 6.3 Particle-Based Simulation (SPH)

```
MEVCUT: fiko-sph-sivi/ altinda tam WebGPU SPH implementasyonu var!

Dokum icin ek pass'ler:
- Solidification tracking (parcik bazli fs update)
- Mold-metal thermal coupling (SPH-grid hybrid)
- Niyama criterion on particles (gradient + cooling rate)

Mevcut SPH pipeline reuse edilerek minimum ek kod ile dokum SPH yapilabilir.
```

### 6.4 Niyama Kriteri GPU

```
Dosya: FikoDokumNiyama.wgsl.ts

@compute @workgroup_size(8, 8, 4)
fn compute_niyama(...) {
  // Gradient: central differences (mevcut niyama.rs mantigi)
  // Cooling rate: (T_prev - T) / dt
  // Niyama = G / sqrt(|dT/dt|)
  // Color mapping for visualization
}

Not: Thermal simulasyonla birlikte her N adimda 1 calistirilir.
```

---

## 7. Faz 6: Hybrid CPU/GPU/WASM Pipeline (Surekli)

### 7.1 Task Distribution Strategy

```
Karar Agaci:

1. WebGPU var mi?
   EVET -> GPU Compute (en hizli)
   HAYIR -> devam

2. WebGL2 + EXT_color_buffer_float var mi?
   EVET -> WebGL2 GPGPU (fragment shader compute)
   HAYIR -> devam

3. WASM + SIMD var mi?
   EVET -> WASM SIMD (10x CPU)
   HAYIR -> devam

4. Web Worker var mi?
   EVET -> CPU multi-thread (worker pool)
   HAYIR -> CPU single-thread (en yavas)
```

### 7.2 Fallback Chain Implementasyonu

```typescript
// FikoComputeDispatcher.ts

class FikoComputeDispatcher {
  private tier: 'webgpu' | 'webgl2' | 'wasm' | 'cpu';

  async dispatch<T>(task: ComputeTask<T>): Promise<T> {
    // Tier'a gore dogru backend'e yonlendir
    switch (this.tier) {
      case 'webgpu':
        try { return await this.webgpuBackend.execute(task); }
        catch { this.tier = 'webgl2'; return this.dispatch(task); }

      case 'webgl2':
        try { return await this.webgl2Backend.execute(task); }
        catch { this.tier = 'wasm'; return this.dispatch(task); }

      case 'wasm':
        try { return await this.wasmBackend.execute(task); }
        catch { this.tier = 'cpu'; return this.dispatch(task); }

      case 'cpu':
        return this.cpuBackend.execute(task);
    }
  }

  // Performance-based tier selection
  async benchmarkAndSelectTier(): Promise<void> {
    // 1000 obje frustum cull ile benchmark
    // En hizli tier'i sec
  }
}
```

### 7.3 Performance Monitoring

```typescript
// FikoGPUProfiler.ts

class FikoGPUProfiler {
  // WebGPU timestamp queries
  private querySet: GPUQuerySet | null;

  // Per-pass timing
  beginPass(name: string): void;
  endPass(name: string): void;

  // Buffer memory tracking
  trackBufferAllocation(buffer: GPUBuffer, label: string): void;
  trackBufferDeallocation(buffer: GPUBuffer): void;

  // Report
  getReport(): {
    passes: { name: string, avgMs: number, maxMs: number }[];
    totalGPUMemory: number;
    bufferCount: number;
    pipelineCount: number;
    frameBudgetUsage: number; // 0-100% of 16.6ms
  };

  // Integration with fiko-performance-monitor.component.ts
  getOverlayData(): PerformanceOverlayData;
}
```

---

## 8. Dosya Yapisi Plani

```
src/service/fikoyt-ui/src/lib/fiko-three-js/IFikoThreeJS/
  fiko-gpu-compute/
    FikoGPUManager.ts            # WebGPU device/adapter yonetimi
    FikoGPUBufferManager.ts      # Buffer pool, staging, ping-pong
    FikoGPUComputeTask.ts        # Generic compute task abstraction
    FikoGPUProfiler.ts           # Timestamp query profiling
    FikoComputeDispatcher.ts     # Tier-based dispatch (GPU->WASM->CPU)
    FikoGPUTextureCodec.ts       # WebGL2 float texture encode/decode

    # CAD Operations
    FikoGPUBVH.ts                # GPU LBVH construction
    FikoGPUCSG.ts                # GPU mesh boolean
    FikoGPUTessellation.ts       # GPU NURBS tessellation
    FikoGPUMeasure.ts            # GPU measurement (distance, area, volume)
    FikoGPUPointQuery.ts         # GPU point-in-mesh
    FikoGPUNearestNeighbor.ts    # GPU spatial queries
    FikoGPUConvexHull.ts         # GPU quickhull

    # Rendering Pipeline
    FikoGPUIndirectDraw.ts       # GPU-driven draw call generation
    FikoGPUHZB.ts                # Hierarchical Z-Buffer occlusion
    FikoGPULODSelector.ts        # Screen-space error LOD
    FikoGPUMeshlet.ts            # Meshlet pipeline (future)

    # WGSL Shaders
    shaders/
      fiko-bvh-shaders.wgsl.ts
      fiko-csg-shaders.wgsl.ts
      fiko-tess-shaders.wgsl.ts
      fiko-measure-shaders.wgsl.ts
      fiko-point-query-shaders.wgsl.ts
      fiko-nn-shaders.wgsl.ts
      fiko-hull-shaders.wgsl.ts
      fiko-indirect-shaders.wgsl.ts
      fiko-hzb-shaders.wgsl.ts
      fiko-lod-shaders.wgsl.ts

    # Dokum Simulation
    dokum/
      FikoDokumLBM.wgsl.ts       # LBM compute shader
      FikoDokumThermal.wgsl.ts   # Thermal compute shader
      FikoDokumNiyama.wgsl.ts    # Niyama criterion shader
      FikoDokumGPUMotor.ts       # Dokum simulation orchestrator
```

---

## 9. Oncelik Sirasi ve Takvim

| Faz | Sure | Oncelik | Etki |
|---|---|---|---|
| **1.1** GPU Frustum Culling (WebGL2) | 3 gun | P0 | Her frame'de calisiyor |
| **1.2** GPU ID Picking (WebGL2) | 2 gun | P0 | Mouse interaction |
| **1.3** GPU HZB Occlusion (WebGL2) | 5 gun | P1 | Buyuk sahneler |
| **2.1** WebGPU Manager | 3 gun | P1 | Altyapi |
| **2.2** ComputeDispatcher | 2 gun | P1 | Fallback zinciri |
| **3.1** GPU BVH | 7 gun | P1 | Tum spatial sorgular |
| **3.4** GPU Measurement | 5 gun | P2 | CAD olcum |
| **4.1** Indirect Draw | 5 gun | P2 | Render performansi |
| **4.3** GPU HZB (compute) | 5 gun | P2 | Render performansi |
| **5.1** LBM GPU | 7 gun | P2 | Dokum simulasyonu |
| **5.2** Thermal GPU | 5 gun | P2 | Dokum simulasyonu |
| **3.2** GPU CSG | 10 gun | P3 | Boolean operasyonlar |
| **3.3** GPU Tessellation | 7 gun | P3 | NURBS |
| **4.4** GPU LOD | 3 gun | P3 | LOD iyilestirme |
| **3.7** GPU Convex Hull | 3 gun | P3 | Collision |
| **4.5** Meshlet Pipeline | 10 gun | P4 | Gelecek |

**Toplam tahmin:** ~80 gun (4 ay, tek gelistirici)

---

## 10. Performans Hedefleri

| Operasyon | Mevcut (CPU/WASM) | WebGL2 GPGPU | WebGPU Compute | Hedef |
|---|---|---|---|---|
| Frustum Cull (10K obj) | 5ms | 1ms | 0.2ms | <1ms |
| ID Picking | 2ms (raycast) | 0.3ms | 0.1ms | <0.5ms |
| Occlusion Cull (50K) | 20ms | 3ms | 0.5ms | <2ms |
| BVH Build (1M tri) | 200ms | N/A | 10ms | <15ms |
| Thickness (100K vtx) | 300ms (CPU) / 30ms (WASM) | 5ms | 1ms | <5ms |
| Edge Detection (50K) | 100ms (CPU) / 10ms (WASM) | 3ms | 0.5ms | <3ms |
| LBM Step (128^3) | 500ms (WASM) | N/A | 2ms | <5ms |
| Thermal Step (128^3) | 200ms (WASM) | N/A | 1ms | <2ms |
| CSG Boolean (100K tri) | 2000ms | N/A | 50ms | <100ms |
| Draw Call Gen (100K) | 10ms | N/A | 0.3ms | <1ms |

---

## 11. Risk ve Azaltma

| Risk | Olasilik | Etki | Azaltma |
|---|---|---|---|
| WebGPU browser desteği kisitli | Orta | Yuksek | WebGL2 fallback her zaman hazir |
| GPU memory limitleri | Dusuk | Orta | Buffer pooling, streaming |
| Shader derleme suresi (ilk yukleme) | Orta | Dusuk | Pipeline cache, warm-up |
| Precision farklari (f32 vs f64) | Dusuk | Orta | Compensated summation, split-precision |
| Mobile GPU performansi | Yuksek | Orta | Adaptive workgroup size, mobile tier |
| Three.js WebGPU API degisiklikleri | Orta | Orta | Abstraction layer, versiyon pinleme |

---

## 12. Bagimlilklar

- Three.js r177+ (WebGPU renderer)
- Chrome 113+ / Firefox 128+ / Safari 18+ (WebGPU)
- EXT_color_buffer_float (WebGL2 compute icin)
- fikoyt-wasm (Rust SIMD fallback)
- three-mesh-bvh (mevcut BVH entegrasyonu)
