aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2019-04-25 18:42:02 +0100
committerEmil Velikov <[email protected]>2019-04-26 11:26:33 +0100
commit5b284fe6bc0a2a5c2d9e5da09a5b86ff8912e474 (patch)
tree0a18ea7a1e2000f781d184dc70ae1e0df6d4a9a9
parentbd0c4e360d08dc1b1a1433530b389358623783bb (diff)
llvmpipe: add lp_fence_timedwait() helper
The function is analogous to lp_fence_wait() while taking at timeout (ns) parameter, as needed for EGL fence/sync. v2: - use absolute UTC time, as per spec (Gustaw) - bail out on cnd_timedwait() failure (Gustaw) v3: - check count/rank under mutex (Gustaw) Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> (v1) Reviewed-by: Gustaw Smolarczyk <[email protected]>
-rw-r--r--src/gallium/drivers/llvmpipe/lp_fence.c29
-rw-r--r--src/gallium/drivers/llvmpipe/lp_fence.h3
2 files changed, 32 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_fence.c b/src/gallium/drivers/llvmpipe/lp_fence.c
index 20cd91cd63d..00cd79d6ba6 100644
--- a/src/gallium/drivers/llvmpipe/lp_fence.c
+++ b/src/gallium/drivers/llvmpipe/lp_fence.c
@@ -125,3 +125,32 @@ lp_fence_wait(struct lp_fence *f)
}
+boolean
+lp_fence_timedwait(struct lp_fence *f, uint64_t timeout)
+{
+ struct timespec ts;
+ int ret;
+
+ timespec_get(&ts, TIME_UTC);
+
+ ts.tv_nsec += timeout % 1000000000L;
+ ts.tv_sec += timeout / 1000000000L;
+ if (ts.tv_nsec >= 1000000000L) {
+ ts.tv_sec++;
+ ts.tv_nsec -= 1000000000L;
+ }
+
+ if (LP_DEBUG & DEBUG_FENCE)
+ debug_printf("%s %d\n", __FUNCTION__, f->id);
+
+ mtx_lock(&f->mutex);
+ assert(f->issued);
+ while (f->count < f->rank) {
+ ret = cnd_timedwait(&f->signalled, &f->mutex, &ts);
+ if (ret != thrd_success)
+ break;
+ }
+ const boolean result = (f->count >= f->rank);
+ mtx_unlock(&f->mutex);
+ return result;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_fence.h b/src/gallium/drivers/llvmpipe/lp_fence.h
index b72026492c6..5ba746d22d1 100644
--- a/src/gallium/drivers/llvmpipe/lp_fence.h
+++ b/src/gallium/drivers/llvmpipe/lp_fence.h
@@ -65,6 +65,9 @@ lp_fence_signalled(struct lp_fence *fence);
void
lp_fence_wait(struct lp_fence *fence);
+boolean
+lp_fence_timedwait(struct lp_fence *fence, uint64_t timeout);
+
void
llvmpipe_init_screen_fence_funcs(struct pipe_screen *screen);