Primeiro boot do TLG no PC: build no Fedora/Nobara e mapeamento do tess ring

- gpu/CMakeLists: Zydis via pkg-config (Fedora), magic_enum do submódulo
  (headers do Fedora sem pasta magic_enum/), Vulkan-Headers 1.4.354 fixado
  como submódulo à frente dos headers do sistema (1.4.341)
- vk_instance.cpp: reset explícito de vk::PipelineBinaryKeyKHR (operator=
  ambíguo nos headers novos)
- actor_hook.h: static_assert em C++ (GCC não aceita _Static_assert)
- runtime_memory: honra hint exato na janela system-reserved
  (0x7_0000_0000..0x8_0000_0000): tessellation factor ring em 0x7f0000000
- run_tlg.sh: prepara, linka e roda o jogo (pipeline binaries off na NVIDIA)

Resultado: boot em 0,41 s, engine em execução, ~28,7 fps (trava de 30)
por 40 s sem falhas, 1148 frames apresentados.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JyWhQUvUQf2YSf8HJWnAtd
This commit is contained in:
HayatoGandClaude Opus 5.5 committed 2026-10-12 21:31:46 -03:00
1 parent c3d15e3df0
commit 29e9ef1c7b
7 files changed
+58 -4

No files matched your search

+3
View File
@@ -16,3 +16,6 @@
[submodule "port/third_party/LibAtrac9"]
path = port/third_party/LibAtrac9
url = https://github.com/Thealexbarney/LibAtrac9.git
[submodule "port/gpu/third_party/vulkan-headers"]
path = port/gpu/third_party/vulkan-headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git
+15 -2
View File
@@ -41,10 +41,18 @@ elseif (GOW3_PGO STREQUAL "use")
endif()
find_package(Vulkan REQUIRED)
# Pinned Vulkan-Headers (submodule) ahead of the system ones: distro headers can lag behind the
# extensions the shadPS4 video core uses (e.g. Fedora 44 ships 1.4.341, VALVE mixed float dot is newer).
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/vulkan-headers/include/vulkan/vulkan.hpp)
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/vulkan-headers/include)
endif()
find_package(fmt REQUIRED)
find_package(Boost REQUIRED)
# gow3 (Windows): MSYS2 has no magic_enum/miniz packages; the submodules are used instead.
find_package(magic_enum QUIET)
# The pinned submodule is preferred: Fedora's magic_enum installs flat headers (no magic_enum/ dir).
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/magic_enum/include/magic_enum/magic_enum.hpp)
find_package(magic_enum QUIET)
endif()
if (NOT magic_enum_FOUND)
add_library(magic_enum INTERFACE)
add_library(magic_enum::magic_enum ALIAS magic_enum)
@@ -77,7 +85,12 @@ if (NOT miniz_FOUND)
unset(CMAKE_POLICY_VERSION_MINIMUM)
add_library(miniz::miniz ALIAS miniz)
endif()
find_package(Zydis REQUIRED)
find_package(Zydis QUIET)
if (NOT Zydis_FOUND)
# Fedora/Nobara ship zydis-devel with a pkg-config file only.
pkg_check_modules(ZYDIS REQUIRED IMPORTED_TARGET zydis)
add_library(Zydis::Zydis ALIAS PkgConfig::ZYDIS)
endif()
find_program(GLSLANG_COMPILER NAMES glslang glslangValidator REQUIRED)
set(SIRIT_USE_SYSTEM_SPIRV_HEADERS OFF CACHE BOOL "" FORCE)
@@ -228,7 +228,7 @@ bool PipelineBinaryCacheRequested() {
bool InitializePipelineBinaryCache(vk::Device device, bool supported,
vk::PipelineBinaryKeyKHR& global_key) {
global_key = {};
global_key = vk::PipelineBinaryKeyKHR{};
if (!PipelineBinaryCacheRequested()) {
LOG_INFO(Render_Vulkan, "Pipeline binary cache disabled by settings; using normal compilation");
return false;
@@ -248,7 +248,7 @@ bool InitializePipelineBinaryCache(vk::Device device, bool supported,
if (result != vk::Result::eSuccess || !global_key.keySize ||
global_key.keySize > VK_MAX_PIPELINE_BINARY_KEY_SIZE_KHR) {
const auto key_size = global_key.keySize;
global_key = {};
global_key = vk::PipelineBinaryKeyKHR{};
LOG_WARNING(Render_Vulkan,
"Pipeline binary cache key unavailable (result {}, size {}); using normal compilation",
vk::to_string(result), key_size);
+4
View File
@@ -23,7 +23,11 @@ typedef struct {
uint32_t seq, pad;
uint64_t reserved;
} Gow3ActorSlot;
#ifdef __cplusplus
static_assert(sizeof(Gow3ActorSlot) == 32, "stub uses a 32-byte stride");
#else
_Static_assert(sizeof(Gow3ActorSlot) == 32, "stub uses a 32-byte stride");
#endif
static inline int gow3_actor_signature_match(const unsigned char *code, uint64_t size) {
return size >= GOW3_ACTOR_HOOK_LENGTH && !memcmp(code, gow3_actor_original, GOW3_ACTOR_HOOK_LENGTH);
+11
View File
@@ -347,7 +347,18 @@ static int overlaps(uintptr_t start, uintptr_t end, int ignore_reserved) {
return 0;
}
/* First-fit search in the PS4 user range, starting from the hint. */
/* System-reserved window (shim AddressSpace::SystemReservedVirtualBase/Size). Gnm places fixed
* objects there, e.g. the tessellation factor ring at 0x7f0000000 that The Last Guardian maps by
* hint and then verifies; an exact free hint in this window is honoured. */
#define SYSTEM_RESERVED_MIN UINT64_C(0x700000000)
#define SYSTEM_RESERVED_MAX UINT64_C(0x800000000)
static int range_free(uintptr_t start, uint64_t size) {
size_t i=vma_index(start);
return i==vma_count || vmas[i].start>=start+size;
}
static uintptr_t find_free(uintptr_t hint, uint64_t size, uint64_t alignment) {
if (hint>=SYSTEM_RESERVED_MIN && hint+size<=SYSTEM_RESERVED_MAX && !(hint%alignment) && range_free(hint,size))
return hint;
uintptr_t at=align_up(hint<USER_MIN ? USER_MIN : hint, alignment);
for (size_t i=vma_index(at); at+size<=USER_MAX; ++i) {
if (i==vma_count || vmas[i].start>=at+size) return at;
Executable
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Prepara e roda The Last Guardian (CUSA03627 v1.03) pelo loader nativo em port/.
# Uso: ./run_tlg.sh [segundos] (padrão: sem limite; feche a janela ou Ctrl+C para sair)
# A pasta do jogo (game/CUSA03627) precisa existir: links para dump/ (base) e dump/patch0 (1.03).
set -euo pipefail
root=$(cd -- "$(dirname -- "$0")" && pwd)
port=$root/port
game=${TLG_GAME_DIR:-$root/game/CUSA03627}
out=$port/out
[[ -x $out/gow3-probe ]] || { echo "Compile primeiro: (cd port && bash build.sh)" >&2; exit 1; }
[[ -f $game/eboot.bin ]] || { echo "Sem eboot.bin em $game" >&2; exit 1; }
python3 "$port/scripts/prepare.py" "$game" --out "$out" >/dev/null
python3 "$port/scripts/link_modules.py" "$game" --out "$out" >/dev/null
python3 "$port/scripts/content_profile.py" "$game" --out "$out" >/dev/null
mkdir -p "$port/user"
# O cache de pipeline binário (VK_KHR_pipeline_binary) trava no driver NVIDIA 595: desligado.
export GOW3_PIPELINE_BINARIES=${GOW3_PIPELINE_BINARIES:-0}
export GOW3_RESTART_COMMAND=${GOW3_RESTART_COMMAND:-"$0"}
log=$out/last_run.log
echo "Rodando (log: $log)"
exec "$out/gow3-probe" "$out/boot-linked.bin" --app0 "$game" --user "$port/user" \
--content-profile "$out/content.bin" --timeout "${1:-0}" > >(tee "$log") 2>&1