Skip to content

profile_guess: SDL_GPU's vkCmd* names and empty #version strings (MARVEL Cosmic Invasion) - #2599

Open
bensaadmucret wants to merge 1 commit into
seedds:mainfrom
bensaadmucret:pr-sdl-vulkan-detect
Open

bensaadmucret wants to merge 1 commit into
seedds:mainfrom
bensaadmucret:pr-sdl-vulkan-detect

Conversation

@bensaadmucret

Copy link
Copy Markdown

What and why

Two misreads of an SDL_GPU main's files, both found bringing up MARVEL Cosmic Invasion (010059D020C26000 v0, build D6A37DEAFF3F5AEA, FNA/SDL_GPU):

  • graphics: a main that imports only vkGetInstanceProcAddr — SDL's Vulkan loader, which an SDL game links for WSI and may never use to draw (Balatro renders with OpenGL, Absolum with NVN) — was read as OpenGL when it also imports EGL and names glShaderSource, which is SDL's unused GL backend. vkGetDeviceProcAddr does not tell the renderer either: the WSI path names it to load the swapchain procs. A vkCmd* name can only come from a table a renderer resolves command-recording procs through — MARVEL's main names 30 of them. vk_names counts them; the loader import plus any of those is graphics=vulkan, with its own survey reason. A main whose own nvnBootstrapLoader import wins as before.
  • gl_src: MARVEL's main holds four bare #version headers (MojoShader prefixes the GLSL it regenerates at run time) which counted as embedded GLSL sources, so the build translated four empty shaders and failed in metallib. A #version string now counts only with a body behind it (>64 bytes to its NUL) — still looser than glsl_sources' void main rule, on purpose.

Adds the finding to docs/reference/packing.md (A Vulkan game read as OpenGL through SDL's loader).

Checked

  • Tests: python3 -m unittest dm.tools.tests.test_profile_guess — 37 tests, including the new SdlVulkan class: loader alone with GL names → gl (Balatro's shape), loader only and no GL name → nvn (Absolum's shape), own nvnBootstrapLoader beating the SDL signal, vk_capture set for an SDL_GPU game without SPIR-V files, and a bare #version header not counting as embedded GLSL. test_docs passes (6 tests).
  • Games run, with title ID and version: MARVEL Cosmic Invasion 010059D020C26000 v0: the provisional profile now comes out graphics=vulkan + vk_capture, and with the sibling PRs the game boots and draws (intro video, 60 fps). Before, the profile said gl and the build captured nothing.
  • Devices and OS: Apple M6, macOS 27.0
  • regress.py impact names profile / every build for this change. The gl_src tightening can only lower that counter (bare headers stop counting); the vk_names path triggers only when a main imports the loader alone and names vkCmd* procs — a shape the supported SDL games do not have (Balatro: OpenGL, names no vkCmd*; Absolum: NVN, own nvnBootstrapLoader). regress.py check --games was not run locally; flagging it honestly for CI.
  • One of four PRs from the same bring-up (the others: EOS platform handle, vk_shaders entry point, vkCmdBlitImage + SDL_GPU device procs).

Docs

  • The finding is in its game note or its docs/reference/<subsystem>.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index)
  • A chain tool changed: dmsh_chain.py --header was run and dm/gfx/nvn/dmsh_chain.h is part of the change
  • No game files, keys or data extracted from a game in the change or the attachments

…VEL Cosmic Invasion)

Two misreads of an SDL_GPU main's files:

- graphics: a main that imports only vkGetInstanceProcAddr (SDL's Vulkan loader, which an SDL game links for WSI and may never use
  to draw — Balatro renders with OpenGL, Absolum with NVN) was read as OpenGL when it also imports EGL and names glShaderSource —
  SDL's unused GL backend. vkGetDeviceProcAddr does not tell the renderer either: the WSI path names it to load the swapchain
  procs. A vkCmd* name can only come from a table a renderer resolves command-recording procs through: MARVEL Cosmic Invasion
  names 30 of them. vk_names counts them in main's strings; the loader import plus any of those is vulkan.

- gl_src: MARVEL's main holds four bare '#version' headers (MojoShader prefixes the GLSL it regenerates at run time) which
  counted as embedded GLSL sources, so the build translated four empty shaders and failed in metallib. A '#version' string now
  counts only with a body behind it (>64 bytes to its NUL).

Checked: shader_sources on MARVEL Cosmic Invasion's extraction gives graphics=vulkan + vk_capture; its four captured SPIR-V
modules translate and the game draws at 60 FPS. SdlVulkan in test_profile_guess covers the loader-only shapes (Balatro gl,
Absolum nvn, own nvnBootstrapLoader beating the SDL signal).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant