Skip to content

render: move make_* into vulkan::factory - #2

Open
igagis wants to merge 12 commits into
mainfrom
ren_factory
Open

igagis wants to merge 12 commits into
mainfrom
ren_factory

Conversation

@igagis

@igagis igagis commented Nov 19, 2026

Copy link
Copy Markdown
Member

Follow-up to cppfw/ruis#190 (render context redesign).

The shareable-object make_* functions now live on a new vulkan::factory that wraps the shared vulkan_device (VkInstance + VkDevice + VkQueue). vulkan::context takes an injected factory and no longer creates GPU objects; it uses the factory's device for swapchain/framebuffer/draw work. The one-shot command buffer, descriptor pool, and pipeline cache/layout/dsl resources move to the factory (shared across all windows), as does all_textures (deferred upload tracking).

Depends on cppfw/ruis#192.

Follow-up to ruis issue #190: the shareable-object make_* functions now
live on a new vulkan::factory that wraps the shared vulkan_device
(VkInstance + VkDevice + VkQueue). vulkan::context takes an injected
factory and no longer creates GPU objects; it uses the factory's device
for swapchain/framebuffer/draw work. The one-shot command buffer,
descriptor pool, and pipeline cache/layout/dsl resources move to the
factory (shared across all windows). all_textures (deferred upload
tracking) moves to the factory.
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

The base-class 'factory' data member hides the type in derived scope,
so the downcasts in the concrete buffer/texture classes now use the
fully-qualified ruis::render::vulkan::factory type.
Comment thread src/ruis/render/vulkan/context.hpp Resolved
Comment thread src/ruis/render/vulkan/index_buffer.cpp Resolved
Comment thread src/ruis/render/vulkan/texture_2d.cpp Resolved
- Rename the factory constructor parameter from rendering_context to
  factory and pass it by value with std::move (a shared_ref should be
  passed by value, not by const reference).
- Drop the redundant ctx_ref members from the Vulkan shaders, GPU objects
  (texture_2d, vertex_buffer, texture_depth, index_buffer) and the
  frame_buffer: the base classes already retain the factory (now
  protected) or the context (frame_buffer), so the derived classes access
  them directly.
- Hide the factory's all_textures list behind private mutable state with
  const register_texture()/unregister_texture() accessors, so the texture
  ctor/dtor no longer need a const_cast on the const factory reference.
- Rename the context's retained factory reference from vu_factory to
  factory and remove the now-unnecessary const_casts on the factory (all
  of its methods are const).
Comment thread src/ruis/render/vulkan/factory.hpp Resolved
The factory obtains all GPU handles from the surface provider and never
uses the native window, so the parameter was dead weight. Drop it.
- Rename surface_provider class to surface (file and class name)
- Make vulkan_device constructor public (remove make() factory method)
  so callers can use make_shared directly
- Rename VkSurfaceKHR member to vk_surface to avoid name clash with class
- Rename vulkan_device class to device (file and class name)
- Rename VkDevice member to vk_device to avoid name clash with class
- Rename surface member 'const device* device' to 'vu_device'
Remove the deferred texture upload mechanism. Textures are now uploaded
synchronously to the GPU when created, using a one-shot command buffer.
This simplifies the code and eliminates the need for tracking uploaded
state across frames.
The Vulkan context now handles presentation through the render context's
swap_frame_buffers() virtual method, eliminating the need for the native
window to hold a pointer back to the context.
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.

2 participants