Loading Texture using multithreading

I try to use multi threading for load textures and fonts. And I’ve noticed that textures loads only in main thread but in other threads it were loaded just white rectangles. Version of monogame is 3.4, use on Linux

OpenGL drivers on all platforms are notoriously bad in supporting multiple threads. This is why we have changed it in the latest development version to do the file loading in the other thread, but the actual texture creation and anything else that touches OpenGL is posted to the main thread while the other thread waits.

Ha! What is advantage your solution if it does not resolve my problem? Or why to create second thread if it will wait while first thread executing?

The largest stall when loading content is the file I/O. Loading the file content on another thread and pushing the OpenGL operations back to the main thread allows the content to be loaded asynchronously while still updating and rendering the game.

No no, I have 3 folders with files and each thread works with one folder

That’s fine. The file I/O (the slowest part of the asset load) will be done on each thread. Once the data is in memory, an action will be invoked on the main thread to send the data to OpenGL. When the main thread is about to render a frame, it will run the invoked actions, then allowing the thread that invoked the action to continue.

This is required for two reasons:

  1. Multhreading support in most OpenGL drivers is notoriously bad. We simply do not know if the user has good or bad drivers. So all OpenGL API calls are done in the main thread in a single-threaded context.
  2. The ContentManager methods expect to be run synchronously and expect operations inside them to be synchronous. Hence we need to block the worker thread for the short amount of time it takes to invoke OpenGL calls on the main thread.