Version: Unity 6.3 LTS (6000.3)
LanguageEnglish
  • C#

IDeviceContext.Flush

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool Flush();

Returns

bool True if the flush operation was successful.

Description

Initiates execution of all enqueued operations on the device.

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 Flush once after enqueuing multiple operations rather than after each individual operation for better performance.

// Enqueue multiple operations
context.WriteBuffer(slice1, data1, event1);
context.WriteBuffer(slice2, data2, event2);
context.ReadBuffer(slice3, data3, event3);

// Submit all operations for execution bool flushSuccess = context.Flush(); Assert.IsTrue(flushSuccess);

// Wait for all operations to complete context.Wait(event1); context.Wait(event2); context.Wait(event3);
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961