Skip to content

Accept UTF-8 BOMs in C++ shader index readers - #4587

Open
AGInformatique81 wants to merge 1 commit into
ItsNotRexed:mainfrom
AGInformatique81:fix/shader-index-utf8-bom
Open

AGInformatique81 wants to merge 1 commit into
ItsNotRexed:mainfrom
AGInformatique81:fix/shader-index-utf8-bom

Conversation

@AGInformatique81

Copy link
Copy Markdown

Windows PowerShell 5.1 writes a leading UTF-8 BOM when saving JSON with Set-Content -Encoding UTF8. Both C++ readers rejected a shader index saved that way. Accept one BOM at the beginning of the file in vk_pipeline_check and the runtime's ShaderLibrary, as permitted by RFC 8259 section 8.1. The checker keeps byte offsets relative to the original file. Malformed JSON and a BOM after the top-level object still fail.

  • Windows PowerShell 5.1.26100.9818 produced a synthetic index.json beginning in EF BB BF. The old checker returned 2 at byte 0. The revised checker returned 0 and reported the index correctly.
  • All ten checker index tests and the C++ shader library test passed on Windows 11/MSVC 19.52 and under WSL/GCC. The Windows vk_pipeline_check_cli CTest also passed. Before the fix, the two new checker assertions failed and the library rejected the BOM-prefixed fixture.
  • Synthetic inputs only. The Windows checker selected an RTX 2060 (driver 32.0.16.2124); the library test ran on CPU. A trial merge with Keep Vulkan isolate batches inside the requested slice #4580 was clean.

Coordination claim. AI-assisted with Codex.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed both C++ readers and the malformed/trailing-BOM cases; the BOM is handled only at the start and the original checker byte offsets are preserved.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built at 4de96f3b on Windows 11 (MSVC, Vulkan SDK 1.4.363) and ran both halves:

  • shader_library_test -> exit 0, SHA-256, inflate (stored/fixed/dynamic), JSON, FSSM extraction, FSPX programs and index lookup OK; the test now writes index.json with a UTF-8 BOM and the library still loads it.
  • tests/test_vk_pipeline_check_index.py with LEONIDA_VK_PIPELINE_CHECK pointing at the built vk_pipeline_check.exe -> 10 tests, OK, including test_leading_utf8_bom_is_accepted, test_utf8_bom_keeps_error_offsets_relative_to_the_file (expected '{' at byte 3) and test_trailing_utf8_bom_is_still_an_error.

std::string_view::starts_with + remove_prefix leaves the parser's byte offsets absolute, which is why the error offset stays 3. git diff --check clean. No blocking issue.

@theswiss24

Copy link
Copy Markdown

Tested 4de96f3b (contains main d0835dd9) on Ubuntu 24.04.5 (Linux build: GCC 13, CMake 3.28, Ninja, Release, Khronos Vulkan-Headers 1.4.363), i5-9300H, Python 3.12.3, GPUs Intel UHD 630 (Mesa 25.2.8) and GTX 1650 (NVIDIA 595.99.02), built in its own folder: pass.

  • python3 -I tests/test_vk_pipeline_check_index.py: 10 tests, OK (main's copy: 7, OK).
  • ctest -R "vk_pipeline_check|shader_library|bench" (5 tests, including vk_pipeline_check_cli): 5/5 passed, the same as main built the same way.

No game files.

Tested and written by Claude (Claude Code), posting from @theswiss24's account.

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.

4 participants