-
Notifications
You must be signed in to change notification settings - Fork 52
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
Make the vku::framework and vku::Window more flexible #30
Comments
I'm happy for you to customise it as you wish. Real use cases will always drive software development. Best of all, develop a game engine or 3D application. |
@andy-thomason I am definitely using the framework for my new code. I am discovering quite a few things to adapt and generalize. By the way, I had stated that I had a working threading but eventually discovered it was buggy. This led me to stackoverflow where a patient soul helped figure out the issue. I will be submitting a pull request with a threaded demo and will update all the demos to cache the queue, rather than asking for it on each draw call. It will take me some time though, as I need to address the framework singleton aspect. I am also working on generalizing the buffer system to easily adapt/use the popular Vulkan Memory Allocator without forcing to use it as I'm sure @lhog wouldn't like that! ;P . |
After discovering the issue for the queue and threading, I am left wondering what approach to take. Here are my notes:
So the question becomes: (:heavy_check_mark: indicates current choices)
Comments/opinions are welcome. Something totally off-topic but that probably will benefit from multi-threaded rendering: I discovered ImGui and have started exploring it with Vulkan for the rendering. I think I may do an open-source demo app for image processing using Vookoo for rendering and ImGui on top for the GUI. |
I have a fairly complete system for synchronized queue access at https://github.com/FunMiles/Vookoo/tree/lock_guard_queues |
That looks very good. The example is relatively short, which is very good.
It is worth timing the calls with rdtsc as mutexes can be expensive if
implemented badly.
At best they are a spin lock on an atomic boolean - at worst an O/S call.
One of the downfalls of OpenGL was the need for a mutex on every call.
…On Thu, Apr 23, 2020 at 4:04 PM FunMiles ***@***.***> wrote:
I have a fairly complete system for synchronized queue access at
https://github.com/FunMiles/Vookoo/tree/lock_guard_queues
There is one example opening two windows: 00-parallelTriangles. There is
no cleanup for closing the windows. I need to do that before submitting a
PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#30 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL36XEWG44BF227WG7R7NLROBKHTANCNFSM4MKEOL5A>
.
|
I do not have experience measuring mutex costs on Windows yet, but I've dealt with them a lot on Unix based system and they are cheap. The important thing to remember is that they should cost only if there is contention. And a good implementation should spin-lock for a bit before going to the OS. One thing you may notice in the last update I made is that rather than submit the static and dynamic command buffers to the queue separately, I've merged them into a single submission to reduce the number of lock/unlock of the queue mutex. On my Mac, there are three queue families, all capable of doing graphics/compute/transfer. Each only has one queue at most. One could try to better pick queue families/queues and try to create multiple queue to assign to various cases to minimize contention likelihood. A round-robin distribution maybe? |
I have started doing rdtsc timings and on the Mac.
The Mac timings are very strange. I may have to raise that with the MoltenVK development team.
|
I realize that the vku_framework.hpp was intended as a way to easily get started with the examples.
However, I've been using it in a new project in which I want to be able to run more than one Vulkan driven window. Doing so, I discovered some weaknesses that for the most part can be remedied with a fairly limited amount of work. I am sure I will discover more issues to be worked on but here are the first things that come to mind:
graphicsQueue.submit(...)
. If the wrapper is used, then it is easy to write:graphicsQueueWrapper->submit(...)
. Theoperator->
of the wrapper returns an object that locks a mutex and has itself anoperator->
that returns a pointer to thevk::Queue
. The object lifetime is guaranteed to encompass the time of the submission and then it is unlock right after. From a user's point of view, it comes at no added complexity.vku::Framework
should really behave like a singleton. It is easy to create twovku::Framework
by mistake and get a crash when one's destructor is called. This also helps in having a single mutex per actual queue (the graphics, compute and present queues can all be the same, yetvku::Window
obtains the presentation queue without reference tovku::Framework
while the user must obtain the graphics and compute queues from thevku::Framework
) .As of now, it is the first point that is important to my use case and I have already tested the wrapper solution.
Is that something of interest to other users?
The text was updated successfully, but these errors were encountered: