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.
92 lines
5.2 KiB
Python
92 lines
5.2 KiB
Python
"""Run actual mapped-stream/pool allocation paths against authored failures and retries."""
|
|
import argparse
|
|
from pathlib import Path
|
|
import os
|
|
import subprocess
|
|
import tempfile
|
|
|
|
RUN_ALL_ARGS = ["--cxx", "{cxx}", "--headers", "{vulkan_headers}"]
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def block(source, marker):
|
|
start = source.index(marker)
|
|
at = source.index('{', start) + 1
|
|
depth = 1
|
|
while depth:
|
|
depth += (source[at] == '{') - (source[at] == '}')
|
|
at += 1
|
|
return source[start:at]
|
|
|
|
|
|
def between(source, start, end):
|
|
"""((Triforce) from start up to, not including, the first end after it)"""
|
|
at = source.index(start)
|
|
return source[at:source.index(end, at + len(start))]
|
|
|
|
|
|
def sim_turf_cut(draw):
|
|
"""((Triforce) vk_draw.cpp's simulated turf as RecordingRes and draw_begin_recording use it: the sample, the readback's
|
|
size, the recording's ready flag and RX_VK_SIM_TURF_ADAPTIVE (on, as by default); the renderer's own turf lists are not
|
|
in use (sim_turf_private_on false, as by default), so no readback is made or read"""
|
|
return "\
|
|
".join([block(draw, "struct SimTurfSample {") + ";",
|
|
"constexpr size_t " + between(draw, "kSimTurfSamplesPerRecording =", ";") + ";",
|
|
between(draw, "thread_local bool sim_turf_monitor_ready", ";") + ";",
|
|
block(draw, "bool sim_turf_adaptive() {"),
|
|
"bool sim_turf_private_on() { return false; }",
|
|
"void sim_turf_observe(uint64_t, bool, uint32_t, uint64_t) {}",
|
|
"void invalidate_mapped(VmaAllocation, uint64_t) {}"])
|
|
|
|
|
|
def main():
|
|
p = argparse.ArgumentParser(description=__doc__)
|
|
p.add_argument('--source', type=Path, default=ROOT)
|
|
p.add_argument('--headers', type=Path, required=True)
|
|
p.add_argument('--cxx', default='g++')
|
|
p.add_argument('--sanitize', action='store_true')
|
|
p.add_argument('--case', default='all')
|
|
a = p.parse_args()
|
|
draw = (a.source / 'gpu/vk/vk_draw.cpp').read_text(encoding='utf-8')
|
|
fixture = (ROOT / 'tests/recording_admission_test.cpp').read_text(encoding='utf-8')
|
|
record = sim_turf_cut(draw) + '\n' + block(draw, 'struct RecordingRes {') + ';'
|
|
assert 'std::vector<Stream> streams;' in record and 'std::vector<VkDescriptorPool> extra;' in record
|
|
record = record.replace('std::vector<Stream> streams;', 'FaultVector<Stream> streams;')
|
|
record = record.replace('std::vector<VkDescriptorPool> extra;', 'FaultVector<VkDescriptorPool> extra;')
|
|
markers = ['bool stream_next(', 'bool stream_reserve(', 'uint64_t stream_alloc(', 'BufferRef stream_copy(']
|
|
if 'bool stream_insert(' in draw:
|
|
markers.insert(0, 'bool stream_insert(')
|
|
stream = '\n'.join(block(draw, marker) for marker in markers)
|
|
start = draw.index(' VkDescriptorSetAllocateInfo ai{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO};', draw.index('bool bind_descriptors('))
|
|
end = draw.index('\n return true;\n}', start) + len('\n return true;')
|
|
fixture = fixture.replace('/* RES */', record).replace('/* STREAM */', stream)
|
|
# ((Triforce, 11-22, DESC-33) make_pool with the half-pool rule's state before it and its counter after it)
|
|
pool = draw[draw.index('bool pool_grow_on() {'):draw.index('void pool_took(')] + block(draw, 'void pool_took(')
|
|
fixture = fixture.replace('/* POOL */', pool)
|
|
fixture = fixture.replace('/* BEGIN */', block(draw, 'void slot_reset_locked(') + '\n' + block(draw, 'void draw_begin_recording(')).replace('/* DESCRIPTORS */', draw[start:end])
|
|
fixture = fixture.replace('/* BANK_CACHE */', block(draw, 'struct BankCache {') + ';')
|
|
fixture = fixture.replace('/* BANK_BRANCH */', block(block(draw, 'VkDescriptorBufferInfo uniform_range('), 'if (index == 0 || index == 2)'))
|
|
cases = ['healthy', 'no-recording', 'initial-buffer', 'initial-map', 'initial-commit', 'pool-retry', 'parallel',
|
|
'growth-buffer', 'growth-map', 'growth-commit', 'overflow', 'rounding', 'alignment-zero',
|
|
'alignment-three', 'grow-off', 'reuse', 'retention', 'descriptor-pool', 'descriptor-set', 'descriptor-commit', 'descriptor-retained', 'bank-retry', 'bank-same',
|
|
'pool-grow', 'pool-grow-off'] # ((Triforce, 11-22, DESC-33) the slots' pools at half: desc_pool_grow.h)
|
|
if a.case != 'all':
|
|
assert a.case in cases
|
|
cases = [a.case]
|
|
with tempfile.TemporaryDirectory(prefix='recording-admission-') as tmp:
|
|
cpp, exe = Path(tmp) / 'fixture.cpp', Path(tmp) / 'fixture.exe'
|
|
cpp.write_text(fixture, encoding='utf-8')
|
|
flags = ['-fsanitize=address,undefined', '-fno-sanitize-recover=all'] if a.sanitize else []
|
|
subprocess.run([a.cxx, '-std=c++20', '-O1', '-pthread', '-Wall', '-Wextra', '-Werror', '-Wno-missing-field-initializers', *flags,
|
|
'-I' + str(a.headers), '-I' + str(a.source / 'gpu' / 'vk'), str(cpp), '-o', str(exe)], check=True)
|
|
env = {k: v for k, v in os.environ.items() if not k.startswith('RX_VK_')}
|
|
for case in cases:
|
|
# (pool-grow-off: the rule's switch back, RX_VK_DESC_POOL_GROW=0)
|
|
subprocess.run([str(exe), case], env={**env, 'RX_VK_DESC_POOL_GROW': '0'} if case == 'pool-grow-off' else env,
|
|
check=True, timeout=15)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|