Module: Mesa
Branch: main
Commit: 35ffadb9e7d6d2ca3f6b2fadb5735696b9732c34
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=35ffadb9e7d6d2ca3f6b2fadb5735696b9732c34

Author: Mike Blumenkrantz <[email protected]>
Date:   Wed Nov 17 14:15:18 2021 -0500

zink: clamp to 500 max batch states on nvidia

I've been advised that leaving this unclamped will use up all the fds
allotted to a process

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13844>

---

 src/gallium/drivers/zink/zink_batch.c  | 4 ++--
 src/gallium/drivers/zink/zink_screen.c | 9 +++++++++
 src/gallium/drivers/zink/zink_screen.h | 1 +
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_batch.c 
b/src/gallium/drivers/zink/zink_batch.c
index ae23a1f6d01..f3433640827 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -339,8 +339,8 @@ post_submit(void *data, void *gdata, int thread_index)
       if (bs->ctx->reset.reset)
          bs->ctx->reset.reset(bs->ctx->reset.data, PIPE_GUILTY_CONTEXT_RESET);
       screen->device_lost = true;
-   } else if (bs->ctx->batch_states_count > 5000) {
-      zink_screen_batch_id_wait(screen, bs->fence.batch_id - 2500, 
PIPE_TIMEOUT_INFINITE);
+   } else if (bs->ctx->batch_states_count > screen->max_fences) {
+      zink_screen_batch_id_wait(screen, bs->fence.batch_id - 
(screen->max_fences / 2), PIPE_TIMEOUT_INFINITE);
    }
 }
 
diff --git a/src/gallium/drivers/zink/zink_screen.c 
b/src/gallium/drivers/zink/zink_screen.c
index 55e8ff8bc24..fa221ce98f4 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -2028,6 +2028,15 @@ zink_internal_create_screen(const struct 
pipe_screen_config *config)
    if (!os_get_total_physical_memory(&screen->total_mem))
       goto fail;
 
+   switch (screen->info.driver_props.driverID) {
+   case VK_DRIVER_ID_NVIDIA_PROPRIETARY:
+      screen->max_fences = 500;
+      break;
+   default:
+      screen->max_fences = 5000;
+      break;
+   }
+
    if (debug_get_bool_option("ZINK_NO_TIMELINES", false))
       screen->info.have_KHR_timeline_semaphore = false;
    if (screen->info.have_KHR_timeline_semaphore)
diff --git a/src/gallium/drivers/zink/zink_screen.h 
b/src/gallium/drivers/zink/zink_screen.h
index 7df140b078f..cb64e67588f 100644
--- a/src/gallium/drivers/zink/zink_screen.h
+++ b/src/gallium/drivers/zink/zink_screen.h
@@ -134,6 +134,7 @@ struct zink_screen {
    uint32_t gfx_queue;
    uint32_t max_queues;
    uint32_t timestamp_valid_bits;
+   unsigned max_fences;
    VkDevice dev;
    VkQueue queue; //gfx+compute
    VkQueue thread_queue; //gfx+compute

Reply via email to