From dda85cf94bdd9d58f0dc4013dbf4b3c985471991 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Sun, 5 Feb 2023 19:33:52 -0800 Subject: [PATCH] venus: move exp features init back to use ring submit Since largeRing has been enforced, there's no need to do renderer submission to fill the exp features. So we move it back after ring has been initialized. Meanwhile, vn_renderer_submit_simple_sync is intentionally left there to be re-used soon for server ping purpose. Signed-off-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_instance.c | 74 ++++----------------------------- src/virtio/vulkan/vn_instance.h | 6 +-- 2 files changed, 11 insertions(+), 69 deletions(-) diff --git a/src/virtio/vulkan/vn_instance.c b/src/virtio/vulkan/vn_instance.c index 0e44ca5bba5..f09a4e5a997 100644 --- a/src/virtio/vulkan/vn_instance.c +++ b/src/virtio/vulkan/vn_instance.c @@ -163,53 +163,19 @@ vn_instance_init_ring(struct vn_instance *instance) return VK_SUCCESS; } -static struct vn_renderer_shmem * -vn_instance_get_reply_shmem_locked(struct vn_instance *instance, - size_t size, - void **ptr); - -static VkResult +static void vn_instance_init_experimental_features(struct vn_instance *instance) { if (instance->renderer->info.vk_mesa_venus_protocol_spec_version != 100000) { if (VN_DEBUG(INIT)) vn_log(instance, "renderer supports no experimental features"); - return VK_SUCCESS; + return; } size_t struct_size = sizeof(instance->experimental); - - /* prepare the reply shmem */ - const size_t reply_size = - vn_sizeof_vkGetVenusExperimentalFeatureData100000MESA_reply( - &struct_size, &instance->experimental); - void *reply_ptr; - struct vn_renderer_shmem *reply_shmem = - vn_instance_get_reply_shmem_locked(instance, reply_size, &reply_ptr); - if (!reply_shmem) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - /* encode the command */ - uint32_t local_data[16]; - struct vn_cs_encoder local_enc = - VN_CS_ENCODER_INITIALIZER_LOCAL(local_data, sizeof(local_data)); - vn_encode_vkGetVenusExperimentalFeatureData100000MESA( - &local_enc, VK_COMMAND_GENERATE_REPLY_BIT_EXT, &struct_size, - &instance->experimental); - - VkResult result = vn_renderer_submit_simple_sync( - instance->renderer, local_data, vn_cs_encoder_get_len(&local_enc)); - if (result != VK_SUCCESS) { - vn_renderer_shmem_unref(instance->renderer, reply_shmem); - return result; - } - - struct vn_cs_decoder reply_dec = - VN_CS_DECODER_INITIALIZER(reply_ptr, reply_size); - vn_decode_vkGetVenusExperimentalFeatureData100000MESA_reply( - &reply_dec, &struct_size, &instance->experimental); - vn_renderer_shmem_unref(instance->renderer, reply_shmem); + vn_call_vkGetVenusExperimentalFeatureData100000MESA( + instance, &struct_size, &instance->experimental); /* if renderer supports multiple_timelines, the driver will use it and * globalFencing support can be assumed. @@ -232,8 +198,6 @@ vn_instance_init_experimental_features(struct vn_instance *instance) instance->experimental.largeRing, instance->experimental.syncFdFencing); } - - return VK_SUCCESS; } static VkResult @@ -581,17 +545,7 @@ 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_init_experimental_features calls this before the ring is - * created - */ - if (likely(instance->ring.id)) { - 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)); - } + vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); } /* TODO avoid this seek command and go lock-free? */ @@ -600,17 +554,7 @@ vn_instance_get_reply_shmem_locked(struct vn_instance *instance, seek_reply_command_stream_data, sizeof(seek_reply_command_stream_data)); vn_encode_vkSeekReplyCommandStreamMESA(&local_enc, 0, offset); vn_cs_encoder_commit(&local_enc); - - /* vn_instance_init_experimental_features calls this before the ring is - * created - */ - 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)); - } + vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); return shmem; } @@ -742,14 +686,12 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, vn_renderer_shmem_pool_init(instance->renderer, &instance->reply_shmem_pool, 1u << 20); - result = vn_instance_init_experimental_features(instance); - if (result != VK_SUCCESS) - goto fail; - result = vn_instance_init_ring(instance); if (result != VK_SUCCESS) goto fail; + vn_instance_init_experimental_features(instance); + result = vn_instance_init_renderer_versions(instance); if (result != VK_SUCCESS) goto fail; diff --git a/src/virtio/vulkan/vn_instance.h b/src/virtio/vulkan/vn_instance.h index 7298d8dc5cc..134b0c50b5b 100644 --- a/src/virtio/vulkan/vn_instance.h +++ b/src/virtio/vulkan/vn_instance.h @@ -44,9 +44,6 @@ struct vn_instance { mtx_t ring_idx_mutex; uint64_t ring_idx_used_mask; - /* XXX staged features to be merged to core venus protocol */ - VkVenusExperimentalFeatures100000MESA experimental; - struct { mtx_t mutex; struct vn_renderer_shmem *shmem; @@ -61,6 +58,9 @@ struct vn_instance { uint32_t roundtrip_next; } ring; + /* XXX staged features to be merged to core venus protocol */ + VkVenusExperimentalFeatures100000MESA experimental; + /* Between the driver and the app, VN_MAX_API_VERSION is what we advertise * and base.base.app_info.api_version is what the app requests. *