mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 16:58:37 +00:00
d3d12: keep the replay serial stack a plain thread_local
861bb0546added geometry_execute_serials() as a function-local thread_local std::vector. A C++ thread_local with a destructor in gta6rt.exe adds TLS callbacks to the image, which the loader's TLS index-0 move must not have (pe_loader.cpp reserve_tls_index0; see VulkanContext::stage_xdxr_table). With it the title's CRT startup hits ucrtbase's one-shot _register_thread_local_exe_atexit_callback guard and terminates: 0xC0000409 (info0=7) at ~1.6 s, before any D3D12 call. Use a fixed aggregate instead: no destructor, no TLS callbacks, the same per-thread LIFO, bounded at 32 replays with overflow reported once. Tested: runtime builds; with LEONIDA_D3D12=vulkan the fix boots past startup and submits, while0b11d86bcexits 0xC0000409 at ~1.5 s. NVIDIA RTX 4090, driver 616.64, Windows 11. AI-assisted (Claude Code). Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@ -2601,19 +2601,42 @@ struct DeviceState {
|
||||
forget_geometry_alias);
|
||||
}
|
||||
// ExecuteCommandLists replays in progress, for GeometryViews::kAfterExecutes (see drain_geometry_releases).
|
||||
static std::vector<std::uint64_t>& geometry_execute_serials() {
|
||||
thread_local std::vector<std::uint64_t> serials;
|
||||
// A plain aggregate on purpose: a C++ thread_local with a destructor in gta6rt.exe adds TLS callbacks to the image
|
||||
// the loader's TLS index-0 move must not have (pe_loader.cpp reserve_tls_index0; VulkanContext::stage_xdxr_table
|
||||
// keeps its range list a member for the same reason). A std::vector here made the title's CRT abort at startup.
|
||||
struct GeometryExecuteSerials {
|
||||
static constexpr unsigned kCapacity = 32; // a replay has not been seen nested this deep
|
||||
std::uint64_t serials[kCapacity]{};
|
||||
unsigned count{};
|
||||
unsigned skipped{}; // replays begun while the stack was full: the innermost, ended first
|
||||
};
|
||||
static GeometryExecuteSerials& geometry_execute_serials() {
|
||||
thread_local GeometryExecuteSerials serials;
|
||||
return serials;
|
||||
}
|
||||
void geometry_execute_begin() {
|
||||
if (!geometry.cap()) return;
|
||||
geometry_execute_serials().push_back(geometry.execute_begin());
|
||||
auto& serials = geometry_execute_serials();
|
||||
if (serials.count == GeometryExecuteSerials::kCapacity) {
|
||||
static std::atomic<bool> logged{false};
|
||||
if (!logged.exchange(true))
|
||||
std::fprintf(stderr, "[rt] d3d12: ExecuteCommandLists nested more than %u deep; a geometry view retired "
|
||||
"in the extra replay is not deferred to it\n",
|
||||
GeometryExecuteSerials::kCapacity);
|
||||
++serials.skipped;
|
||||
return;
|
||||
}
|
||||
serials.serials[serials.count++] = geometry.execute_begin();
|
||||
}
|
||||
void geometry_execute_end() {
|
||||
if (!geometry.cap()) return;
|
||||
auto& serials = geometry_execute_serials();
|
||||
if (!geometry.cap() || serials.empty()) return;
|
||||
const std::uint64_t serial = serials.back();
|
||||
serials.pop_back();
|
||||
if (serials.skipped != 0) {
|
||||
--serials.skipped;
|
||||
return;
|
||||
}
|
||||
if (serials.count == 0) return;
|
||||
const std::uint64_t serial = serials.serials[--serials.count];
|
||||
geometry.execute_end(serial, [this] { return context->submitted_retire_ticket(); });
|
||||
}
|
||||
static rt::d3d12::GeometryCopy copy_geometry(std::uint8_t* to, const std::uint8_t* from, std::size_t size) {
|
||||
|
||||
Reference in New Issue
Block a user