Skip to content

runtime/shims: shim Win32 localization, priority-boost, and named-pipe APIs (RT-WIN32-ENV-LOC-PIPE) - #1242

Open
piyonchu wants to merge 1 commit into
ProjectLeonida:mainfrom
piyonchu:pr/win32-loc-priority-pipe-shims
Open

piyonchu wants to merge 1 commit into
ProjectLeonida:mainfrom
piyonchu:pr/win32-loc-priority-pipe-shims

Conversation

@piyonchu

@piyonchu piyonchu commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Claim ID: RT-WIN32-ENV-LOC-PIPE

Adds runtime/shims/win32_env.cpp, runtime/test/win32_env_test.cpp, and documents LEONIDA_GEO / LEONIDA_LOCALE in runtime/README.md (wired into runtime/CMakeLists.txt and scripts/build_runtime.ps1, rebased onto cont/main 16f505304 at 1a5b65a38):

  • Shims GetUserDefaultGeoName, GetUserDefaultLocaleName, and LocaleNameToLCID (api-ms-win-core-localization-l1-2-{0,3}.dll, kernel32.dll, kernelbase.dll) with offline fallback and LEONIDA_GEO / LEONIDA_LOCALE overrides.
  • Shims SetProcessPriorityBoost (api-ms-win-core-processthreads-l1-1-2.dll, kernel32.dll, kernelbase.dll) in-process so title priority-boost toggles do not mutate the host gta6rt scheduler policy.
  • Shims WaitNamedPipeA/W and SetNamedPipeHandleState (api-ms-win-core-namedpipe-l1-1-0.dll, kernel32.dll, kernelbase.dll), returning ERROR_BAD_PATHNAME for WaitNamedPipeA(nullptr) and ERROR_INVALID_PARAMETER for WaitNamedPipeW(nullptr) without faulting on Windows 11.
  • Adds win32_env and win32_env_override CTest cases in runtime/test/win32_env_test.cpp.

Verification

  • Host: Windows 11 (10.0.26100 SDK), MSVC (RelWithDebInfo), at 1a5b65a38.
  • ctest --test-dir runtime/build -C RelWithDebInfo -R "^win32_env" --output-on-failure: 100% tests passed out of 2 (win32_env, win32_env_override).
  • python -I tests/test_docs_env_vars.py: Ran 5 tests ... OK.
  • python -I tests/test_docs_encoding.py: Ran 1 test ... OK.
  • python -I tests/test_text_encoding.py: Ran 2 tests ... OK.
  • python -I tests/test_ctest_registration.py: Ran 7 tests ... OK.
  • python -I scripts/check_no_game_data.py ... and git diff --check cont/main..HEAD: clean.
  • No game files used; CPU runtime test only (no GPU required). AI-assisted.

@piyonchu
piyonchu force-pushed the pr/win32-loc-priority-pipe-shims branch from 1085a12 to 1a8cc62 Compare November 25, 2026 02:17
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@piyonchu
piyonchu force-pushed the pr/win32-loc-priority-pipe-shims branch from 1a8cc62 to bd263ca Compare November 25, 2026 14:26
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 26, 2026
@piyonchu
piyonchu force-pushed the pr/win32-loc-priority-pipe-shims branch from bd263ca to f222051 Compare November 26, 2026 21:36
@piyonchu

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (fac8b4bb9, head commit f22205149), resolving the scripts/build_runtime.ps1 fallback file list conflict cleanly (shims\xapu_queue.cpp + shims\win32_env.cpp).

Verified locally after rebase:

  • git diff --check cont/main..HEAD
  • python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/win32_env.cpp runtime/test/win32_env_test.cpp scripts/build_runtime.ps1
  • cmake --build runtime/build --config RelWithDebInfo --target gta6rt win32_env_test
  • ctest --test-dir runtime/build -C RelWithDebInfo -R "^win32_env$" --output-on-failure (1/1 passed)

tiguan26 pushed a commit to tiguan26/leonida that referenced this pull request Nov 28, 2026
The f16 interpolation always wrote the low destination half via
low_half() and dropped the VOP3 output modifiers. Write through
write_half() (op_sel[3], SDWA) and apply omod then clamp to the f16
result in f32 so the conversion rounds once, matching write_f()'s order.

Addresses VIC-BT-029 from audit ProjectLeonida#1242.

Validation:
- cargo test -p victory-shader --locked -- --test-threads=1
  --skip emit::valu_tests --skip emit::waterfall_tests
- cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings
- cargo xtask policy
@MoonEyes

Copy link
Copy Markdown
Collaborator

Blocker: tests/test_docs_env_vars.py fails with this PR merged onto main: LEONIDA_GEO and LEONIDA_LOCALE (read in runtime/shims/win32_env.cpp) are documented in no .md. Could you add them to the docs page that lists the runtime variables?

