vulkan-cereal: plumb virtgpu ctx_id to process pipe
The virtio-gpu context ID is an unique identifier allocated by the
guest kernel, via idr_alloc(..). These IDs can be reused, but
virtio-gpu gurantees that re-use will only happens after a
particular context has been destroyed.
Many operations related to resource sharing between guest
processes, and between gfxstream and virtgpu are done in reference
to this context id.
gfxstream has a clear analogue to this already --> m_puid, which
is set via connecting to the "pipe:GLProcessPipe" service in the
guest.
The immediate goal is is make m_puid == ctx_id, so the guest
kernel can reference each host render thread via the ctx_id.
BUG=202552093
TEST=run Cuttlefish
Change-Id: Iadc0c288be6a869261658db87c5c569389f73f5b
diff --git a/host-common/opengl/GLProcessPipe.cpp b/host-common/opengl/GLProcessPipe.cpp
index 7ff3298..d2da1a2 100644
--- a/host-common/opengl/GLProcessPipe.cpp
+++ b/host-common/opengl/GLProcessPipe.cpp
@@ -89,7 +89,12 @@
m_uniqueId = loadStream->getBe64();
m_hasData = (loadStream->getByte() != 0);
} else {
- m_uniqueId = ++s_headId;
+ if (flags & ANDROID_PIPE_VIRTIO_GPU_BIT) {
+ m_uniqueId = (uint64_t)(uintptr_t)hwPipe;
+ s_headId = m_uniqueId;
+ } else {
+ m_uniqueId = ++s_headId;
+ }
}
AutoLock lock(sRegistry.lock);
sRegistry.ids.insert(m_uniqueId);