smithay icon indicating copy to clipboard operation
smithay copied to clipboard

anvil/udev: Dynamic support for pixman rendererer

Open ids1024 opened this issue 1 year ago • 5 comments

With the changes here, the anvil udev backend will use pixman for rendering if ANVIL_USE_PIXMAN is set.

To do:

  • Figure out how to deal with Send bound on MemoryRenderBuffer, and no Send for PixmanTexture
  • Fix build with debug feature (need to abstract texture)
  • Make render node optional, and automatically use pixman if hardware acceleration isn't present
  • Pixman support in x11/winit backends

It's not entirely clear how best to abstract renderers dynamically:

  • Should an enum wrapper implement the Renderer trait?
    • How does that impact performance or binary size compare to dispatching to a render function twice like this currently does?
    • Will also need enums over texture, frame, error; and probably a panic if these types are mismatched in some way
  • Would any changes to Renderer and related traits make it easier to abstract over, and dispatch at runtime to different renderers?

ids1024 avatar Aug 05 '24 22:08 ids1024

I tried to create a wrapper enum implementing the renderer traits. Bind is the most "problematic" as this can be different per renderer.

Macro based implementation: https://github.com/cmeissl/smithay/blob/3834756520cfb8db5c21b9b5485d16bdc7cdab6e/src/backend/renderer/auto.rs Usage of the enum: https://github.com/cmeissl/smithay/blob/3834756520cfb8db5c21b9b5485d16bdc7cdab6e/anvil/src/render.rs#L28

cmeissl avatar Aug 07 '24 19:08 cmeissl

I was thinking a macro might make sense. That looks handy. Although macro rules macros like that get a bit complicated.

ids1024 avatar Aug 07 '24 20:08 ids1024

Updated on top of https://github.com/Smithay/smithay/pull/1600.

Testing this I see a crash:

2024-12-04T18:08:44.814186Z  WARN anvil::udev: Error during rendering: ContextLost(BufferDestroyed)
thread 'main' panicked at anvil/src/udev.rs:1613:30:
Rendering loop lost: The underlying buffer has been destroyed

I guess that's an existing issue with the pixman renderer, and not something changed here? Hm.

ids1024 avatar Dec 04 '24 18:12 ids1024

Updated so the debug feature builds, and all the feature combinations tested on CI now work. Still needs a fix for that crash.

Exactly how best to abstract over multiple renderers remains an open question.

ids1024 avatar Dec 05 '24 23:12 ids1024

This seems to be working correctly, including with the debug feature.

We may want to change how renderers are abstracted dynamically in the future (and provide some helper for this in Smithay), but this seems good for now, to have a way to test Pixman rendering properly.

ids1024 avatar Dec 09 '24 17:12 ids1024