mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:35:52 +01:00
[PR #768] [CLOSED] OLD-8364: runtime: remove TLS-0 static init guards and thread_local in core Vulkan D3D12 runtime #807
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#807
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/768
Author: @whoalin1
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:d3d12-tls0-static-guards📝 Commits (1)
6f9252bruntime: remove TLS-0 static init guards and thread_local in core Vulkan D3D12 runtime📊 Changes
13 files changed (+652 additions, -78 deletions)
View changed files
📝
runtime/CMakeLists.txt(+8 -0)📝
runtime/shims/d3d12_com.cpp(+24 -8)📝
runtime/shims/d3d12_pipeline_compile.h(+13 -2)📝
runtime/shims/d3d12_vulkan_device.cpp(+69 -18)📝
runtime/src/fsdraw_probe.h(+10 -2)📝
runtime/src/queue_holds.h(+26 -13)📝
runtime/src/shader_library.h(+26 -15)📝
runtime/src/title_page_watch.h(+15 -7)📝
runtime/src/title_va_alias.h(+13 -2)📝
runtime/src/vulkan_aftermath.cpp(+2 -1)📝
runtime/src/vulkan_aftermath.h(+67 -4)📝
runtime/src/vulkan_indirect_clamp.h(+13 -6)➕
runtime/test/d3d12_tls_safe_test.cpp(+366 -0)📄 Description
Restores my open PR from the original repository (OLD-8364), rebased onto current
main(2d73c242f, updated forZlibErrorreturn frominflate_codesandkRev4constexpr placement).Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7133003627
Summary
When guest retail threads run with their own TLS block in
gs:[0x58]slot 0, MSVC function-local magic statics (_Init_thread_header/_tls_index/$TSS) andthread_localvariables crash on first touch inside D3D12 runtime calls.This PR removes all MSVC static initialization guards and
thread_localuses from the core Vulkan D3D12 runtime and adds a TLS-slot-0-poisoned regression test:runtime/shims/d3d12_vulkan_device.cpp: replaces function-local magic statics andthread_localwith TLS-0-safeINIT_ONCE/ lock-free initialization.runtime/shims/d3d12_com.cpp: removes function-localstatic std::mutex/static std::setguards inlog_once/note_once.runtime/src/queue_holds.h: eliminatesthread_local/ magic-static TLS-slot-0 dependencies.runtime/src/shader_library.h: promotes deflate fixed Huffman tables (kFixedHuffmanTables) andkRev4toinline constexprat namespace scope so fixed-Huffman zlib inflation never emits a function-local static init guard.runtime/test/d3d12_tls_safe_test.cpp&runtime/CMakeLists.txt: addsd3d12_tls_safetest that poisons TLS slot 0 before exercising device creation, shader cache,log_once,note_once, and unimplemented-stub logging across threads.Verification (rebased on
2d73c242f,LEONIDA_VK_VALIDATION=1)dumpbin /SYMBOLSond3d12_vulkan_device.cpp.objandd3d12_com.cpp.obj: 0 hits for_Init_thread_header,_tls_index, or$TSSshader_library_test— pass (rc=0)d3d12_tls_safe_test(rc=0, 0 validation errors)d3d12_com_test(rc=0, 0 validation errors)d3d12_shader_cache_test(rc=0, 0 validation errors)d3d12_tls_safe_test(rc=0, 0 validation errors)d3d12_com_test(rc=0, 0 validation errors)d3d12_shader_cache_test(rc=0, 0 validation errors)AI-assisted (Gemini 4 Neon).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.