radv: Improve fence signalling in QueueSubmit.
Only signalling it once. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
This commit is contained in:
parent
a9c8424e08
commit
45f4a639a8
|
@ -3739,6 +3739,13 @@ static VkResult radv_signal_fence(struct radv_queue *queue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool radv_submit_has_effects(const VkSubmitInfo *info)
|
||||||
|
{
|
||||||
|
return info->commandBufferCount ||
|
||||||
|
info->waitSemaphoreCount ||
|
||||||
|
info->signalSemaphoreCount;
|
||||||
|
}
|
||||||
|
|
||||||
VkResult radv_QueueSubmit(
|
VkResult radv_QueueSubmit(
|
||||||
VkQueue _queue,
|
VkQueue _queue,
|
||||||
uint32_t submitCount,
|
uint32_t submitCount,
|
||||||
|
@ -3747,12 +3754,18 @@ VkResult radv_QueueSubmit(
|
||||||
{
|
{
|
||||||
RADV_FROM_HANDLE(radv_queue, queue, _queue);
|
RADV_FROM_HANDLE(radv_queue, queue, _queue);
|
||||||
VkResult result;
|
VkResult result;
|
||||||
bool fence_emitted = false;
|
uint32_t fence_idx = 0;
|
||||||
|
bool flushed_caches = false;
|
||||||
|
|
||||||
|
if (fence != VK_NULL_HANDLE) {
|
||||||
|
for (uint32_t i = 0; i < submitCount; ++i)
|
||||||
|
if (radv_submit_has_effects(pSubmits + i))
|
||||||
|
fence_idx = i;
|
||||||
|
} else
|
||||||
|
fence_idx = UINT32_MAX;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < submitCount; i++) {
|
for (uint32_t i = 0; i < submitCount; i++) {
|
||||||
if (!pSubmits[i].commandBufferCount &&
|
if (!radv_submit_has_effects(pSubmits + i) && fence_idx != i)
|
||||||
!pSubmits[i].waitSemaphoreCount &&
|
|
||||||
!pSubmits[i].signalSemaphoreCount)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
VkPipelineStageFlags wait_dst_stage_mask = 0;
|
VkPipelineStageFlags wait_dst_stage_mask = 0;
|
||||||
|
@ -3764,25 +3777,23 @@ VkResult radv_QueueSubmit(
|
||||||
.cmd_buffers = pSubmits[i].pCommandBuffers,
|
.cmd_buffers = pSubmits[i].pCommandBuffers,
|
||||||
.cmd_buffer_count = pSubmits[i].commandBufferCount,
|
.cmd_buffer_count = pSubmits[i].commandBufferCount,
|
||||||
.wait_dst_stage_mask = wait_dst_stage_mask,
|
.wait_dst_stage_mask = wait_dst_stage_mask,
|
||||||
.flush_caches = !fence_emitted,
|
.flush_caches = !flushed_caches,
|
||||||
.wait_semaphores = pSubmits[i].pWaitSemaphores,
|
.wait_semaphores = pSubmits[i].pWaitSemaphores,
|
||||||
.wait_semaphore_count = pSubmits[i].waitSemaphoreCount,
|
.wait_semaphore_count = pSubmits[i].waitSemaphoreCount,
|
||||||
.signal_semaphores = pSubmits[i].pSignalSemaphores,
|
.signal_semaphores = pSubmits[i].pSignalSemaphores,
|
||||||
.signal_semaphore_count = pSubmits[i].signalSemaphoreCount,
|
.signal_semaphore_count = pSubmits[i].signalSemaphoreCount,
|
||||||
.fence = fence
|
.fence = i == fence_idx ? fence : VK_NULL_HANDLE
|
||||||
});
|
});
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
fence_emitted = true;
|
flushed_caches = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fence != VK_NULL_HANDLE) {
|
if (fence != VK_NULL_HANDLE && !submitCount) {
|
||||||
if (!fence_emitted) {
|
result = radv_signal_fence(queue, fence);
|
||||||
result = radv_signal_fence(queue, fence);
|
if (result != VK_SUCCESS)
|
||||||
if (result != VK_SUCCESS)
|
return result;
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue