yshui / picom

A lightweight compositor for X11 with animation support
https://picom.app/
Other
4.07k stars 584 forks source link

[Discussion] Getting rid of GLX #42

Open 9ary opened 5 years ago

9ary commented 5 years ago

I've noticed your notes on trying out Vulkan and EGL. Here are my personal findings on the matter.

The DRI3 extension can export X Pixmaps as kernel dma-buf objects. This is very useful, as you can use a pair of extensions in EGL and Vulkan to import those objects and use them for texturing. This is the same mechanism that is used by PRIME for multi-GPU systems (eg integrated + discrete graphics) to share buffers between devices, and by Wayland for both multi-GPU support and compositing.

Unfortunately NVIDIA's proprietary driver does not support dma-buf (for licensing reasons), so DRI3 is not available either on that driver. They do support another, standard, EGL_KHR_stream extension which is completely different. I don't know if that can be used to export X11 Pixmaps in the same way. All relevant DRM-based (i915/i965, radeon/amdgpu, nouveau) drivers support dma-buf and DRI3. It's not clear whether they support EGL_KHR_stream. This is a problem for Wayland compositors as well, as it requires a lot of duplicate effort to support both extensions, and most of them have decided not to support the proprietary driver at all.

Things apparently look a little better for Vulkan, but I'm not entirely sure if that helps us at all on X.

Relevant extensions:

yshui commented 5 years ago

Thanks, this is very useful.

yshui commented 5 years ago

This is a problem for Wayland compositors as well

Right, I remember there was some controversy regarding the EGLStream extension. I don't think it is implemented by any of the open source drivers.

clapbr commented 5 years ago

There is this https://github.com/ilia-glushchenko/VulkanCompositor but I couldnt make it work yet, its really new

9ary commented 5 years ago

It looks like there isn't even any X code or proper rendering in there yet.

yshui commented 5 years ago

I think that probably isn't meant to be a X compositor.

clapbr commented 5 years ago

https://cgit.kde.org/kwin.git/log/?h=fredrik/vulkan - kwin vulkan initial work, looks abandoned but might be useful

9ary commented 5 years ago

Ah yes I remember that being a thing. I'll check out how it works.

9ary commented 5 years ago

This isn't directly relevant, it would maybe make writing a Vulkan renderer a little easier, but it's not very likely to change the initial problem which is gaining meaningful access to the framebuffer of other applications.

clapbr commented 5 years ago

another project to borrow ideas from https://www.phoronix.com/scan.php?page=news_item&px=Chamferwm-Vulkan-WM

absolutelynothelix commented 1 year ago

https://github.com/absolutelynothelix/picom/issues/1

let's see how it'll go.

absolutelynothelix commented 1 year ago

after a few weeks of work and about 1500 lines of code there is a somewhat initial vulkan backend implementation. currently it's only capable of alpha blending and somewhat vsync, asking it for more will likely result in a segfault. if someone wants to try to run it there is a recommended scenario:

git clone https://github.com/absolutelynothelix/picom.git picom-vulkan
cd picom-vulkan
git checkout vulkan
git submodule update --init --recursive
CFLAGS=-DDEBUG_VULKAN_BACKEND meson setup --buildtype=debug build
ninja -C build
build/src/picom --config=/dev/null --backend=vulkan --log-level=INFO

use with A LOT OF care, it's very fragile :)

random devlogs are still available at absolutelynothelix#1