nx2: measure the TSC on AMD, no rethrows for rejected shaders, debug hooks off the hot path

- AMD CPUs have no CPUID leaf 0x15, so the TSC frequency stayed 0 and
  every guest CNTPCT read went through QueryPerformanceCounter (~10% of
  the game's main core in title 1). Measure it like Intel CPUs without
  a crystal frequency.
- A rejected native shader was rethrown (two C++ throws) every time it
  was bound; return false instead (~1-2% of the GPU thread).
- The semaphore watch, pushbuffer entry hashing, first-write trace and
  per-macro debug logs ran on every command word or macro call; they
  now cost a flag check unless their environment variable is set
  (~4% of the GPU thread). Also starts the macro engine's profile zone.
This commit is contained in:
Takoroka 2026-10-28 23:07:49 -04:00
commit 2671edfe36

View file

@ -225,6 +225,13 @@ const CPUCaps g_cpu_caps = [] {
}
}
// AMD CPUs have no leaf 0x15 (Zen 4 stops at 0x10): measure their invariant TSC too, or every
// guest clock read (CNTPCT, which games read thousands of times a frame) goes through the
// host's much slower QueryPerformanceCounter.
if (caps.invariant_tsc && caps.tsc_frequency == 0) {
caps.tsc_frequency = X64::EstimateRDTSCFrequency();
}
if (max_std_fn >= 0x16) {
__cpuid(cpu_id, 0x16);
caps.base_frequency = cpu_id[0];