Skip to content

Commit b870973

Browse files
committed
Comments Update
1 parent 29500f0 commit b870973

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

include/nbl/video/utilities/SIntendedSubmitInfo.h

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,45 @@ struct SIntendedSubmitInfo final : core::Uncopyable
7575
}
7676

7777
public:
78-
// This parameter is required but may be unused if there is no need (no overflow) to do submit
78+
// This parameter is required but may be unused if there is no need (no overflow) to perform submit operations (no call to `overflowSubmit` or `submit`)
7979
IQueue* queue = nullptr;
80-
// Use this parameter to wait for previous operations to finish before whatever commands the Utility you're using records
80+
81+
// Use this parameter to wait for previous operations to finish before whatever commands the Utility you're using records.
8182
std::span<const IQueue::SSubmitInfo::SSemaphoreInfo> waitSemaphores = {};
82-
// Fill the commandbuffers you want to run before the first command the Utility records to run in the same submit,
83-
// for example baked command buffers with pipeline barrier commands.
83+
84+
// Fill the commandbuffers you want to run before the first command the Utility records to run in the same submit,
85+
// for example, baked command buffers with pipeline barrier commands.
8486
std::span<const IQueue::SSubmitInfo::SCommandBufferInfo> prevCommandBuffers = {};
85-
// A set of command buffers the Utility can round robin its transient commands. All must be individually resettable.
86-
// Command buffers are cycled through for use and submission in a simple modular arithmetic fashion.
87-
// EXACTLY ONE commandbuffer must be in recording state! This is the one the utility will use immediately to record commands.
88-
// But remember that even though its scratch, you can record some of your own preceeding commands into it as well.
87+
88+
// A set of command buffers the Utility can use in a round-robin manner for its transient commands. All command buffers must be individually resettable.
89+
// Command buffers are cycled through for use and submission using a simple modular arithmetic fashion.
90+
// EXACTLY ONE commandbuffer must be in recording state! This is the one the utilities will use immediately to record commands.
91+
// However, even though it's scratch, you can record some of your own preceding commands into it as well.
8992
std::span<IQueue::SSubmitInfo::SCommandBufferInfo> scratchCommandBuffers = {};
90-
// This semaphore is needed to ensure correct and valid usage of the command buffer used to record the next submit by ensuring they are not currently pending.
91-
// The initial `scratchSemaphore.value` gets incremented and signalled on each submit, can start at 0 because an overflow will signal `value+1`.
92-
// `[Multi]TimelineEventHandler` to latch cleanups on `scratchSemaphore` where this value, so make sure you're submitting by yourself manually and use the functions provided here.
93-
// is a value that they expect to actually get signalled in the future.
94-
// NOTE: To ensure deterministic behavior, do not attempt to signal this semaphore yourself.
95-
// You can actually examine the change in `scratchSemaphore.value` to figure out how many submits occurred.
93+
94+
// This semaphore is needed to "stitch together" additional submits, ensuring they occur before and after the original intended signals and waits.
95+
// It also ensures safe usage of the scratch command buffers by blocking the CPU if the command buffer is in a PENDING state and not safe to begin.
96+
// The initial `scratchSemaphore.value` gets incremented and signaled on each submit. It can start at 0 because an overflow will signal `value+1`.
97+
// NOTE: You should signal this semaphore when doing your last/tail submit manually OR when not submitting the recorded scratch at all
98+
// (in which case, signal from Host or another submit). Why? The utilities that deal with `SIntendedSubmitInfo` might use the
99+
// `[Multi]TimelineEventHandler` to latch cleanups/deallocations on `scratchSemaphore`, and `getFutureScratchSemaphore()`
100+
// is the value they expect to get signaled in the future.
101+
// NOTE: Each overflow submit bumps the value to wait and signal by +1. A utility may overflow an arbitrary number of times.
102+
// Therefore, DO NOT choose the values for waits and signals manually, and do not modify the `scratchSemaphore` field after initialization or first use.
103+
// You can examine the change in `scratchSemaphore.value` to observe how many overflows or submits have occurred.
96104
IQueue::SSubmitInfo::SSemaphoreInfo scratchSemaphore = {};
97-
// Optional: If you had a semaphore whose highest pending signal is 45 but gave the scratch a value of 68 (causing 69 to get signalled in a popped submit),
98-
// but only used 4 scratch command buffers, we'd wait for the semaphore to reach 66 before resetting the next scratch command buffer.
99-
// That is obviously suboptimal if the next scratch command buffer wasn't pending with a signal of 67 at all (you'd wait until 70 gets signalled).
100-
// Therefore you would need to override this behaviour somehow and be able to tell to only wait for the semaphore at values higher than 68.
105+
106+
// Optional: If you had a semaphore whose highest pending signal is 45 but gave the scratch a value of 68 (causing 69 to get signaled in a popped submit),
107+
// but only used 4 scratch command buffers, we'd wait for the semaphore to reach 66 before resetting the next scratch command buffer.
108+
// This is obviously suboptimal if the next scratch command buffer wasn't pending with a signal of 67 at all (you'd be waiting until 70 gets signaled).
109+
// Therefore, you would need to override this behavior to only wait for semaphore values higher than 68.
101110
size_t initialScratchValue = 0;
102-
// Optional: Callback to perform some other CPU work while blocking for one of the submitted scratch command buffers to complete execution.
103-
// Can get called repeatedly! The argument is the scratch semaphore (so it can poll itself to know when to finish work - prevent priority inversion)
111+
112+
// Optional: Callback to perform some other CPU work while blocking for one of the submitted scratch command buffers to complete execution.
113+
// This callback may be called repeatedly! The argument provided is the scratch semaphore, allowing it to poll itself to determine when it can finish its work,
114+
// preventing priority inversion.
104115
std::function<void(const ISemaphore::SWaitInfo&)> overflowCallback = {};
105-
116+
106117
//
107118
inline ISemaphore::SWaitInfo getFutureScratchSemaphore() const {return {scratchSemaphore.semaphore,scratchSemaphore.value+1};}
108119

0 commit comments

Comments
 (0)