Skip to content

[Linux] Enhance Vulkan integration, file dialog handling, and asset loading - #5

Draft
Talv wants to merge 12 commits into
FernandoS27:masterfrom
Talv:master
Draft

Talv wants to merge 12 commits into
FernandoS27:masterfrom
Talv:master

Conversation

@Talv

@Talv Talv commented Nov 12, 2026

Copy link
Copy Markdown

I know that current version on Git is kinda out of date, so submitting it as draft. I'll re-retest this stuff once you update the sources or publish updated Linux package. Thanks!

While testing this I also found some MPQ bugs, reported here: FernandoS27/WhiteoutLib#4

Linux builds need the LunarG Vulkan SDK beside the tree: it carries slangc
and VMA (neither is packaged on Arch) and the Vulkan-Hpp version CI pins.
It lives in .deps/ and must never be committed.
…ProcAddr

A default-constructed vk::raii::Context goes through Vulkan-Hpp's
DynamicLoader, which dlopens libvulkan.so before libvulkan.so.1. The Linux
AppImage bundles only libvulkan.so.1, so on hosts that ship the unversioned
dev symlink (e.g. Arch's vulkan-icd-loader) the host loader was pulled in
beside the bundled one. The instance was created through one loader and
queried through the other: the VK_KHR_surface entry points resolved to NULL
and startup segfaulted in vkGetPhysicalDeviceSurfaceSupportKHR.

The binary already links the loader GLFW opens, so disable Vulkan-Hpp's
loader helper and hand the Context the linked vkGetInstanceProcAddr. One
loader per process; a future default-constructed Context fails to compile
instead of loading a second one.
Every NFD call site treated NFD_ERROR exactly like the user pressing
Cancel, so a broken dialog backend looked like a dead menu item with no
trace in the Log Console. NFD was also initialised from two places in the
viewer and never in ModelExplorer, whose CASC folder picker called into
NFD uninitialised.

On the xdg-desktop-portal backend that is not an error return: a dialog
over a missing or failed init aborts inside libdbus. Put the four dialog
kinds behind tools/common/native_dialogs, which initialises NFD once on
first use, skips the dialog if that failed, and logs failures to stderr.
It lives in WhiteoutFlakesExplorerLib so the embedded Storage Explorer
shares it.
NFD's default GTK backend draws its own GTK3 dialog on every desktop, so
Plasma users got a GTK file chooser instead of KDE's. The portal backend
asks the desktop over D-Bus, which shows its own dialog: KDE's on Plasma,
GNOME's on GNOME. It also drops GTK3 from the AppImage, which linuxdeploy
bundled without the GTK plugin (92.9 -> 69.0 MB locally), and it is the
backend a sandboxed build needs.

WDX_NFD_PORTAL (default ON) is forced onto NFD_PORTAL so existing build
trees, whose cache already holds NFD's own OFF default, switch too;
-DWDX_NFD_PORTAL=OFF brings GTK back for setups with no portal running.
The previous commit's dialog guard keeps a missing portal from aborting.
CI installs libdbus-1-dev in place of libgtk-3-dev.
A texture that no source could supply left its slot on the white
placeholder without a word, so a model rendering untextured gave no hint
which file was missing. Log every failed texture read, by path or
fileDataID, to stderr where the Log Console picks it up. Model and effect
misses stay silent for now (TODO).
AssetManager lowercases every path it requests, so on a case-sensitive
filesystem a texture shipped beside a model as Assets/Textures/Foo_Diff.dds
was looked up as assets/textures/foo_diff.dds and never found: on Linux no
loose SC2 mod texture resolved. After the exact lookup misses,
FileResolver now matches each path component ignoring ASCII case. An
exact match still wins, ties resolve deterministically, and directories
are listed only on a miss.
An .m3 names its textures relative to the root of the mod it ships in
(Assets/Textures/x.dds), but the disk lookup only looked beside the model,
so one stored as Mod.SC2Mod/Assets/Units/X/x.m3, or under a Base.SC2Assets
component, found none of its own textures. Opening a StarCraft II model
now finds the enclosing .SC2Mod/.SC2Map/.SC2Campaign (or the folder
holding the Assets/ tree it sits in) and searches that mod's asset roots
after the model's own folder, so no existing lookup changes. The provider
is shared across tabs, so the roots follow the most recently opened
document, as the base path already does.
A model can use textures that live in another mod: the game finds them
through whichever map loads both, but a viewer opening the model on its
own cannot. [IO.Sc2] FallbackMods now lists mods, maps and campaigns that
are searched, in order, after the game's storage misses; each folder is
indexed on first use and read Base.SC2Assets first. The list is explicit:
no folder of mods is scanned and nothing is added by default. Searching
after the storage, not before, keeps one mod's override of a stock
texture from replacing it everywhere. The list lives in the game's
provider slot, so switching to another game does not carry it along,
and each fallback hit is logged.
Most distributed mods and maps are single MPQ files, not folders, and the
fallback list skipped them. A packed .SC2Mod/.SC2Map/.SC2Campaign entry is
now opened with WhiteoutLib's MPQ reader and read like a folder:
Base.SC2Assets first, extension alternatives, case-insensitive. A build
without MPQ support says so instead of failing silently.
Case-insensitive resolution listed directories on every disk miss, and a
StarCraft II model load misses thousands of times: the model catalog reads
3,780 GameData files and every one asks the disk before the archive. That
was ~30k getdents calls per load, and with the model in a folder of 5,000
files the catalog's read+parse went from 224 ms to 3.5 s. FileResolver
now caches each listing until its roots change, so a folder is listed
once per open (~270 calls, timings back to baseline). A cached match is
checked on disk before it is returned, so a deleted file is never an
answer; a differently-cased file added after its folder was listed waits
for the next open.
The fallback mod index built its keys with path::generic_string(), which
on Windows converts to the ANSI code page: a mod with non-ASCII names
would index under mangled keys or throw. Use PathToUtf8, as every other
path the index and the lookups compare does.
Exposes [IO.Sc2] FallbackMods on the StarCraft II IO page as an ordered
list edited like the MPQ list: a folder picker for mod folders, a file
picker for packed mods, and a refusal for anything that is not a
.SC2Mod/.SC2Map/.SC2Campaign. Entries that no longer exist are marked.
An edit that leaves the game storage unopened re-runs the asset retry
itself, because a fallback mod can still fill those misses and the
storage open retries only on success. Strings added to all eleven
catalogs.
@Talv Talv changed the title Enhance Vulkan integration, file dialog handling, and asset loading [Linux] Enhance Vulkan integration, file dialog handling, and asset loading Nov 12, 2026
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.

2 participants