upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/vk_queue_test.cpp
diff options
context:
space:
mode:
authorShni <niamelyrz@gmail.com>2026-11-23 08:23:27 -0600
committerGitHub <noreply@github.com>2026-11-23 08:23:27 -0600
commit14b6deeb5817dce22085014222d8b6a10f352420 (patch)
treee6fb93b879cc8e9101ce1e32a0c343e22b751432 /runtime/test/vk_queue_test.cpp
parent779c8da45a18a7f3671d964479488f1d44da094e (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.cpp29
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.
37constexpr std::uint32_t kStalls = 3; 40constexpr std::uint32_t kStalls = 3;
41PFN_vkGetSemaphoreCounterValue real_get_semaphore_counter_value = nullptr;
38PFN_vkWaitSemaphores real_wait_semaphores = nullptr; 42PFN_vkWaitSemaphores real_wait_semaphores = nullptr;
39std::atomic<std::uint32_t> injected_stalls{0}; 43std::atomic<std::uint32_t> injected_stalls{0};
44std::atomic<bool> hold_progress{false};
45
46VKAPI_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
41VKAPI_ATTR VkResult VKAPI_CALL stalling_wait_semaphores(VkDevice device, const VkSemaphoreWaitInfo* info, 55VKAPI_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));