I've been wondering how loading assets within a running game loop might work and can only think of a few methods, all with pitfalls.
Which one of these, if any, is correct?
1. Device can be used from another thread, so just destroy and create textures, vertex buffers etc from a worker thread.
2. DeviceContext is NOT thread safe but I wonder if it means that under no circumstance at all another thread should touch it or is it only the currently used textures and buffers? eg. can I still map/unmap an unused texture while other ones are bound to the pipeline? (I have a bad feeling about this)
This would allow to keep a pool of ID3D11ShaderResourceViews that get reused.
3. Is there a way a different DeviceContext can load assets and share/transfer them to the first one? (sounds icky)
I do know how to use ReadFile, GetOverlappedResult asynchronously but what good is the ability to load large image files this way if I cannot create the actual assets async'ly too?
The only code examples I've seen were using something like C++/CLI and weren't really that helpful, although it gave me the impression that a combination of ReadFile and 1. were used from the high level view insight the code gave me. They didn't init the FILE_FLAG_OVERLAPPED though but it seems they spawn a thread manually with this kind of semantics I'm unfamiliar with: task<Platform::Array<byte>^>
I'm talking about this for example: https://msdn.microsoft.com/en-us/library/windows/apps/jj651549.aspx