Skip to content

refactor(vulkan): own backend initialization - #1

Open
florishafkenscheid wants to merge 3 commits into
cochcoder:vulkanfrom
florishafkenscheid:pr/vulkan-backend-initialization
Open

refactor(vulkan): own backend initialization#1
florishafkenscheid wants to merge 3 commits into
cochcoder:vulkanfrom
florishafkenscheid:pr/vulkan-backend-initialization

Conversation

@florishafkenscheid

Copy link
Copy Markdown

Summary

Makes Vulkan renderer initialization transactional and gives the renderer explicit ownership of the shared backend services it installs.

  • adds a reusable RollbackScope for reverse-order construction cleanup
  • groups the upload stream, download stream, and atlas reader into one owned RenderBackendServices.Registration
  • constructs VkRenderCore through a factory and transfers ownership only after initialization succeeds
  • adds tests for rollback behavior and backend service registration

Motivation

VkRenderCore publishes 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:

Upload stream already initialized

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 test using Java 25
  • tests cover rollback ordering, cancellation and commit behavior
  • tests cover successful registration, conflicting registration, partial-install rollback, and identity-safe cleanup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant