#pragma once #include #include #include #include namespace rt::d3d12_trace { inline std::atomic tracing{false}; // Correlate an Xbox stream audit with its backend result, including concurrent creation jobs. inline thread_local unsigned long long last_sequence = 0; inline thread_local const char* stream_refusal = nullptr; inline void set_enabled(bool enable) noexcept { tracing.store(enable, std::memory_order_relaxed); } inline bool enabled() noexcept { return tracing.load(std::memory_order_relaxed); } // Callers supply fixed method names and outcomes only. Keep one ordered record per call across threads. inline void record(const char* method, const char* outcome = "called") noexcept { if (!enabled()) return; static std::mutex mutex; static unsigned long long sequence = 0; const std::lock_guard lock(mutex); last_sequence = ++sequence; std::fprintf(stderr, "[d3d12-trace] #%llu %s %s\n", last_sequence, method, outcome); std::fflush(stderr); } inline HRESULT result(const char* method, HRESULT code) noexcept { record(method, code == E_NOTIMPL ? "unsupported" : FAILED(code) ? "failed" : "ok"); return code; } } // namespace rt::d3d12_trace