-
Notifications
You must be signed in to change notification settings - Fork 342
High-level scene API #1826
Comments
I think a separate library would be the best place for this. The should also be a way to hook into wlroots itself if the user chooses to do something a bit more custom sometimes |
I was leaning towards external too. Adding some ways to "go lower" would be nice, but we need to be careful to not make doing that really complex, defeating the purpose of the API. |
I think we would need a more detailed design doc written up before we could judge whether to include it in wlroots or not. Rather than |
+1 for |
Hi there, I'm working on https://git.sr.ht/~bl4ckb0ne/wltrunk, a library based on wlroots that aims to bring a higher level API. I'll gladly discuss anything on either irc (i'm on #sway-devel with the same handle) or by mail. |
I don't think I would like to see the scene API end up in wltrunk. |
Note that |
I've seriously been thinking about implementing this. I haven't come up with a C API, but a have list of ideas, none of which are particularly original. Use case
Protocols
Rendering
Scene-graph
Atomic updates
CursorI don't know if I want to make a special provisions for cursors or not.
OR
The first is much cleaner but it only works if the cursor is synchronized with the rest of the presentation. That is only true on the DRM backend. Outputs
More radical ideas
|
This is an excellent draft, I'm really excited about it. A few questions occur to me:
|
Wayfire needs a single rendering operation from wlroots: Render a surface texture to a given framebuffer with a given scissor region. Currently, If you do decide that it is really nice for wlroots to remove |
As a Wayland compositor, you kind of have to care, especially when getting to the level of textures. It's just the nature of what we're doing. With The idea for custom renderers was always supposed to be that you have your low-level client buffers (dmabufs and shm), and you do with them whatever you want to, using whatever dmabuf-capable API you want. It should be possible to write a Vulkan Wayland compositor without touching a single piece of EGL or OpenGL. You could even write a Wayland compositor that only ever tries to use direct scanout and planes, and doesn't even have a renderer.
But a helper for OpenGL textures is just not something I can write. It touches more areas than just texture uploads. In order to do it properly, I need a hand in a bunch of other calls you make, as well as in your shaders. Most of the useful OpenGL things our renderer does requires touching the shaders, and a shader generator library is something I REALLY don't want to have. A helper specifically for the OpenGL part of handling If you want to read from an EGLImage:
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image); and you have a texture you can use. If you want to draw to an EGLImage:This one is even easier. GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image); And that's it. It acts completely like a normal texture after this; attach it to your framebuffer object and start drawing like normal. You can do it as a renderbuffer too. GLuint rb;
glGenRenderbuffers(1, &rb);
glBindRenderbuffer(GL_RENDERBUFFER, rb);
glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, egl_image); Renderer v6 plans to drop |
But I find it acceptable since I need to do it (even if I had access to texture/EGLImage/whatever). Anyway I see that you want to do a large refactoring of the rendering code both in wlroots and compositors. Just ping me when your changes are ready, so I can try to update Wayfire and see whether I can get all I need. In the worst case, I'll end up copying most of wlr_renderer to Wayfire. |
I understand you want wlr_surfaces to be able to do explicit synchronization stuff. I'm not sure it's a good idea for a first step, maybe we should start with wlr_buffers and expand to wlr_surfaces later.
Why are layers necessary? Why not just set a z-index on each view?
+1 It would be nice to also allow for custom GPU data too. Making
Hmm. Sway shows a "saved" wlr_buffer when the layout changes. I wonder how that fits in this design.
Side note, we still need to keep the wlr_texture part of the renderer. Hmm, it seems (from your later comments) like you want to make this private to wlr_scene?
Well this design doesn't require renderer v6. We could land the groundwork for this with the current renderer infrastructure.
Hmm. Why not just set an "absolute" position on views instead? A tree seems a little bit complicated and I'm not sure it'd be really useful.
Here comes multi-planar textures...
Hmm. I have to agree with @ammen99 here. See #1904 for a potential solution. |
The scene is supposed to handle everything involving presentation, including
I'd have to try and actually implement it to see what kind of issues arise and how much
Yes.
I definitely should have phrased that better: it doesn't obsolete renderer v6. This can be implemented on top of the current EGL stuff we already have.
It's an ergonomics thing. Remember that the use case for this is intended to be very strict: basic 2D Wayland compositors. It also provides a useful form of grouping. Subsurfaces are defined as a tree, and can be represented easily here too. When putting a view on top of another, instead of looking for the subsurface which is the highest and putting it on top of that, you can just "put it on top of the layer these subsurfaces are all on". Subsurfaces are also the reason it uses relative positioning. You can move the group around easily without having to go through and move each one individually.
Fundamentally the same. There's just more than one EGLImage/texture. The more complex bit is using them in your shaders.
As I mentioned on IRC, this would be more for some "OpenGL toolkit" kind of interface, rather than being bolted-on to |
The main reason to keep |
That's the nature of writing a renderer for a Wayland compositor, though. The "batteries not included" design of wlroots was supposed to allow you to see those gory details. And then we have helpers for common things where it makes sense.
BUT I do think an equivalent that specifically targeted OpenGL would make a lot more sense; not some half-ass abstraction that it currently is. Basically something that is responsible for spitting out GL textures that people writing custom renderers can use, and maybe not a lot else. You wouldn't need pixel uploading, drawing quads, scissor regions or any of that. |
I'm on the fence. The prime directive of wlroots is to reduce the workload on compositors without doing anything that prevents them from taking the wheel when they need to. I think that this code is going to end up looking basically identical for all compositors, and non-trivial to boot. I'd be interested in seeing what @emersion's proposed experiment turned out. |
When it comes to huge things like OpenGL, I think the better thing to do is to just get out of the way and let people write OpenGL. I don't think people writing their own renderers want us to write it for them by layering a bunch of stuff on top of it. |
I would agree totally if the question were only about wl_shm, where the most work you have to do with OpenGL is uploading pixels, which everyone else does. But wl_drm and linux-dmabuf are both Wayland specific and require some extra thought and attention, which is where wlroots seems to naturally come in. |
I agree. That falls under "something that is responsible for spitting out GL textures" and "the integration bits". |
Mind, the two (allowing to attach wlr_surface or wlr_buffer) aren't exclusive. We already have different "view types" (solid color, compositor buffer) so having a wlr_surface and a wlr_buffer would be almost free. Having both would allow compositors that would want to have more control over the displayed buffer (e.g. current Sway) to do it without issues. It would also allow compositors to implement custom frame scheduling without throwing away everything.
I'd expect compositors to iterate over all of their view surfaces and update the wlr_scene with their internal state. |
I'm still wondering what the interface with the backend should be. The scene would need to interface with DRM planes and Wayland subsurfaces.
|
Minimal API draft: enum wlr_scene_node_type {
WLR_SCENE_NODE_ROOT,
WLR_SCENE_NODE_TREE,
WLR_SCENE_NODE_SURFACE,
WLR_SCENE_NODE_OUTPUT,
};
struct wlr_scene_node_state {
struct wl_list children; // wlr_scene_node_state.link
struct wl_list link; // wlr_scene_node_state.children
bool enabled;
int x, y;
};
struct wlr_scene_node {
enum wlr_scene_node_type type;
struct wlr_scene_node *parent;
struct wlr_scene_node_state current, pending;
};
struct wlr_scene {
struct wlr_scene_node node;
};
struct wlr_scene_tree {
struct wlr_scene_node node;
};
struct wlr_scene_surface {
struct wlr_scene_node node;
struct wlr_surface *surface;
};
struct wlr_scene_output {
struct wlr_scene_node node;
struct wlr_output *output;
};
struct wlr_scene *wlr_scene_create(void);
void wlr_scene_destroy(struct wlr_scene *scene);
void wlr_scene_node_destroy(struct wlr_scene_node *node);
void wlr_scene_node_commit(struct wlr_scene_node *node);
void wlr_scene_node_toggle(struct wlr_scene_node *node, bool enabled);
void wlr_scene_node_move(struct wlr_scene_node *node, int x, int y);
void wlr_scene_node_place_above(struct wlr_scene_node *node,
struct wlr_scene_node *ref);
void wlr_scene_node_place_below(struct wlr_scene_node *node,
struct wlr_scene_node *ref);
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_node *parent);
struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_node *parent,
struct wlr_surface *surface);
struct wlr_scene_output *wlr_scene_output_create(struct wlr_scene *scene); |
Seems like a good start. |
I don't think it's that bad if the backend has its own separate scene API. They are sufficiently different enough.
It would be nice to keep any complexity about the layout and global transforms outside of the backend. We can keep everything as close as it can possibly be to the values that libliftoff and KMS wants to see. |
Hmm, actually libliftoff cares a lot about keeping the same scenegraph objects because it needs to track which surfaces are updated frequently to put these in planes before others. |
Well, if persistent state helps, that's fine. It's slightly more complexity for the compositor scene graph, but not that much. |
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
This new API allows compositors to display buffers without needing to perform rendering operations. This API can be implemented on Wayland using subsurfaces and on DRM using KMS planes. The goal is to make use of this API in a future scene-graph API. References: swaywm#1826
This new API allows compositors to display buffers without needing to perform rendering operations. This API can be implemented on Wayland using subsurfaces and on DRM using KMS planes. The goal is to make use of this API in a future scene-graph API. References: swaywm#1826
This new API allows compositors to display buffers without needing to perform rendering operations. This API can be implemented on Wayland using subsurfaces and on DRM using KMS planes. The goal is to make use of this API in a future scene-graph API. References: swaywm#1826
This new API allows compositors to display buffers without needing to perform rendering operations. This API can be implemented on Wayland using subsurfaces and on DRM using KMS planes. The goal is to make use of this API in a future scene-graph API. References: swaywm#1826
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
This new API allows compositors to display buffers without needing to perform rendering operations. This API can be implemented on Wayland using subsurfaces and on DRM using KMS planes. The goal is to make use of this API in a future scene-graph API. References: swaywm#1826
This new API allows compositors to display buffers without needing to perform rendering operations. This API can be implemented on Wayland using subsurfaces and on DRM using KMS planes. The goal is to make use of this API in a future scene-graph API. References: swaywm#1826
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
This new API allows compositors to display buffers without needing to perform rendering operations. This API can be implemented on Wayland using subsurfaces and on DRM using KMS planes. The goal is to make use of this API in a future scene-graph API. References: swaywm#1826
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: swaywm#1826 (comment)
A new wlr_scene API has been added, following the design ideas from [1]. The new API contains the minimal set of features required to make the API useful. The goal is to design a solid fundation and add more features in the future. [1]: #1826 (comment)
The basic API has landed in #1966, and various PRs have been adding functionality. Let's close this issue and create new dedicated issues for missing features. |
Over time, I've been pushing to make many of our API lower-level and efficient as they could reasonably be. Unfortunately, this does make things much harder to use, especially for people without specialised knowledge, making the barrier to entry still very high for using wlroots.
Basically, I think we need a restricted "easy mode" API that can help people still do everything as efficiently as possible (all handled internally). This honestly wouldn't be that different than WLC or a parts of libweston.
Instead of the user handling rendering with damage tracking, planes, and all that shit we want to add, they just say "the window goes here".
I don't know how high-level this really should be. Should this handle shells, drag-and-drop, or other complex operations? Does this even belong in wlroots itself or should it exist as a layered library in its own repository?
The name I was thinking for it is
wlr_desktop
.The text was updated successfully, but these errors were encountered: