From e5a005dd0c517fbe58c2949647d14c2fdd1b65f8 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 29 Aug 2021 22:07:24 -0700 Subject: [PATCH] venus: support reply shmem without ring Let vn_instance_get_reply_shmem_locked use the renderer if it is called before the ring is initialized. Signed-off-by: Chia-I Wu Reviewed-by: Yiwei Zhang Reviewed-by: Ryan Neph Part-of: --- src/virtio/vulkan/vn_instance.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/virtio/vulkan/vn_instance.c b/src/virtio/vulkan/vn_instance.c index 3a1beb6124f..892e2691c94 100644 --- a/src/virtio/vulkan/vn_instance.c +++ b/src/virtio/vulkan/vn_instance.c @@ -556,8 +556,14 @@ vn_instance_get_reply_shmem_locked(struct vn_instance *instance, vn_encode_vkSetReplyCommandStreamMESA(&local_enc, 0, &stream); vn_cs_encoder_commit(&local_enc); - vn_instance_roundtrip(instance); - vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); + if (likely(instance->ring.id)) { + vn_instance_roundtrip(instance); + vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); + } else { + vn_renderer_submit_simple(instance->renderer, + set_reply_command_stream_data, + vn_cs_encoder_get_len(&local_enc)); + } } /* TODO avoid this seek command and go lock-free? */ @@ -567,7 +573,14 @@ vn_instance_get_reply_shmem_locked(struct vn_instance *instance, const size_t offset = instance->reply.used; vn_encode_vkSeekReplyCommandStreamMESA(&local_enc, 0, offset); vn_cs_encoder_commit(&local_enc); - vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); + + if (likely(instance->ring.id)) { + vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); + } else { + vn_renderer_submit_simple(instance->renderer, + seek_reply_command_stream_data, + vn_cs_encoder_get_len(&local_enc)); + } *ptr = instance->reply.ptr + offset; instance->reply.used += size;