Skip to content

Commit a6683b6

Browse files
trivedivivekSS-JIA
andauthored
[ET-VK] 2/n Split dispatches between multiple command buffers. Add semaphore support to Adapter::submit_cmd. (#12522)
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * #12525 * #12523 * __->__ #12522 * #12519 This diff adds semaphore support to `Adapter::submit_cmd` by modifying its function signature to include `wait_semaphore` and `signal_semaphore` parameters. The updated function now takes into account the new semaphore parameters and correctly configures the pipeline stages using `VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT`. Differential Revision: [D78360041](https://our.internmc.facebook.com/intern/diff/D78360041/) --------- Co-authored-by: Stephen Jia <[email protected]>
1 parent 7a4ec13 commit a6683b6

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

backends/vulkan/runtime/vk_api/Adapter.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,17 +307,22 @@ void Adapter::return_queue(Adapter::Queue& compute_queue) {
307307
void Adapter::submit_cmd(
308308
const Adapter::Queue& device_queue,
309309
VkCommandBuffer cmd,
310-
VkFence fence) {
310+
VkFence fence,
311+
VkSemaphore wait_semaphore,
312+
VkSemaphore signal_semaphore) {
313+
const VkPipelineStageFlags flags = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
314+
const bool set_wait_semaphore = wait_semaphore != VK_NULL_HANDLE;
315+
const bool set_signal_semaphore = signal_semaphore != VK_NULL_HANDLE;
311316
const VkSubmitInfo submit_info{
312317
VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType
313318
nullptr, // pNext
314-
0u, // waitSemaphoreCount
315-
nullptr, // pWaitSemaphores
316-
nullptr, // pWaitDstStageMask
319+
set_wait_semaphore ? 1u : 0u, // waitSemaphoreCount
320+
set_wait_semaphore ? &wait_semaphore : nullptr, // pWaitSemaphores
321+
&flags, // pWaitDstStageMask
317322
1u, // commandBufferCount
318323
&cmd, // pCommandBuffers
319-
0u, // signalSemaphoreCount
320-
nullptr, // pSignalSemaphores
324+
set_signal_semaphore ? 1u : 0u, // signalSemaphoreCount
325+
set_signal_semaphore ? &signal_semaphore : nullptr, // pSignalSemaphores
321326
};
322327

323328
std::lock_guard<std::mutex> queue_lock(

backends/vulkan/runtime/vk_api/Adapter.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,12 @@ class Adapter final {
242242

243243
// Command Buffer Submission
244244

245-
void
246-
submit_cmd(const Queue&, VkCommandBuffer, VkFence fence = VK_NULL_HANDLE);
245+
void submit_cmd(
246+
const Queue&,
247+
VkCommandBuffer,
248+
VkFence fence = VK_NULL_HANDLE,
249+
VkSemaphore wait_semaphore = VK_NULL_HANDLE,
250+
VkSemaphore signal_semaphore = VK_NULL_HANDLE);
247251

248252
std::string stringize() const;
249253
friend std::ostream& operator<<(std::ostream&, const Adapter&);

0 commit comments

Comments
 (0)