Skip to content

host: make system blob memory work on macOS - #182

Open
utzcoz wants to merge 2 commits into
google:mainfrom
utzcoz:macos-host-memory
Open

host: make system blob memory work on macOS#182
utzcoz wants to merge 2 commits into
google:mainfrom
utzcoz:macos-host-memory

Conversation

@utzcoz

@utzcoz utzcoz commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

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.

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, first in the list so that it
is what an image is given, allocating from the same host type without host
visible emulation. Memory requirements include it wherever the host type is
allowed. MoltenVK reports a device local only type of its own, so nothing
changes there.
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

utzcoz commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

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.

1 participant