doc: reword thread safety guarantees

This commit is contained in:
Ronny Chan 2023-02-13 02:32:29 -05:00 committed by GitHub
parent 893c58c53d
commit 58ed82e245
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -154,12 +154,16 @@ static GL_DEFAULT_MVP: &[f32; 16] = &[
### Thread safety ### Thread safety
In general, it is **safe** to create a filter chain instance from a different thread, but drawing frames requires In general, it is **safe** to create a filter chain instance from a different thread, but drawing frames requires
**externally synchronization** of the filter chain object. Additionally, filter chain creation requires external synchronization **external synchronization** of the filter chain object.
of the graphics devices queue where applicable, as loading LUT textures requires submission of commands to the graphics queue,
unless the `filter_chain_create_deferred` methods are used. Filter chains can be created from any thread, but requires external synchronization of the graphics device queue where applicable
(in Direct3D 11, the immediate context is considered the graphics device queue), as loading LUTs requires command submission to the GPU.
Initialization of GPU resources may be deferred asynchronously using the `filter_chain_create_deferred` functions, but the caller is responsible for
submitting the recorded commands to the graphics device queue, and **ensuring that the work is complete** before drawing shader pass frames.
OpenGL has an additional restriction where creating the filter chain instance in a different thread is safe **if and only if** OpenGL has an additional restriction where creating the filter chain instance in a different thread is safe **if and only if**
the thread local OpenGL context is initialized to the same context as the drawing thread. the thread local OpenGL context is initialized to the same context as the drawing thread. Support for deferral of GPU resource initialization
is not available to OpenGL.
### Writing a librashader Runtime ### Writing a librashader Runtime