@@ -296,7 +296,6 @@ class SK_API GrContext : public GrRecordingContext {
296296 // /////////////////////////////////////////////////////////////////////////
297297 // Misc.
298298
299-
300299 /* *
301300 * Inserts a list of GPU semaphores that the current GPU-backed API must wait on before
302301 * executing any more commands on the GPU. Skia will take ownership of the underlying semaphores
@@ -307,20 +306,35 @@ class SK_API GrContext : public GrRecordingContext {
307306 bool wait (int numSemaphores, const GrBackendSemaphore* waitSemaphores);
308307
309308 /* *
310- * Call to ensure all drawing to the context has been issued to the underlying 3D API.
309+ * Call to ensure all drawing to the context has been flushed and submitted to the underlying 3D
310+ * API. This is equivalent to calling GrContext::flush with a default GrFlushInfo followed by
311+ * GrContext::submit.
311312 */
312- void flushAndSubmit () { this ->flush (GrFlushInfo (), GrPrepareForExternalIORequests ()); }
313+ void flushAndSubmit () {
314+ this ->flush (GrFlushInfo (), GrPrepareForExternalIORequests ());
315+ this ->submit ();
316+ }
313317
314318 /* *
315- * Call to ensure all drawing to the context has been issued to the underlying 3D API.
319+ * Call to ensure all drawing to the context has been flushed to underlying 3D API specific
320+ * objects. A call to GrContext::submit is always required to ensure work is actually sent to
321+ * the gpu. Some specific API details:
322+ * GL: Commands are actually sent to the driver, but glFlush is never called. Thus some
323+ * sync objects from the flush will not be valid until a submission occurs.
324+ *
325+ * Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command
326+ * buffer or encoder objects. However, these objects are not sent to the gpu until a
327+ * submission occurs.
316328 *
317- * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will have
318- * been submitted and can be waited on (it is possible Skia failed to create a subset of the
319- * semaphores). If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not have
320- * submitted any semaphores to be signaled on the GPU. Thus the client should not have the GPU
321- * wait on any of the semaphores passed in with the GrFlushInfo. Regardless of whether
322- * semaphores were submitted to the GPU or not, the client is still responsible for deleting any
323- * initialized semaphores.
329+ * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be
330+ * submitted to the gpu during the next submit call (it is possible Skia failed to create a
331+ * subset of the semaphores). The client should not wait on these semaphores until after submit
332+ * has been called, but must keep them alive until then. If a submit flag was passed in with the
333+ * flush these valid semaphores can we waited on immediately. If this call returns
334+ * GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on
335+ * the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in with
336+ * the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the
337+ * client is still responsible for deleting any initialized semaphores.
324338 * Regardleess of semaphore submission the context will still be flushed. It should be
325339 * emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not
326340 * happen. It simply means there were no semaphores submitted to the GPU. A caller should only
@@ -331,26 +345,54 @@ class SK_API GrContext : public GrRecordingContext {
331345 }
332346
333347 /* *
334- * Call to ensure all drawing to the context has been issued to the underlying 3D API.
348+ * Call to ensure all drawing to the context has been flushed to underlying 3D API specific
349+ * objects. A call to GrContext::submit is always required to ensure work is actually sent to
350+ * the gpu. Some specific API details:
351+ * GL: Commands are actually sent to the driver, but glFlush is never called. Thus some
352+ * sync objects from the flush will not be valid until submit is called.
335353 *
336- * If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not have created or
337- * added any semaphores to signal on the GPU. Thus the client should not have the GPU wait on
338- * any of the semaphores passed in with the GrFlushInfo. However, any pending commands to the
339- * context will still be flushed. It should be emphasized that a return value of
340- * GrSemaphoresSubmitted::kNo does not mean the flush did not happen. It simply means there were
341- * no semaphores submitted to the GPU. A caller should only take this as a failure if they
342- * passed in semaphores to be submitted.
354+ * Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command
355+ * buffer or encoder objects. However, these objects are not sent to the gpu until
356+ * submit is called.
357+ *
358+ * Note: The default values for GrFlushInfo will submit the work the gpu.
359+ *
360+ * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be
361+ * submitted to the gpu during the next submit call (it is possible Skia failed to create a
362+ * subset of the semaphores). The client should not wait on these semaphores until after submit
363+ * has been called, but must keep them alive until then. If this call returns
364+ * GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on
365+ * the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in with
366+ * the GrFlushInfo. The client is always responsible for deleting any initialized semaphores.
367+ * Regardleess of semaphore submission the context will still be flushed. It should be
368+ * emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not
369+ * happen. It simply means there were no semaphores submitted to the GPU. A caller should only
370+ * take this as a failure if they passed in semaphores to be submitted.
343371 *
344372 * If the GrPrepareForExternalIORequests contains valid gpu backed SkSurfaces or SkImages, Skia
345373 * will put the underlying backend objects into a state that is ready for external uses. See
346- * declaration of GrPreopareForExternalIORequests for more details.
374+ * declaration of GrPreopareForExternalIORequests for more details. Note that the backend
375+ * objects will not be moved to this state until submit has been called. If subsequent flushes
376+ * are called between this and submit, those objects are no longer guaranteed to be in a state
377+ * that is ready for external use.
347378 */
348379 GrSemaphoresSubmitted flush (const GrFlushInfo&, const GrPrepareForExternalIORequests&);
349380
350381 /* *
351- * Placeholder no-op submit call.
382+ * Submit outstanding work to the gpu from all previously un-submitted flushes. The return
383+ * value of the submit will indicate whether or not the submission to the GPU was successful.
384+ *
385+ * If the call returns true, all previously passed in semaphores in flush calls will have been
386+ * submitted to the GPU and they can safely be waited on. The caller should wait on those
387+ * semaphores or perform some other global synchronization before deleting the semaphores.
388+ *
389+ * If it returns false, then those same semaphores will not have been submitted and we will not
390+ * try to submit them again. The caller is free to delete the semaphores at any time.
391+ *
392+ * If the syncCpu flag is true this function will return once the gpu has finished with all
393+ * submitted work.
352394 */
353- bool submit (bool syncToCpu = false );
395+ bool submit (bool syncCpu = false );
354396
355397 /* *
356398 * Checks whether any asynchronous work is complete and if so calls related callbacks.
0 commit comments