Wayland support - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93) +---- Forum: GSoC (https://forum.kodi.tv/forumdisplay.php?fid=299) +----- Forum: GSOC 2017 (https://forum.kodi.tv/forumdisplay.php?fid=274) +----- Thread: Wayland support (/showthread.php?tid=309254) Pages:
1
2
|
RE: Wayland support - yol - 2017-03-24 (2017-03-21, 14:33)RockerC Wrote:Well, VA-API is part of the proposal (for the cards/drivers that support it).(2017-03-21, 00:24)yolk Wrote: Ah OK - I didn't look specifically into VDPAU. But if that's clear there is no reason to include it in the proposal, so I've removed it.Could substitute VDPAU with VAAPI (VA API)? http://en.wikipedia.org/wiki/Video_Acceleration_API RE: Wayland support - daniels - 2017-05-06 Congratulations on being accepted this year! I'm one of the Wayland developers, and would be more than happy to help and answer any questions you have, either here or as 'daniels' on Freenode. Using wp_presentation would be really great. Unfortunately it's still not implemented in Mutter for boring internal infrastructural reasons, but I'd expect that to change soon. Native YUV support would also be really nice to have, though again, Mutter doesn't yet support it. :\ The news article linked to is very old, which mainly describes work with the wl_drm protocol, something which is an internal implementation detail of Mesa and thus not supported on other platforms. We do also reserve the right to break that interface, so please don't rely on it! Instead, I'd be looking more towards the zwp_linux_dmabuf_v1 interface, which is again supported by Weston, and will be supported by Mutter within the next couple of months I hope. Using dmabuf directly allows you to be in full control of the presentation layer, not having to route around EGL/VA-API's own presentation support. If this is a viable option then I'd personally be very happy to see it, though I wouldn't be surprised if this required a fair bit of rework on Kodi, so please don't necessarily take this as good advice. This is the route VA-API is going down as well: allowing clients to access dmabuf handles directly and drive presentation themselves. Best of luck with your summer, and please get in touch if I can help at all! RE: Wayland support - FernetMenta - 2017-05-06 Kodi's presentation component is independent from decoding APIs like VAAPi or VDPAU. Kodi renders GL textures. The requirement on a windowing system is that Kodi needs to know when a texture rendered through GL becomes visible on screen. Kodi also needs to sync its clock with vertical retrace aka vblank. The windowing system should provide some mechanism to do so. RE: Wayland support - daniels - 2017-05-06 (2017-05-06, 16:13)FernetMenta Wrote: Kodi's presentation component is independent from decoding APIs like VAAPi or VDPAU. Kodi renders GL textures. The requirement on a windowing system is that Kodi needs to know when a texture rendered through GL becomes visible on screen. That's reasonable. Bearing in mind that this isn't the bad old days of destructive X11 compositors though, I would be interested to explore direct buffer attachment with you guys. In other words, not using the GPU (via GL) to copy the buffers and do conversion, but offload that to the compositor, where we can potentially use the display controller overlays to do so, with no copying. Our colour management isn't quite up to scratch for perfectly lossless pipelines yet, but we're hoping to make it so in the fairly near future. Having at least a pathway to an implementation in Kodi would be a great testbed for this. This usually gives quite good filtering/scaling/conversion through the overlays, as well as helping bring down power usage, and maybe even bring up performance thanks to reduced memory bandwidth. Anyway, one for the future. (2017-05-06, 16:13)FernetMenta Wrote: Kodi also needs to sync its clock with vertical retrace aka vblank. The windowing system should provide some mechanism to do so. Hm, vblank itself is not quite what you want to be synchronising to. The kernel needs to submit its final configuration to the hardware just before vblank. In turn, the compositor needs to submit its final display configuration to the kernel, before the kernel reaches that critical timing point. In turn, the client needs to submit its final frame to the compositor, a bit before the compositor submits to the kernel. The exact mechanics of the frame timings are a little fluid, but the point is that 'vblank' is a very specific term, where what you want is more like the critical presentation commit point, wherever that may lie. (For Weston's default configuration, this is 7ms before vblank.) RE: Wayland support - FernetMenta - 2017-05-06 1) presentation For this thread we stay with GL rendering and our own color management. We have things like 3dlut and I think doing this at the app level leaves us with more options. Rendering video in paralled to GL may be an option for an additional path. As you said, something for the futur. 2) vblank We don't use this for precise timing but to sync the clock. We allow an variance of 30% and also have some error correction if we miss a vblank. The point here is that display fps never matches video frame rate to 100% and if you sync to system clock sooner or later the error gets bigger than frametime. Dropping a frame or duplicating one causes noticeable stutter. RE: Wayland support - daniels - 2017-05-06 (2017-05-06, 18:13)FernetMenta Wrote: 1) presentationTotally understand. (2017-05-06, 18:13)FernetMenta Wrote: 2) vblankI see what you mean, but I'm not sure I agree with the sentiment. Like I say, the deadline by which you need to present for a given frame, will always fall at a certain point within CPU time. The compositor decides when it will repaint for the next frame, and it is this deadline the app must meet. Using vblank is one way to get this information, but not the only way and not necessarily entirely correct. I feel it is useful in that sense to avoid talking about vblank (in the very specific CRT-derived timing sense) unless you truly mean the actual display device, but this is primarily useful for obtaining time-to-light information for A/V sync, rather than trying to derive the deadline you must meet to submit your next frame. RE: Wayland support - FernetMenta - 2017-05-06 Not sure we are talking about the same thing. We use vblank information not for a/v sync but for adjusting playback speed to the display. Kodi does not need to know whether refresh rate is exaclty 23.976 or 24.0 or someting slightly off. If you play some 23.976 material on a 24Hz display it will run sllightly faster but smooth. I am not talking about presentation time. Kodi needs to get the beat of vertical retrace. RE: Wayland support - yol - 2017-05-08 (2017-05-06, 14:34)daniels Wrote: Congratulations on being accepted this year! I'm one of the Wayland developers, and would be more than happy to help and answer any questions you have, either here or as 'daniels' on Freenode. Thanks! Having a Wayland developer around to ask directly will certainly come in handy :-) As FernetMenta already said though, support for non-RGB surfaces will probably be very low priority as far as this GSoC project goes. Allow me to ask one quick question: Are you aware of any "good" C++ bindings for Wayland? RE: Wayland support - yol - 2017-05-12 Hi community, I've set up a GitHub repository for my GSoC project: https://github.com/pkerling/xbmc I've added the tasks from the proposal as issues there so you can track the progress. Do feel free to comment there, test the code, report bugs. etc. as soon as there is something to test :-) RE: Wayland support - yol - 2017-06-11 Hi again, basic Wayland support is now integrated into the master branch at https://github.com/pkerling/xbmc To summarize what I did over the first two weeks of coding period:
I regularly update the project board which should give you an idea about what I'm working on at the moment. Next step is cleaning up VAAPI and xdg_shell support. In the end I did rewrite most of the prior implementation, but I used it a lot for reference. Note that there is nothing inherently wrong with the old code, the basic stuff did work after all. It was just using a deprecated implementation model (CWinSystemEGL) that was slated for removal anyway because it does not make sense from an architectural POV - EGL is not a windowing system, just a means to get a GL surface. Actually, most other code depending on CWinSystemEGL has also already been refactored now. Additionally, the old implementation included a whole lot of code for integration testing that I decided not to add. It complicates the implementation a lot, is very time-intensive to port and maintain, and provides not enough benefit to make up for it in my opinion. The repository also has basic build instructions, and it would be cool if some interested parties would get the code, try to run it on their compositor of choice and report the results. RE: Wayland support - yol - 2017-08-23 Wayland Support Google Summer of Code 2017 Work Product Submission Student: Philipp Kerling Motivation The Wayland protocol is slowly but steadily gaining traction in the Linux world as successor to the X11 display server and is generally seen to replace it in the long term, which is why it is essential for Kodi to support it if it wants to continue to deliver a good user experience on Linux. Kodi did already have a Wayland windowing implementation originally written by Sam Spilsbury during GSoC 2013, but it got removed from master for unsolved infrastructure reasons some time ago and was never on-par with the X11 implementation feature-wise. Goals My main goal was quite simply to get Kodi to natively support Wayland again, if possible as well as it currently supports X11. This was refined into a number of sub-goals/features in my initial proposal categorized as "basic" (i.e. necessary so you can reasonably use it at all), "additional," and "possible extension." These goals can be found in full in the original proposal. They are not revisited goal-for-goal here, but in summary all basic and additional features were completed. One possible extension feature (namely full touch support) was implemented. The remaining ones are listed further down in this document as future work. Implemented features The following major features were implemented (links go to GitHub issues, in approximate implementation order):
Code During development I commited all work to my Kodi fork at GitHub. Further improvements might be made there before they get integrated into mainline. In preparation of the GSoC work product submission, all Wayland-related changes were submitted as one pull request against the master branch of the Kodi mainline repository. It was fully merged in the last week of the coding period. Kodi can be built as usual. To select the Wayland platform, the additional CMake arguments Code: -DCORE_PLATFORM_NAME=wayland -DWAYLAND_RENDER_SYSTEM=gl The main pull request against master had 124 changed files with 9,832 added and 292 removed lines. Development process I had planned to salvage as much of the previous code as possible, but different design choices I made ultimately meant that I ended up writing most of it from scratch. Still, I was frequently checking the prior implementation to see which parts of Kodi I have to touch and how I can go about solving some specific aspects. To get a bit more concrete here, where the approach differs most is how the Wayland protocol objects are used in object-oriented C++. Previously a home-grown approach was used, probably because there were no C++ bindings for libwayland-client at the time. The resulting wrapper code is quite tedious to write and maintain, which is why I decided to use the C++ waylandpp library as base. Even though it is not quite mature yet, I figured that my time would be better spent improving waylandpp than trying to come up with something new on my own. It is of course possible to use the C API of libwayland-client directly without any wrappers, but this is not a very nice solution since the Wayland protocol is really made out to be used in an object-oriented fashion if the language allows for it. Much to my delight, the author of waylandpp was very responsive and supporting, which means that all improvements and feature additions I made to waylandpp at this point are already merged upstream. Unfortunately, it soon became clear that the novel approaches that Wayland took compared to X11, Windows, and most other windowing systems were not a good match for the Kodi windowing infrastructure: Wayland is designed such that clients have minimal control over the desktop for security reasons. This for example means that applications cannot just set arbitrary video modes. They can only tell what their preference would be to the compositor, which then decides and in turn tells the applications what size they get. On the one hand, I do think that this is a good design decision since it solves a lot of problems that XRandR has like leaving the desktop in a bad resolution when a program crashes. On the other hand, it does mean that a lot of things have to be done differently and that Kodi cannot provide a perfect experience on Wayland for the time being. The reason is that there currently is no practically useful way to tell the compositor e.g. what refresh rate the output should use, so switching to the correct modeline for playback at original speed without occasional micro-stutters is not possible. As far as the actual implementation is concernced, the Kodi code assumes the traditional procedure of fetching a list of valid resolutions and then being able to switch to any resolution immediately and basically without failure. Changing this in a satisfying way would require quite a lot of refactoring that would have to touch all of the current windowing implementations, too. This is a lot of work, requires coordination with all platform maintainers, and is not realistic to be completed within the GSoC timeframe, so I instead tried to make minimal adjustments to the Kodi resolution switching code that allow the Wayland implementation to work without impacting any other windowing system. The downside to this is that the Wayland code is not as clean as it could or should be and that there is an increased risk of weird stuff happening. During the past three months I also had to learn that Wayland is still quite new to the scene and that a lot of bugs still lurk in the various components. I had to report and sometimes fix bugs in compositors and other third-party components such as mutter, weston, and libva. Finding these bugs and determining whose fault it is that something did not work as expected took more time than I had initially anticipated. Future work
Acknowledgements I am very grateful to the Kodi team and community for accepting me as student this year and my mentor FernetMenta for always being quick to respond, giving valuable advice, and investing a lot of his private time to review my work. This also goes for a lot of other team members (namely fritsch, lrusak, martijn, paxxi, rechi, and wsnipex) that followed my journey and supported me at specific tasks. Furthermore, I would like to thank the #wayland IRC community and specifically pq and SardemFF7 for their time and advice that helped me move forward several times. Contributions to Kodi apart from Wayland PR
Contributions to third-party projects waylandpp
libva
intel-vaapi-driver
cpython weston
Bugs reported to third-party projects mutter/gnome-shell
weston RE: Wayland support - wsnipex - 2017-08-24 Congratulations and thank you for your awesome work! |