-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vulkan: Parallel pipeline creation #16802
Conversation
535caa3
to
0237606
Compare
Oh, I managed to reproduce the hang on Mac! Where the callstacks were a bit unexpected:
(skipped all the threads that didn't seem to do anything interesting) Very odd. |
I think this might be an issue where the thread pool is already full of blocked tasks, that are waiting for a task that's scheduled to run on the threadpool. Ugh, might need some kind of priority scheme? |
Are threads that are waiting aren't suspended or rescheduled to let other threads (which might be the one being waited for) in the threadpool to run? |
Correct, they aren't. That would require a multiplexing system like libuv or something (which is how nodejs works.) PPSSPP's thread manager simply schedules tasks and waits for them to complete before the thread can run more. If it waits for something else, its place on the queue is blocked until it's done. -[Unknown] |
…r interface. Useful for things that should be run ASAP even if the threadpool is full, at a small extra cost. (Not recommended for very small tasks). Considering using this to resolve the deadlocks in #16802.
0237606
to
d772b7b
Compare
I did a bit of a brute force solution, where the tasks that might be depended on by other tasks (the VkShaderModule creation) is now run on dedicated threads instead of on the pool. Overhead should be pretty negligble compared to the shader build costs. This seems fairly solid now, will test it a little more though. |
d772b7b
to
a67604d
Compare
This seems solid now, and it's really night and day on PowerVR devices. ARM Mali devices aren't expected to benefit much until the very latest drivers unfortunately. Will test a little more and then go for it. |
How about adreno gpu's? |
Just tried, seems to be noticeably better on Adreno as well. On my Poco F1, shader stutter isn't entirely gone, but there's definitely less of it. |
Resurrected this old code in my efforts to make things comfortably playable on the A21 - see #16567.
I previously added parallel shader compilation, but that only took care of the GLSL generation and compilation to SPIR-V. This calls the actual pipeline creation in parallel on the threadpool.
I didn't expect it, but unlike Mali, the PowerVR driver benefits immensely from parallel pipeline creation. With this, shader stutter on the device is finally almost kinda bearable. Almost.
However, can't get this in just yet - there's a weird deadlock to debug, that happens mostly when a lot of shaders are created in a bunch. Haven't gotten it to happen on PC yet. Some kind of notify thing maybe?Hm, since fixing #16804 and rebasing, I haven't seen the hang again, I think. We should probably just get this in and see what happens...
It might be a good idea to disable this on GPUs where we know it doesn't help, too.
Also, first I thought about deleting the "compiler thread" as well, but that now performs pretty important job of "smartly" distributing the compile jobs after implicitly collecting bunches of them. Though not sure the benefit of that is very great...