1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/// WASM Optimizasyon Profil Sistemi
///
/// Oyun türüne göre otomatik GPU kaynak yönetimi sağlar.
/// Tarayıcı ortamında maksimum performans için gereksiz
/// subsistemler otomatik devre dışı bırakılır.
///
/// # Kullanım
/// ```rust,ignore
/// let profile = WebProfile::fighter(); // Dövüş oyunu preset'i
/// let profile = WebProfile::racing(); // Yarış oyunu preset'i
/// let profile = WebProfile::sandbox(); // Açık dünya / sandbox
/// let profile = WebProfile::custom() // Özel konfigürasyon
/// .with_particles(true, 5000)
/// .with_shadows(true)
/// .with_post_processing(PostProcessLevel::Medium);
/// ```
/// Post-processing kalite seviyesi
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PostProcessLevel {
/// Sadece tone mapping, gamma correction
Minimal,
/// Bloom + tone mapping (DoF yok)
Low,
/// Bloom + chromatic aberration + vignette (DoF yok)
Medium,
/// Full pipeline (bloom + DoF + film grain + vignette + CA)
High,
}
/// Shadow kalite seviyesi
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ShadowQuality {
/// Gölge yok
Off,
/// Tek cascade, düşük çözünürlük
Low,
/// 2 cascade, orta çözünürlük
Medium,
/// 4 cascade, yüksek çözünürlük (masaüstü varsayılan)
High,
}
/// WASM ortamında GPU kaynak konfigürasyonu
#[derive(Clone, Debug)]
pub struct WebProfile {
/// Profil adı (log ve debug için)
pub name: &'static str,
// ── GPU Compute Subsystems ────────────────────────────
/// GPU particle sistemi aktif mi?
pub gpu_particles_enabled: bool,
/// Maksimum GPU particle sayısı
pub gpu_particles_max: u32,
/// GPU fizik simülasyonu aktif mi?
pub gpu_physics_enabled: bool,
/// Maksimum GPU fizik nesnesi
pub gpu_physics_max: u32,
/// GPU sıvı simülasyonu aktif mi?
pub gpu_fluid_enabled: bool,
/// Maksimum GPU sıvı parçacığı
pub gpu_fluid_max: u32,
// ── Rendering Pipeline ───────────────────────────────
/// Deferred rendering aktif mi? (false = forward only)
pub deferred_enabled: bool,
/// GPU frustum culling aktif mi?
pub gpu_cull_enabled: bool,
/// Gölge kalitesi
pub shadow_quality: ShadowQuality,
/// Post-processing seviyesi
pub post_process_level: PostProcessLevel,
// ── Screen Space Effects ─────────────────────────────
/// SSAO (Ambient Occlusion) aktif mi?
pub ssao_enabled: bool,
/// SSR (Screen Space Reflections) aktif mi?
pub ssr_enabled: bool,
/// SSGI (Screen Space Global Illumination) aktif mi?
pub ssgi_enabled: bool,
/// TAA (Temporal Anti-Aliasing) aktif mi?
pub taa_enabled: bool,
/// Volumetric lighting (God Rays) aktif mi?
pub volumetric_enabled: bool,
// ── Resource Limits ──────────────────────────────────
/// Maksimum bind group sayısı (Chrome WebGPU = 4)
pub max_bind_groups: u32,
/// Maksimum instance sayısı (instanced rendering)
pub max_instances: usize,
/// HDR texture formatı (Rgba16Float vs Rgba8Unorm)
pub use_hdr: bool,
}
impl WebProfile {
// ════════════════════════════════════════════════════════
// PRESET'LER — Oyun türüne göre hazır profiller
// ════════════════════════════════════════════════════════
/// 🥊 Dövüş oyunu — 2 karakter, arena, hit efektleri
/// Particles: düşük (hit spark), Fluid: kapalı, Deferred: kapalı
pub fn fighter() -> Self {
Self {
name: "Fighter",
gpu_particles_enabled: true,
gpu_particles_max: 2_000, // Hit spark'lar için yeterli
gpu_physics_enabled: false,
gpu_physics_max: 0,
gpu_fluid_enabled: false,
gpu_fluid_max: 0,
deferred_enabled: false,
gpu_cull_enabled: false,
shadow_quality: ShadowQuality::Off,
post_process_level: PostProcessLevel::Medium,
ssao_enabled: false,
ssr_enabled: false,
ssgi_enabled: false,
taa_enabled: false,
volumetric_enabled: false,
max_bind_groups: 4,
max_instances: 256,
use_hdr: true,
}
}
/// 🏎️ Yarış oyunu — çok nesne, hız efektleri, geniş sahne
/// Particles: orta (toz/kıvılcım), Fluid: kapalı, Shadows: düşük
pub fn racing() -> Self {
Self {
name: "Racing",
gpu_particles_enabled: true,
gpu_particles_max: 10_000, // Toz, kıvılcım, exhaust
gpu_physics_enabled: false,
gpu_physics_max: 0,
gpu_fluid_enabled: false,
gpu_fluid_max: 0,
deferred_enabled: false,
gpu_cull_enabled: false, // CPU culling yeterli
shadow_quality: ShadowQuality::Low,
post_process_level: PostProcessLevel::Medium,
ssao_enabled: false,
ssr_enabled: false,
ssgi_enabled: false,
taa_enabled: false,
volumetric_enabled: false,
max_bind_groups: 4,
max_instances: 512,
use_hdr: true,
}
}
/// 🌊 Su/sıvı odaklı oyun — SPH fluid, fizik etkileşimi
/// Particles: orta, Fluid: aktif (düşük limit), Physics: düşük
pub fn fluid() -> Self {
Self {
name: "Fluid",
gpu_particles_enabled: true,
gpu_particles_max: 5_000,
gpu_physics_enabled: true,
gpu_physics_max: 1_000,
gpu_fluid_enabled: true,
gpu_fluid_max: 10_000, // Mobil/web için 10K yeterli
deferred_enabled: false,
gpu_cull_enabled: false,
shadow_quality: ShadowQuality::Off,
post_process_level: PostProcessLevel::Low,
ssao_enabled: false,
ssr_enabled: false,
ssgi_enabled: false,
taa_enabled: false,
volumetric_enabled: false,
max_bind_groups: 4,
max_instances: 128,
use_hdr: true,
}
}
/// 🏗️ Sandbox / açık dünya — dengeli, her şeyden biraz
pub fn sandbox() -> Self {
Self {
name: "Sandbox",
gpu_particles_enabled: true,
gpu_particles_max: 5_000,
gpu_physics_enabled: true,
gpu_physics_max: 5_000,
gpu_fluid_enabled: false,
gpu_fluid_max: 0,
deferred_enabled: false,
gpu_cull_enabled: false,
shadow_quality: ShadowQuality::Low,
post_process_level: PostProcessLevel::Low,
ssao_enabled: false,
ssr_enabled: false,
ssgi_enabled: false,
taa_enabled: false,
volumetric_enabled: false,
max_bind_groups: 4,
max_instances: 1024,
use_hdr: true,
}
}
/// 🖥️ Masaüstü — tüm özellikler açık (varsayılan native profil)
pub fn desktop() -> Self {
Self {
name: "Desktop",
gpu_particles_enabled: true,
gpu_particles_max: 100_000,
gpu_physics_enabled: true,
gpu_physics_max: 50_000,
gpu_fluid_enabled: true,
gpu_fluid_max: 100_000,
deferred_enabled: true,
gpu_cull_enabled: true,
shadow_quality: ShadowQuality::High,
post_process_level: PostProcessLevel::High,
ssao_enabled: true,
ssr_enabled: true,
ssgi_enabled: true,
taa_enabled: true,
volumetric_enabled: true,
max_bind_groups: 8,
max_instances: 16384,
use_hdr: true,
}
}
/// 📱 Minimum — en düşük ayarlar (eski donanım / mobil)
pub fn minimal() -> Self {
Self {
name: "Minimal",
gpu_particles_enabled: false,
gpu_particles_max: 0,
gpu_physics_enabled: false,
gpu_physics_max: 0,
gpu_fluid_enabled: false,
gpu_fluid_max: 0,
deferred_enabled: false,
gpu_cull_enabled: false,
shadow_quality: ShadowQuality::Off,
post_process_level: PostProcessLevel::Minimal,
ssao_enabled: false,
ssr_enabled: false,
ssgi_enabled: false,
taa_enabled: false,
volumetric_enabled: false,
max_bind_groups: 4,
max_instances: 64,
use_hdr: false,
}
}
// ════════════════════════════════════════════════════════
// BUILDER API — Özel profil oluşturma
// ════════════════════════════════════════════════════════
/// Boş profil (her şey kapalı) — builder ile özelleştir
pub fn custom() -> Self {
Self::minimal()
}
pub fn with_particles(mut self, enabled: bool, max: u32) -> Self {
self.gpu_particles_enabled = enabled;
self.gpu_particles_max = max;
self
}
pub fn with_physics(mut self, enabled: bool, max: u32) -> Self {
self.gpu_physics_enabled = enabled;
self.gpu_physics_max = max;
self
}
pub fn with_fluid(mut self, enabled: bool, max: u32) -> Self {
self.gpu_fluid_enabled = enabled;
self.gpu_fluid_max = max;
self
}
pub fn with_shadows(mut self, quality: ShadowQuality) -> Self {
self.shadow_quality = quality;
self
}
pub fn with_post_processing(mut self, level: PostProcessLevel) -> Self {
self.post_process_level = level;
self
}
pub fn with_deferred(mut self, enabled: bool) -> Self {
self.deferred_enabled = enabled;
self
}
pub fn with_ssao(mut self, enabled: bool) -> Self {
self.ssao_enabled = enabled;
self
}
pub fn with_ssr(mut self, enabled: bool) -> Self {
self.ssr_enabled = enabled;
self
}
pub fn with_max_instances(mut self, max: usize) -> Self {
self.max_instances = max;
self
}
// ════════════════════════════════════════════════════════
// UTILITY
// ════════════════════════════════════════════════════════
/// Mevcut platforma göre varsayılan profil seç
pub fn auto() -> Self {
#[cfg(target_arch = "wasm32")]
{
Self::fighter()
}
#[cfg(not(target_arch = "wasm32"))]
{
Self::desktop()
}
}
/// Profil özetini logla
pub fn log_summary(&self) {
log::info!("╔══════════════════════════════════════════╗");
log::info!("║ WebProfile: {:26} ║", self.name);
log::info!("╠══════════════════════════════════════════╣");
log::info!(
"║ Particles: {:>6} ({}) ║",
if self.gpu_particles_enabled {
format!("{}", self.gpu_particles_max)
} else {
"OFF".to_string()
},
if self.gpu_particles_enabled {
"✓"
} else {
"✗"
}
);
log::info!(
"║ Physics: {:>6} ({}) ║",
if self.gpu_physics_enabled {
format!("{}", self.gpu_physics_max)
} else {
"OFF".to_string()
},
if self.gpu_physics_enabled {
"✓"
} else {
"✗"
}
);
log::info!(
"║ Fluid: {:>6} ({}) ║",
if self.gpu_fluid_enabled {
format!("{}", self.gpu_fluid_max)
} else {
"OFF".to_string()
},
if self.gpu_fluid_enabled { "✓" } else { "✗" }
);
log::info!("║ Shadows: {:?}{:>16} ║", self.shadow_quality, "");
log::info!("║ PostFX: {:?}{:>16} ║", self.post_process_level, "");
log::info!(
"║ Deferred: {:<24} ║",
if self.deferred_enabled { "✓" } else { "✗" }
);
log::info!(
"║ SSAO: {:<24} ║",
if self.ssao_enabled { "✓" } else { "✗" }
);
log::info!("║ Instances: {:<24} ║", self.max_instances);
log::info!("╚══════════════════════════════════════════╝");
}
}
impl Default for WebProfile {
fn default() -> Self {
Self::auto()
}
}