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:
authortedin7 <110300616+tedin7@users.noreply.github.com>2026-11-23 15:11:02 +0100
committerGitHub <noreply@github.com>2026-11-23 08:11:02 -0600
commite76cb47fb500b74f51d0aa51e680cc72beed09c9 (patch)
treec958a0f618e0b3d6b1b54f7298635e04ba43160f /runtime/test/vk_queue_test.cpp
parent82c6e08dd5a18ee46e8f82eefd265d9d9687afd0 (diff)
Runtime: D3D12 queues share a VkQueue when the GPU has no free one (Intel UHD 770 queueCount 1), plus a CPU-signal hang fix (#5110)
Squash-merged after review of PR #5110 - Runtime: D3D12 queues share a VkQueue when the GPU has no free one (Intel UHD 770 queueCount 1), plus a CPU-signal hang fix
Diffstat (limited to 'runtime/test/vk_queue_test.cpp')
-rw-r--r--runtime/test/vk_queue_test.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/runtime/test/vk_queue_test.cpp b/runtime/test/vk_queue_test.cpp
index 4f2fbdd46..761a00675 100644
--- a/runtime/test/vk_queue_test.cpp
+++ b/runtime/test/vk_queue_test.cpp
@@ -116,6 +116,48 @@ int check_picker() {
116 return 0; 116 return 0;
117} 117}
118 118
119// Which VkQueue each new D3D12 queue leases (CreateCommandQueue): an unused one while there is one, its own family's
120// first, then the one with the fewest D3D12 queues. `own` and `graphics` count the D3D12 queues on each VkQueue.
121int check_queue_slots() {
122 const auto lease = [](std::vector<std::uint32_t>& own, std::vector<std::uint32_t>& graphics) {
123 const auto slot = pick_queue_slot({own, graphics});
124 if (slot.pool != SIZE_MAX) ++(slot.pool == 0 ? own : graphics)[slot.index];
125 return slot;
126 };
127 { // Enough queues (an RTX 5080: 8 compute, 16 graphics): every COMPUTE queue gets a VkQueue of its own.
128 std::vector<std::uint32_t> compute(8, 0), graphics(16, 0);
129 for (std::size_t i = 0; i < 8; ++i) {
130 const auto slot = lease(compute, graphics);
131 EXPECT(slot.pool == 0 && slot.index == i);
132 }
133 const auto ninth = lease(compute, graphics);
134 EXPECT(ninth.pool == 1 && ninth.index == 0); // then an unused graphics queue, not a shared compute one
135 }
136 { // One VkQueue per family (LEONIDA_VK_MAX_QUEUES_PER_FAMILY=1): DIRECT, COMPUTE, then they share.
137 std::vector<std::uint32_t> none, compute(1, 0), graphics(1, 0);
138 EXPECT(lease(none, graphics).pool == 1);
139 EXPECT(lease(compute, graphics).pool == 0);
140 const auto second_compute = lease(compute, graphics);
141 EXPECT(second_compute.pool == 0 && compute[0] == 2); // a tie goes to the type's own family
142 const auto third_compute = lease(compute, graphics);
143 EXPECT(third_compute.pool == 1 && graphics[0] == 2); // then the queue with fewer D3D12 queues
144 --compute[0];
145 --compute[0]; // two COMPUTE queues released
146 EXPECT(lease(compute, graphics).pool == 0);
147 }
148 { // A queue released by its last D3D12 queue is unused again and preferred to sharing.
149 std::vector<std::uint32_t> none, graphics{3, 0, 2};
150 const auto slot = lease(none, graphics);
151 EXPECT(slot.pool == 1 && slot.index == 1);
152 }
153 { // No VkQueue at all.
154 std::vector<std::uint32_t> none;
155 EXPECT(pick_queue_slot({none, none}).pool == SIZE_MAX);
156 }
157 std::printf("queue slots: distinct while free, shared by fewest users after\n");
158 return 0;
159}
160
119constexpr std::uint32_t kSize = 64 * 1024; 161constexpr std::uint32_t kSize = 64 * 1024;
120constexpr std::uint32_t kTex = 64; // 64x64 RGBA8: row pitch 256, already aligned 162constexpr std::uint32_t kTex = 64; // 64x64 RGBA8: row pitch 256, already aligned
121 163
@@ -124,7 +166,7 @@ std::uint8_t pattern(std::uint32_t i, std::uint8_t seed) { return std::uint8_t(i
124} // namespace 166} // namespace
125 167
126int main() { 168int main() {
127 if (check_picker()) return 1; 169 if (check_picker() || check_queue_slots()) return 1;
128 170
129 vktest::Device d; 171 vktest::Device d;
130 d.all_queue_types = true; 172 d.all_queue_types = true;