Merge "Use context specific ring for EXPORT_SYNC_VK" am: c18926df28 am: 8786b23936 am: 1830dd6848 am: 2512a2ce2d am: 3a77e72f9c am: 1f0d1b7bac

Original change: https://android-review.googlesource.com/c/device/generic/vulkan-cereal/+/2585586

Change-Id: Icda80c881802edcebd57d515413ab51ca4cee164
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
GitOrigin-RevId: 6656bfd28a9192887e8c9ecc8607daeaa3eda20b
diff --git a/stream-servers/virtio-gpu-gfxstream-renderer.cpp b/stream-servers/virtio-gpu-gfxstream-renderer.cpp
index b4370c9..dcf591e 100644
--- a/stream-servers/virtio-gpu-gfxstream-renderer.cpp
+++ b/stream-servers/virtio-gpu-gfxstream-renderer.cpp
@@ -774,6 +774,15 @@
             }
             case GFXSTREAM_CREATE_EXPORT_SYNC_VK:
             case GFXSTREAM_CREATE_IMPORT_SYNC_VK: {
+                // The guest sync export assumes fence context support and always uses
+                // VIRTGPU_EXECBUF_RING_IDX. With this, the task created here must use
+                // the same ring as the fence created for the virtio gpu command or the
+                // fence may be signaled without properly waiting for the task to complete.
+                ring = VirtioGpuRingContextSpecific{
+                    .mCtxId = ctxId,
+                    .mRingIdx = 0,
+                };
+
                 DECODE(exportSyncVK, gfxstream::gfxstreamCreateExportSyncVK, buffer)
 
                 uint64_t device_handle =