mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-20 16:49:57 -04:00
Triforce v0.5.0
In-game mods (GameBanana browser, search and installs, with the Mask Salesman), code-patch and cheat mods, the devs' test18 to test45 work (full performance overlay, frame pacing on, steady frame rate, save export and import, bug capture, new options rows, Setup's Mods page and Add to Steam), occlusion queries and new defaults, Auto resolution that scales, replay helper threads and robust buffers off by default, the options in sections.
This commit is contained in:
@@ -20,12 +20,13 @@ def function(marker):
|
||||
return source[start:end]
|
||||
|
||||
functions = '\n'.join(function(marker) for marker in [
|
||||
'bool on()', 'void mark(', 'bool reflex_swapchain_stale()',
|
||||
'bool on()', 'void mark(', 'void mark_shown(', 'bool reflex_swapchain_stale()',
|
||||
'void reflex_swapchain_created(', 'void reflex_swapchain_destroyed()',
|
||||
'void reflex_present_begins()', 'void reflex_submit_ends()',
|
||||
'const void* reflex_present_id(', 'void reflex_presented()', 'void reflex_sleep()',
|
||||
'const void* reflex_present_id(', 'void reflex_presented()', 'bool sleep_now()', 'void reflex_sleep()',
|
||||
])
|
||||
fixture = r'''
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <initializer_list>
|
||||
@@ -42,22 +43,25 @@ struct VkSemaphoreWaitInfo {int type;unsigned semaphoreCount=0;const uint64_t* p
|
||||
struct VkSetLatencyMarkerInfoNV {int type;uint64_t presentID=0;int marker=0;};
|
||||
struct PresentId {const void* pNext=nullptr;unsigned swapchainCount=0;const uint64_t* pPresentIds=nullptr;};
|
||||
void (*before_lock)()=nullptr;
|
||||
namespace lab_ab { inline bool on(const char*) { return false; } } // ((Triforce) the lab's in-run A/B knobs: none here)
|
||||
struct TestMutex {
|
||||
std::mutex native;
|
||||
void lock(){auto hook=before_lock;before_lock=nullptr;if(hook)hook();native.lock();}
|
||||
void unlock(){native.unlock();}
|
||||
};
|
||||
int markers=0,sleeps=0,modes=0;bool invalid=false,fg=false;int wanted=1;
|
||||
void marker_call(int,uint64_t chain,const VkSetLatencyMarkerInfoNV*){if(!chain)invalid=true;++markers;}
|
||||
int markers=0,sleeps=0,modes=0;bool invalid=false,fg=false;int wanted=1;uint64_t marked_id=0;
|
||||
void marker_call(int,uint64_t chain,const VkSetLatencyMarkerInfoNV* i){if(!chain)invalid=true;++markers;marked_id=i->presentID;}
|
||||
int sleep_call(int,uint64_t chain,const VkLatencySleepInfoNV*){if(!chain)invalid=true;++sleeps;return VK_SUCCESS;}
|
||||
struct Reflex {
|
||||
bool ready=true,latency=true,latency_next=true,frame_marked=true;
|
||||
uint64_t swapchain=42,swapchain_generation=0,wake=100,wake_value=0,id=1;
|
||||
bool ready=true,latency=true,latency_next=true,frame_marked=true,shown_marked=false;
|
||||
uint64_t swapchain=42,swapchain_generation=0,wake=100,wake_value=0,id=1,shown_id=0;
|
||||
int mode=1;TestMutex mu;PresentId pid;
|
||||
uint32_t interval_us=0;std::atomic<bool> game_sleeps{false},slept_after{false};std::atomic<int64_t> hosted_ns{0};
|
||||
void (*marker)(int,uint64_t,const VkSetLatencyMarkerInfoNV*)=marker_call;
|
||||
int (*sleep)(int,uint64_t,const VkLatencySleepInfoNV*)=sleep_call;
|
||||
} state;
|
||||
struct {int device=1;}dev;
|
||||
int64_t clock_now=0;int64_t now_ns(){return clock_now;}struct {int64_t (*now_ns)();} host_v{now_ns},*host=&host_v;
|
||||
Reflex& rx(){return state;}
|
||||
bool framegen_on(){return fg;}
|
||||
int wanted_mode(){return wanted;}
|
||||
@@ -83,6 +87,8 @@ int vkWaitSemaphores(int,const VkSemaphoreWaitInfo* wait,uint64_t){
|
||||
void reset(){
|
||||
state.swapchain=42;state.swapchain_generation=0;state.ready=state.latency=state.latency_next=state.frame_marked=true;
|
||||
state.wake_value=0;state.id=1;state.mode=1;markers=sleeps=modes=0;invalid=fg=false;wanted=1;before_lock=nullptr;action=Keep;
|
||||
state.shown_marked=false;state.shown_id=0;marked_id=0;
|
||||
state.game_sleeps=false;state.slept_after=false;state.hosted_ns=0;clock_now=0;
|
||||
}
|
||||
void retire_before_lock(){reflex_swapchain_destroyed();}
|
||||
int main(){
|
||||
@@ -101,6 +107,24 @@ int main(){
|
||||
reset();action=ReuseHandle;reflex_sleep();action=Keep;reflex_sleep();if(invalid||markers!=2||!state.frame_marked)return 9;
|
||||
reset();reflex_present_begins();reflex_submit_ends();reflex_present_id(nullptr);reflex_presented();
|
||||
if(invalid||markers!=5)return 10;
|
||||
// (Triforce) while the game's thread takes the sleep where its frame starts (RX_VK_REFLEX_LIMIT: reflex_pace), the one
|
||||
// after the present is left out; one taken after a present is noted for the next frame start, the present its time
|
||||
reset();state.game_sleeps=true;reflex_sleep();if(invalid||sleeps||markers||modes||state.slept_after)return 11;
|
||||
reset();reflex_sleep();if(sleeps!=1||!state.slept_after)return 12;
|
||||
reset();if(!sleep_now()||sleeps!=1||state.slept_after)return 15;
|
||||
clock_now=777;reflex_presented();if(state.hosted_ns!=777)return 13;
|
||||
reset();before_lock=retire_before_lock;reflex_sleep();if(state.slept_after)return 14;
|
||||
// ((Triforce) RX_VK_PRESENT_THREAD) the present thread gives a frame's present after the game's thread slept into the next
|
||||
// frame: its id and markers are still that frame's, taken as its submit ended; without a submit's end, no present markers
|
||||
reset();reflex_present_begins();reflex_submit_ends();if(marked_id!=1)return 16;
|
||||
reflex_sleep();if(state.id!=2||!state.frame_marked||marked_id!=2)return 17;
|
||||
const auto* pid=(const PresentId*)reflex_present_id(nullptr);
|
||||
if(!pid||*pid->pPresentIds!=1||marked_id!=1)return 18;
|
||||
markers=0;reflex_presented();if(markers!=1||marked_id!=1||invalid)return 19;
|
||||
reset();int alone=1;if(reflex_present_id(&alone)!=&alone||markers)return 20;
|
||||
reflex_presented();if(markers)return 21;
|
||||
reset();reflex_submit_ends();auto old=state.swapchain;reflex_swapchain_destroyed();reflex_swapchain_created(old);
|
||||
if(reflex_present_id(&alone)!=&alone||state.shown_marked)return 22; // (a chain made again in between: none)
|
||||
std::puts("PASS: Reflex retirement before locks and across waits, reused handles, stable wait targets and recovery");
|
||||
}
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user