Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Flush()

Initiates execution of all enqueued operations on the device.
Read time 1 minuteLast updated 6 days ago

Definition

bool Flush()

Returns

Type

Description

boolTrue if the flush operation was successful.

Remarks

Forces the device to begin processing all previously enqueued operations such as buffer reads, writes, and compute operations. Some implementations may flush automatically, while others require explicit flushing.
This method returns immediately after submitting the operations to the device. Non-blocking operations that produce an event can be followed by a call to IDeviceContext.Wait, to perform a blocking wait while the event completes. Use IDeviceContext.IsCompleted to determine if an event produced by an asynchronous operation has completed.
Performance Note: Call IDeviceContext.Flush() once after enqueuing multiple operations rather than after each individual operation for better performance.

Examples

// Enqueue multiple operationscontext.WriteBuffer(slice1, data1, event1);context.WriteBuffer(slice2, data2, event2);context.ReadBuffer(slice3, data3, event3);// Submit all operations for executionbool flushSuccess = context.Flush();Assert.IsTrue(flushSuccess);// Wait for all operations to completecontext.Wait(event1);context.Wait(event2);context.Wait(event3);