update client visuals, performance and diagnostics
This commit is contained in:
1 parent
361892bf0b
commit
875bab0310
155 files changed
+40855
-421
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include <thread>
|
||||
#include "../src/game/performance.h"
|
||||
inline void test_performance() {
|
||||
performance::reset();
|
||||
assert(performance::present_sync(1,0)==1);
|
||||
performance::uncapped_present=true;
|
||||
assert(performance::present_sync(1,0)==0 && performance::present_sync(3,DXGI_PRESENT_TEST)==3);
|
||||
performance::particles=true;performance::keep=50;performance::burst_limit=0;
|
||||
int dropped=0;for(int i=0;i<100;++i)dropped+=performance::suppress(0,true,1000);
|
||||
assert(dropped==50);
|
||||
performance::keep=0;
|
||||
assert(!performance::suppress(2,true,1000) && !performance::suppress(0,false,1000));
|
||||
performance::keep=100;performance::burst_limit=10;
|
||||
int allowed=0;for(int i=0;i<100;++i)allowed+=!performance::suppress(0,true,1000);
|
||||
assert(allowed==10 && !performance::suppress(0,true,1100));
|
||||
performance::budget_state=0;
|
||||
std::atomic<int> total{0};std::vector<std::thread> workers;
|
||||
for(int i=0;i<8;++i)workers.emplace_back([&]{for(int n=0;n<1000;++n)if(!performance::over_budget(2000,317))++total;});
|
||||
for(auto& thread:workers)thread.join();assert(total==317);
|
||||
assert(!performance::over_budget(2100,317));
|
||||
// An older thread must not reset the next window's budget.
|
||||
const auto newer=performance::budget_state.load();assert(performance::over_budget(2000,317));
|
||||
assert(performance::budget_state==newer);
|
||||
performance::adaptive_density adaptive;adaptive.reset(50);
|
||||
for(int i=0;i<40;++i)adaptive.update(1./30,120,50);
|
||||
assert(adaptive.current<50);
|
||||
for(int i=0;i<960;++i)adaptive.update(1./240,120,50);
|
||||
assert(adaptive.current==50);
|
||||
const int saved=adaptive.current;adaptive.update(std::nan(""),120,50);assert(adaptive.current==saved);
|
||||
performance::refresh_gate refresh;
|
||||
assert(refresh.due(1000,1,1,0,30));assert(!refresh.due(1016,1,1,0,30));assert(refresh.due(1034,1,1,0,30));
|
||||
assert(refresh.due(1035,2,1,0,30));assert(refresh.due(1036,2,2,0,30));assert(refresh.due(1037,2,2,1,30));
|
||||
assert(refresh.due(1038,2,2,1,0));refresh.valid=false;assert(refresh.due(1039,2,2,1,30));
|
||||
performance::reset();assert(!performance::particles && !performance::uncapped_present && performance::hud_hz==0);
|
||||
std::cout<<"PASS: adaptive native particles, concurrent burst budgets, composed filters, HUD refresh invalidation and reversible Present sync\n";
|
||||
}
|
||||
Reference in new issue
Block a user