Skip to content

InoxRenderer trait maintenance & updates#115

Open
ArcturusEmrys wants to merge 5 commits intoInochi2D:mainfrom
ArcturusEmrys:inoxrenderer-update
Open

InoxRenderer trait maintenance & updates#115
ArcturusEmrys wants to merge 5 commits intoInochi2D:mainfrom
ArcturusEmrys:inoxrenderer-update

Conversation

@ArcturusEmrys
Copy link
Contributor

This PR contains various rendering trait improvements that are necessary for other PRs I've filed, notably the wgpu renderer in #112 and disabled node hiding in #114.

  • InoxRenderer methods now always take &mut self, so renderers don't have to use interior mutability.
    • This is predominantly necessary for wgpu (see WGPU (WebGPU/Vulkan/Metal etc) renderer #112) which does not carry nearly as much mutable state as OpenGL does.
    • I did not remove the existing interior mutability surrounding GlCache as it caused borrow checker issues in the OpenGL renderer.
  • on_begin_draw and on_end_draw have been promoted to proper trait methods.
    • This allows renderers to always set up state before drawing happens.
    • InoxRendererExt now calls these methods correctly in draw, so the OpenGL example app doesn't have to.
  • on_begin_draw now returns a DrawSession<'_> struct that can own its own resources.
    • This removed a significant amount of call sequencing checks (e.g. "are we in a draw pass already?") and if let Some() blocks from the wgpu renderer.
    • DrawSession is a trait with an associated lifetime so that the draw session can also reference renderer resources.
    • InoxRenderer impls provide a generic associated type called Draw which their on_begin_draw is supposed to call.
    • on_end_draw is used to signal the end of drawing and request presentation to the screen. We specifically do not use Drop for this, in keeping with the convention that dropping a Future cancels the associated work.
  • Added &Puppet parameter to all DrawSessionExt methods (needed for Don't render disabled nodes #114)

This ensures that:

 * The renderer does not have to hold empty space for temporaries that are only used during the draw process
 * `on_begin_draw` is always called before any drawing operations can occur
 * Drawing is always cleaned up, either in `on_end_draw` or `Drop` (our impls currently use `on_end_draw`)
@ArcturusEmrys ArcturusEmrys changed the title InoxRenderer maintenance & updates InoxRenderer trait maintenance & updates Feb 25, 2026
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