refactor(vulkan): own backend initialization - #1
Open
florishafkenscheid wants to merge 3 commits into
Open
Conversation
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.
Summary
Makes Vulkan renderer initialization transactional and gives the renderer explicit ownership of the shared backend services it installs.
RollbackScopefor reverse-order construction cleanupRenderBackendServices.RegistrationVkRenderCorethrough a factory and transfers ownership only after initialization succeedsMotivation
VkRenderCorepublishes several process-wide backend services while its constructor is still creating GPU resources and renderer subsystems.If a later initialization step fails, the constructor can exit with only part of the renderer initialized. Previously installed services may then remain globally registered, causing subsequent renderer creation attempts to fail with errors such as:
Implementation
RollbackScope records cleanup operations immediately after each resource is acquired and executes them in reverse order if construction fails. Once the renderer has been fully created, the scope is committed and normal ownership transfers to VkRenderCore.
RenderBackendServices.install(...) installs the shared backend services as a single unit and returns an identity-safe registration handle. Closing that handle removes only the services belonging to that registration.
This also makes the ownership boundary explicit: VkRenderCore owns the registration and closes it during normal renderer shutdown.
Testing
./gradlew testusing Java 25