diff options
| author | Shni <niamelyrz@gmail.com> | 2026-11-23 08:23:27 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-23 08:23:27 -0600 |
| commit | 14b6deeb5817dce22085014222d8b6a10f352420 (patch) | |
| tree | e6fb93b879cc8e9101ce1e32a0c343e22b751432 /runtime/test/vk_queue_test.cpp | |
| parent | 779c8da45a18a7f3671d964479488f1d44da094e (diff) | |
test(runtime): make vk_queue_test cap/timeout backlog check deterministic (#6281)
Squash-merged after diff review of PR #6281 - test(runtime): make vk_queue_test cap/timeout backlog check deterministic
Diffstat (limited to 'runtime/test/vk_queue_test.cpp')
| -rw-r--r-- | runtime/test/vk_queue_test.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/runtime/test/vk_queue_test.cpp b/runtime/test/vk_queue_test.cpp index 761a00675..744adfab8 100644 --- a/runtime/test/vk_queue_test.cpp +++ b/runtime/test/vk_queue_test.cpp | |||
| @@ -34,15 +34,32 @@ VKAPI_ATTR VkResult VKAPI_CALL counting_allocate_command_buffers(VkDevice device | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | // Makes the queue's first kStalls waits for room time out at once, as on a GPU that stopped making progress. | 36 | // Makes the queue's first kStalls waits for room time out at once, as on a GPU that stopped making progress. |
| 37 | // While hold_progress is set, timeline counter queries report 0 so a fast GPU cannot retire command buffers | ||
| 38 | // before the loop reaches kMaxQueuedCommandBuffers; once kStalls timeouts have been injected, real progress | ||
| 39 | // resumes and the wait completes normally. | ||
| 37 | constexpr std::uint32_t kStalls = 3; | 40 | constexpr std::uint32_t kStalls = 3; |
| 41 | PFN_vkGetSemaphoreCounterValue real_get_semaphore_counter_value = nullptr; | ||
| 38 | PFN_vkWaitSemaphores real_wait_semaphores = nullptr; | 42 | PFN_vkWaitSemaphores real_wait_semaphores = nullptr; |
| 39 | std::atomic<std::uint32_t> injected_stalls{0}; | 43 | std::atomic<std::uint32_t> injected_stalls{0}; |
| 44 | std::atomic<bool> hold_progress{false}; | ||
| 45 | |||
| 46 | VKAPI_ATTR VkResult VKAPI_CALL holding_semaphore_counter(VkDevice device, VkSemaphore semaphore, | ||
| 47 | std::uint64_t* value) { | ||
| 48 | if (hold_progress.load()) { | ||
| 49 | *value = 0; | ||
| 50 | return VK_SUCCESS; | ||
| 51 | } | ||
| 52 | return real_get_semaphore_counter_value(device, semaphore, value); | ||
| 53 | } | ||
| 40 | 54 | ||
| 41 | VKAPI_ATTR VkResult VKAPI_CALL stalling_wait_semaphores(VkDevice device, const VkSemaphoreWaitInfo* info, | 55 | VKAPI_ATTR VkResult VKAPI_CALL stalling_wait_semaphores(VkDevice device, const VkSemaphoreWaitInfo* info, |
| 42 | std::uint64_t timeout) { | 56 | std::uint64_t timeout) { |
| 43 | if (timeout == VulkanQueue::kQueuedWaitNs && injected_stalls.load() < kStalls) { | 57 | if (timeout == VulkanQueue::kQueuedWaitNs) { |
| 44 | ++injected_stalls; | 58 | if (injected_stalls.load() < kStalls) { |
| 45 | return VK_TIMEOUT; | 59 | ++injected_stalls; |
| 60 | return VK_TIMEOUT; | ||
| 61 | } | ||
| 62 | hold_progress.store(false); | ||
| 46 | } | 63 | } |
| 47 | return real_wait_semaphores(device, info, timeout); | 64 | return real_wait_semaphores(device, info, timeout); |
| 48 | } | 65 | } |
| @@ -349,12 +366,18 @@ int main() { | |||
| 349 | const CommandList* big_lists[] = {&big_copy}; | 366 | const CommandList* big_lists[] = {&big_copy}; |
| 350 | 367 | ||
| 351 | real_allocate_command_buffers = context.vk.vkAllocateCommandBuffers; | 368 | real_allocate_command_buffers = context.vk.vkAllocateCommandBuffers; |
| 369 | real_get_semaphore_counter_value = context.vk.vkGetSemaphoreCounterValue; | ||
| 352 | real_wait_semaphores = context.vk.vkWaitSemaphores; | 370 | real_wait_semaphores = context.vk.vkWaitSemaphores; |
| 353 | context.vk.vkAllocateCommandBuffers = counting_allocate_command_buffers; | 371 | context.vk.vkAllocateCommandBuffers = counting_allocate_command_buffers; |
| 372 | context.vk.vkGetSemaphoreCounterValue = holding_semaphore_counter; | ||
| 354 | context.vk.vkWaitSemaphores = stalling_wait_semaphores; | 373 | context.vk.vkWaitSemaphores = stalling_wait_semaphores; |
| 355 | allocated_command_buffers = 0; | 374 | allocated_command_buffers = 0; |
| 375 | injected_stalls.store(0); | ||
| 376 | hold_progress.store(true); | ||
| 356 | for (std::uint32_t i = 0; i < kSubmits; ++i) EXPECT(direct.execute(big_lists) == ReplayResult::success); | 377 | for (std::uint32_t i = 0; i < kSubmits; ++i) EXPECT(direct.execute(big_lists) == ReplayResult::success); |
| 378 | hold_progress.store(false); | ||
| 357 | context.vk.vkAllocateCommandBuffers = real_allocate_command_buffers; | 379 | context.vk.vkAllocateCommandBuffers = real_allocate_command_buffers; |
| 380 | context.vk.vkGetSemaphoreCounterValue = real_get_semaphore_counter_value; | ||
| 358 | context.vk.vkWaitSemaphores = real_wait_semaphores; | 381 | context.vk.vkWaitSemaphores = real_wait_semaphores; |
| 359 | EXPECT(direct.signal(fence.semaphore(), 5)); | 382 | EXPECT(direct.signal(fence.semaphore(), 5)); |
| 360 | EXPECT(fence.wait(5, 20'000'000'000ull)); | 383 | EXPECT(fence.wait(5, 20'000'000'000ull)); |