host: make system blob memory work on macOS - #182
Open
utzcoz wants to merge 2 commits into
Open
Conversation
Contributor
Author
Contributor
Author
|
Friendly ping @gurchetansingh @jmacnak for reviewing. |
utzcoz
force-pushed
the
macos-host-memory
branch
from
September 9, 2026 13:54
eba0d61 to
2b5933a
Compare
Collaborator
|
@jmacnak knows this code well, would be the right person to review |
jmacnak
requested changes
Sep 9, 2026
utzcoz
force-pushed
the
macos-host-memory
branch
2 times, most recently
from
September 10, 2026 15:53
8a8f716 to
293c959
Compare
With system blobs, host visible memory is shared memory imported as a host pointer, and Metal cannot bind a tiled image to that. A device that reports one unified memory type, as kosmickrisp does, then has nowhere to put an image, and kk_image_plane_bind asserts on the first one. Add a guest only type in that case: device local, allocating from the same host type without host visible emulation. A tiled image is offered that type alone, since the host visible one cannot hold it; a linear image may still use either. MoltenVK reports a device local only type of its own, so nothing changes there. The type goes first, not last: the spec requires a memory type whose flags are a strict subset of another's to sit at a lower index, and device local alone is a subset of every host visible type here. Metal is what makes this the common case, so it is behind __APPLE__.
System blob memory is named shared-memory-vk-N with a per process counter and opened without O_EXCL. A server that is killed leaves its objects behind, the next one reuses the names, and on macOS an object that already has a size cannot be resized: ftruncate fails with EINVAL and vkAllocateMemory fails. Put the pid in the name, and on Apple unlink the object as soon as it exists; the descriptor keeps it alive and is what the guest is handed.
utzcoz
force-pushed
the
macos-host-memory
branch
from
September 10, 2026 16:01
293c959 to
7129900
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two host fixes for running the guest Vulkan driver through kumquat on macOS.
Both only take effect with SystemBlob enabled.
vulkan: add a guest only device local memory type when the host reports a
single host visible unified type. Metal cannot bind a tiled image to an
imported host pointer; this gives images ordinary device memory. Unit test
added.
base: put the pid in the shared memory name and unlink it on creation, so a
killed server does not leave objects that make the next ftruncate fail.
Tested with bazel test //host/vulkan:gfxstream_emulatedphysicalmemory_tests,
and vulkaninfo, vkcube and a dEQP-VK smoke run on kosmickrisp and MoltenVK.