// GpuTampon dinamik guncelleme (ping-pong) SAF mantik testleri — Vulkan cihazi // gerektirmez. guncelle()'nin slot secimi/buyume politikasi gpu_tampon.hpp'deki // constexpr yardimcilarda yasar; GPU tarafi ayni mantigi birebir kullanir. // // Guvenlik sozlesmesi (ucusteKare=2): yeni karede OTEKI slota yazilir; o slot en // son 2+ kare once cizildi ve kareBasla fence-beklemesi o kareyi tamamladi → // GPU'nun okudugu belleoe asla yazilmaz (device-idle beklemeden). #include "fiko/render/gpu_tampon.hpp" #include "fiko_test.hpp" using namespace fiko; FIKO_TEST(gpu_tampon_ilk_guncelleme_aktif_slota) { // Statik→dinamik gecis: ilk yazim aktif slota (0) yapilir, eski statik tampon // emekli edilir (ertelenmis yikim). FIKO_KONTROL(gpuTamponHedefSlot(false, 0, 10, ~0ull) == 0); } FIKO_TEST(gpu_tampon_yeni_kare_slot_degistirir) { // Kare ilerledi → oteki slot (ping-pong): GPU onceki karede aktif olani okuyabilir. FIKO_KONTROL(gpuTamponHedefSlot(true, 0, 11, 10) == 1); FIKO_KONTROL(gpuTamponHedefSlot(true, 1, 12, 11) == 0); // Kareler atlansa da (scrubber durakladi) yine oteki slota gecilir. FIKO_KONTROL(gpuTamponHedefSlot(true, 1, 500, 12) == 0); } FIKO_TEST(gpu_tampon_ayni_kare_ayni_slot) { // Ayni karede ikinci guncelle: ayni slota yeniden yaz (henuz submit edilmedi, // onceki kare bu slotu kullanmadi — flip etmek onceki karenin okudugu slota // yazmak olurdu, YASAK). FIKO_KONTROL(gpuTamponHedefSlot(true, 1, 10, 10) == 1); FIKO_KONTROL(gpuTamponHedefSlot(true, 0, 10, 10) == 0); } FIKO_TEST(gpu_tampon_ardisik_kareler_donusumlu) { // Oynatma benzetimi: her kare bir guncelle — slotlar donusumlu (0,1,0,1...). u32 aktif = 0; u64 son = ~0ull; bool dinamik = false; u32 onceki = 99; for (u64 kare = 1; kare <= 8; ++kare) { const u32 hedef = gpuTamponHedefSlot(dinamik, aktif, kare, son); if (dinamik) FIKO_KONTROL(hedef != onceki); // ardisik karede ayni slota yazilmaz aktif = hedef; onceki = hedef; son = kare; dinamik = true; } } FIKO_TEST(gpu_tampon_kapasite_buyume_payli) { // %50 buyume payi: ufak dalgalanmalar yeniden tahsis tetiklemez. FIKO_KONTROL(gpuTamponKapasite(1000) == 1500); FIKO_KONTROL(gpuTamponKapasite(1) == 1); // Buyume monotonic: kapasite >= istenen bayt. for (u64 b : {64ull, 4096ull, 1'000'000ull}) FIKO_KONTROL(gpuTamponKapasite(b) >= b); // Senaryo: 1000 bayt yukle (kapasite 1500) → 1400 bayt kapasiteye SIGAR // (yeniden tahsis yok), 1600 sigmaz (tek buyume). u64 taban = 1000; // non-const: C4127 (sabit kosul) uyarisini onler u64 kap = gpuTamponKapasite(taban); FIKO_KONTROL(1400 <= kap); FIKO_KONTROL(1600 > kap); }