Mesa (main): d3d12: Handle non-infinite wait timeouts > 49.7 days as infinite

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 9 04:32:07 UTC 2021


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

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Tue Nov  2 10:02:57 2021 -0700

d3d12: Handle non-infinite wait timeouts > 49.7 days as infinite

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12268>

---

 src/gallium/drivers/d3d12/d3d12_fence.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_fence.cpp b/src/gallium/drivers/d3d12/d3d12_fence.cpp
index e3b39dd584f..b00d2ffae6c 100644
--- a/src/gallium/drivers/d3d12/d3d12_fence.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_fence.cpp
@@ -28,6 +28,9 @@
 
 #include "util/u_memory.h"
 
+constexpr uint64_t NsPerMs = 1000000;
+constexpr uint64_t MaxTimeoutInNs = (uint64_t)UINT_MAX * NsPerMs;
+
 #ifdef _WIN32
 static void
 close_event(HANDLE event, int fd)
@@ -46,7 +49,7 @@ create_event(int *fd)
 static bool
 wait_event(HANDLE event, int event_fd, uint64_t timeout_ns)
 {
-   DWORD timeout_ms = (timeout_ns == PIPE_TIMEOUT_INFINITE) ? INFINITE : timeout_ns / 1000000;
+   DWORD timeout_ms = (timeout_ns == PIPE_TIMEOUT_INFINITE || timeout_ns > MaxTimeoutInNs) ? INFINITE : timeout_ns / NsPerMs;
    return WaitForSingleObject(event, timeout_ms) == WAIT_OBJECT_0;
 }
 #else
@@ -71,7 +74,7 @@ create_event(int *fd)
 static bool
 wait_event(HANDLE event, int event_fd, uint64_t timeout_ns)
 {
-   int timeout_ms = (timeout_ns == PIPE_TIMEOUT_INFINITE) ? -1 : timeout_ns / 1000000;
+   int timeout_ms = (timeout_ns == PIPE_TIMEOUT_INFINITE || timeout_ns > MaxTimeoutInNs) ? -1 : timeout_ns / NsPerMs;
    return sync_wait(event_fd, timeout_ms) == 0;
 }
 #endif



More information about the mesa-commit mailing list