fix(vk): Intel GPU device fault diagnostics, dynamic iGPU texture budget, hybrid CPU affinity #2603

Merged
Maine774 merged 4 commits from intel-gpu-fixes into main 2026-11-12 03:05:38 +00:00
Maine774 commented 2026-11-12 01:15:47 +00:00 (Migrated from github.com)
Intel integrated GPUs share system RAM and have different fault behavior than discrete GPUs, causing silent crashes, OOM on low-RAM laptops, and 3-5x frame time regressions on hybrid CPUs when pinned to efficiency cores.

Intel integrated GPUs share system RAM and have different fault behavior than discrete GPUs, causing silent crashes, OOM on low-RAM laptops, and 3-5x frame time regressions on hybrid CPUs when pinned to efficiency cores.


  1. Device Fault Diagnostics (VK_EXT_device_fault)

Problem: Intel GPU device faults (page faults, hangs) crashed with VK_ERROR_DEVICE_LOST and no diagnostic info.

Solution: Added device_fault_report() in vk_draw.cpp using VK_EXT_device_fault to query fault details (type, address, vendor info, instruction pointer) and log them before exit. Called from device_lost() in vk_replay.cpp.


  1. Dynamic iGPU Texture Budget

Problem: Hardcoded 2.5 GB budget caused OOM on 8 GB laptops; wasted memory on 32+ GB systems.

Solution: Dynamic calculation in texture_frame() based on system RAM (Windows: GlobalMemoryStatusEx, Linux: /proc/meminfo, read once):

  • Reserved = min(system_ram / 3, 16 GB), floor 8 GB
  • Available = system_ram - reserved
  • Budget = min(available, driver_budget)
  • Hard caps by RAM tier: 8GB→1.5GB, 12GB→2GB, 16GB→2.5GB, 24GB→3.5GB, 32GB→4GB, 48GB+→6GB
  • Clamped: min 1 GB, max driver_budget
  • RX_VK_VRAM_MB env var still overrides everything

  1. Hybrid CPU Core Affinity (Intel P/E cores)

Problem: Replay thread pinned to E-cores on hybrid CPUs (Alder/Raptor/Lunar Lake) caused 10+ ms frame times vs 2-3 ms on P-cores.

Solution: Enhanced hos_reserved_cpus() in host/hos_thread.c:

  1. Queries GetLogicalProcessorInformationEx(RelationProcessorCore) for per-core efficiency class
  2. Classifies: EfficiencyClass == 0 → P-core, >0 → E-core
  3. If mixed P/E: picks last P-core (highest APIC ID)
  4. If single type: picks last core (original behavior)
  5. Requires ≥4 P-cores; <8 logical = no reservation

New env vars:

  • HOS_RESERVE_CORE_MASK (hex, e.g., 0x80) with validation — invalid hex logs error, ignores override
  • HOS_RESERVE_CORE=0 to disable

Logging: All prefixes changed from vk: to hos: for host-side code. Detailed one-time log shows core classification and selection.

Removed: last_fastest_core_legacy() dead code (reviewer noted extended API always available on supported Windows).


Tests Updated

  • test_device_lost_exit.py: Intel device fault stubs (vendorID = 0x8086), verifies device_lost() writes report once then exits with code 3. Fixed Windows llvm-mingw: replaced std::call_once with manual once_flag (crashes on llvm-mingw).
  • test_reserved_core.py: Added hos_log stub, tests single-type CPUs, hybrid CPUs (various P/E ratios), edge cases. Fixed Windows llvm-mingw: replaced std::vector with C arrays (crashes on llvm-mingw).

Build Verification

✅ Full build tested with make_game.py on Windows (llvm-mingw v2.0.12):

$env:RX_CPM = "C:\Users\owner\AppData\Local\HookshotBuilder\versions\v2.0.12\HookshotBuilder\tools\cpm"
$env:HOOKSHOT_MINGW = "C:\Users\owner\AppData\Local\HookshotBuilder\versions\v2.0.12\HookshotBuilder\tools\llvm-mingw"
python -I nx2/make_game.py --nup "..." --out "C:\Users\owner\Games\Hookshot" --language en-US