Checked locally on main c1ecf04: the same test file(s) pass on main without this PR.

AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes.

@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Native Windows 11 + MSVC 19.44 Verification (f222051496 + origin/main adfb3821a2)

Verdict: C++ shim & tests PASS (0 /W4 warnings), 1 CI blocker + 2 hygiene/doc items below

Environment & Merge Check

  • Host: Windows 11 (10.0.26200), MSVC 19.44.35228 (x64, /W4 /permissive- /utf-8 /O2 /EHsc)
  • Merge hygiene: Clean merge onto origin/main (adfb3821a2, git merge-tree --write-tree rc=0); check_no_game_data.py, test_ctest_registration.py (7/7), test_build_runtime_batch.py (1/1), test_build_runtime_cmake.py (1/1), and test_text_encoding.py (2/2) all OK (and all 10/10 fallback file-list checks in test_build_runtime_fallback.py pass).

C++ Shim & Live Host Windows 11 Results

  • Live host Windows 11 (10.0.26200) SEH probe: Confirmed native ::WaitNamedPipeW(nullptr, 0) raises hardware SEH 0xC0000005 (EXCEPTION_ACCESS_VIOLATION), whereas ::WaitNamedPipeA(nullptr, 0) returns FALSE with ERROR_BAD_PATHNAME (161).
  • win32_env_test.exe (default): PASS (28 check(s), 0 failure(s), 0.10 s, 0 /W4 warnings).
  • win32_env_test.exe --expect-override (LEONIDA_GEO=jp, LEONIDA_LOCALE=en-GB): PASS (30 check(s), 0 failure(s), 0.06 s).

Findings to Address Before Merge

  1. [Blocker — CI failure] tests/test_docs_env_vars.py fails on PR #1242 + origin/main (adfb3821a2): LEONIDA_GEO (runtime/shims/win32_env.cpp:69) and LEONIDA_LOCALE (runtime/shims/win32_env.cpp:81) are read by the runtime shim without being documented in docs/ (test_docs_env_vars.py passes rc=0 on origin/main alone).
  2. [Encoding hygiene] UTF-8 BOM in scripts/build_runtime.ps1: Head f222051496 prepends a 3-byte UTF-8 BOM (EF BB BF) at byte 0 of scripts/build_runtime.ps1 (origin/main is BOM-free UTF-8). Please strip those 3 leading bytes when updating the branch.
  3. [Minor PR summary / error-code note] WaitNamedPipeW(nullptr, ...) last-error value: The PR description states "preserving ERROR_BAD_PATHNAME for WaitNamedPipeA/W(nullptr)", while wait_named_pipe_w (runtime/shims/win32_env.cpp:197) sets ERROR_INVALID_PARAMETER (87, tested at win32_env_test.cpp:131) and wait_named_pipe_a sets ERROR_BAD_PATHNAME (161). Either error code avoids the Windows 11 null-dereference fault, so just align whichever side was intended.

AI-assisted.

@piyonchu
piyonchu force-pushed the pr/win32-loc-priority-pipe-shims branch from f222051 to 1a5b65a Compare November 29, 2026 01:08
@piyonchu

Copy link
Copy Markdown
Contributor Author

Addressed all three findings and rebased onto cont/main (16f505304, head 1a5b65a38), thanks @MoonEyes and @zmasi!

  1. test_docs_env_vars.py blocker (runtime/README.md): Documented LEONIDA_GEO and LEONIDA_LOCALE under ### Win32 localization overrides in runtime/README.md.
  2. UTF-8 BOM (scripts/build_runtime.ps1): Stripped the 3-byte UTF-8 BOM from scripts/build_runtime.ps1.
  3. PR summary alignment: Updated the PR description to state ERROR_BAD_PATHNAME for WaitNamedPipeA(nullptr) and ERROR_INVALID_PARAMETER for WaitNamedPipeW(nullptr), matching win32_env.cpp and win32_env_test.cpp.

Verified locally after 1a5b65a38:

  • python -I tests/test_docs_env_vars.py: Ran 5 tests ... OK
  • python -I tests/test_docs_encoding.py: Ran 1 test ... OK
  • python -I tests/test_text_encoding.py: Ran 2 tests ... OK
  • python -I tests/test_ctest_registration.py: Ran 7 tests ... OK
  • ctest --test-dir runtime/build -C RelWithDebInfo -R "^win32_env" --output-on-failure: 2/2 passed (win32_env, win32_env_override)
  • (Note: tests/test_build_runtime_fallback.py passed 10/11; only test_the_loader_gets_the_stack_reserve_cmake_gives_it failed on cont/main's runtime/CMakeLists.txt layout, untouched by this PR.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants