swaywm / wlroots

A modular Wayland compositor library
https://gitlab.freedesktop.org/wlroots/wlroots/
MIT License
2.15k stars 341 forks source link

Support 10bit color #1378

Open maletor opened 5 years ago

maletor commented 5 years ago

Discussed previously in the past. 10 bit color should work if configured (or detected?) properly.

https://github.com/swaywm/sway/issues/1348#issuecomment-328394287 https://github.com/swaywm/wlroots/issues/54#issuecomment-321395585


https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_shm-enum-format


wlroots has migrated to gitlab.freedesktop.org. This issue has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1378

emersion commented 5 years ago

Can we composite in 10-bit? (See GL_EXT_color_buffer_float)

AntiSC2 commented 5 years ago

Wayland/Weston has now started work on HDR support with a proposed design here: https://lists.freedesktop.org/archives/wayland-devel/2019-January/039808.html

AndreasBackx commented 4 years ago

Any update on this perhaps? Would be up for testing this if needed.

tadeokondrak commented 4 years ago

I was able to get wlroots working with 10-bit output:

diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 60f8ecaa..fb0602f3 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -109,10 +109,11 @@ static bool add_plane(struct wlr_drm_backend *drm,
    for (size_t j = 0; j < drm_plane->count_formats; ++j) {
        uint32_t fmt = drm_plane->formats[j];

-       if (fmt == DRM_FORMAT_ARGB8888) {
-           // Prefer formats with alpha channel
+       if (fmt == DRM_FORMAT_XRGB2101010) {
            rgb_format = fmt;
            break;
+       } else if (fmt == DRM_FORMAT_ARGB8888) {
+           rgb_format = fmt;
        } else if (fmt == DRM_FORMAT_XRGB8888) {
            rgb_format = fmt;
        }
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index 25101a4b..7ff0f023 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -32,7 +32,7 @@ bool init_drm_renderer(struct wlr_drm_backend *drm,
        EGL_NONE,
    };

-   renderer->gbm_format = GBM_FORMAT_ARGB8888;
+   renderer->gbm_format = GBM_FORMAT_ARGB2101010;
    renderer->wlr_rend = create_renderer_func(&renderer->egl,
        EGL_PLATFORM_GBM_MESA, renderer->gbm,
        config_attribs, renderer->gbm_format);

Tested it with glpaper with a shader with particularly bad banding on 8-bit, seems to work fine. Not sure if this is the only place wher changes are needed (other than wl_shm formats).