Previously, when copying textures for video transmission, MTLCommandBuffer::waitUntilCompleted was used to detect when the texture copy command was finished. Since this method is called on the rendering thread, it could cause subsequent graphics-related operations to block.
This fix uses MTLCommandBuffer::addCompletedHandler and semaphores to implement the wait process. It waits for the semaphore's signal on the worker thread, the load on the rendering thread is reduced.
This is a performance optimization fix for Metal.
Previously, when copying textures for video transmission, MTLCommandBuffer::waitUntilCompleted was used to detect when the texture copy command was finished. Since this method is called on the rendering thread, it could cause subsequent graphics-related operations to block.
This fix uses MTLCommandBuffer::addCompletedHandler and semaphores to implement the wait process. It waits for the semaphore's signal on the worker thread, the load on the rendering thread is reduced.
Refer to this sample provided by Apple.