Mesa (master): venus: wait on vkQueuePresentKHR

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 14 21:23:56 UTC 2021


Module: Mesa
Branch: master
Commit: 37f03a2c4c5e4e2844e04042c790e7f45a64a771
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=37f03a2c4c5e4e2844e04042c790e7f45a64a771

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Thu Apr  1 12:31:21 2021 -0700

venus: wait on vkQueuePresentKHR

Add vn_renderer_info::has_implicit_fencing.  Force vkQueueWaitIdle
during vkQueuePresentKHR when it is false.

This kills the performance, but we have to do this until the kernel does
implicit fencing.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei at chromium.org>
Reviewed-by: Ryan Neph <ryanneph at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10146>

---

 src/virtio/vulkan/vn_queue.c            | 21 +++++++++------------
 src/virtio/vulkan/vn_renderer.h         |  1 +
 src/virtio/vulkan/vn_renderer_virtgpu.c |  2 ++
 src/virtio/vulkan/vn_renderer_vtest.c   |  1 +
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/virtio/vulkan/vn_queue.c b/src/virtio/vulkan/vn_queue.c
index f1c0600e4d1..74ab5ff83ab 100644
--- a/src/virtio/vulkan/vn_queue.c
+++ b/src/virtio/vulkan/vn_queue.c
@@ -360,25 +360,22 @@ vn_QueueSubmit(VkQueue _queue,
       return vn_error(dev->instance, result);
    }
 
-   /* XXX The implicit fence won't work because the host is not aware of it.
-    * It is guest-only and the guest kernel does not wait.  We need kernel
-    * support, or better yet, an explicit fence that the host is aware of.
-    *
-    * vn_AcquireNextImage2KHR is also broken.
-    */
    if (wsi_mem) {
-      if (!VN_DEBUG(WSI)) {
+      /* XXX this is always false and kills the performance */
+      if (dev->instance->renderer_info.has_implicit_fencing) {
          vn_renderer_submit(dev->instance->renderer,
                             &(const struct vn_renderer_submit){
                                .bos = &wsi_mem->base_bo,
                                .bo_count = 1,
                             });
       } else {
-         static uint32_t ratelimit;
-         if (ratelimit < 10) {
-            vn_log(dev->instance,
-                   "forcing vkQueueWaitIdle before presenting");
-            ratelimit++;
+         if (VN_DEBUG(WSI)) {
+            static uint32_t ratelimit;
+            if (ratelimit < 10) {
+               vn_log(dev->instance,
+                      "forcing vkQueueWaitIdle before presenting");
+               ratelimit++;
+            }
          }
 
          vn_QueueWaitIdle(submit.queue);
diff --git a/src/virtio/vulkan/vn_renderer.h b/src/virtio/vulkan/vn_renderer.h
index 08a83cc664e..45548f82071 100644
--- a/src/virtio/vulkan/vn_renderer.h
+++ b/src/virtio/vulkan/vn_renderer.h
@@ -108,6 +108,7 @@ struct vn_renderer_info {
    bool has_cache_management;
    bool has_timeline_sync;
    bool has_external_sync;
+   bool has_implicit_fencing;
 
    uint32_t max_sync_queue_count;
 
diff --git a/src/virtio/vulkan/vn_renderer_virtgpu.c b/src/virtio/vulkan/vn_renderer_virtgpu.c
index c9d4184ef55..efee48a99d8 100644
--- a/src/virtio/vulkan/vn_renderer_virtgpu.c
+++ b/src/virtio/vulkan/vn_renderer_virtgpu.c
@@ -1251,6 +1251,8 @@ virtgpu_get_info(struct vn_renderer *renderer, struct vn_renderer_info *info)
    info->has_timeline_sync = false;
    info->has_external_sync = false;
 
+   info->has_implicit_fencing = false;
+
    info->max_sync_queue_count = gpu->max_sync_queue_count;
 
    const struct virgl_renderer_capset_venus *capset = &gpu->capset.data;
diff --git a/src/virtio/vulkan/vn_renderer_vtest.c b/src/virtio/vulkan/vn_renderer_vtest.c
index ff9290d55ba..31d1a623175 100644
--- a/src/virtio/vulkan/vn_renderer_vtest.c
+++ b/src/virtio/vulkan/vn_renderer_vtest.c
@@ -910,6 +910,7 @@ vtest_get_info(struct vn_renderer *renderer, struct vn_renderer_info *info)
    info->has_cache_management = false;
    info->has_timeline_sync = true;
    info->has_external_sync = false;
+   info->has_implicit_fencing = false;
 
    info->max_sync_queue_count = vtest->max_sync_queue_count;
 



More information about the mesa-commit mailing list