mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 01:49:59 -04:00
Let one replay worker record each long run of draws from a copy of the replay state, behind NX2NAVI_REPLAY_WORKERS.
Stage 1 of recording a submission on several threads. A submission's draws come in runs between ops that have to stay in the replay's order on its own thread (dispatches, copies, texture and buffer clears, events, the game's barriers, calls). With NX2NAVI_REPLAY_WORKERS=1 a run of 16 draws or more is recorded by a worker thread: it takes a copy of the replay state, records the run into a command buffer of its own pool with a draw context of its own, ends it behind a full barrier and hands the state back. vk_sync_append puts that command buffer into the part between the replay's own pieces before and after it, so the GPU runs everything in the op stream's order. The submitting thread waits for each run, so every side effect keeps the replay's order; this stage checks that a run recorded apart from a copy of the state gives the same pictures. The default, 0, replays as before. walk's handling of the ops that do not steer it moves into op_one, which the worker uses too. NX2NAVI_REPLAY_RUNS=1 logs every 600 frames how the draws fall into such runs and which ops break them. The draw replay's hot functions load their recording context once instead of at every use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -705,6 +705,15 @@ int vk_exec_record(VkCommandBuffer cb, const uint64_t *handles, int n, uint64_t
|
||||
// batch) without a signal, and returns a new begun one for the rest of the submission. The submission's timeline value
|
||||
// is signalled by its last part, whose signal covers every earlier part in submission order.
|
||||
VkCommandBuffer vk_sync_split(void);
|
||||
// Inside vk_exec_record, for the replay workers (vk_exec.c): vk_sync_append ends the command buffer recorded so far,
|
||||
// puts it and then cbs (recorded by the workers) into the part, in that order, and returns a new begun one for the rest
|
||||
// of the part; vk_sync_append_room says whether the part has room for n more. A worker claims and begins a command
|
||||
// buffer of its own pool for the submission being recorded with vk_sync_worker_begin(w) and ends it with
|
||||
// vk_sync_worker_end, on its own thread, while the submitting thread waits for it.
|
||||
int vk_sync_append_room(int n);
|
||||
VkCommandBuffer vk_sync_append(const VkCommandBuffer *cbs, int n);
|
||||
VkCommandBuffer vk_sync_worker_begin(int w);
|
||||
void vk_sync_worker_end(VkCommandBuffer cb);
|
||||
extern int vk_sub_in_frame; // replay: the submission being recorded is the frame's n-th (0 the first; vk_backend.c)
|
||||
// Runs fn(arg) on the completion thread once fence is done on the GPU (event writes, counter reports, sync state).
|
||||
// Callbacks run in the order they were added, after those of earlier values; a value already done runs at once there.
|
||||
|
||||
Reference in New Issue
Block a user