mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 04:58:05 +02:00
venus: add vn_get_semaphore_counter_value that takes vn_relax_state
No behavior change in this commit. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40790>
This commit is contained in:
parent
9764c494ef
commit
20533207d3
1 changed files with 36 additions and 22 deletions
|
|
@ -2195,13 +2195,14 @@ vn_DestroySemaphore(VkDevice device,
|
|||
vk_free(alloc, sem);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vn_GetSemaphoreCounterValue(VkDevice device,
|
||||
VkSemaphore semaphore,
|
||||
uint64_t *pValue)
|
||||
static VkResult
|
||||
vn_get_semaphore_counter_value(VkDevice dev_handle,
|
||||
VkSemaphore sem_handle,
|
||||
struct vn_relax_state *relax_state,
|
||||
uint64_t *out_value)
|
||||
{
|
||||
struct vn_device *dev = vn_device_from_handle(device);
|
||||
struct vn_semaphore *sem = vn_semaphore_from_handle(semaphore);
|
||||
struct vn_device *dev = vn_device_from_handle(dev_handle);
|
||||
struct vn_semaphore *sem = vn_semaphore_from_handle(sem_handle);
|
||||
ASSERTED struct vn_sync_payload *payload = sem->payload;
|
||||
|
||||
assert(payload->type == VN_SYNC_TYPE_DEVICE_ONLY);
|
||||
|
|
@ -2236,11 +2237,11 @@ vn_GetSemaphoreCounterValue(VkDevice device,
|
|||
.pNext = NULL,
|
||||
.flags = 0,
|
||||
.semaphoreCount = 1,
|
||||
.pSemaphores = &semaphore,
|
||||
.pSemaphores = &sem_handle,
|
||||
.pValues = &counter,
|
||||
};
|
||||
|
||||
vn_async_vkWaitSemaphores(dev->primary_ring, device, &wait_info,
|
||||
vn_async_vkWaitSemaphores(dev->primary_ring, dev_handle, &wait_info,
|
||||
UINT64_MAX);
|
||||
|
||||
/* search pending cmds for already signaled values */
|
||||
|
|
@ -2269,10 +2270,10 @@ vn_GetSemaphoreCounterValue(VkDevice device,
|
|||
counter = MAX2(counter, sem->feedback.signaled_counter);
|
||||
simple_mtx_unlock(&sem->feedback.counter_mtx);
|
||||
|
||||
*pValue = counter;
|
||||
*out_value = counter;
|
||||
} else {
|
||||
VkResult result = vn_call_vkGetSemaphoreCounterValue(
|
||||
dev->primary_ring, device, semaphore, pValue);
|
||||
dev->primary_ring, dev_handle, sem_handle, out_value);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
|
@ -2284,9 +2285,9 @@ vn_GetSemaphoreCounterValue(VkDevice device,
|
|||
* won't go backwards. e.g. multiple threads querying when suspended
|
||||
*/
|
||||
simple_mtx_lock(&sem->feedback.counter_mtx);
|
||||
if (*pValue >= sem->feedback.suspended_counter) {
|
||||
vn_feedback_set_counter(sem->feedback.slot, *pValue);
|
||||
sem->feedback.suspended_counter = *pValue;
|
||||
if (*out_value >= sem->feedback.suspended_counter) {
|
||||
vn_feedback_set_counter(sem->feedback.slot, *out_value);
|
||||
sem->feedback.suspended_counter = *out_value;
|
||||
sem->feedback.pollable = true;
|
||||
}
|
||||
simple_mtx_unlock(&sem->feedback.counter_mtx);
|
||||
|
|
@ -2296,6 +2297,17 @@ vn_GetSemaphoreCounterValue(VkDevice device,
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vn_GetSemaphoreCounterValue(VkDevice device,
|
||||
VkSemaphore semaphore,
|
||||
uint64_t *pValue)
|
||||
{
|
||||
struct vn_device *dev = vn_device_from_handle(device);
|
||||
VkResult result =
|
||||
vn_get_semaphore_counter_value(device, semaphore, NULL, pValue);
|
||||
return vn_result(dev->instance, result);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vn_SignalSemaphore(VkDevice device, const VkSemaphoreSignalInfo *pSignalInfo)
|
||||
{
|
||||
|
|
@ -2330,12 +2342,13 @@ static VkResult
|
|||
vn_find_first_signaled_semaphore(VkDevice device,
|
||||
const VkSemaphore *semaphores,
|
||||
const uint64_t *values,
|
||||
uint32_t count)
|
||||
uint32_t count,
|
||||
struct vn_relax_state *relax_state)
|
||||
{
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
uint64_t val = 0;
|
||||
VkResult result =
|
||||
vn_GetSemaphoreCounterValue(device, semaphores[i], &val);
|
||||
VkResult result = vn_get_semaphore_counter_value(device, semaphores[i],
|
||||
relax_state, &val);
|
||||
if (result != VK_SUCCESS || val >= values[i])
|
||||
return result;
|
||||
}
|
||||
|
|
@ -2346,13 +2359,14 @@ static VkResult
|
|||
vn_remove_signaled_semaphores(VkDevice device,
|
||||
VkSemaphore *semaphores,
|
||||
uint64_t *values,
|
||||
uint32_t *count)
|
||||
uint32_t *count,
|
||||
struct vn_relax_state *relax_state)
|
||||
{
|
||||
uint32_t cur = 0;
|
||||
for (uint32_t i = 0; i < *count; i++) {
|
||||
uint64_t val = 0;
|
||||
VkResult result =
|
||||
vn_GetSemaphoreCounterValue(device, semaphores[i], &val);
|
||||
VkResult result = vn_get_semaphore_counter_value(device, semaphores[i],
|
||||
relax_state, &val);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
if (val < values[i])
|
||||
|
|
@ -2384,8 +2398,8 @@ vn_WaitSemaphores(VkDevice device,
|
|||
struct vn_relax_state relax_state =
|
||||
vn_relax_init(dev->instance, VN_RELAX_REASON_SEMAPHORE);
|
||||
while (result == VK_NOT_READY) {
|
||||
result = vn_remove_signaled_semaphores(device, semaphores, values,
|
||||
&semaphore_count);
|
||||
result = vn_remove_signaled_semaphores(
|
||||
device, semaphores, values, &semaphore_count, &relax_state);
|
||||
result =
|
||||
vn_update_sync_result(dev, result, abs_timeout, &relax_state);
|
||||
}
|
||||
|
|
@ -2399,7 +2413,7 @@ vn_WaitSemaphores(VkDevice device,
|
|||
while (result == VK_NOT_READY) {
|
||||
result = vn_find_first_signaled_semaphore(
|
||||
device, pWaitInfo->pSemaphores, pWaitInfo->pValues,
|
||||
pWaitInfo->semaphoreCount);
|
||||
pWaitInfo->semaphoreCount, &relax_state);
|
||||
result =
|
||||
vn_update_sync_result(dev, result, abs_timeout, &relax_state);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue