mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-25 18:48:51 -04:00
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
192 lines
13 KiB
C++
192 lines
13 KiB
C++
// Draws and dispatches (vk_draw.cpp).
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "vk_internal.h"
|
|
#include "vk_state.h"
|
|
|
|
namespace mkwvk {
|
|
/// Something other than the draw path pushed or bound descriptors in the recording (its next push is whole)
|
|
void descriptors_disturbed();
|
|
|
|
/// ((Triforce, S8, FSR3-07) The texture LOD bias while DLSS or FSR scales the 3D with jitter (sharpen_rules.h lod_bias, on
|
|
/// the scene's material samplers, lod_biased): an upscaler that drew a frame says its render size and output width (note), and
|
|
/// once a present (tick, vk_replay.cpp) the bias follows them, the samplers made anew when it changes. Only the draws into
|
|
/// targets of that render size, or of this frame's scene camera's (scene, below), take it (vk_draw.cpp draw_in_scene): no dispatch, shadow map or capture. RX_VK_UPSCALE_LOD_BIAS=0:
|
|
/// none, the game's own bias alone (for a lab A/B); a negative number (-1, -1.5): that bias in its place
|
|
void upscale_lod_note(uint32_t render_w, uint32_t render_h, uint32_t output_w);
|
|
void upscale_lod_tick();
|
|
/// ((Triforce, S8) The scene camera's target size this frame, as the upscaler's notes take it in stream order
|
|
/// (temporal_note_scene_draw, fsr3_inputs::note_scene_draw): the draws at that size are the scene in the frame the game's
|
|
/// dynamic resolution moved to it, before the upscale notes it (sharpen_rules.h lod_scene_now)
|
|
void upscale_lod_scene(uint32_t width, uint32_t height);
|
|
|
|
/// A graphics pipeline as triforce_pipelines.bin keeps it (the precompile's notes): what built it
|
|
struct PipeNote {
|
|
uint64_t key, prog, variant;
|
|
uint32_t topo, n, samples, depth_format, has_depth;
|
|
uint32_t color_format[8];
|
|
NvnState s;
|
|
};
|
|
/// (vk_predict.cpp) The pipelines the notes predict for the kept graphics program variants no note names (key 0: not made yet)
|
|
/// (Triforce) A predicted pipeline as what it is made from: the program variant, the note whose vertex layout it takes and
|
|
/// the note whose targets and state it takes. 32 bytes against a note's ~26 KB: the plan is kept in a file, and the notes
|
|
/// are made again from it (predict_rebuild) when the programs' file can no longer be gone through whole (after the
|
|
/// precompile took the noted programs out of its list)
|
|
struct PredictPlan {
|
|
uint64_t prog, variant, vertex_note, output_note;
|
|
};
|
|
/// ((Triforce, 11-22, the performance audit's PIPE-44) What a prediction left out, for its line: noted variants the programs'
|
|
/// file has no face for, and vertex layouts that did not fit their program's inputs (RX_VK_PREDICT_TYPES=1: predict_types.h)
|
|
struct PredictCounts {
|
|
size_t no_face = 0, misfits = 0;
|
|
};
|
|
std::vector<std::unique_ptr<PipeNote>> predict_pipelines(const std::vector<std::unique_ptr<PipeNote>>& notes, size_t* programs,
|
|
std::vector<PredictPlan>* plan = nullptr, PredictCounts* counts = nullptr);
|
|
std::vector<std::unique_ptr<PipeNote>> predict_rebuild(const std::vector<std::unique_ptr<PipeNote>>& notes,
|
|
const std::vector<PredictPlan>& plan);
|
|
/// ((Triforce, 11-21, PIPE-83) One predicted pipeline's note into n, of the note V whose vertex layout and the note O whose
|
|
/// targets and state it takes: what predict_rebuild makes of each plan entry
|
|
void predicted_into(PipeNote& n, const PipeNote& V, const PipeNote& O, uint64_t prog, uint64_t variant);
|
|
}
|
|
|
|
#include <functional>
|
|
|
|
#include "vk_internal.h"
|
|
#include "vk_state.h"
|
|
|
|
namespace mkwvk {
|
|
|
|
struct DrawArgs {
|
|
int prim = 0;
|
|
bool indexed = false;
|
|
int itype = 0; // NVNindexType: byte, short, int
|
|
int count = 0, first = 0, base_vertex = 0, base_instance = 0, instances = 1;
|
|
uint64_t ibuf = 0;
|
|
// indirect: arguments at indirect (stride, up to max), their count at count_addr (or 0)
|
|
uint64_t indirect = 0, count_addr = 0;
|
|
int max = 0, stride = 0;
|
|
// mesh shading (NVN2 task / mesh programs): workgroups, or indirect as above
|
|
bool mesh = false;
|
|
int groups[3] = {0, 1, 1};
|
|
uint32_t first_task = 0; // (hookshot: a direct mesh draw's first task workgroup, NVN's DrawMeshTasks(first, count))
|
|
};
|
|
|
|
/// A recording starts (its slot's descriptor pool and upload stream are reset); value: the timeline value it signals
|
|
void draw_begin_recording(int slot, VkCommandBuffer cmd, uint64_t value);
|
|
/// ((Triforce, 11-21, the performance audit's REPLAY-04) the slot's descriptor pools and grown streams reset now, before the
|
|
/// recording's first packet, so that draw_begin_recording finds it done (vk_draw.cpp)
|
|
void draw_slot_reset(int slot);
|
|
/// Publish CPU writes from this slot's used streams before its commands reach the GPU (also for worker slots).
|
|
void draw_flush_recording(int slot);
|
|
/// The recording's stream still holds [at, at + n) in the mapping at base (a reset starts used over)
|
|
bool stream_holds(const uint8_t* base, uint64_t at, uint64_t n);
|
|
/// The open render pass ends (before transfers, clears, barriers and the recording's end)
|
|
void end_pass(VkCommandBuffer cmd);
|
|
/// (Triforce) RX_VK_SPLIT_BARRIER (barrier_rules.h, vk_replay.cpp maybe_split): before a part's split ends the pass, whether one
|
|
/// is open (not with the parallel replay); its targets and what its draws sampled and wrote kept for pass_carry_resume
|
|
bool pass_carry_take();
|
|
bool draw_pass_open(); // ((Triforce) Threaded rendering's parts, vk_replay.cpp maybe_split: this thread's render pass open)
|
|
/// The pass pass_carry_take kept, begun again on cmd (the next part's) with its targets behind vk_texture.cpp pass_resume_barrier,
|
|
/// with what its draws sampled and wrote: draw_hazards and clear_after_draws go on as in one pass. go: false drops it (the split
|
|
/// went the old way, with full barriers)
|
|
void pass_carry_resume(VkCommandBuffer cmd, bool go);
|
|
void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d);
|
|
/// Clears of the bound targets, inside the open pass (NOP_CLEAR_COLOR, NOP_CLEAR_DS)
|
|
void clear_color_target(VkCommandBuffer cmd, NvnState& s, int index, const float rgba[4], uint32_t mask);
|
|
void clear_depth_stencil(VkCommandBuffer cmd, NvnState& s, float depth, bool depth_mask, uint32_t stencil,
|
|
uint32_t stencil_mask);
|
|
void clear_stats(int64_t* clears, int64_t* masked);
|
|
/// indirect: the workgroup counts' GPU address (x, y, z unused)
|
|
void dispatch(VkCommandBuffer cmd, NvnState& s, uint32_t x, uint32_t y, uint32_t z, uint64_t indirect);
|
|
void dry_mark_written(NvnState& s, bool compute, bool first); // (hookshot: the parallel replay's dry pass)
|
|
void dry_marks_begin(); // (at the start of each dry pass: the last targets it skipped by are forgotten)
|
|
/// (Triforce) The dry pass with a temporal upscaler or a frame generation on (stream_order.h): a draw (NVN primitive prim, or a
|
|
/// mesh draw) told to their hooks as draw() tells them, true at the engine's point before the bloom; a dispatch, true where it
|
|
/// may be the upscale's. At the first true the dry pass stops telling them, and the segments' recording takes over there in
|
|
/// order (vk_replay.cpp replay_handle)
|
|
bool dry_temporal_draw(NvnState& s, int prim, bool mesh);
|
|
bool dry_temporal_dispatch(NvnState& s);
|
|
/// (Triforce) The early tail (vk_replay.cpp, tail_early.h): a dispatch that is the gameplay upscale's, where a frame's tail
|
|
/// begins; and the watch on the game's programs that reach guest memory past their bindings (page table, texel buffers), counted
|
|
/// while it is on
|
|
bool upscale_dispatch(NvnState& s);
|
|
void draw_tail_watch(bool on);
|
|
uint64_t draw_tail_programs();
|
|
/// (Triforce, vk_replay.cpp) While a segment is recorded whose draws the dry pass told the temporal hooks: draw() does not
|
|
/// tell them again
|
|
bool replay_hooks_told();
|
|
/// (Triforce, vk_replay.cpp) The draw or dispatch being recorded: its place in the stream (the command buffer's replay, then
|
|
/// its draws and dispatches before it), the same whichever thread records it
|
|
uint64_t replay_stream_pos();
|
|
/// (Triforce, 11-17, vk_replay.cpp "occlusion queries") RX_VK_OCC_QUERY (default on, =0 off): NVN's samples-passed reports from Vulkan
|
|
/// occlusion queries. occ_live: the queries run (set once, at the first recording; false: none of these is called). draw()
|
|
/// calls occ_draw_enter as a draw comes in, occ_draw_begin once its pass is open (a count's first draw of a pass begins a
|
|
/// query) and occ_draw_issued for each draw it records (a count missing one is not kept); end_pass calls occ_pass_end before
|
|
/// the pass ends (a query begun in a pass ends in it)
|
|
extern bool occ_live;
|
|
void occ_draw_enter();
|
|
void occ_draw_begin(VkCommandBuffer cmd);
|
|
/// ((Triforce, 11-22, GPUWORK-01) a draw that writes colour, its pass open, before occ_draw_begin: counted, and with
|
|
/// RX_VK_OCC_DEPTH_ONLY the count it falls in is given up)
|
|
void occ_draw_colour(VkCommandBuffer cmd);
|
|
/// ((Triforce, 11-22, DESC-82) whether the thread's count has a query open now (after occ_draw_begin); RX_VK_OCC_LEAN=3, the
|
|
/// census of the colour-off draws such a query counts (occ_lean.h), on: vk_draw.cpp)
|
|
bool occ_counting();
|
|
bool occ_lean_census_on();
|
|
void occ_draw_issued();
|
|
/// ((Triforce, 11-22, PIPE-29) whether this thread's draws are inside a samples-passed count now: draw()'s depth budget waits
|
|
/// for those (a draw left out there changes what the count says)
|
|
bool occ_counting_now();
|
|
void occ_pass_end(VkCommandBuffer cmd);
|
|
void draw_stats(int64_t* draws, int64_t* skipped, int64_t* dispatches, int64_t* pipelines);
|
|
void draw_stats2(int64_t* passes, int64_t* mesh, double* pipeline_ms);
|
|
void draw_stats3(int64_t* pending_skips, int64_t* waits, double* wait_ms);
|
|
/// (Triforce) Of draw_stats3's wait_ms, in microseconds so far: the replay's waits for pipelines (a draw's, waited for whole or
|
|
/// from the frame's budget) and for translations (a draw's and a dispatch's program, the dry pass's too): the performance
|
|
/// overlay's Pipeline waits and Shader waits (vk_menu.cpp perf_sample). Atomic counters: read from any thread
|
|
void draw_wait_split(int64_t* pipe_us, int64_t* shader_us);
|
|
/// (Triforce, vk_replay.cpp hold_step, once a present) The draws and dispatches left out since the last present because their
|
|
/// program or pipeline was still being made (0 with RX_VK_HOLD_PIPELINES=0): such a frame is held as one with a texture owed
|
|
/// its bytes (present_hold.h, pipe_wait.h). And the hold's mode for the next frame's draws (present_hold::Mode): with DEFERS a
|
|
/// full-screen draw whose pipeline is not ready is left out, its frame held, rather than waited for
|
|
int64_t draw_left_out_take();
|
|
void draw_hold_mode(int mode);
|
|
int64_t draw_dummy_textures(); // (Triforce: texture bindings that sampled the dummy so far: RX_VK_FRAME_TRACE)
|
|
/// (hookshot) pipelines linked from stage libraries in the draw, and the libraries asked of the driver for them: had, and cold;
|
|
/// of the cold, those a worker has built since, and the workers' time in them. False: no stage libraries (RX_VK_GPL)
|
|
bool draw_stats4(int64_t* links, double* link_ms, int64_t* lib_hits, int64_t* lib_cold, int64_t* lib_built, double* lib_build_ms);
|
|
void draw_skip_report(double frames); // (hookshot) skips by the line that made them
|
|
int64_t draw_desc_reused();
|
|
/// (RX_VK_DESC_SLOTGEN) Of those, the reuses the global registrations' generation check would have rebuilt for
|
|
int64_t draw_slotgen_saves();
|
|
/// RX_VK_FLASH_RECORD=<key>,...: the last frames' draws of those programs, written to the log for frames around a flash
|
|
void draw_records_log(uint64_t frame_lo, uint64_t frame_hi);
|
|
void pass_traces_log(uint64_t frame_lo, uint64_t frame_hi); // (RX_VK_PASS_TRACE=1)
|
|
/// Changes with every uniform update the stream makes (vk_replay.cpp): descriptors bound before may be stale
|
|
uint64_t ub_generation();
|
|
/// A background thread (shader translation, pipeline builds) reads guest memory from the captures only, never the stream's
|
|
/// uniform updates: that list is the replay's, which grows and is pruned while such a thread runs
|
|
void ub_thread_off();
|
|
/// ((Triforce) the Debug tab's Descriptor reuse and Sampler cache rows as the menu has them: they apply in play (vk_menu.cpp
|
|
/// menu_tick, each frame). RX_VK_DESC_SLOTGEN and RX_VK_SAMPLER_CACHE hold them for a run
|
|
void menu_debug_rows(int descriptor_reuse, int sampler_cache);
|
|
/// The pipeline cache to disk (force: whatever was built since the last save; else only after a few new ones)
|
|
void pipeline_cache_save(bool force);
|
|
/// (Triforce) Once a present, on its thread: the fast-linked pipelines whole builds have replaced are destroyed once no draw
|
|
/// recorded with one can still be on its way (gpl_rules.h). Nothing without the fast pipeline link
|
|
void gpl_retire_run();
|
|
/// (vk_memory.cpp) The menu's Restart and Exit, before the window closes: no verdict on the memory trial for a session ended on purpose
|
|
void memory_trial_orderly_end();
|
|
|
|
/// The stream's uniform updates (UPDATE_UB, vk_replay.cpp) that overlap [addr, addr + n) and may not be in guest
|
|
/// memory yet when the GPU reads it: a copy of the range with them applied, at the offset alloc returns in the
|
|
/// recording's stream (mapped at base), or UINT64_MAX when none overlaps
|
|
uint64_t ub_overlay(uint64_t addr, uint64_t n, uint8_t* base, uint64_t (*alloc)(uint64_t, uint64_t), uint64_t align);
|
|
/// Guest memory as the stream's place sees it: as submitted, the stream's uniform updates before it over it
|
|
bool ub_read(uint64_t addr, void* dst, uint64_t n);
|
|
|
|
} // namespace mkwvk
|