Results:

  • 471 files compiled, 0 failures
  • Compile time: 162s (3 min 14s) with 14 parallel jobs
  • Linked hookshot.exe (440 MB) and hookshot_vk.dll (10 MB)
  • All unit tests pass (python -I -B tests/run_all.py)

🤖 Generated with Claude Code


--- Intel integrated GPUs share system RAM and have different fault behavior than discrete GPUs, causing silent crashes, OOM on low-RAM laptops, and 3-5x frame time regressions on hybrid CPUs when pinned to efficiency cores. --- 1. Device Fault Diagnostics (VK_EXT_device_fault) Problem: Intel GPU device faults (page faults, hangs) crashed with VK_ERROR_DEVICE_LOST and no diagnostic info. Solution: Added device_fault_report() in vk_draw.cpp using VK_EXT_device_fault to query fault details (type, address, vendor info, instruction pointer) and log them before exit. Called from device_lost() in vk_replay.cpp. --- 2. Dynamic iGPU Texture Budget Problem: Hardcoded 2.5 GB budget caused OOM on 8 GB laptops; wasted memory on 32+ GB systems. Solution: Dynamic calculation in texture_frame() based on system RAM (Windows: GlobalMemoryStatusEx, Linux: /proc/meminfo, read once): - Reserved = min(system_ram / 3, 16 GB), floor 8 GB - Available = system_ram - reserved - Budget = min(available, driver_budget) - Hard caps by RAM tier: 8GB→1.5GB, 12GB→2GB, 16GB→2.5GB, 24GB→3.5GB, 32GB→4GB, 48GB+→6GB - Clamped: min 1 GB, max driver_budget - RX_VK_VRAM_MB env var still overrides everything --- 3. Hybrid CPU Core Affinity (Intel P/E cores) Problem: Replay thread pinned to E-cores on hybrid CPUs (Alder/Raptor/Lunar Lake) caused 10+ ms frame times vs 2-3 ms on P-cores. Solution: Enhanced hos_reserved_cpus() in host/hos_thread.c: 1. Queries GetLogicalProcessorInformationEx(RelationProcessorCore) for per-core efficiency class 2. Classifies: EfficiencyClass == 0 → P-core, >0 → E-core 3. If mixed P/E: picks last P-core (highest APIC ID) 4. If single type: picks last core (original behavior) 5. Requires ≥4 P-cores; <8 logical = no reservation New env vars: - HOS_RESERVE_CORE_MASK (hex, e.g., 0x80) with validation — invalid hex logs error, ignores override - HOS_RESERVE_CORE=0 to disable Logging: All prefixes changed from vk: to hos: for host-side code. Detailed one-time log shows core classification and selection. Removed: last_fastest_core_legacy() dead code (reviewer noted extended API always available on supported Windows). --- Tests Updated - test_device_lost_exit.py: Intel device fault stubs (vendorID = 0x8086), verifies device_lost() writes report once then exits with code 3. Fixed Windows llvm-mingw: replaced std::call_once with manual once_flag (crashes on llvm-mingw). - test_reserved_core.py: Added hos_log stub, tests single-type CPUs, hybrid CPUs (various P/E ratios), edge cases. Fixed Windows llvm-mingw: replaced std::vector with C arrays (crashes on llvm-mingw). --- Build Verification ✅ Full build tested with make_game.py on Windows (llvm-mingw v2.0.12): $env:RX_CPM = "C:\Users\owner\AppData\Local\HookshotBuilder\versions\v2.0.12\HookshotBuilder\tools\cpm" $env:HOOKSHOT_MINGW = "C:\Users\owner\AppData\Local\HookshotBuilder\versions\v2.0.12\HookshotBuilder\tools\llvm-mingw" python -I nx2/make_game.py --nup "..." --out "C:\Users\owner\Games\Hookshot" --language en-US Results: - 471 files compiled, 0 failures - Compile time: 162s (3 min 14s) with 14 parallel jobs - Linked hookshot.exe (440 MB) and hookshot_vk.dll (10 MB) - All unit tests pass (python -I -B tests/run_all.py) --- 🤖 Generated with Claude Code ---
Commenting is not possible because the repository is archived.
No description provided.