From: Yiwei Zhang Date: Wed, 5 Apr 2023 20:51:52 +0000 (-0700) Subject: venus: move exp feature init back to ring and remove unused function X-Git-Tag: upstream/23.3.3~10227 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57afa79933e64717fdf72eddfe3cf8b09d8aca49;p=platform%2Fupstream%2Fmesa.git venus: move exp feature init back to ring and remove unused function This mostly undos 476c771e34fefaf2aab12ca3417d04a5be4ce46d and removes the unused vn_renderer_submit_simple_sync. Signed-off-by: Yiwei Zhang Part-of: --- diff --git a/src/virtio/vulkan/vn_instance.c b/src/virtio/vulkan/vn_instance.c index e532fd6..1157f3f 100644 --- a/src/virtio/vulkan/vn_instance.c +++ b/src/virtio/vulkan/vn_instance.c @@ -171,11 +171,6 @@ 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 vn_instance_init_experimental_features(struct vn_instance *instance) { @@ -187,37 +182,8 @@ vn_instance_init_experimental_features(struct vn_instance *instance) } 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); VkVenusExperimentalFeatures100000MESA *exp_feats = &instance->experimental; @@ -559,6 +525,7 @@ vn_instance_get_reply_shmem_locked(struct vn_instance *instance, { VN_TRACE_FUNC(); struct vn_renderer_shmem_pool *pool = &instance->reply_shmem_pool; + const struct vn_renderer_shmem *saved_pool_shmem = pool->shmem; size_t offset; struct vn_renderer_shmem *shmem = @@ -569,14 +536,7 @@ vn_instance_get_reply_shmem_locked(struct vn_instance *instance, assert(shmem == pool->shmem); *out_ptr = shmem->mmap_ptr + offset; - bool needs_set_stream = false; - if (likely(instance->ring.id)) { - needs_set_stream = shmem != instance->ring.reply_shmem; - } else { - needs_set_stream = shmem != instance->renderer_reply_shmem; - } - - if (needs_set_stream) { + if (shmem != saved_pool_shmem) { uint32_t set_reply_command_stream_data[16]; struct vn_cs_encoder local_enc = VN_CS_ENCODER_INITIALIZER_LOCAL( set_reply_command_stream_data, @@ -587,19 +547,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); - instance->ring.reply_shmem = shmem; - } else { - vn_renderer_submit_simple(instance->renderer, - set_reply_command_stream_data, - vn_cs_encoder_get_len(&local_enc)); - instance->renderer_reply_shmem = shmem; - } + vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); } /* TODO avoid this seek command and go lock-free? */ @@ -608,17 +556,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; } @@ -754,11 +692,11 @@ 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); + result = vn_instance_init_ring(instance); if (result != VK_SUCCESS) goto fail; - result = vn_instance_init_ring(instance); + result = vn_instance_init_experimental_features(instance); if (result != VK_SUCCESS) goto fail; diff --git a/src/virtio/vulkan/vn_instance.h b/src/virtio/vulkan/vn_instance.h index bff0d5b..d526b01 100644 --- a/src/virtio/vulkan/vn_instance.h +++ b/src/virtio/vulkan/vn_instance.h @@ -40,24 +40,16 @@ struct vn_instance { struct vn_renderer *renderer; struct vn_renderer_shmem_pool reply_shmem_pool; - /* cache "set" stream for renderer submission replies */ - const struct vn_renderer_shmem *renderer_reply_shmem; 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; struct vn_ring ring; uint64_t id; - /* cache "set" stream for ring submission replies */ - const struct vn_renderer_shmem *reply_shmem; - struct vn_cs_encoder upload; uint32_t command_dropped; @@ -66,6 +58,9 @@ struct vn_instance { uint64_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. * diff --git a/src/virtio/vulkan/vn_renderer_util.c b/src/virtio/vulkan/vn_renderer_util.c index 4c8809a..895c533 100644 --- a/src/virtio/vulkan/vn_renderer_util.c +++ b/src/virtio/vulkan/vn_renderer_util.c @@ -5,45 +5,6 @@ #include "vn_renderer_util.h" -VkResult -vn_renderer_submit_simple_sync(struct vn_renderer *renderer, - const void *cs_data, - size_t cs_size) -{ - struct vn_renderer_sync *sync; - VkResult result = - vn_renderer_sync_create(renderer, 0, VN_RENDERER_SYNC_BINARY, &sync); - if (result != VK_SUCCESS) - return result; - - const struct vn_renderer_submit submit = { - .batches = - &(const struct vn_renderer_submit_batch){ - .cs_data = cs_data, - .cs_size = cs_size, - .ring_idx = 0, /* CPU ring */ - .syncs = &sync, - .sync_values = &(const uint64_t){ 1 }, - .sync_count = 1, - }, - .batch_count = 1, - }; - const struct vn_renderer_wait wait = { - .timeout = UINT64_MAX, - .syncs = &sync, - .sync_values = &(const uint64_t){ 1 }, - .sync_count = 1, - }; - - result = vn_renderer_submit(renderer, &submit); - if (result == VK_SUCCESS) - result = vn_renderer_wait(renderer, &wait); - - vn_renderer_sync_destroy(renderer, sync); - - return result; -} - void vn_renderer_shmem_pool_init(UNUSED struct vn_renderer *renderer, struct vn_renderer_shmem_pool *pool, diff --git a/src/virtio/vulkan/vn_renderer_util.h b/src/virtio/vulkan/vn_renderer_util.h index 8fd8747..3150c88 100644 --- a/src/virtio/vulkan/vn_renderer_util.h +++ b/src/virtio/vulkan/vn_renderer_util.h @@ -34,11 +34,6 @@ vn_renderer_submit_simple(struct vn_renderer *renderer, return vn_renderer_submit(renderer, &submit); } -VkResult -vn_renderer_submit_simple_sync(struct vn_renderer *renderer, - const void *cs_data, - size_t cs_size); - void vn_renderer_shmem_pool_init(struct vn_renderer *renderer, struct vn_renderer_shmem_pool *pool,