Mesa (staging/22.1): vulkan/wsi/x11: Use atomic_int with sent_image_count

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 28 17:12:06 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 2820d39bb45ce6ab9e947ca67eb8f8726aade3db
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2820d39bb45ce6ab9e947ca67eb8f8726aade3db

Author: Jordan Justen <jordan.l.justen at intel.com>
Date:   Tue Apr 12 14:46:39 2022 -0700

vulkan/wsi/x11: Use atomic_int with sent_image_count

Without this being atomically incremented and decremented, I observed
this assert triggering in debug builds:

  src/vulkan/wsi/wsi_common_x11.c:x11_present_to_x11_dri3():

  assert(chain->sent_image_count <= chain->base.image_count);

I think this was happening since,

  src/vulkan/wsi/wsi_common_x11.c:x11_handle_dri3_present_event()

which decrements chain->sent_image_count may be run in a separate
thread.

Fixes: d0bc1ad3776 ("vulkan/wsi/x11: add sent image counter")
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15908>
(cherry picked from commit 212fb25b267120c6cc8eead21a7eb016f2b58f2a)

---

 .pick_status.json               | 2 +-
 src/vulkan/wsi/wsi_common_x11.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index db28e3ac461..abdc1161901 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -211,7 +211,7 @@
         "description": "vulkan/wsi/x11: Use atomic_int with sent_image_count",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "d0bc1ad3776bce7d4b356e2a3d8bdbb9ae64e588"
     },
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 563bf13f8c9..7dfb4c1b82d 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -29,6 +29,7 @@
 #include <xcb/shm.h>
 
 #include "util/macros.h"
+#include <stdatomic.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -914,7 +915,7 @@ struct x11_swapchain {
    uint64_t                                     send_sbc;
    uint64_t                                     last_present_msc;
    uint32_t                                     stamp;
-   int                                          sent_image_count;
+   atomic_int                                   sent_image_count;
 
    bool                                         has_present_queue;
    bool                                         has_acquire_queue;



More information about the mesa-commit mailing list