-
Notifications
You must be signed in to change notification settings - Fork 594
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 RenderContext class a singleton, migrate some setup functionality to it #921
Comments
I think we should look at stuff like that in the greater scheme of our planned framework refactoring. There are lots of things that need rework or improvement, but maybe we should start to prioritize things and concentrate on more interesting things like new samples. I'm kinda getting the feeling that we're moving to bike shedding territory with all off this and forget about important stuff that needs fixing. |
I also think we shouldn't rush to do all of these things. We already invested a lot of effort into planing the framework rework and @tomadamatkinson is working on that. |
Closing this for now. Our main coal is to unify the framework, but we want to concentrate on adding new samples instead of doing further (large) changes to the framework. |
RenderContext
and theHPPRenderContext
types are required by lots of the more interesting pieces of functionality in the code, and end up getting passed in a function signatures (or alternatively, theRenderContext
owner,VulkanSample
gets passes, such as in thevkb::Gui
class) or a child (almost always avkb::Device
class).This leads to an excessive number of cases where objects need to retain references to devices or render contexts (consider the
Buffer
andImage
classes which use VMA for all their work, but still have to be initialized with references tovkb::Device
because the parent classVulkanResource
requires it.An alternative to this would be to make the
RenderContext
class a singleton, and ensure that only one exists at any given time, and that all other classes can access it via a staticRenderContext::get
method that either returns the singleton instance or throws an exception if it hasn't yet been initialized.This would free a vast number of classes that currently need to be passed a reference to the
RenderContext
or theDevice
, or in the case ofGui
theVulkanSample
from requiring that. In every case the code in question could simply call something likeRenderContext::get()->get_device()
or something similar.In such a re-design, the
RenderContext
should own the initialization of the instance, the physical device and the device as well as the swapchain, allowing a chunk of the code currently inVulkanSample
to be migrated to that class.The text was updated successfully, but these errors were encountered: