Conversation
Owner
Author
|
Tried using multiple threads to record passes but it's not really worth it. Even in a really favorable use case (lots of passes with lots of draws), and after removing all the locks, I was only able to get around a 2.5x speedup in It's still probably useful to merge what's here though (letting people use graphics module from any thread). I found one more thread safety issue to fix though, |
Simpler and more fine-grained than relying on graphics module to do it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch makes a lot of graphics module functionality thread safe. It just guards the global command buffer with a mutex. It allows threads to create/read/write buffers, textures, materials, meshes, models, shaders, etc. There isn't any noticeable overhead for single-threaded usage.
I tested this by creating a bunch of threads that call
newTexturein a loop, and didn't see any crashes, corruptedstats.textureMemoryvalues, and TSAN didn't complain about anything. So that's a good sign I guess.Pass is pretty much already thread safe, so it should already be possible to record multiple passes from multiple threads.
There are a couple of remaining TODOs before this can be merged:
lovrBufferCreateAlso, a separate but related change is to change
lovr.graphics.submitto use multiple threads to record passes, and also add a method onPassto ask it to start recording its command buffer right away. This could impact things, because nowrecordRenderPassandrecordComputePasswould need to start locking things instead of assuming the lock is already held.