Skip to content

Commit 4e48f0b

Browse files
Important fix for Intel GPUs in ex 07
1 parent 495850f commit 4e48f0b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

07_StagingAndMultipleQueues/main.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
8989

9090
private:
9191
smart_refctd_ptr<ISemaphore> m_imagesLoadedSemaphore, m_imagesProcessedSemaphore, m_histogramSavedSemaphore;
92-
std::atomic<uint32_t> m_imagesLoadedCnt, m_imagesProcessedCnt, m_imagesDownloadedCnt, m_imagesSavedCnt;
9392
std::atomic<uint32_t> imageHandlesCreated = 0u;
93+
std::atomic<uint32_t> transfersSubmitted = 0u;
9494
std::array<core::smart_refctd_ptr<IGPUImage>, IMAGE_CNT> images;
9595

9696
static constexpr uint32_t FRAMES_IN_FLIGHT = 3u;
@@ -243,6 +243,8 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
243243
};
244244
transferUpQueue->startCapture();
245245
getTransferUpQueue()->submit(intendedSubmit.popSubmit({&signalSemaphore,1}));
246+
transfersSubmitted++;
247+
transfersSubmitted.notify_one();
246248
transferUpQueue->endCapture();
247249

248250

@@ -454,6 +456,12 @@ class StagingAndMultipleQueuesApp final : public application_templates::BasicMul
454456
submitInfo[0].commandBuffers = cmdBuffSubmitInfo;
455457
submitInfo[0].signalSemaphores = signalSemaphoreSubmitInfo;
456458
submitInfo[0].waitSemaphores = {waitSemaphoreSubmitInfo, imageToProcessId < FRAMES_IN_FLIGHT ? 1u : 2u};
459+
// Some Devices like all of the Intel GPUs do not have enough queues for us to allocate different queues to compute and transfers,
460+
// so our `BasicMultiQueueApplication` will "alias" a single queue to both usages. Normally you don't need to care, but here we're
461+
// attempting to do "out-of-order" "submit-before-signal" so we need to "hold back" submissions if the queues are aliased!
462+
if (getTransferUpQueue()==computeQueue)
463+
for (auto old = transfersSubmitted.load(); old <= imageToProcessId; old = transfersSubmitted.load())
464+
transfersSubmitted.wait(old);
457465
computeQueue->startCapture();
458466
computeQueue->submit(submitInfo);
459467
computeQueue->endCapture();

0 commit comments

Comments
 (0)