mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 13:18:37 +00:00
LEONIDA_SKIP_COMPUTE is a play-time setting: the game drops the listed programs' dispatches. The precompile also refused to build them, one "not built (LEONIDA_SKIP_COMPUTE)" line each and no override. Players run it with the game's environment (docs/running.md), so their skip list kept those programs out of the journal for good, and a later run without the list compiled them in the game. - precompile_compute_pipelines builds every compute entry; with the list set it says how many entries it names. --skip-listed leaves them out on purpose, one line each. - The last line counts the whole run: built (compiled, from a cache), journaled already, being built by another process, failed; left out: of those the list names, not buildable, filtered out (--filter, the size bounds and now --limit too). - BuildHost::unbuildable no longer checks the list. The compile server checks it itself, as before: the game that starts it drops those dispatches. Docs: running.md, linux_proton.md and d3d12_vulkan.md no longer give compile time as the reason for the skip list. The 89-167 s per program came from wave64-emulated packs; with a native wave64 pack on an RX 7900 XTX (RADV, Mesa 26.3.1, Wine) all 721 library programs of 2 MiB or more built, 360 of them in 170 s on 32 threads, 2.5-32 s each, the largest (13 MiB) in 28.5 s alone, at a peak of 14 GiB of RAM. Two world runs on that card with all of them journaled and no skip list took them all from the journal and got no further than runs with the list (a stop with the GPU idle at 404 s; an idle-queue device loss at about 214 s, which also happens with the list set). Their output is not checked, so the docs keep the skip list and LEONIDA_RT_AS=off as the setting of our longest runs. Test: precompile_skip_list (test/check_precompile_skip_list.cmake) precompiles two synthetic compute modules, one of them listed, three times: with the list set both are built; with --skip-listed only the other one is, and the listed one is named; a second run into the first journal finds both journaled. It fails on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
6.7 KiB
CMake
124 lines
6.7 KiB
CMake
# gta6rt --precompile-pipelines and LEONIDA_SKIP_COMPUTE (shims/d3d12_precompile.h): the play-time skip list does not
|
|
# keep programs out of the pipeline journal; --skip-listed does, and the closing line counts both.
|
|
# cmake -DGTA6RT=<gta6rt.exe> [-DRUNNER=<wine>] -DSPV_A=<compute .spv> -DSPV_B=<another compute .spv>
|
|
# -DTEST_DIR=<scratch folder> -P check_precompile_skip_list.cmake
|
|
# A library of two synthetic compute entries, one of them named by LEONIDA_SKIP_COMPUTE, is precompiled three times:
|
|
# 1. into an empty journal with the list set and no flag: both entries are built;
|
|
# 2. into another empty journal with --skip-listed: only the unlisted one is, and the listed one is reported;
|
|
# 3. into the first journal again: both are journaled already, nothing is built.
|
|
# The verdicts are read from the output and the journal folders, since under Wine an exit status alone can look fine.
|
|
cmake_minimum_required(VERSION 3.24)
|
|
|
|
foreach(var GTA6RT SPV_A SPV_B TEST_DIR)
|
|
if(NOT DEFINED ${var} OR "${${var}}" STREQUAL "")
|
|
message(FATAL_ERROR "check_precompile_skip_list.cmake: -D${var}=... is required")
|
|
endif()
|
|
endforeach()
|
|
|
|
file(REMOVE_RECURSE "${TEST_DIR}")
|
|
file(MAKE_DIRECTORY "${TEST_DIR}/shaders")
|
|
# Two different modules: entries with the same module and layout share one journal file.
|
|
file(COPY_FILE "${SPV_A}" "${TEST_DIR}/shaders/precompile_kept.spv")
|
|
file(COPY_FILE "${SPV_B}" "${TEST_DIR}/shaders/precompile_listed.spv")
|
|
# The runtime's library takes an entry only with a program hash; these two name no real program.
|
|
set(meta "\"stage\":\"cs\",\"bindings\":[],\"push_constant_bytes\":144,\"local_size\":[1,1,1],\"wave64\":false")
|
|
string(REPEAT "a" 64 hash_kept)
|
|
string(REPEAT "b" 64 hash_listed)
|
|
file(WRITE "${TEST_DIR}/shaders/index.json"
|
|
"{\"precompile_kept\":{\"fssm_sha256\":\"${hash_kept}\",${meta}},"
|
|
"\"precompile_listed\":{\"fssm_sha256\":\"${hash_listed}\",${meta}}}\n")
|
|
|
|
# Only what this test sets: a journal setting or helper from the caller's environment would change the counts.
|
|
foreach(var LEONIDA_PIPELINE_JOURNAL LEONIDA_PIPELINE_CACHE_BYTES LEONIDA_PIPELINE_JOURNAL_BYTES
|
|
LEONIDA_PIPELINE_JOURNAL_SEED_DIR LEONIDA_COMPILE_HELPER LEONIDA_LAZY_COMPUTE)
|
|
unset(ENV{${var}})
|
|
endforeach()
|
|
file(TO_NATIVE_PATH "${TEST_DIR}/shaders" shaders)
|
|
set(ENV{LEONIDA_SHADERS} "${shaders}")
|
|
set(ENV{LEONIDA_SKIP_COMPUTE} "precompile_listed")
|
|
|
|
set(failures "")
|
|
set(all_output "")
|
|
# Runs the precompile with the journal in <cache> and the extra arguments; sets `out` and `code` in the caller.
|
|
function(precompile label cache)
|
|
file(TO_NATIVE_PATH "${TEST_DIR}/${cache}" cache_dir)
|
|
set(ENV{LEONIDA_PIPELINE_CACHE_DIR} "${cache_dir}")
|
|
execute_process(COMMAND ${RUNNER} "${GTA6RT}" --precompile-pipelines --threads 1 ${ARGN}
|
|
WORKING_DIRECTORY "${TEST_DIR}"
|
|
TIMEOUT 90
|
|
RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE output)
|
|
string(REPLACE "\r\n" "\n" output "\n${output}\n")
|
|
set(out "${output}" PARENT_SCOPE)
|
|
set(code "${result}" PARENT_SCOPE)
|
|
set(all_output "${all_output}--- ${label} (exit ${result}) ---${output}" PARENT_SCOPE)
|
|
endfunction()
|
|
# Functions, not macros: a macro would substitute the patterns' text and undo their backslash escapes.
|
|
function(expect label pattern)
|
|
if(NOT out MATCHES "${pattern}")
|
|
set(failures "${failures}${label}: no match for '${pattern}'\n" PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
function(expect_not label pattern)
|
|
if(out MATCHES "${pattern}")
|
|
set(failures "${failures}${label}: unexpected match for '${pattern}'\n" PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
function(expect_exit label want)
|
|
if(NOT "${code}" STREQUAL "${want}")
|
|
set(failures "${failures}${label}: exit ${code}, not ${want}\n" PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|
|
function(journal_files cache var)
|
|
file(GLOB files "${TEST_DIR}/${cache}/pipeline_cache.d/cs-*.bin")
|
|
list(LENGTH files count)
|
|
set(${var} ${count} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
# 1. The list is set, no flag: both entries are built and nothing is reported as left out by the list.
|
|
precompile("list set, no flag" cache_all)
|
|
if(code STREQUAL "1" AND out MATCHES "the Vulkan device could not be created|the runtime builds no compute pipeline")
|
|
message("SKIP: no Vulkan device for the precompile here${all_output}")
|
|
return()
|
|
endif()
|
|
expect_exit("list set, no flag" 0)
|
|
expect("list set, no flag" "\n\\[precompile\\] LEONIDA_SKIP_COMPUTE names 1 of the entries: built anyway")
|
|
expect("list set, no flag" "\n\\[precompile\\] 2 compute entries to build ")
|
|
expect_not("list set, no flag" "precompile_listed: not built")
|
|
expect("list set, no flag" "\n\\[precompile\\] done: 2 built \\([0-9]+ compiled, [0-9]+ from a cache\\), 0 journaled already, 0 being built by another process, 0 failed; left out: 0 of 1 listed in LEONIDA_SKIP_COMPUTE, 0 not buildable, 0 filtered out; in [0-9]+ s\n")
|
|
# A driver that returns no cache data leaves no journal file; then step 3 has nothing to find.
|
|
set(journaled TRUE)
|
|
if(out MATCHES "compiled \\(not journaled\\)")
|
|
set(journaled FALSE)
|
|
message("note: the driver gave no cache data, so the journal-file checks are left out")
|
|
else()
|
|
journal_files(cache_all count)
|
|
if(NOT count EQUAL 2)
|
|
string(APPEND failures "list set, no flag: ${count} journal files, not 2\n")
|
|
endif()
|
|
endif()
|
|
|
|
# 2. --skip-listed: the listed entry is left out and named, the other one is built.
|
|
precompile("--skip-listed" cache_listed --skip-listed)
|
|
expect_exit("--skip-listed" 0)
|
|
expect("--skip-listed" "\n\\[precompile\\] precompile_listed: not built \\(LEONIDA_SKIP_COMPUTE, --skip-listed\\)\n")
|
|
expect("--skip-listed" "\n\\[precompile\\] 1 compute entries to build \\([^)]*, 1 left out by --skip-listed, 0 not buildable\\)")
|
|
expect("--skip-listed" "\n\\[precompile\\] done: 1 built \\([0-9]+ compiled, [0-9]+ from a cache\\), 0 journaled already, 0 being built by another process, 0 failed; left out: 1 of 1 listed in LEONIDA_SKIP_COMPUTE \\(--skip-listed\\), 0 not buildable, 0 filtered out; in [0-9]+ s\n")
|
|
if(journaled)
|
|
journal_files(cache_listed count)
|
|
if(NOT count EQUAL 1)
|
|
string(APPEND failures "--skip-listed: ${count} journal files, not 1\n")
|
|
endif()
|
|
endif()
|
|
|
|
# 3. The first journal again: both entries are there, nothing is built.
|
|
if(journaled)
|
|
precompile("again" cache_all)
|
|
expect_exit("again" 0)
|
|
expect("again" "\n\\[precompile\\] done: 0 built \\(0 compiled, 0 from a cache\\), 2 journaled already, 0 being built by another process, 0 failed; left out: 0 of 1 listed in LEONIDA_SKIP_COMPUTE, 0 not buildable, 0 filtered out; in [0-9]+ s\n")
|
|
endif()
|
|
|
|
if(failures)
|
|
message(FATAL_ERROR "gta6rt --precompile-pipelines and LEONIDA_SKIP_COMPUTE:\n${failures}${all_output}")
|
|
endif()
|
|
message("precompile and LEONIDA_SKIP_COMPUTE: built regardless of the list, left out with --skip-listed${all_output}")
|