vn_update_sync_result(struct vn_device *dev,
VkResult result,
int64_t abs_timeout,
- uint32_t *iter)
+ struct vn_relax_state *relax_state)
{
switch (result) {
case VK_NOT_READY:
os_time_get_nano() >= abs_timeout)
result = VK_TIMEOUT;
else
- vn_relax(&dev->instance->ring.ring, iter, "client");
+ vn_relax(relax_state);
break;
default:
assert(result == VK_SUCCESS || result < 0);
const int64_t abs_timeout = os_time_get_absolute_timeout(timeout);
VkResult result = VK_NOT_READY;
- uint32_t iter = 0;
if (fenceCount > 1 && waitAll) {
VkFence local_fences[8];
VkFence *fences = local_fences;
}
memcpy(fences, pFences, sizeof(*fences) * fenceCount);
+ struct vn_relax_state relax_state =
+ vn_relax_init(&dev->instance->ring.ring, "client");
while (result == VK_NOT_READY) {
result = vn_remove_signaled_fences(device, fences, &fenceCount);
- result = vn_update_sync_result(dev, result, abs_timeout, &iter);
+ result =
+ vn_update_sync_result(dev, result, abs_timeout, &relax_state);
}
+ vn_relax_fini(&relax_state);
if (fences != local_fences)
vk_free(alloc, fences);
} else {
+ struct vn_relax_state relax_state =
+ vn_relax_init(&dev->instance->ring.ring, "client");
while (result == VK_NOT_READY) {
result = vn_find_first_signaled_fence(device, pFences, fenceCount);
- result = vn_update_sync_result(dev, result, abs_timeout, &iter);
+ result =
+ vn_update_sync_result(dev, result, abs_timeout, &relax_state);
}
+ vn_relax_fini(&relax_state);
}
return vn_result(dev->instance, result);
const int64_t abs_timeout = os_time_get_absolute_timeout(timeout);
VkResult result = VK_NOT_READY;
- uint32_t iter = 0;
if (pWaitInfo->semaphoreCount > 1 &&
!(pWaitInfo->flags & VK_SEMAPHORE_WAIT_ANY_BIT)) {
uint32_t semaphore_count = pWaitInfo->semaphoreCount;
sizeof(*semaphores) * semaphore_count);
memcpy(values, pWaitInfo->pValues, sizeof(*values) * semaphore_count);
+ struct vn_relax_state relax_state =
+ vn_relax_init(&dev->instance->ring.ring, "client");
while (result == VK_NOT_READY) {
result = vn_remove_signaled_semaphores(device, semaphores, values,
&semaphore_count);
- result = vn_update_sync_result(dev, result, abs_timeout, &iter);
+ result =
+ vn_update_sync_result(dev, result, abs_timeout, &relax_state);
}
+ vn_relax_fini(&relax_state);
if (semaphores != local_semaphores)
vk_free(alloc, semaphores);
} else {
+ struct vn_relax_state relax_state =
+ vn_relax_init(&dev->instance->ring.ring, "client");
while (result == VK_NOT_READY) {
result = vn_find_first_signaled_semaphore(
device, pWaitInfo->pSemaphores, pWaitInfo->pValues,
pWaitInfo->semaphoreCount);
- result = vn_update_sync_result(dev, result, abs_timeout, &iter);
+ result =
+ vn_update_sync_result(dev, result, abs_timeout, &relax_state);
}
+ vn_relax_fini(&relax_state);
}
return vn_result(dev->instance, result);
}
static uint32_t
-vn_ring_wait_seqno(const struct vn_ring *ring, uint32_t seqno)
+vn_ring_wait_seqno(struct vn_ring *ring, uint32_t seqno)
{
/* A renderer wait incurs several hops and the renderer might poll
* repeatedly anyway. Let's just poll here.
*/
- uint32_t iter = 0;
+ struct vn_relax_state relax_state = vn_relax_init(ring, "ring seqno");
do {
const uint32_t head = vn_ring_load_head(ring);
- if (vn_ring_ge_seqno(ring, head, seqno))
+ if (vn_ring_ge_seqno(ring, head, seqno)) {
+ vn_relax_fini(&relax_state);
return head;
- vn_relax(ring, &iter, "ring seqno");
+ }
+ vn_relax(&relax_state);
} while (true);
}
}
static uint32_t
-vn_ring_wait_space(const struct vn_ring *ring, uint32_t size)
+vn_ring_wait_space(struct vn_ring *ring, uint32_t size)
{
assert(size <= ring->buffer_size);
VN_TRACE_FUNC();
/* see the reasoning in vn_ring_wait_seqno */
- uint32_t iter = 0;
+ struct vn_relax_state relax_state = vn_relax_init(ring, "ring space");
do {
- vn_relax(ring, &iter, "ring space");
- if (vn_ring_has_space(ring, size, &head))
+ vn_relax(&relax_state);
+ if (vn_ring_has_space(ring, size, &head)) {
+ vn_relax_fini(&relax_state);
return head;
+ }
} while (true);
}
}
* This is thread-safe.
*/
void
-vn_ring_wait(const struct vn_ring *ring, uint32_t seqno)
+vn_ring_wait(struct vn_ring *ring, uint32_t seqno)
{
vn_ring_wait_seqno(ring, seqno);
}