Cloudef / wlc

High-level Wayland compositor library
MIT License
331 stars 58 forks source link

Add modesetting support #265

Closed zsrkmyn closed 6 years ago

zsrkmyn commented 7 years ago

I've made some effort to make wlc to support modesetting due to the issue I posted SirCmpwn/sway#1212, but the codes is not fully tested, since I am not familiar with wlc and wayland. Frankly speaking, It's just my first try to use wayland.

ddevault commented 7 years ago

If I understand correctly, the mode change should be accompanied with a call to wlc_output_set_resolution, right?

zsrkmyn commented 7 years ago

Thanks for patiently reviewing the code. I'll fix the problems you metioned above soon.

I am not sure whether mode change should be accompainied with a call to wlc_output_set_resolution or not. The original code does this so I keep it unchanged. Should I split it out?

ddevault commented 7 years ago

wlc_output_set_resolution is used to change the size of wlc's internal buffer (which is distinct from the mode).

ddevault commented 7 years ago

I'm fine either way with calling it manually or having wlc do it on set_mode. Should be documented, though.

zsrkmyn commented 7 years ago

It seems the code here related to drm fails when changing resolution. It says No space left on device. I may do some research on drm tomorrow.

zsrkmyn commented 7 years ago

It's kind of hard to solve the problem. The problem occurs because the width and the height of gbm_surface (more spcifically, the width and the height of the frame buffer in gbm_surface) mismatch with the resolution. However, the gbm_surface (and its frame buffer) is created when the output created (drm.c:L584), with the width and height set to info->width and info->height, and these two variables are set in drm_query() to the current mode with highest priority (drm.c:L467), and to the preferred mode with second highest priority (drm.c:L476). So, in my case, they were set to current mode, which is 1280x720, so the size of the frame buffer in gdm_surface is ceated with the size of 1280x720. And when we change the mode to 1920x1080, the frame buffer is unchanged, and thus when the page_flip() is called, the error occurs.

Since the gbm_surface is created when the output is created and is backend-related (only to drm), it's not easy to fix the problem. I am now trying to add a new api to bsurface.api so that surface can be update via the api after setting mode, but the original code of managing frame buffer seems a bit complicated for me.

Enerccio commented 7 years ago

wouldn't easiest solution be to have output carry a "backend resize" internal callback that then would be called when modeset changes? Then gbm could have code that would destroy old frame buffer and create new one?

ddevault commented 7 years ago

FYI, sway 0.14-rc1 shipped today, so the sway side of modesetting support is not happening. I still want to see this ship, but I forgot about this PR prefer a conservative release for now. Will try to make sure it's merged around 0.15 time (or before).

zsrkmyn commented 7 years ago

I'm so sorry to put off fixing bugs in this PR for long, but I am really busy these days and almost forget this PR as well... I wonder whether sway still depends on wlc's modesetting. If so, I may try to work on it next week.

ddevault commented 7 years ago

No worries. It can wait until the next release cycle. I'll have a look at it myself then if need be.

ddevault commented 6 years ago

Was looking into this for sway 0.15 and I decided that the effort required to clean this up and ship it is greater than the amount I'm willing to put in considering that wlroots is on the horizon. Sorry - if you want to clean this up yourself though I'd be happy to merge it!

zsrkmyn commented 6 years ago

I am glad that sway has supported modesetting, and I am so sorry that I finally decide to give up this PR. Thank you a lot for all your assistance!