diff options
Diffstat (limited to 'runtime/test/vk_queue_query_sync_test.cpp')
| -rw-r--r-- | runtime/test/vk_queue_query_sync_test.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/runtime/test/vk_queue_query_sync_test.cpp b/runtime/test/vk_queue_query_sync_test.cpp index a03e369b9..49f4015c8 100644 --- a/runtime/test/vk_queue_query_sync_test.cpp +++ b/runtime/test/vk_queue_query_sync_test.cpp | |||
| @@ -291,6 +291,73 @@ int main() { | |||
| 291 | std::printf("queue/query sync: pending Wait() preserved across failed vkQueueSubmit ok\n"); | 291 | std::printf("queue/query sync: pending Wait() preserved across failed vkQueueSubmit ok\n"); |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | // 3b. The same for a batch held behind a Wait with no submitted Signal (queue_holds.h): its submission | ||
| 295 | // fails when the CPU Signal releases it, the failure is reported through take_held_failure(), and its | ||
| 296 | // waits stay for the next submission, as when the call is not held. A Signal queued behind the failed | ||
| 297 | // batch still runs. | ||
| 298 | { | ||
| 299 | VulkanFence gate(context, 0), after(context, 0); | ||
| 300 | EXPECT(gate.semaphore() != VK_NULL_HANDLE && after.semaphore() != VK_NULL_HANDLE); | ||
| 301 | const std::uint64_t pattern = 0x0badf00dcafe1234ULL; | ||
| 302 | std::memcpy(src_ptr, &pattern, sizeof(pattern)); | ||
| 303 | std::memset(dst_ptr, 0, sizeof(pattern)); | ||
| 304 | CommandList copy_list; | ||
| 305 | EXPECT(copy_list.copy_buffer({2, 0, 1, 0, sizeof(pattern)})); | ||
| 306 | EXPECT(copy_list.close()); | ||
| 307 | const CommandList* ptr = ©_list; | ||
| 308 | |||
| 309 | queue_a.wait(gate.semaphore(), 1); | ||
| 310 | EXPECT(queue_a.execute({&ptr, 1}) == ReplayResult::success); // held: the Signal is not submitted yet | ||
| 311 | EXPECT(queue_a.signal(after.semaphore(), 1)); // held behind it | ||
| 312 | EXPECT(after.completed() == 0 && queue_a.take_held_failure() == ReplayResult::success); | ||
| 313 | driver::fail_next_submit.store(VK_ERROR_OUT_OF_HOST_MEMORY); | ||
| 314 | EXPECT(gate.signal(1)); // releases the batch on this thread | ||
| 315 | EXPECT(queue_a.take_held_failure() == ReplayResult::unsupported); | ||
| 316 | EXPECT(queue_a.take_held_failure() == ReplayResult::success); // reported once | ||
| 317 | EXPECT(queue_a.idle() && after.completed() == 1); // the Signal behind it still signaled | ||
| 318 | |||
| 319 | driver::captured_wait_count.store(0); | ||
| 320 | driver::captured_wait_sem.store(0); | ||
| 321 | driver::captured_wait_val.store(0); | ||
| 322 | driver::capture_next_waits.store(true); | ||
| 323 | EXPECT(queue_a.execute({&ptr, 1}) == ReplayResult::success); | ||
| 324 | EXPECT(queue_a.idle()); | ||
| 325 | EXPECT(driver::captured_wait_count.load() == 1); // the failed batch's wait on (gate, 1) came along | ||
| 326 | EXPECT(driver::captured_wait_sem.load() == reinterpret_cast<std::uintptr_t>(gate.semaphore())); | ||
| 327 | EXPECT(driver::captured_wait_val.load() == 1); | ||
| 328 | std::uint64_t got = 0; | ||
| 329 | std::memcpy(&got, dst_ptr, sizeof(got)); | ||
| 330 | EXPECT(got == pattern); | ||
| 331 | std::printf("queue/query sync: failed held batch reported, its wait kept for the retry, Signal behind it ran\n"); | ||
| 332 | } | ||
| 333 | |||
| 334 | // 3c. A Signal whose vkQueueSubmit fails signals nothing: a queue waiting for it stays held (the value is not | ||
| 335 | // counted as submitted), and the application's retry of the Signal goes through and releases it. | ||
| 336 | { | ||
| 337 | VulkanFence fence(context, 0); | ||
| 338 | EXPECT(fence.semaphore() != VK_NULL_HANDLE); | ||
| 339 | const std::uint64_t pattern = 0x5ca1ab1e0ddba11ULL; | ||
| 340 | std::memcpy(src_ptr, &pattern, sizeof(pattern)); | ||
| 341 | std::memset(dst_ptr, 0, sizeof(pattern)); | ||
| 342 | CommandList copy_list; | ||
| 343 | EXPECT(copy_list.copy_buffer({2, 0, 1, 0, sizeof(pattern)})); | ||
| 344 | EXPECT(copy_list.close()); | ||
| 345 | const CommandList* ptr = ©_list; | ||
| 346 | queue_b.wait(fence.semaphore(), 1); | ||
| 347 | EXPECT(queue_b.execute({&ptr, 1}) == ReplayResult::success); // held for the Signal | ||
| 348 | driver::fail_next_submit.store(VK_ERROR_OUT_OF_HOST_MEMORY); | ||
| 349 | EXPECT(!queue_a.signal(fence.semaphore(), 1)); // the submit fails | ||
| 350 | EXPECT(queue_b.idle() && fence.completed() == 0); | ||
| 351 | std::uint64_t got = 1; | ||
| 352 | std::memcpy(&got, dst_ptr, sizeof(got)); | ||
| 353 | EXPECT(got == 0); // the waiter did not run | ||
| 354 | EXPECT(queue_a.signal(fence.semaphore(), 1)); // the retry signals, and releases it | ||
| 355 | EXPECT(queue_b.idle() && queue_a.idle() && fence.completed() == 1); | ||
| 356 | std::memcpy(&got, dst_ptr, sizeof(got)); | ||
| 357 | EXPECT(got == pattern); | ||
| 358 | std::printf("queue/query sync: a failed Signal does not release its waiters; the retry does\n"); | ||
| 359 | } | ||
| 360 | |||
| 294 | // 4. Concurrent multi-queue EndQuery + ResolveQueries + temporary query pool add/remove stress. | 361 | // 4. Concurrent multi-queue EndQuery + ResolveQueries + temporary query pool add/remove stress. |
| 295 | // Each iteration uses a distinct query slot so no slot is reset while another submission resolves it. | 362 | // Each iteration uses a distinct query slot so no slot is reset while another submission resolves it. |
| 296 | { | 363 | { |